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 v140_or_es3(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(140, 300);
145 v400_fs_only(const _mesa_glsl_parse_state
*state
)
147 return state
->is_version(400, 0) &&
148 state
->stage
== MESA_SHADER_FRAGMENT
;
152 es31(const _mesa_glsl_parse_state
*state
)
154 return state
->is_version(0, 310);
158 texture_rectangle(const _mesa_glsl_parse_state
*state
)
160 return state
->ARB_texture_rectangle_enable
;
164 texture_external(const _mesa_glsl_parse_state
*state
)
166 return state
->OES_EGL_image_external_enable
;
169 /** True if texturing functions with explicit LOD are allowed. */
171 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
173 /* Texturing functions with "Lod" in their name exist:
174 * - In the vertex shader stage (for all languages)
175 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
176 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
178 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
179 * don't need to explicitly check state->es_shader.
181 return state
->stage
== MESA_SHADER_VERTEX
||
182 state
->is_version(130, 300) ||
183 state
->ARB_shader_texture_lod_enable
;
187 v110_lod(const _mesa_glsl_parse_state
*state
)
189 return !state
->es_shader
&& lod_exists_in_stage(state
);
193 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
195 return state
->ARB_shader_texture_lod_enable
;
199 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
201 return state
->ARB_shader_texture_lod_enable
&&
202 state
->ARB_texture_rectangle_enable
;
206 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
208 return state
->is_version(330, 300) ||
209 state
->ARB_shader_bit_encoding_enable
||
210 state
->ARB_gpu_shader5_enable
;
214 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
216 return state
->is_version(450, 310) ||
217 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
221 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
223 return state
->ARB_shading_language_packing_enable
||
224 state
->is_version(420, 300);
228 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
230 return state
->ARB_shading_language_packing_enable
||
231 state
->ARB_gpu_shader5_enable
||
232 state
->is_version(400, 300);
236 gpu_shader5(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
242 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
244 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
248 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
250 return state
->ARB_shading_language_packing_enable
||
251 state
->ARB_gpu_shader5_enable
||
252 state
->is_version(400, 310);
256 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
258 return state
->stage
== MESA_SHADER_FRAGMENT
&&
259 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
264 texture_array_lod(const _mesa_glsl_parse_state
*state
)
266 return lod_exists_in_stage(state
) &&
267 state
->EXT_texture_array_enable
;
271 fs_texture_array(const _mesa_glsl_parse_state
*state
)
273 return state
->stage
== MESA_SHADER_FRAGMENT
&&
274 state
->EXT_texture_array_enable
;
278 texture_array(const _mesa_glsl_parse_state
*state
)
280 return state
->EXT_texture_array_enable
;
284 texture_multisample(const _mesa_glsl_parse_state
*state
)
286 return state
->is_version(150, 310) ||
287 state
->ARB_texture_multisample_enable
;
291 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
293 return state
->is_version(150, 320) ||
294 state
->ARB_texture_multisample_enable
||
295 state
->OES_texture_storage_multisample_2d_array_enable
;
299 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
301 return texture_multisample(state
) &&
302 state
->EXT_shader_samples_identical_enable
;
306 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
308 return texture_multisample_array(state
) &&
309 state
->EXT_shader_samples_identical_enable
;
313 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
315 return state
->stage
== MESA_SHADER_FRAGMENT
&&
316 (state
->is_version(400, 0) ||
317 state
->ARB_texture_cube_map_array_enable
);
321 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
323 return state
->is_version(400, 0) ||
324 state
->ARB_texture_cube_map_array_enable
;
328 texture_query_levels(const _mesa_glsl_parse_state
*state
)
330 return state
->is_version(430, 0) ||
331 state
->ARB_texture_query_levels_enable
;
335 texture_query_lod(const _mesa_glsl_parse_state
*state
)
337 return state
->stage
== MESA_SHADER_FRAGMENT
&&
338 state
->ARB_texture_query_lod_enable
;
342 texture_gather(const _mesa_glsl_parse_state
*state
)
344 return state
->is_version(400, 0) ||
345 state
->ARB_texture_gather_enable
||
346 state
->ARB_gpu_shader5_enable
;
350 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
352 return state
->is_version(400, 310) ||
353 state
->ARB_texture_gather_enable
||
354 state
->ARB_gpu_shader5_enable
;
357 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
358 * used for relaxation of const offset requirements.
361 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
363 return !state
->is_version(400, 0) &&
364 !state
->ARB_gpu_shader5_enable
&&
365 (state
->ARB_texture_gather_enable
||
366 state
->is_version(0, 310));
369 /* Desktop GL or OES_standard_derivatives + fragment shader only */
371 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
373 return state
->stage
== MESA_SHADER_FRAGMENT
&&
374 (state
->is_version(110, 300) ||
375 state
->OES_standard_derivatives_enable
);
379 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
381 return state
->stage
== MESA_SHADER_FRAGMENT
&&
382 (state
->is_version(450, 0) ||
383 state
->ARB_derivative_control_enable
);
387 tex1d_lod(const _mesa_glsl_parse_state
*state
)
389 return !state
->es_shader
&& lod_exists_in_stage(state
);
392 /** True if sampler3D exists */
394 tex3d(const _mesa_glsl_parse_state
*state
)
396 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
397 * OES_texture_3D extension, and in GLSL ES 3.00.
399 return !state
->es_shader
||
400 state
->OES_texture_3D_enable
||
401 state
->language_version
>= 300;
405 fs_tex3d(const _mesa_glsl_parse_state
*state
)
407 return state
->stage
== MESA_SHADER_FRAGMENT
&&
408 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
412 tex3d_lod(const _mesa_glsl_parse_state
*state
)
414 return tex3d(state
) && lod_exists_in_stage(state
);
418 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
420 return state
->has_atomic_counters();
424 shader_clock(const _mesa_glsl_parse_state
*state
)
426 return state
->ARB_shader_clock_enable
;
430 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
432 return state
->has_shader_storage_buffer_objects();
436 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
438 return state
->AMD_shader_trinary_minmax_enable
;
442 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
444 return (state
->is_version(420, 310) ||
445 state
->ARB_shader_image_load_store_enable
);
449 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
451 return (state
->is_version(420, 320) ||
452 state
->ARB_shader_image_load_store_enable
||
453 state
->OES_shader_image_atomic_enable
);
457 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
459 return (state
->is_version(450, 320) ||
460 state
->OES_shader_image_atomic_enable
);
464 shader_image_size(const _mesa_glsl_parse_state
*state
)
466 return state
->is_version(430, 310) ||
467 state
->ARB_shader_image_size_enable
;
471 shader_samples(const _mesa_glsl_parse_state
*state
)
473 return state
->is_version(450, 0) ||
474 state
->ARB_shader_texture_image_samples_enable
;
478 gs_streams(const _mesa_glsl_parse_state
*state
)
480 return gpu_shader5(state
) && gs_only(state
);
484 fp64(const _mesa_glsl_parse_state
*state
)
486 return state
->has_double();
490 compute_shader(const _mesa_glsl_parse_state
*state
)
492 return state
->stage
== MESA_SHADER_COMPUTE
;
496 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
498 return compute_shader(state
) || shader_storage_buffer_object(state
);
502 barrier_supported(const _mesa_glsl_parse_state
*state
)
504 return compute_shader(state
) ||
505 state
->stage
== MESA_SHADER_TESS_CTRL
;
510 /******************************************************************************/
515 * builtin_builder: A singleton object representing the core of the built-in
518 * It generates IR for every built-in function signature, and organizes them
521 class builtin_builder
{
528 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
529 const char *name
, exec_list
*actual_parameters
);
532 * A shader to hold all the built-in signatures; created by this module.
534 * This includes signatures for every built-in, regardless of version or
535 * enabled extensions. The availability predicate associated with each
536 * signature allows matching_signature() to filter out the irrelevant ones.
543 /** Global variables used by built-in functions. */
544 ir_variable
*gl_ModelViewProjectionMatrix
;
545 ir_variable
*gl_Vertex
;
547 void create_shader();
548 void create_intrinsics();
549 void create_builtins();
552 * IR builder helpers:
554 * These convenience functions assist in emitting IR, but don't necessarily
555 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
558 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
559 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
560 ir_constant
*imm(float f
, unsigned vector_elements
=1);
561 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
562 ir_constant
*imm(int i
, unsigned vector_elements
=1);
563 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
564 ir_constant
*imm(double d
, unsigned vector_elements
=1);
565 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
566 ir_dereference_variable
*var_ref(ir_variable
*var
);
567 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
568 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
570 ir_expression
*asin_expr(ir_variable
*x
);
571 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
574 * Call function \param f with parameters specified as the linked
575 * list \param params of \c ir_variable objects. \param ret should
576 * point to the ir_variable that will hold the function return
577 * value, or be \c NULL if the function has void return type.
579 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
581 /** Create a new function and add the given signatures. */
582 void add_function(const char *name
, ...);
584 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
585 unsigned num_arguments
,
589 * Create a new image built-in function for all known image types.
590 * \p flags is a bitfield of \c image_function_flags flags.
592 void add_image_function(const char *name
,
593 const char *intrinsic_name
,
594 image_prototype_ctr prototype
,
595 unsigned num_arguments
,
599 * Create new functions for all known image built-ins and types.
600 * If \p glsl is \c true, use the GLSL built-in names and emit code
601 * to call into the actual compiler intrinsic. If \p glsl is
602 * false, emit a function prototype with no body for each image
605 void add_image_functions(bool glsl
);
607 ir_function_signature
*new_sig(const glsl_type
*return_type
,
608 builtin_available_predicate avail
,
609 int num_params
, ...);
612 * Function signature generators:
615 ir_function_signature
*unop(builtin_available_predicate avail
,
616 ir_expression_operation opcode
,
617 const glsl_type
*return_type
,
618 const glsl_type
*param_type
);
619 ir_function_signature
*binop(builtin_available_predicate avail
,
620 ir_expression_operation opcode
,
621 const glsl_type
*return_type
,
622 const glsl_type
*param0_type
,
623 const glsl_type
*param1_type
);
625 #define B0(X) ir_function_signature *_##X();
626 #define B1(X) ir_function_signature *_##X(const glsl_type *);
627 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
628 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
629 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
630 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
667 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
668 const glsl_type
*val_type
,
669 const glsl_type
*blend_type
);
678 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
679 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
680 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
681 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
682 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
683 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
684 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
685 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
686 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
687 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
688 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
689 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
702 BA1(determinant_mat2
);
703 BA1(determinant_mat3
);
704 BA1(determinant_mat4
);
712 BA1(greaterThanEqual
);
721 /** Flags to _texture() */
722 #define TEX_PROJECT 1
724 #define TEX_COMPONENT 4
725 #define TEX_OFFSET_NONCONST 8
726 #define TEX_OFFSET_ARRAY 16
728 ir_function_signature
*_texture(ir_texture_opcode opcode
,
729 builtin_available_predicate avail
,
730 const glsl_type
*return_type
,
731 const glsl_type
*sampler_type
,
732 const glsl_type
*coord_type
,
734 B0(textureCubeArrayShadow
);
735 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
736 const glsl_type
*return_type
,
737 const glsl_type
*sampler_type
,
738 const glsl_type
*coord_type
,
739 const glsl_type
*offset_type
= NULL
);
743 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
744 const glsl_type
*stream_type
);
745 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
746 const glsl_type
*stream_type
);
749 BA2(textureQueryLod
);
750 B1(textureQueryLevels
);
751 BA2(textureSamplesIdentical
);
779 B1(interpolateAtCentroid
)
780 B1(interpolateAtOffset
)
781 B1(interpolateAtSample
)
783 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
784 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
785 builtin_available_predicate avail
);
787 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
788 const glsl_type
*type
);
789 ir_function_signature
*_atomic_op2(const char *intrinsic
,
790 builtin_available_predicate avail
,
791 const glsl_type
*type
);
792 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
793 const glsl_type
*type
);
794 ir_function_signature
*_atomic_op3(const char *intrinsic
,
795 builtin_available_predicate avail
,
796 const glsl_type
*type
);
802 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
803 unsigned num_arguments
,
805 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
806 unsigned num_arguments
,
808 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
809 unsigned num_arguments
,
811 ir_function_signature
*_image(image_prototype_ctr prototype
,
812 const glsl_type
*image_type
,
813 const char *intrinsic_name
,
814 unsigned num_arguments
,
817 ir_function_signature
*_memory_barrier_intrinsic(
818 builtin_available_predicate avail
);
819 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
820 builtin_available_predicate avail
);
822 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
823 const glsl_type
*type
);
824 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
825 const glsl_type
*type
);
836 enum image_function_flags
{
837 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
838 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
839 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
840 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
841 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
842 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
843 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
844 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
845 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
848 } /* anonymous namespace */
851 * Core builtin_builder functionality:
854 builtin_builder::builtin_builder()
856 gl_ModelViewProjectionMatrix(NULL
),
862 builtin_builder::~builtin_builder()
864 ralloc_free(mem_ctx
);
867 ir_function_signature
*
868 builtin_builder::find(_mesa_glsl_parse_state
*state
,
869 const char *name
, exec_list
*actual_parameters
)
871 /* The shader currently being compiled requested a built-in function;
872 * it needs to link against builtin_builder::shader in order to get them.
874 * Even if we don't find a matching signature, we still need to do this so
875 * that the "no matching signature" error will list potential candidates
876 * from the available built-ins.
878 state
->uses_builtin_functions
= true;
880 ir_function
*f
= shader
->symbols
->get_function(name
);
884 ir_function_signature
*sig
=
885 f
->matching_signature(state
, actual_parameters
, true);
893 builtin_builder::initialize()
895 /* If already initialized, don't do it again. */
899 mem_ctx
= ralloc_context(NULL
);
906 builtin_builder::release()
908 ralloc_free(mem_ctx
);
916 builtin_builder::create_shader()
918 /* The target doesn't actually matter. There's no target for generic
919 * GLSL utility code that could be linked against any stage, so just
920 * arbitrarily pick GL_VERTEX_SHADER.
922 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
923 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
925 gl_ModelViewProjectionMatrix
=
926 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
927 "gl_ModelViewProjectionMatrix",
930 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
932 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
933 shader
->symbols
->add_variable(gl_Vertex
);
939 * Create ir_function and ir_function_signature objects for each
943 builtin_builder::create_intrinsics()
945 add_function("__intrinsic_atomic_read",
946 _atomic_counter_intrinsic(shader_atomic_counters
),
948 add_function("__intrinsic_atomic_increment",
949 _atomic_counter_intrinsic(shader_atomic_counters
),
951 add_function("__intrinsic_atomic_predecrement",
952 _atomic_counter_intrinsic(shader_atomic_counters
),
955 add_function("__intrinsic_atomic_add",
956 _atomic_intrinsic2(buffer_atomics_supported
,
957 glsl_type::uint_type
),
958 _atomic_intrinsic2(buffer_atomics_supported
,
959 glsl_type::int_type
),
961 add_function("__intrinsic_atomic_min",
962 _atomic_intrinsic2(buffer_atomics_supported
,
963 glsl_type::uint_type
),
964 _atomic_intrinsic2(buffer_atomics_supported
,
965 glsl_type::int_type
),
967 add_function("__intrinsic_atomic_max",
968 _atomic_intrinsic2(buffer_atomics_supported
,
969 glsl_type::uint_type
),
970 _atomic_intrinsic2(buffer_atomics_supported
,
971 glsl_type::int_type
),
973 add_function("__intrinsic_atomic_and",
974 _atomic_intrinsic2(buffer_atomics_supported
,
975 glsl_type::uint_type
),
976 _atomic_intrinsic2(buffer_atomics_supported
,
977 glsl_type::int_type
),
979 add_function("__intrinsic_atomic_or",
980 _atomic_intrinsic2(buffer_atomics_supported
,
981 glsl_type::uint_type
),
982 _atomic_intrinsic2(buffer_atomics_supported
,
983 glsl_type::int_type
),
985 add_function("__intrinsic_atomic_xor",
986 _atomic_intrinsic2(buffer_atomics_supported
,
987 glsl_type::uint_type
),
988 _atomic_intrinsic2(buffer_atomics_supported
,
989 glsl_type::int_type
),
991 add_function("__intrinsic_atomic_exchange",
992 _atomic_intrinsic2(buffer_atomics_supported
,
993 glsl_type::uint_type
),
994 _atomic_intrinsic2(buffer_atomics_supported
,
995 glsl_type::int_type
),
997 add_function("__intrinsic_atomic_comp_swap",
998 _atomic_intrinsic3(buffer_atomics_supported
,
999 glsl_type::uint_type
),
1000 _atomic_intrinsic3(buffer_atomics_supported
,
1001 glsl_type::int_type
),
1004 add_image_functions(false);
1006 add_function("__intrinsic_memory_barrier",
1007 _memory_barrier_intrinsic(shader_image_load_store
),
1009 add_function("__intrinsic_group_memory_barrier",
1010 _memory_barrier_intrinsic(compute_shader
),
1012 add_function("__intrinsic_memory_barrier_atomic_counter",
1013 _memory_barrier_intrinsic(compute_shader
),
1015 add_function("__intrinsic_memory_barrier_buffer",
1016 _memory_barrier_intrinsic(compute_shader
),
1018 add_function("__intrinsic_memory_barrier_image",
1019 _memory_barrier_intrinsic(compute_shader
),
1021 add_function("__intrinsic_memory_barrier_shared",
1022 _memory_barrier_intrinsic(compute_shader
),
1025 add_function("__intrinsic_shader_clock",
1026 _shader_clock_intrinsic(shader_clock
,
1027 glsl_type::uvec2_type
),
1032 * Create ir_function and ir_function_signature objects for each built-in.
1034 * Contains a list of every available built-in.
1037 builtin_builder::create_builtins()
1040 add_function(#NAME, \
1041 _##NAME(glsl_type::float_type), \
1042 _##NAME(glsl_type::vec2_type), \
1043 _##NAME(glsl_type::vec3_type), \
1044 _##NAME(glsl_type::vec4_type), \
1048 add_function(#NAME, \
1049 _##NAME(always_available, glsl_type::float_type), \
1050 _##NAME(always_available, glsl_type::vec2_type), \
1051 _##NAME(always_available, glsl_type::vec3_type), \
1052 _##NAME(always_available, glsl_type::vec4_type), \
1053 _##NAME(fp64, glsl_type::double_type), \
1054 _##NAME(fp64, glsl_type::dvec2_type), \
1055 _##NAME(fp64, glsl_type::dvec3_type), \
1056 _##NAME(fp64, glsl_type::dvec4_type), \
1059 #define FD130(NAME) \
1060 add_function(#NAME, \
1061 _##NAME(v130, glsl_type::float_type), \
1062 _##NAME(v130, glsl_type::vec2_type), \
1063 _##NAME(v130, glsl_type::vec3_type), \
1064 _##NAME(v130, glsl_type::vec4_type), \
1065 _##NAME(fp64, glsl_type::double_type), \
1066 _##NAME(fp64, glsl_type::dvec2_type), \
1067 _##NAME(fp64, glsl_type::dvec3_type), \
1068 _##NAME(fp64, glsl_type::dvec4_type), \
1071 #define FDGS5(NAME) \
1072 add_function(#NAME, \
1073 _##NAME(gpu_shader5, glsl_type::float_type), \
1074 _##NAME(gpu_shader5, glsl_type::vec2_type), \
1075 _##NAME(gpu_shader5, glsl_type::vec3_type), \
1076 _##NAME(gpu_shader5, glsl_type::vec4_type), \
1077 _##NAME(fp64, glsl_type::double_type), \
1078 _##NAME(fp64, glsl_type::dvec2_type), \
1079 _##NAME(fp64, glsl_type::dvec3_type), \
1080 _##NAME(fp64, glsl_type::dvec4_type), \
1084 add_function(#NAME, \
1085 _##NAME(glsl_type::float_type), \
1086 _##NAME(glsl_type::vec2_type), \
1087 _##NAME(glsl_type::vec3_type), \
1088 _##NAME(glsl_type::vec4_type), \
1089 _##NAME(glsl_type::int_type), \
1090 _##NAME(glsl_type::ivec2_type), \
1091 _##NAME(glsl_type::ivec3_type), \
1092 _##NAME(glsl_type::ivec4_type), \
1096 add_function(#NAME, \
1097 _##NAME(always_available, glsl_type::float_type), \
1098 _##NAME(always_available, glsl_type::vec2_type), \
1099 _##NAME(always_available, glsl_type::vec3_type), \
1100 _##NAME(always_available, glsl_type::vec4_type), \
1101 _##NAME(always_available, glsl_type::int_type), \
1102 _##NAME(always_available, glsl_type::ivec2_type), \
1103 _##NAME(always_available, glsl_type::ivec3_type), \
1104 _##NAME(always_available, glsl_type::ivec4_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), \
1111 #define FIUD(NAME) \
1112 add_function(#NAME, \
1113 _##NAME(always_available, glsl_type::float_type), \
1114 _##NAME(always_available, glsl_type::vec2_type), \
1115 _##NAME(always_available, glsl_type::vec3_type), \
1116 _##NAME(always_available, glsl_type::vec4_type), \
1118 _##NAME(always_available, glsl_type::int_type), \
1119 _##NAME(always_available, glsl_type::ivec2_type), \
1120 _##NAME(always_available, glsl_type::ivec3_type), \
1121 _##NAME(always_available, glsl_type::ivec4_type), \
1123 _##NAME(v130, glsl_type::uint_type), \
1124 _##NAME(v130, glsl_type::uvec2_type), \
1125 _##NAME(v130, glsl_type::uvec3_type), \
1126 _##NAME(v130, glsl_type::uvec4_type), \
1127 _##NAME(fp64, glsl_type::double_type), \
1128 _##NAME(fp64, glsl_type::dvec2_type), \
1129 _##NAME(fp64, glsl_type::dvec3_type), \
1130 _##NAME(fp64, glsl_type::dvec4_type), \
1134 add_function(#NAME, \
1135 _##NAME(glsl_type::int_type), \
1136 _##NAME(glsl_type::ivec2_type), \
1137 _##NAME(glsl_type::ivec3_type), \
1138 _##NAME(glsl_type::ivec4_type), \
1140 _##NAME(glsl_type::uint_type), \
1141 _##NAME(glsl_type::uvec2_type), \
1142 _##NAME(glsl_type::uvec3_type), \
1143 _##NAME(glsl_type::uvec4_type), \
1146 #define FIUBD(NAME) \
1147 add_function(#NAME, \
1148 _##NAME(always_available, glsl_type::float_type), \
1149 _##NAME(always_available, glsl_type::vec2_type), \
1150 _##NAME(always_available, glsl_type::vec3_type), \
1151 _##NAME(always_available, glsl_type::vec4_type), \
1153 _##NAME(always_available, glsl_type::int_type), \
1154 _##NAME(always_available, glsl_type::ivec2_type), \
1155 _##NAME(always_available, glsl_type::ivec3_type), \
1156 _##NAME(always_available, glsl_type::ivec4_type), \
1158 _##NAME(v130, glsl_type::uint_type), \
1159 _##NAME(v130, glsl_type::uvec2_type), \
1160 _##NAME(v130, glsl_type::uvec3_type), \
1161 _##NAME(v130, glsl_type::uvec4_type), \
1163 _##NAME(always_available, glsl_type::bool_type), \
1164 _##NAME(always_available, glsl_type::bvec2_type), \
1165 _##NAME(always_available, glsl_type::bvec3_type), \
1166 _##NAME(always_available, glsl_type::bvec4_type), \
1168 _##NAME(fp64, glsl_type::double_type), \
1169 _##NAME(fp64, glsl_type::dvec2_type), \
1170 _##NAME(fp64, glsl_type::dvec3_type), \
1171 _##NAME(fp64, glsl_type::dvec4_type), \
1174 #define FIUD2_MIXED(NAME) \
1175 add_function(#NAME, \
1176 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1177 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1178 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1179 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1181 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1182 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1183 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1185 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1186 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1187 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1188 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1190 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1191 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1192 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1194 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1195 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1196 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1197 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1199 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1200 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1201 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1203 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1204 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1205 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1206 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1207 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1208 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1209 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1220 add_function("atan",
1221 _atan(glsl_type::float_type
),
1222 _atan(glsl_type::vec2_type
),
1223 _atan(glsl_type::vec3_type
),
1224 _atan(glsl_type::vec4_type
),
1225 _atan2(glsl_type::float_type
),
1226 _atan2(glsl_type::vec2_type
),
1227 _atan2(glsl_type::vec3_type
),
1228 _atan2(glsl_type::vec4_type
),
1254 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1255 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1256 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1257 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1259 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1260 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1261 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1263 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1264 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1265 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1266 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1268 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1269 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1270 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1280 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1281 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1282 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1283 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1285 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1286 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1287 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1289 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1290 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1291 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1292 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1294 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1295 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1296 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1298 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1299 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1300 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1301 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1303 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1304 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1305 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1306 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1308 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1309 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1310 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1311 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1313 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1314 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1315 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1316 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1318 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1319 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1320 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1321 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1324 add_function("step",
1325 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1326 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1327 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1328 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1330 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1331 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1332 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1333 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1334 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1335 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1336 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1338 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1339 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1340 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1343 add_function("smoothstep",
1344 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1345 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1346 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1347 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1349 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1350 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1351 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1352 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1353 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1354 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1355 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1357 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1358 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1359 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1367 add_function("intBitsToFloat",
1368 _intBitsToFloat(glsl_type::int_type
),
1369 _intBitsToFloat(glsl_type::ivec2_type
),
1370 _intBitsToFloat(glsl_type::ivec3_type
),
1371 _intBitsToFloat(glsl_type::ivec4_type
),
1373 add_function("uintBitsToFloat",
1374 _uintBitsToFloat(glsl_type::uint_type
),
1375 _uintBitsToFloat(glsl_type::uvec2_type
),
1376 _uintBitsToFloat(glsl_type::uvec3_type
),
1377 _uintBitsToFloat(glsl_type::uvec4_type
),
1380 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1381 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1382 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1383 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1384 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1385 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1386 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1387 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1388 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1389 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1390 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1391 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1398 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1399 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1402 add_function("ftransform", _ftransform(), NULL
);
1407 add_function("matrixCompMult",
1408 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1409 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1410 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1411 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1412 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1413 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1414 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1415 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1416 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1417 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1418 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1419 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1420 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1421 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1422 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1423 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1424 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1425 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1427 add_function("outerProduct",
1428 _outerProduct(v120
, glsl_type::mat2_type
),
1429 _outerProduct(v120
, glsl_type::mat3_type
),
1430 _outerProduct(v120
, glsl_type::mat4_type
),
1431 _outerProduct(v120
, glsl_type::mat2x3_type
),
1432 _outerProduct(v120
, glsl_type::mat2x4_type
),
1433 _outerProduct(v120
, glsl_type::mat3x2_type
),
1434 _outerProduct(v120
, glsl_type::mat3x4_type
),
1435 _outerProduct(v120
, glsl_type::mat4x2_type
),
1436 _outerProduct(v120
, glsl_type::mat4x3_type
),
1437 _outerProduct(fp64
, glsl_type::dmat2_type
),
1438 _outerProduct(fp64
, glsl_type::dmat3_type
),
1439 _outerProduct(fp64
, glsl_type::dmat4_type
),
1440 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1441 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1442 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1443 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1444 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1445 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1447 add_function("determinant",
1448 _determinant_mat2(v120
, glsl_type::mat2_type
),
1449 _determinant_mat3(v120
, glsl_type::mat3_type
),
1450 _determinant_mat4(v120
, glsl_type::mat4_type
),
1451 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1452 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1453 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1456 add_function("inverse",
1457 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1458 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1459 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1460 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1461 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1462 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1464 add_function("transpose",
1465 _transpose(v120
, glsl_type::mat2_type
),
1466 _transpose(v120
, glsl_type::mat3_type
),
1467 _transpose(v120
, glsl_type::mat4_type
),
1468 _transpose(v120
, glsl_type::mat2x3_type
),
1469 _transpose(v120
, glsl_type::mat2x4_type
),
1470 _transpose(v120
, glsl_type::mat3x2_type
),
1471 _transpose(v120
, glsl_type::mat3x4_type
),
1472 _transpose(v120
, glsl_type::mat4x2_type
),
1473 _transpose(v120
, glsl_type::mat4x3_type
),
1474 _transpose(fp64
, glsl_type::dmat2_type
),
1475 _transpose(fp64
, glsl_type::dmat3_type
),
1476 _transpose(fp64
, glsl_type::dmat4_type
),
1477 _transpose(fp64
, glsl_type::dmat2x3_type
),
1478 _transpose(fp64
, glsl_type::dmat2x4_type
),
1479 _transpose(fp64
, glsl_type::dmat3x2_type
),
1480 _transpose(fp64
, glsl_type::dmat3x4_type
),
1481 _transpose(fp64
, glsl_type::dmat4x2_type
),
1482 _transpose(fp64
, glsl_type::dmat4x3_type
),
1487 FIUD(greaterThanEqual
)
1492 _any(glsl_type::bvec2_type
),
1493 _any(glsl_type::bvec3_type
),
1494 _any(glsl_type::bvec4_type
),
1498 _all(glsl_type::bvec2_type
),
1499 _all(glsl_type::bvec3_type
),
1500 _all(glsl_type::bvec4_type
),
1504 _not(glsl_type::bvec2_type
),
1505 _not(glsl_type::bvec3_type
),
1506 _not(glsl_type::bvec4_type
),
1509 add_function("textureSize",
1510 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1511 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1512 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1514 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1515 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1516 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1518 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1519 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1520 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1522 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1523 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1524 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1526 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1527 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1528 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1530 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1531 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1532 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1533 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1534 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1535 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1537 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1538 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1540 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1541 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1542 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1543 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1545 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1546 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1547 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1548 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1550 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1551 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1552 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1553 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1554 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1555 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1557 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1558 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1559 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1562 add_function("textureSamples",
1563 _textureSamples(glsl_type::sampler2DMS_type
),
1564 _textureSamples(glsl_type::isampler2DMS_type
),
1565 _textureSamples(glsl_type::usampler2DMS_type
),
1567 _textureSamples(glsl_type::sampler2DMSArray_type
),
1568 _textureSamples(glsl_type::isampler2DMSArray_type
),
1569 _textureSamples(glsl_type::usampler2DMSArray_type
),
1572 add_function("texture",
1573 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1574 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1575 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1577 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1578 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1579 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1581 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1582 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1583 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1585 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1586 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1587 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1589 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1590 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1591 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1593 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1594 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1595 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1597 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1598 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1599 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1601 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1602 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1603 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1605 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1606 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1607 /* samplerCubeArrayShadow is special; it has an extra parameter
1608 * for the shadow comparitor since there is no vec5 type.
1610 _textureCubeArrayShadow(),
1612 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1613 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1614 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1616 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1618 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1619 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1620 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1622 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1623 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1624 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1626 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1627 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1628 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1630 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1631 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1632 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1634 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1635 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1636 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1638 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1639 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1640 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1642 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1643 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1644 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1646 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1647 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1648 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1650 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1653 add_function("textureLod",
1654 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1655 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1656 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1658 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1659 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1660 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1662 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1663 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1664 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1666 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1667 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1668 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1670 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1671 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1673 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1674 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1675 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1677 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1678 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1679 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1681 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1682 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1683 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1685 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1688 add_function("textureOffset",
1689 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1690 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1691 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1693 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1694 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1695 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1697 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1698 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1699 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1701 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1702 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1703 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1705 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1707 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1708 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1710 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1711 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1712 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1714 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1715 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1716 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1718 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1720 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1721 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1722 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1724 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1725 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1726 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1728 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1729 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1730 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1732 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1733 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1735 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1736 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1737 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1739 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1740 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1741 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1743 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1746 add_function("textureProj",
1747 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1748 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1749 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1750 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1751 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1752 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1754 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1755 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1756 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1757 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1758 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1759 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1761 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1763 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1765 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1766 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1768 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1769 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1770 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1771 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1772 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1773 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1775 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1777 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1778 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1779 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1780 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1781 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1782 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1784 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1785 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1786 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1787 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1788 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1789 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1791 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1792 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1793 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1795 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1796 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1799 add_function("texelFetch",
1800 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1801 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1802 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1804 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1805 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1806 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1808 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1809 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1810 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1812 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1813 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1814 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1816 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1817 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1818 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1820 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1821 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1822 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1824 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1825 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1826 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1828 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1829 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1830 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1832 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1833 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1834 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1837 add_function("texelFetchOffset",
1838 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1839 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1840 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1842 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1843 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1844 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1846 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1847 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1848 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1850 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1851 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1852 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1854 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1855 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1856 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1858 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1859 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1860 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1864 add_function("textureProjOffset",
1865 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1866 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1867 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1868 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1869 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1870 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1872 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1873 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1874 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1875 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1876 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1877 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1879 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1880 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1881 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1883 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1884 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1886 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1887 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1888 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1889 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1890 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1891 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1893 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1895 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1896 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1897 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1898 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1899 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1900 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1902 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1903 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1904 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1905 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1906 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1907 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1909 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1910 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1911 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1914 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 add_function("textureLodOffset",
1918 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1919 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1920 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1922 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1923 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1924 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1926 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1927 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1928 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1930 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1931 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1933 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1934 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1935 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1937 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1938 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1939 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1941 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1944 add_function("textureProjLod",
1945 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1946 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1947 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1948 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1949 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1950 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1952 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1953 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1954 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1955 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1956 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1957 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1959 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1960 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1961 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1963 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1964 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1967 add_function("textureProjLodOffset",
1968 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1969 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1971 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1972 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1973 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1975 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1976 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1977 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1978 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1979 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1980 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1982 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1983 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1984 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1986 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1987 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1990 add_function("textureGrad",
1991 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1992 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1993 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1995 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1996 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1997 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1999 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2000 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2001 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2003 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2004 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2005 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2007 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2008 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2009 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2011 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2013 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2014 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2015 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2017 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2018 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2019 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2021 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2022 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2023 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2025 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2026 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2027 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2029 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2030 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2033 add_function("textureGradOffset",
2034 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2035 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2036 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2038 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2039 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2040 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2042 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2043 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2044 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2046 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2047 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2048 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2050 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2052 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2053 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2055 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2056 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2057 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2059 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2060 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2061 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2063 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2064 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2067 add_function("textureProjGrad",
2068 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2069 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2070 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2071 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2072 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2073 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2075 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2076 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2077 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2078 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2079 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2080 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2082 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2083 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2084 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2086 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2087 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2088 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2089 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2090 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2091 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2093 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2095 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2096 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2099 add_function("textureProjGradOffset",
2100 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2101 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2102 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2103 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2104 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2105 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2107 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2108 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2109 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2110 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2111 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2112 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2114 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2115 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2116 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2118 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2119 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2120 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2121 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2122 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2123 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2125 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2127 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2128 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2131 add_function("EmitVertex", _EmitVertex(), NULL
);
2132 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2133 add_function("EmitStreamVertex",
2134 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2135 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2137 add_function("EndStreamPrimitive",
2138 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2139 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2141 add_function("barrier", _barrier(), NULL
);
2143 add_function("textureQueryLOD",
2144 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2145 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2146 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2148 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2149 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2150 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2152 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2153 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2154 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2156 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2157 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2158 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2160 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2161 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2162 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2164 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2165 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2166 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2168 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2169 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2170 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2172 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2173 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2174 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2175 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2176 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2177 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2180 add_function("textureQueryLod",
2181 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2182 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2183 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2185 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2186 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2187 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2189 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2190 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2191 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2193 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2194 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2195 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2197 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2198 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2199 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2201 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2202 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2203 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2205 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2206 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2207 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2209 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2210 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2211 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2212 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2213 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2214 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2217 add_function("textureQueryLevels",
2218 _textureQueryLevels(glsl_type::sampler1D_type
),
2219 _textureQueryLevels(glsl_type::sampler2D_type
),
2220 _textureQueryLevels(glsl_type::sampler3D_type
),
2221 _textureQueryLevels(glsl_type::samplerCube_type
),
2222 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2223 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2224 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2225 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2226 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2227 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2228 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2229 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2230 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2232 _textureQueryLevels(glsl_type::isampler1D_type
),
2233 _textureQueryLevels(glsl_type::isampler2D_type
),
2234 _textureQueryLevels(glsl_type::isampler3D_type
),
2235 _textureQueryLevels(glsl_type::isamplerCube_type
),
2236 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2237 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2238 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2240 _textureQueryLevels(glsl_type::usampler1D_type
),
2241 _textureQueryLevels(glsl_type::usampler2D_type
),
2242 _textureQueryLevels(glsl_type::usampler3D_type
),
2243 _textureQueryLevels(glsl_type::usamplerCube_type
),
2244 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2245 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2246 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2250 add_function("textureSamplesIdenticalEXT",
2251 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2252 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2253 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2255 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2256 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2257 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2260 add_function("texture1D",
2261 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2262 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2265 add_function("texture1DArray",
2266 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2267 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2270 add_function("texture1DProj",
2271 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2272 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2273 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2274 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2277 add_function("texture1DLod",
2278 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2281 add_function("texture1DArrayLod",
2282 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2285 add_function("texture1DProjLod",
2286 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2287 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2290 add_function("texture2D",
2291 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2292 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2293 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2296 add_function("texture2DArray",
2297 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2298 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2301 add_function("texture2DProj",
2302 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2303 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2304 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2305 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2306 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2307 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2310 add_function("texture2DLod",
2311 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2314 add_function("texture2DArrayLod",
2315 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2318 add_function("texture2DProjLod",
2319 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2320 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2323 add_function("texture3D",
2324 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2325 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2328 add_function("texture3DProj",
2329 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2330 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2333 add_function("texture3DLod",
2334 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2337 add_function("texture3DProjLod",
2338 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2341 add_function("textureCube",
2342 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2343 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2346 add_function("textureCubeLod",
2347 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2350 add_function("texture2DRect",
2351 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2354 add_function("texture2DRectProj",
2355 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2356 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2359 add_function("shadow1D",
2360 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2361 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2364 add_function("shadow1DArray",
2365 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2366 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2369 add_function("shadow2D",
2370 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2371 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2374 add_function("shadow2DArray",
2375 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2376 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2379 add_function("shadow1DProj",
2380 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2381 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2384 add_function("shadow2DProj",
2385 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2386 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2389 add_function("shadow1DLod",
2390 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2393 add_function("shadow2DLod",
2394 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2397 add_function("shadow1DArrayLod",
2398 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2401 add_function("shadow1DProjLod",
2402 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2405 add_function("shadow2DProjLod",
2406 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2409 add_function("shadow2DRect",
2410 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2413 add_function("shadow2DRectProj",
2414 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2417 add_function("texture1DGradARB",
2418 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2421 add_function("texture1DProjGradARB",
2422 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2423 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2426 add_function("texture2DGradARB",
2427 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2430 add_function("texture2DProjGradARB",
2431 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2432 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2435 add_function("texture3DGradARB",
2436 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2439 add_function("texture3DProjGradARB",
2440 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2443 add_function("textureCubeGradARB",
2444 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2447 add_function("shadow1DGradARB",
2448 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2451 add_function("shadow1DProjGradARB",
2452 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2455 add_function("shadow2DGradARB",
2456 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2459 add_function("shadow2DProjGradARB",
2460 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2463 add_function("texture2DRectGradARB",
2464 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2467 add_function("texture2DRectProjGradARB",
2468 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2469 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2472 add_function("shadow2DRectGradARB",
2473 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2476 add_function("shadow2DRectProjGradARB",
2477 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2480 add_function("textureGather",
2481 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2482 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2483 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2485 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2486 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2487 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2489 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2490 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2491 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2493 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2494 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2495 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2497 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2498 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2499 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2501 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2502 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2503 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2505 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2506 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2507 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2509 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2510 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2511 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2513 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2514 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2515 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2517 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2518 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2519 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2521 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2522 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2523 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2524 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2525 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2528 add_function("textureGatherOffset",
2529 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2530 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2531 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2533 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2534 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2535 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2537 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2538 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2539 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2541 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2542 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2543 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2545 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2546 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2547 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2549 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2550 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2551 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2553 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2554 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2555 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2557 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2558 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2559 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2561 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2562 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2563 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2565 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2566 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2567 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2569 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2570 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2571 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2573 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2574 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2577 add_function("textureGatherOffsets",
2578 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2579 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2580 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2582 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2583 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2584 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2586 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2587 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2588 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2590 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2591 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2592 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2594 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2595 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2596 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2598 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2599 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2600 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2602 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2603 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2604 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2629 add_function("ldexp",
2630 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2631 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2632 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2633 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2634 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2635 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2636 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2637 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2640 add_function("frexp",
2641 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2642 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2643 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2644 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2645 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2646 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2647 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2648 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2650 add_function("uaddCarry",
2651 _uaddCarry(glsl_type::uint_type
),
2652 _uaddCarry(glsl_type::uvec2_type
),
2653 _uaddCarry(glsl_type::uvec3_type
),
2654 _uaddCarry(glsl_type::uvec4_type
),
2656 add_function("usubBorrow",
2657 _usubBorrow(glsl_type::uint_type
),
2658 _usubBorrow(glsl_type::uvec2_type
),
2659 _usubBorrow(glsl_type::uvec3_type
),
2660 _usubBorrow(glsl_type::uvec4_type
),
2662 add_function("imulExtended",
2663 _mulExtended(glsl_type::int_type
),
2664 _mulExtended(glsl_type::ivec2_type
),
2665 _mulExtended(glsl_type::ivec3_type
),
2666 _mulExtended(glsl_type::ivec4_type
),
2668 add_function("umulExtended",
2669 _mulExtended(glsl_type::uint_type
),
2670 _mulExtended(glsl_type::uvec2_type
),
2671 _mulExtended(glsl_type::uvec3_type
),
2672 _mulExtended(glsl_type::uvec4_type
),
2674 add_function("interpolateAtCentroid",
2675 _interpolateAtCentroid(glsl_type::float_type
),
2676 _interpolateAtCentroid(glsl_type::vec2_type
),
2677 _interpolateAtCentroid(glsl_type::vec3_type
),
2678 _interpolateAtCentroid(glsl_type::vec4_type
),
2680 add_function("interpolateAtOffset",
2681 _interpolateAtOffset(glsl_type::float_type
),
2682 _interpolateAtOffset(glsl_type::vec2_type
),
2683 _interpolateAtOffset(glsl_type::vec3_type
),
2684 _interpolateAtOffset(glsl_type::vec4_type
),
2686 add_function("interpolateAtSample",
2687 _interpolateAtSample(glsl_type::float_type
),
2688 _interpolateAtSample(glsl_type::vec2_type
),
2689 _interpolateAtSample(glsl_type::vec3_type
),
2690 _interpolateAtSample(glsl_type::vec4_type
),
2693 add_function("atomicCounter",
2694 _atomic_counter_op("__intrinsic_atomic_read",
2695 shader_atomic_counters
),
2697 add_function("atomicCounterIncrement",
2698 _atomic_counter_op("__intrinsic_atomic_increment",
2699 shader_atomic_counters
),
2701 add_function("atomicCounterDecrement",
2702 _atomic_counter_op("__intrinsic_atomic_predecrement",
2703 shader_atomic_counters
),
2706 add_function("atomicAdd",
2707 _atomic_op2("__intrinsic_atomic_add",
2708 buffer_atomics_supported
,
2709 glsl_type::uint_type
),
2710 _atomic_op2("__intrinsic_atomic_add",
2711 buffer_atomics_supported
,
2712 glsl_type::int_type
),
2714 add_function("atomicMin",
2715 _atomic_op2("__intrinsic_atomic_min",
2716 buffer_atomics_supported
,
2717 glsl_type::uint_type
),
2718 _atomic_op2("__intrinsic_atomic_min",
2719 buffer_atomics_supported
,
2720 glsl_type::int_type
),
2722 add_function("atomicMax",
2723 _atomic_op2("__intrinsic_atomic_max",
2724 buffer_atomics_supported
,
2725 glsl_type::uint_type
),
2726 _atomic_op2("__intrinsic_atomic_max",
2727 buffer_atomics_supported
,
2728 glsl_type::int_type
),
2730 add_function("atomicAnd",
2731 _atomic_op2("__intrinsic_atomic_and",
2732 buffer_atomics_supported
,
2733 glsl_type::uint_type
),
2734 _atomic_op2("__intrinsic_atomic_and",
2735 buffer_atomics_supported
,
2736 glsl_type::int_type
),
2738 add_function("atomicOr",
2739 _atomic_op2("__intrinsic_atomic_or",
2740 buffer_atomics_supported
,
2741 glsl_type::uint_type
),
2742 _atomic_op2("__intrinsic_atomic_or",
2743 buffer_atomics_supported
,
2744 glsl_type::int_type
),
2746 add_function("atomicXor",
2747 _atomic_op2("__intrinsic_atomic_xor",
2748 buffer_atomics_supported
,
2749 glsl_type::uint_type
),
2750 _atomic_op2("__intrinsic_atomic_xor",
2751 buffer_atomics_supported
,
2752 glsl_type::int_type
),
2754 add_function("atomicExchange",
2755 _atomic_op2("__intrinsic_atomic_exchange",
2756 buffer_atomics_supported
,
2757 glsl_type::uint_type
),
2758 _atomic_op2("__intrinsic_atomic_exchange",
2759 buffer_atomics_supported
,
2760 glsl_type::int_type
),
2762 add_function("atomicCompSwap",
2763 _atomic_op3("__intrinsic_atomic_comp_swap",
2764 buffer_atomics_supported
,
2765 glsl_type::uint_type
),
2766 _atomic_op3("__intrinsic_atomic_comp_swap",
2767 buffer_atomics_supported
,
2768 glsl_type::int_type
),
2771 add_function("min3",
2772 _min3(glsl_type::float_type
),
2773 _min3(glsl_type::vec2_type
),
2774 _min3(glsl_type::vec3_type
),
2775 _min3(glsl_type::vec4_type
),
2777 _min3(glsl_type::int_type
),
2778 _min3(glsl_type::ivec2_type
),
2779 _min3(glsl_type::ivec3_type
),
2780 _min3(glsl_type::ivec4_type
),
2782 _min3(glsl_type::uint_type
),
2783 _min3(glsl_type::uvec2_type
),
2784 _min3(glsl_type::uvec3_type
),
2785 _min3(glsl_type::uvec4_type
),
2788 add_function("max3",
2789 _max3(glsl_type::float_type
),
2790 _max3(glsl_type::vec2_type
),
2791 _max3(glsl_type::vec3_type
),
2792 _max3(glsl_type::vec4_type
),
2794 _max3(glsl_type::int_type
),
2795 _max3(glsl_type::ivec2_type
),
2796 _max3(glsl_type::ivec3_type
),
2797 _max3(glsl_type::ivec4_type
),
2799 _max3(glsl_type::uint_type
),
2800 _max3(glsl_type::uvec2_type
),
2801 _max3(glsl_type::uvec3_type
),
2802 _max3(glsl_type::uvec4_type
),
2805 add_function("mid3",
2806 _mid3(glsl_type::float_type
),
2807 _mid3(glsl_type::vec2_type
),
2808 _mid3(glsl_type::vec3_type
),
2809 _mid3(glsl_type::vec4_type
),
2811 _mid3(glsl_type::int_type
),
2812 _mid3(glsl_type::ivec2_type
),
2813 _mid3(glsl_type::ivec3_type
),
2814 _mid3(glsl_type::ivec4_type
),
2816 _mid3(glsl_type::uint_type
),
2817 _mid3(glsl_type::uvec2_type
),
2818 _mid3(glsl_type::uvec3_type
),
2819 _mid3(glsl_type::uvec4_type
),
2822 add_image_functions(true);
2824 add_function("memoryBarrier",
2825 _memory_barrier("__intrinsic_memory_barrier",
2826 shader_image_load_store
),
2828 add_function("groupMemoryBarrier",
2829 _memory_barrier("__intrinsic_group_memory_barrier",
2832 add_function("memoryBarrierAtomicCounter",
2833 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2836 add_function("memoryBarrierBuffer",
2837 _memory_barrier("__intrinsic_memory_barrier_buffer",
2840 add_function("memoryBarrierImage",
2841 _memory_barrier("__intrinsic_memory_barrier_image",
2844 add_function("memoryBarrierShared",
2845 _memory_barrier("__intrinsic_memory_barrier_shared",
2849 add_function("clock2x32ARB",
2850 _shader_clock(shader_clock
,
2851 glsl_type::uvec2_type
),
2862 builtin_builder::add_function(const char *name
, ...)
2866 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2870 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2876 stuff
.push_tail(sig
);
2877 validate_ir_tree(&stuff
);
2880 f
->add_signature(sig
);
2884 shader
->symbols
->add_function(f
);
2888 builtin_builder::add_image_function(const char *name
,
2889 const char *intrinsic_name
,
2890 image_prototype_ctr prototype
,
2891 unsigned num_arguments
,
2894 static const glsl_type
*const types
[] = {
2895 glsl_type::image1D_type
,
2896 glsl_type::image2D_type
,
2897 glsl_type::image3D_type
,
2898 glsl_type::image2DRect_type
,
2899 glsl_type::imageCube_type
,
2900 glsl_type::imageBuffer_type
,
2901 glsl_type::image1DArray_type
,
2902 glsl_type::image2DArray_type
,
2903 glsl_type::imageCubeArray_type
,
2904 glsl_type::image2DMS_type
,
2905 glsl_type::image2DMSArray_type
,
2906 glsl_type::iimage1D_type
,
2907 glsl_type::iimage2D_type
,
2908 glsl_type::iimage3D_type
,
2909 glsl_type::iimage2DRect_type
,
2910 glsl_type::iimageCube_type
,
2911 glsl_type::iimageBuffer_type
,
2912 glsl_type::iimage1DArray_type
,
2913 glsl_type::iimage2DArray_type
,
2914 glsl_type::iimageCubeArray_type
,
2915 glsl_type::iimage2DMS_type
,
2916 glsl_type::iimage2DMSArray_type
,
2917 glsl_type::uimage1D_type
,
2918 glsl_type::uimage2D_type
,
2919 glsl_type::uimage3D_type
,
2920 glsl_type::uimage2DRect_type
,
2921 glsl_type::uimageCube_type
,
2922 glsl_type::uimageBuffer_type
,
2923 glsl_type::uimage1DArray_type
,
2924 glsl_type::uimage2DArray_type
,
2925 glsl_type::uimageCubeArray_type
,
2926 glsl_type::uimage2DMS_type
,
2927 glsl_type::uimage2DMSArray_type
2930 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2932 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2933 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
2934 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2935 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2936 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2937 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2938 num_arguments
, flags
));
2941 shader
->symbols
->add_function(f
);
2945 builtin_builder::add_image_functions(bool glsl
)
2947 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2949 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2950 "__intrinsic_image_load",
2951 &builtin_builder::_image_prototype
, 0,
2952 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2953 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2954 IMAGE_FUNCTION_READ_ONLY
));
2956 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2957 "__intrinsic_image_store",
2958 &builtin_builder::_image_prototype
, 1,
2959 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2960 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2961 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2962 IMAGE_FUNCTION_WRITE_ONLY
));
2964 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2966 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2967 "__intrinsic_image_atomic_add",
2968 &builtin_builder::_image_prototype
, 1, atom_flags
);
2970 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2971 "__intrinsic_image_atomic_min",
2972 &builtin_builder::_image_prototype
, 1, atom_flags
);
2974 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2975 "__intrinsic_image_atomic_max",
2976 &builtin_builder::_image_prototype
, 1, atom_flags
);
2978 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2979 "__intrinsic_image_atomic_and",
2980 &builtin_builder::_image_prototype
, 1, atom_flags
);
2982 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2983 "__intrinsic_image_atomic_or",
2984 &builtin_builder::_image_prototype
, 1, atom_flags
);
2986 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2987 "__intrinsic_image_atomic_xor",
2988 &builtin_builder::_image_prototype
, 1, atom_flags
);
2990 add_image_function((glsl
? "imageAtomicExchange" :
2991 "__intrinsic_image_atomic_exchange"),
2992 "__intrinsic_image_atomic_exchange",
2993 &builtin_builder::_image_prototype
, 1,
2994 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
2995 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
));
2997 add_image_function((glsl
? "imageAtomicCompSwap" :
2998 "__intrinsic_image_atomic_comp_swap"),
2999 "__intrinsic_image_atomic_comp_swap",
3000 &builtin_builder::_image_prototype
, 2, atom_flags
);
3002 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3003 "__intrinsic_image_size",
3004 &builtin_builder::_image_size_prototype
, 1,
3005 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
3007 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3008 "__intrinsic_image_samples",
3009 &builtin_builder::_image_samples_prototype
, 1,
3010 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3011 IMAGE_FUNCTION_MS_ONLY
);
3015 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3017 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3021 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3023 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3027 builtin_builder::imm(bool b
, unsigned vector_elements
)
3029 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3033 builtin_builder::imm(float f
, unsigned vector_elements
)
3035 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3039 builtin_builder::imm(int i
, unsigned vector_elements
)
3041 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3045 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3047 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3051 builtin_builder::imm(double d
, unsigned vector_elements
)
3053 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3057 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3059 return new(mem_ctx
) ir_constant(type
, &data
);
3062 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3064 ir_dereference_variable
*
3065 builtin_builder::var_ref(ir_variable
*var
)
3067 return new(mem_ctx
) ir_dereference_variable(var
);
3070 ir_dereference_array
*
3071 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3073 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3076 /** Return an element of a matrix */
3078 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3080 return swizzle(array_ref(var
, column
), row
, 1);
3084 * Implementations of built-in functions:
3087 ir_function_signature
*
3088 builtin_builder::new_sig(const glsl_type
*return_type
,
3089 builtin_available_predicate avail
,
3095 ir_function_signature
*sig
=
3096 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3099 va_start(ap
, num_params
);
3100 for (int i
= 0; i
< num_params
; i
++) {
3101 plist
.push_tail(va_arg(ap
, ir_variable
*));
3105 sig
->replace_parameters(&plist
);
3109 #define MAKE_SIG(return_type, avail, ...) \
3110 ir_function_signature *sig = \
3111 new_sig(return_type, avail, __VA_ARGS__); \
3112 ir_factory body(&sig->body, mem_ctx); \
3113 sig->is_defined = true;
3115 #define MAKE_INTRINSIC(return_type, avail, ...) \
3116 ir_function_signature *sig = \
3117 new_sig(return_type, avail, __VA_ARGS__); \
3118 sig->is_intrinsic = true;
3120 ir_function_signature
*
3121 builtin_builder::unop(builtin_available_predicate avail
,
3122 ir_expression_operation opcode
,
3123 const glsl_type
*return_type
,
3124 const glsl_type
*param_type
)
3126 ir_variable
*x
= in_var(param_type
, "x");
3127 MAKE_SIG(return_type
, avail
, 1, x
);
3128 body
.emit(ret(expr(opcode
, x
)));
3132 #define UNOP(NAME, OPCODE, AVAIL) \
3133 ir_function_signature * \
3134 builtin_builder::_##NAME(const glsl_type *type) \
3136 return unop(&AVAIL, OPCODE, type, type); \
3139 #define UNOPA(NAME, OPCODE) \
3140 ir_function_signature * \
3141 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3143 return unop(avail, OPCODE, type, type); \
3146 ir_function_signature
*
3147 builtin_builder::binop(builtin_available_predicate avail
,
3148 ir_expression_operation opcode
,
3149 const glsl_type
*return_type
,
3150 const glsl_type
*param0_type
,
3151 const glsl_type
*param1_type
)
3153 ir_variable
*x
= in_var(param0_type
, "x");
3154 ir_variable
*y
= in_var(param1_type
, "y");
3155 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3156 body
.emit(ret(expr(opcode
, x
, y
)));
3160 #define BINOP(NAME, OPCODE, AVAIL) \
3161 ir_function_signature * \
3162 builtin_builder::_##NAME(const glsl_type *return_type, \
3163 const glsl_type *param0_type, \
3164 const glsl_type *param1_type) \
3166 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3170 * Angle and Trigonometry Functions @{
3173 ir_function_signature
*
3174 builtin_builder::_radians(const glsl_type
*type
)
3176 ir_variable
*degrees
= in_var(type
, "degrees");
3177 MAKE_SIG(type
, always_available
, 1, degrees
);
3178 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3182 ir_function_signature
*
3183 builtin_builder::_degrees(const glsl_type
*type
)
3185 ir_variable
*radians
= in_var(type
, "radians");
3186 MAKE_SIG(type
, always_available
, 1, radians
);
3187 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3191 UNOP(sin
, ir_unop_sin
, always_available
)
3192 UNOP(cos
, ir_unop_cos
, always_available
)
3194 ir_function_signature
*
3195 builtin_builder::_tan(const glsl_type
*type
)
3197 ir_variable
*theta
= in_var(type
, "theta");
3198 MAKE_SIG(type
, always_available
, 1, theta
);
3199 body
.emit(ret(div(sin(theta
), cos(theta
))));
3204 builtin_builder::asin_expr(ir_variable
*x
)
3208 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3211 add(imm(M_PI_4f
- 1.0f
),
3213 add(imm(0.086566724f
),
3214 mul(abs(x
), imm(-0.03102955f
))))))))));
3218 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3220 exec_list actual_params
;
3222 foreach_in_list(ir_variable
, var
, ¶ms
) {
3223 actual_params
.push_tail(var_ref(var
));
3226 ir_function_signature
*sig
=
3227 f
->exact_matching_signature(NULL
, &actual_params
);
3231 ir_dereference_variable
*deref
=
3232 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3234 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3237 ir_function_signature
*
3238 builtin_builder::_asin(const glsl_type
*type
)
3240 ir_variable
*x
= in_var(type
, "x");
3241 MAKE_SIG(type
, always_available
, 1, x
);
3243 body
.emit(ret(asin_expr(x
)));
3248 ir_function_signature
*
3249 builtin_builder::_acos(const glsl_type
*type
)
3251 ir_variable
*x
= in_var(type
, "x");
3252 MAKE_SIG(type
, always_available
, 1, x
);
3254 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3259 ir_function_signature
*
3260 builtin_builder::_atan2(const glsl_type
*type
)
3262 ir_variable
*vec_y
= in_var(type
, "vec_y");
3263 ir_variable
*vec_x
= in_var(type
, "vec_x");
3264 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3266 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3267 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3268 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3269 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3270 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3271 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3272 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3274 /* If |x| >= 1.0e-8 * |y|: */
3276 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3278 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3280 /* Then...call atan(y/x) */
3281 do_atan(outer_then
, glsl_type::float_type
, r
, div(y
, x
));
3283 /* ...and fix it up: */
3284 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3285 inner_if
->then_instructions
.push_tail(
3286 if_tree(gequal(y
, imm(0.0f
)),
3287 assign(r
, add(r
, imm(M_PIf
))),
3288 assign(r
, sub(r
, imm(M_PIf
)))));
3289 outer_then
.emit(inner_if
);
3292 outer_if
->else_instructions
.push_tail(
3293 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3295 body
.emit(outer_if
);
3297 body
.emit(assign(vec_result
, r
, 1 << i
));
3299 body
.emit(ret(vec_result
));
3305 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3308 * range-reduction, first step:
3310 * / y_over_x if |y_over_x| <= 1.0;
3312 * \ 1.0 / y_over_x otherwise
3314 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3315 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3321 * approximate atan by evaluating polynomial:
3323 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3324 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3325 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3327 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3328 body
.emit(assign(tmp
, mul(x
, x
)));
3329 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3331 imm(0.0536813784310406f
)),
3333 imm(0.1173503194786851f
)),
3335 imm(0.1938924977115610f
)),
3337 imm(0.3326756418091246f
)),
3339 imm(0.9999793128310355f
)),
3342 /* range-reduction fixup */
3343 body
.emit(assign(tmp
, add(tmp
,
3344 mul(b2f(greater(abs(y_over_x
),
3345 imm(1.0f
, type
->components()))),
3351 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3354 ir_function_signature
*
3355 builtin_builder::_atan(const glsl_type
*type
)
3357 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3358 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3360 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3361 do_atan(body
, type
, tmp
, y_over_x
);
3362 body
.emit(ret(tmp
));
3367 ir_function_signature
*
3368 builtin_builder::_sinh(const glsl_type
*type
)
3370 ir_variable
*x
= in_var(type
, "x");
3371 MAKE_SIG(type
, v130
, 1, x
);
3373 /* 0.5 * (e^x - e^(-x)) */
3374 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3379 ir_function_signature
*
3380 builtin_builder::_cosh(const glsl_type
*type
)
3382 ir_variable
*x
= in_var(type
, "x");
3383 MAKE_SIG(type
, v130
, 1, x
);
3385 /* 0.5 * (e^x + e^(-x)) */
3386 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3391 ir_function_signature
*
3392 builtin_builder::_tanh(const glsl_type
*type
)
3394 ir_variable
*x
= in_var(type
, "x");
3395 MAKE_SIG(type
, v130
, 1, x
);
3397 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3398 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3399 add(exp(x
), exp(neg(x
))))));
3404 ir_function_signature
*
3405 builtin_builder::_asinh(const glsl_type
*type
)
3407 ir_variable
*x
= in_var(type
, "x");
3408 MAKE_SIG(type
, v130
, 1, x
);
3410 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3415 ir_function_signature
*
3416 builtin_builder::_acosh(const glsl_type
*type
)
3418 ir_variable
*x
= in_var(type
, "x");
3419 MAKE_SIG(type
, v130
, 1, x
);
3421 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3425 ir_function_signature
*
3426 builtin_builder::_atanh(const glsl_type
*type
)
3428 ir_variable
*x
= in_var(type
, "x");
3429 MAKE_SIG(type
, v130
, 1, x
);
3431 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3432 sub(imm(1.0f
), x
))))));
3438 * Exponential Functions @{
3441 ir_function_signature
*
3442 builtin_builder::_pow(const glsl_type
*type
)
3444 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3447 UNOP(exp
, ir_unop_exp
, always_available
)
3448 UNOP(log
, ir_unop_log
, always_available
)
3449 UNOP(exp2
, ir_unop_exp2
, always_available
)
3450 UNOP(log2
, ir_unop_log2
, always_available
)
3451 UNOPA(sqrt
, ir_unop_sqrt
)
3452 UNOPA(inversesqrt
, ir_unop_rsq
)
3456 UNOPA(abs
, ir_unop_abs
)
3457 UNOPA(sign
, ir_unop_sign
)
3458 UNOPA(floor
, ir_unop_floor
)
3459 UNOPA(trunc
, ir_unop_trunc
)
3460 UNOPA(round
, ir_unop_round_even
)
3461 UNOPA(roundEven
, ir_unop_round_even
)
3462 UNOPA(ceil
, ir_unop_ceil
)
3463 UNOPA(fract
, ir_unop_fract
)
3465 ir_function_signature
*
3466 builtin_builder::_mod(builtin_available_predicate avail
,
3467 const glsl_type
*x_type
, const glsl_type
*y_type
)
3469 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3472 ir_function_signature
*
3473 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3475 ir_variable
*x
= in_var(type
, "x");
3476 ir_variable
*i
= out_var(type
, "i");
3477 MAKE_SIG(type
, avail
, 2, x
, i
);
3479 ir_variable
*t
= body
.make_temp(type
, "t");
3480 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3481 body
.emit(assign(i
, t
));
3482 body
.emit(ret(sub(x
, t
)));
3487 ir_function_signature
*
3488 builtin_builder::_min(builtin_available_predicate avail
,
3489 const glsl_type
*x_type
, const glsl_type
*y_type
)
3491 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3494 ir_function_signature
*
3495 builtin_builder::_max(builtin_available_predicate avail
,
3496 const glsl_type
*x_type
, const glsl_type
*y_type
)
3498 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3501 ir_function_signature
*
3502 builtin_builder::_clamp(builtin_available_predicate avail
,
3503 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3505 ir_variable
*x
= in_var(val_type
, "x");
3506 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3507 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3508 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3510 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3515 ir_function_signature
*
3516 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3518 ir_variable
*x
= in_var(val_type
, "x");
3519 ir_variable
*y
= in_var(val_type
, "y");
3520 ir_variable
*a
= in_var(blend_type
, "a");
3521 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3523 body
.emit(ret(lrp(x
, y
, a
)));
3528 ir_function_signature
*
3529 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3530 const glsl_type
*val_type
,
3531 const glsl_type
*blend_type
)
3533 ir_variable
*x
= in_var(val_type
, "x");
3534 ir_variable
*y
= in_var(val_type
, "y");
3535 ir_variable
*a
= in_var(blend_type
, "a");
3536 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3538 /* csel matches the ternary operator in that a selector of true choses the
3539 * first argument. This differs from mix(x, y, false) which choses the
3540 * second argument (to remain consistent with the interpolating version of
3541 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3543 * To handle the behavior mismatch, reverse the x and y arguments.
3545 body
.emit(ret(csel(a
, y
, x
)));
3550 ir_function_signature
*
3551 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3553 ir_variable
*edge
= in_var(edge_type
, "edge");
3554 ir_variable
*x
= in_var(x_type
, "x");
3555 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3557 ir_variable
*t
= body
.make_temp(x_type
, "t");
3558 if (x_type
->vector_elements
== 1) {
3559 /* Both are floats */
3560 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3561 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3563 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3564 } else if (edge_type
->vector_elements
== 1) {
3565 /* x is a vector but edge is a float */
3566 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3567 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3568 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3570 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3573 /* Both are vectors */
3574 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3575 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3576 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3579 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3589 ir_function_signature
*
3590 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3592 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3593 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3594 ir_variable
*x
= in_var(x_type
, "x");
3595 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3597 /* From the GLSL 1.10 specification:
3600 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3601 * return t * t * (3 - 2 * t);
3604 ir_variable
*t
= body
.make_temp(x_type
, "t");
3605 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3606 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3608 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3613 ir_function_signature
*
3614 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3616 ir_variable
*x
= in_var(type
, "x");
3617 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3619 body
.emit(ret(nequal(x
, x
)));
3624 ir_function_signature
*
3625 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3627 ir_variable
*x
= in_var(type
, "x");
3628 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3630 ir_constant_data infinities
;
3631 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3632 switch (type
->base_type
) {
3633 case GLSL_TYPE_FLOAT
:
3634 infinities
.f
[i
] = INFINITY
;
3636 case GLSL_TYPE_DOUBLE
:
3637 infinities
.d
[i
] = INFINITY
;
3640 unreachable("unknown type");
3644 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3649 ir_function_signature
*
3650 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3652 ir_variable
*x
= in_var(type
, "x");
3653 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3654 body
.emit(ret(bitcast_f2i(x
)));
3658 ir_function_signature
*
3659 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3661 ir_variable
*x
= in_var(type
, "x");
3662 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3663 body
.emit(ret(bitcast_f2u(x
)));
3667 ir_function_signature
*
3668 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3670 ir_variable
*x
= in_var(type
, "x");
3671 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3672 body
.emit(ret(bitcast_i2f(x
)));
3676 ir_function_signature
*
3677 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3679 ir_variable
*x
= in_var(type
, "x");
3680 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3681 body
.emit(ret(bitcast_u2f(x
)));
3685 ir_function_signature
*
3686 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3688 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3689 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3690 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3694 ir_function_signature
*
3695 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3697 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3698 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3699 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3703 ir_function_signature
*
3704 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3706 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3707 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3708 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3712 ir_function_signature
*
3713 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3715 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3716 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3717 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3721 ir_function_signature
*
3722 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3724 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3725 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3726 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3730 ir_function_signature
*
3731 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3733 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3734 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3735 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3740 ir_function_signature
*
3741 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3743 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3744 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3745 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3749 ir_function_signature
*
3750 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3752 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3753 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3754 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3758 ir_function_signature
*
3759 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3761 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3762 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3763 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3767 ir_function_signature
*
3768 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3770 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3771 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3772 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3776 ir_function_signature
*
3777 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3779 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3780 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3781 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3785 ir_function_signature
*
3786 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3788 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3789 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3790 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3794 ir_function_signature
*
3795 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3797 ir_variable
*x
= in_var(type
, "x");
3798 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3800 body
.emit(ret(sqrt(dot(x
, x
))));
3805 ir_function_signature
*
3806 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3808 ir_variable
*p0
= in_var(type
, "p0");
3809 ir_variable
*p1
= in_var(type
, "p1");
3810 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3812 if (type
->vector_elements
== 1) {
3813 body
.emit(ret(abs(sub(p0
, p1
))));
3815 ir_variable
*p
= body
.make_temp(type
, "p");
3816 body
.emit(assign(p
, sub(p0
, p1
)));
3817 body
.emit(ret(sqrt(dot(p
, p
))));
3823 ir_function_signature
*
3824 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3826 if (type
->vector_elements
== 1)
3827 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3829 return binop(avail
, ir_binop_dot
,
3830 type
->get_base_type(), type
, type
);
3833 ir_function_signature
*
3834 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3836 ir_variable
*a
= in_var(type
, "a");
3837 ir_variable
*b
= in_var(type
, "b");
3838 MAKE_SIG(type
, avail
, 2, a
, b
);
3840 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3841 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3843 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3844 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3849 ir_function_signature
*
3850 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3852 ir_variable
*x
= in_var(type
, "x");
3853 MAKE_SIG(type
, avail
, 1, x
);
3855 if (type
->vector_elements
== 1) {
3856 body
.emit(ret(sign(x
)));
3858 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3864 ir_function_signature
*
3865 builtin_builder::_ftransform()
3867 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3869 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3870 glsl_type::vec4_type
,
3871 var_ref(gl_ModelViewProjectionMatrix
),
3872 var_ref(gl_Vertex
))));
3874 /* FINISHME: Once the ir_expression() constructor handles type inference
3875 * for matrix operations, we can simplify this to:
3877 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3882 ir_function_signature
*
3883 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3885 ir_variable
*N
= in_var(type
, "N");
3886 ir_variable
*I
= in_var(type
, "I");
3887 ir_variable
*Nref
= in_var(type
, "Nref");
3888 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3890 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3891 ret(N
), ret(neg(N
))));
3896 ir_function_signature
*
3897 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3899 ir_variable
*I
= in_var(type
, "I");
3900 ir_variable
*N
= in_var(type
, "N");
3901 MAKE_SIG(type
, avail
, 2, I
, N
);
3903 /* I - 2 * dot(N, I) * N */
3904 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3909 ir_function_signature
*
3910 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3912 ir_variable
*I
= in_var(type
, "I");
3913 ir_variable
*N
= in_var(type
, "N");
3914 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3915 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3917 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3918 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3920 /* From the GLSL 1.10 specification:
3921 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3923 * return genType(0.0)
3925 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3927 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3928 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3929 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3930 mul(n_dot_i
, n_dot_i
)))))));
3931 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3932 ret(ir_constant::zero(mem_ctx
, type
)),
3933 ret(sub(mul(eta
, I
),
3934 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3939 ir_function_signature
*
3940 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3942 ir_variable
*x
= in_var(type
, "x");
3943 ir_variable
*y
= in_var(type
, "y");
3944 MAKE_SIG(type
, avail
, 2, x
, y
);
3946 ir_variable
*z
= body
.make_temp(type
, "z");
3947 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3948 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3955 ir_function_signature
*
3956 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3961 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3962 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3963 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3965 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3966 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3968 MAKE_SIG(type
, avail
, 2, c
, r
);
3970 ir_variable
*m
= body
.make_temp(type
, "m");
3971 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3972 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3979 ir_function_signature
*
3980 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3982 const glsl_type
*transpose_type
=
3983 glsl_type::get_instance(orig_type
->base_type
,
3984 orig_type
->matrix_columns
,
3985 orig_type
->vector_elements
);
3987 ir_variable
*m
= in_var(orig_type
, "m");
3988 MAKE_SIG(transpose_type
, avail
, 1, m
);
3990 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3991 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3992 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3993 body
.emit(assign(array_ref(t
, j
),
3994 matrix_elt(m
, i
, j
),
4003 ir_function_signature
*
4004 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4006 ir_variable
*m
= in_var(type
, "m");
4007 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4009 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4010 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4015 ir_function_signature
*
4016 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4018 ir_variable
*m
= in_var(type
, "m");
4019 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4022 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4023 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4026 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4027 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4030 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4031 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4033 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4034 mul(matrix_elt(m
, 0, 1), f2
)),
4035 mul(matrix_elt(m
, 0, 2), f3
))));
4040 ir_function_signature
*
4041 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4043 ir_variable
*m
= in_var(type
, "m");
4044 const glsl_type
*btype
= type
->get_base_type();
4045 MAKE_SIG(btype
, avail
, 1, m
);
4047 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4048 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4049 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4050 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4051 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4052 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4053 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4054 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4055 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4056 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4057 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4058 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4059 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4060 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4061 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4062 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4063 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4064 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4065 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4067 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)))));
4068 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)))));
4069 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)))));
4070 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)))));
4071 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)))));
4072 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)))));
4073 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)))));
4074 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)))));
4075 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)))));
4076 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)))));
4077 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)))));
4078 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)))));
4079 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)))));
4080 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)))));
4081 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)))));
4082 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)))));
4083 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)))));
4084 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)))));
4085 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)))));
4087 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4089 body
.emit(assign(adj_0
,
4090 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4091 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4092 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4094 body
.emit(assign(adj_0
, neg(
4095 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4096 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4097 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4099 body
.emit(assign(adj_0
,
4100 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4101 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4102 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4104 body
.emit(assign(adj_0
, neg(
4105 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4106 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4107 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4110 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4115 ir_function_signature
*
4116 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4118 ir_variable
*m
= in_var(type
, "m");
4119 MAKE_SIG(type
, avail
, 1, m
);
4121 ir_variable
*adj
= body
.make_temp(type
, "adj");
4122 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4123 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4124 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4125 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4127 ir_expression
*det
=
4128 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4129 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4131 body
.emit(ret(div(adj
, det
)));
4135 ir_function_signature
*
4136 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4138 ir_variable
*m
= in_var(type
, "m");
4139 const glsl_type
*btype
= type
->get_base_type();
4140 MAKE_SIG(type
, avail
, 1, m
);
4142 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4143 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4144 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4146 body
.emit(assign(f11_22_21_12
,
4147 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4148 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4149 body
.emit(assign(f10_22_20_12
,
4150 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4151 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4152 body
.emit(assign(f10_21_20_11
,
4153 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4154 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4156 ir_variable
*adj
= body
.make_temp(type
, "adj");
4157 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4158 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4159 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4161 body
.emit(assign(array_ref(adj
, 0), neg(
4162 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4163 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4165 body
.emit(assign(array_ref(adj
, 1),
4166 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4167 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4169 body
.emit(assign(array_ref(adj
, 2), neg(
4170 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4171 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4174 body
.emit(assign(array_ref(adj
, 0),
4175 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4176 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4178 body
.emit(assign(array_ref(adj
, 1), neg(
4179 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4180 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4182 body
.emit(assign(array_ref(adj
, 2),
4183 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4184 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4187 ir_expression
*det
=
4188 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4189 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4190 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4192 body
.emit(ret(div(adj
, det
)));
4197 ir_function_signature
*
4198 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4200 ir_variable
*m
= in_var(type
, "m");
4201 const glsl_type
*btype
= type
->get_base_type();
4202 MAKE_SIG(type
, avail
, 1, m
);
4204 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4205 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4206 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4207 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4208 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4209 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4210 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4211 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4212 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4213 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4214 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4215 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4216 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4217 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4218 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4219 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4220 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4221 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4222 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4224 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)))));
4225 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)))));
4226 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)))));
4227 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)))));
4228 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)))));
4229 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)))));
4230 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)))));
4231 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)))));
4232 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)))));
4233 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)))));
4234 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)))));
4235 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)))));
4236 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)))));
4237 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)))));
4238 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)))));
4239 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)))));
4240 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)))));
4241 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)))));
4242 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)))));
4244 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4245 body
.emit(assign(array_ref(adj
, 0),
4246 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4247 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4248 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4250 body
.emit(assign(array_ref(adj
, 1), neg(
4251 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4252 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4253 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4255 body
.emit(assign(array_ref(adj
, 2),
4256 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4257 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4258 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4260 body
.emit(assign(array_ref(adj
, 3), neg(
4261 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4262 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4263 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4266 body
.emit(assign(array_ref(adj
, 0), neg(
4267 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4268 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4269 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4271 body
.emit(assign(array_ref(adj
, 1),
4272 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4273 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4274 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4276 body
.emit(assign(array_ref(adj
, 2), neg(
4277 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4278 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4279 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4281 body
.emit(assign(array_ref(adj
, 3),
4282 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4283 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4284 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4287 body
.emit(assign(array_ref(adj
, 0),
4288 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4289 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4290 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4292 body
.emit(assign(array_ref(adj
, 1), neg(
4293 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4294 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4295 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4297 body
.emit(assign(array_ref(adj
, 2),
4298 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4299 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4300 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4302 body
.emit(assign(array_ref(adj
, 3), neg(
4303 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4304 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4305 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4308 body
.emit(assign(array_ref(adj
, 0), neg(
4309 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4310 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4311 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4313 body
.emit(assign(array_ref(adj
, 1),
4314 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4315 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4316 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4318 body
.emit(assign(array_ref(adj
, 2), neg(
4319 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4320 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4321 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4323 body
.emit(assign(array_ref(adj
, 3),
4324 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4325 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4326 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4329 ir_expression
*det
=
4330 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4331 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4332 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4333 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4335 body
.emit(ret(div(adj
, det
)));
4341 ir_function_signature
*
4342 builtin_builder::_lessThan(builtin_available_predicate avail
,
4343 const glsl_type
*type
)
4345 return binop(avail
, ir_binop_less
,
4346 glsl_type::bvec(type
->vector_elements
), type
, type
);
4349 ir_function_signature
*
4350 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4351 const glsl_type
*type
)
4353 return binop(avail
, ir_binop_lequal
,
4354 glsl_type::bvec(type
->vector_elements
), type
, type
);
4357 ir_function_signature
*
4358 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4359 const glsl_type
*type
)
4361 return binop(avail
, ir_binop_greater
,
4362 glsl_type::bvec(type
->vector_elements
), type
, type
);
4365 ir_function_signature
*
4366 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4367 const glsl_type
*type
)
4369 return binop(avail
, ir_binop_gequal
,
4370 glsl_type::bvec(type
->vector_elements
), type
, type
);
4373 ir_function_signature
*
4374 builtin_builder::_equal(builtin_available_predicate avail
,
4375 const glsl_type
*type
)
4377 return binop(avail
, ir_binop_equal
,
4378 glsl_type::bvec(type
->vector_elements
), type
, type
);
4381 ir_function_signature
*
4382 builtin_builder::_notEqual(builtin_available_predicate avail
,
4383 const glsl_type
*type
)
4385 return binop(avail
, ir_binop_nequal
,
4386 glsl_type::bvec(type
->vector_elements
), type
, type
);
4389 ir_function_signature
*
4390 builtin_builder::_any(const glsl_type
*type
)
4392 ir_variable
*v
= in_var(type
, "v");
4393 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4395 const unsigned vec_elem
= v
->type
->vector_elements
;
4396 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4401 ir_function_signature
*
4402 builtin_builder::_all(const glsl_type
*type
)
4404 ir_variable
*v
= in_var(type
, "v");
4405 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4407 const unsigned vec_elem
= v
->type
->vector_elements
;
4408 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4413 UNOP(not, ir_unop_logic_not
, always_available
)
4416 has_lod(const glsl_type
*sampler_type
)
4418 assert(sampler_type
->is_sampler());
4420 switch (sampler_type
->sampler_dimensionality
) {
4421 case GLSL_SAMPLER_DIM_RECT
:
4422 case GLSL_SAMPLER_DIM_BUF
:
4423 case GLSL_SAMPLER_DIM_MS
:
4430 ir_function_signature
*
4431 builtin_builder::_textureSize(builtin_available_predicate avail
,
4432 const glsl_type
*return_type
,
4433 const glsl_type
*sampler_type
)
4435 ir_variable
*s
= in_var(sampler_type
, "sampler");
4436 /* The sampler always exists; add optional lod later. */
4437 MAKE_SIG(return_type
, avail
, 1, s
);
4439 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4440 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4442 if (has_lod(sampler_type
)) {
4443 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4444 sig
->parameters
.push_tail(lod
);
4445 tex
->lod_info
.lod
= var_ref(lod
);
4447 tex
->lod_info
.lod
= imm(0u);
4450 body
.emit(ret(tex
));
4455 ir_function_signature
*
4456 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4458 ir_variable
*s
= in_var(sampler_type
, "sampler");
4459 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4461 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4462 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4463 body
.emit(ret(tex
));
4468 ir_function_signature
*
4469 builtin_builder::_texture(ir_texture_opcode opcode
,
4470 builtin_available_predicate avail
,
4471 const glsl_type
*return_type
,
4472 const glsl_type
*sampler_type
,
4473 const glsl_type
*coord_type
,
4476 ir_variable
*s
= in_var(sampler_type
, "sampler");
4477 ir_variable
*P
= in_var(coord_type
, "P");
4478 /* The sampler and coordinate always exist; add optional parameters later. */
4479 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4481 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4482 tex
->set_sampler(var_ref(s
), return_type
);
4484 const int coord_size
= sampler_type
->coordinate_components();
4486 if (coord_size
== coord_type
->vector_elements
) {
4487 tex
->coordinate
= var_ref(P
);
4489 /* The incoming coordinate also has the projector or shadow comparitor,
4490 * so we need to swizzle those away.
4492 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4495 /* The projector is always in the last component. */
4496 if (flags
& TEX_PROJECT
)
4497 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4499 if (sampler_type
->sampler_shadow
) {
4500 if (opcode
== ir_tg4
) {
4501 /* gather has refz as a separate parameter, immediately after the
4504 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4505 sig
->parameters
.push_tail(refz
);
4506 tex
->shadow_comparitor
= var_ref(refz
);
4508 /* The shadow comparitor is normally in the Z component, but a few types
4509 * have sufficiently large coordinates that it's in W.
4511 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4515 if (opcode
== ir_txl
) {
4516 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4517 sig
->parameters
.push_tail(lod
);
4518 tex
->lod_info
.lod
= var_ref(lod
);
4519 } else if (opcode
== ir_txd
) {
4520 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4521 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4522 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4523 sig
->parameters
.push_tail(dPdx
);
4524 sig
->parameters
.push_tail(dPdy
);
4525 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4526 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4529 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4530 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4531 ir_variable
*offset
=
4532 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4533 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4534 sig
->parameters
.push_tail(offset
);
4535 tex
->offset
= var_ref(offset
);
4538 if (flags
& TEX_OFFSET_ARRAY
) {
4539 ir_variable
*offsets
=
4540 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4541 "offsets", ir_var_const_in
);
4542 sig
->parameters
.push_tail(offsets
);
4543 tex
->offset
= var_ref(offsets
);
4546 if (opcode
== ir_tg4
) {
4547 if (flags
& TEX_COMPONENT
) {
4548 ir_variable
*component
=
4549 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4550 sig
->parameters
.push_tail(component
);
4551 tex
->lod_info
.component
= var_ref(component
);
4554 tex
->lod_info
.component
= imm(0);
4558 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4559 * inconsistent with both textureLodOffset and textureGradOffset.
4561 if (opcode
== ir_txb
) {
4562 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4563 sig
->parameters
.push_tail(bias
);
4564 tex
->lod_info
.bias
= var_ref(bias
);
4567 body
.emit(ret(tex
));
4572 ir_function_signature
*
4573 builtin_builder::_textureCubeArrayShadow()
4575 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4576 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4577 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4578 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4580 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4581 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4583 tex
->coordinate
= var_ref(P
);
4584 tex
->shadow_comparitor
= var_ref(compare
);
4586 body
.emit(ret(tex
));
4591 ir_function_signature
*
4592 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4593 const glsl_type
*return_type
,
4594 const glsl_type
*sampler_type
,
4595 const glsl_type
*coord_type
,
4596 const glsl_type
*offset_type
)
4598 ir_variable
*s
= in_var(sampler_type
, "sampler");
4599 ir_variable
*P
= in_var(coord_type
, "P");
4600 /* The sampler and coordinate always exist; add optional parameters later. */
4601 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4603 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4604 tex
->coordinate
= var_ref(P
);
4605 tex
->set_sampler(var_ref(s
), return_type
);
4607 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4608 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4609 sig
->parameters
.push_tail(sample
);
4610 tex
->lod_info
.sample_index
= var_ref(sample
);
4611 tex
->op
= ir_txf_ms
;
4612 } else if (has_lod(sampler_type
)) {
4613 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4614 sig
->parameters
.push_tail(lod
);
4615 tex
->lod_info
.lod
= var_ref(lod
);
4617 tex
->lod_info
.lod
= imm(0u);
4620 if (offset_type
!= NULL
) {
4621 ir_variable
*offset
=
4622 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4623 sig
->parameters
.push_tail(offset
);
4624 tex
->offset
= var_ref(offset
);
4627 body
.emit(ret(tex
));
4632 ir_function_signature
*
4633 builtin_builder::_EmitVertex()
4635 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4637 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4638 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4643 ir_function_signature
*
4644 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4645 const glsl_type
*stream_type
)
4647 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4649 * "Emit the current values of output variables to the current output
4650 * primitive on stream stream. The argument to stream must be a constant
4651 * integral expression."
4653 ir_variable
*stream
=
4654 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4656 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4658 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4663 ir_function_signature
*
4664 builtin_builder::_EndPrimitive()
4666 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4668 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4669 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4674 ir_function_signature
*
4675 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4676 const glsl_type
*stream_type
)
4678 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4680 * "Completes the current output primitive on stream stream and starts
4681 * a new one. The argument to stream must be a constant integral
4684 ir_variable
*stream
=
4685 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4687 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4689 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4694 ir_function_signature
*
4695 builtin_builder::_barrier()
4697 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4699 body
.emit(new(mem_ctx
) ir_barrier());
4703 ir_function_signature
*
4704 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4705 const glsl_type
*sampler_type
,
4706 const glsl_type
*coord_type
)
4708 ir_variable
*s
= in_var(sampler_type
, "sampler");
4709 ir_variable
*coord
= in_var(coord_type
, "coord");
4710 /* The sampler and coordinate always exist; add optional parameters later. */
4711 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4713 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4714 tex
->coordinate
= var_ref(coord
);
4715 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4717 body
.emit(ret(tex
));
4722 ir_function_signature
*
4723 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4725 ir_variable
*s
= in_var(sampler_type
, "sampler");
4726 const glsl_type
*return_type
= glsl_type::int_type
;
4727 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4729 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4730 tex
->set_sampler(var_ref(s
), return_type
);
4732 body
.emit(ret(tex
));
4737 ir_function_signature
*
4738 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4739 const glsl_type
*sampler_type
,
4740 const glsl_type
*coord_type
)
4742 ir_variable
*s
= in_var(sampler_type
, "sampler");
4743 ir_variable
*P
= in_var(coord_type
, "P");
4744 const glsl_type
*return_type
= glsl_type::bool_type
;
4745 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4747 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4748 tex
->coordinate
= var_ref(P
);
4749 tex
->set_sampler(var_ref(s
), return_type
);
4751 body
.emit(ret(tex
));
4756 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4757 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4758 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4759 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4760 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4761 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4763 ir_function_signature
*
4764 builtin_builder::_fwidth(const glsl_type
*type
)
4766 ir_variable
*p
= in_var(type
, "p");
4767 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4769 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4774 ir_function_signature
*
4775 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4777 ir_variable
*p
= in_var(type
, "p");
4778 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4780 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4781 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4786 ir_function_signature
*
4787 builtin_builder::_fwidthFine(const glsl_type
*type
)
4789 ir_variable
*p
= in_var(type
, "p");
4790 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4792 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4793 abs(expr(ir_unop_dFdy_fine
, p
)))));
4798 ir_function_signature
*
4799 builtin_builder::_noise1(const glsl_type
*type
)
4801 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4804 ir_function_signature
*
4805 builtin_builder::_noise2(const glsl_type
*type
)
4807 ir_variable
*p
= in_var(type
, "p");
4808 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4810 ir_constant_data b_offset
;
4811 b_offset
.f
[0] = 601.0f
;
4812 b_offset
.f
[1] = 313.0f
;
4813 b_offset
.f
[2] = 29.0f
;
4814 b_offset
.f
[3] = 277.0f
;
4816 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4817 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4818 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4819 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4820 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4821 body
.emit(assign(t
, a
, WRITEMASK_X
));
4822 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4828 ir_function_signature
*
4829 builtin_builder::_noise3(const glsl_type
*type
)
4831 ir_variable
*p
= in_var(type
, "p");
4832 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4834 ir_constant_data b_offset
;
4835 b_offset
.f
[0] = 601.0f
;
4836 b_offset
.f
[1] = 313.0f
;
4837 b_offset
.f
[2] = 29.0f
;
4838 b_offset
.f
[3] = 277.0f
;
4840 ir_constant_data c_offset
;
4841 c_offset
.f
[0] = 1559.0f
;
4842 c_offset
.f
[1] = 113.0f
;
4843 c_offset
.f
[2] = 1861.0f
;
4844 c_offset
.f
[3] = 797.0f
;
4846 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4847 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4848 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4849 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4850 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4851 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4852 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4853 body
.emit(assign(t
, a
, WRITEMASK_X
));
4854 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4855 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4861 ir_function_signature
*
4862 builtin_builder::_noise4(const glsl_type
*type
)
4864 ir_variable
*p
= in_var(type
, "p");
4865 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4867 ir_variable
*_p
= body
.make_temp(type
, "_p");
4869 ir_constant_data p_offset
;
4870 p_offset
.f
[0] = 1559.0f
;
4871 p_offset
.f
[1] = 113.0f
;
4872 p_offset
.f
[2] = 1861.0f
;
4873 p_offset
.f
[3] = 797.0f
;
4875 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4877 ir_constant_data offset
;
4878 offset
.f
[0] = 601.0f
;
4879 offset
.f
[1] = 313.0f
;
4880 offset
.f
[2] = 29.0f
;
4881 offset
.f
[3] = 277.0f
;
4883 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4884 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4885 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4886 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4887 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4888 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4889 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4890 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4891 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4892 body
.emit(assign(t
, a
, WRITEMASK_X
));
4893 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4894 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4895 body
.emit(assign(t
, d
, WRITEMASK_W
));
4901 ir_function_signature
*
4902 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4904 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4905 ir_variable
*value
= in_var(type
, "value");
4906 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4907 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4908 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4910 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
4911 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
4913 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
4914 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
4915 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
4920 ir_function_signature
*
4921 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4923 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4924 ir_variable
*base
= in_var(type
, "base");
4925 ir_variable
*insert
= in_var(type
, "insert");
4926 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4927 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4928 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4930 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
4931 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
4933 body
.emit(ret(bitfield_insert(base
, insert
,
4934 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
4935 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
4940 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4942 ir_function_signature
*
4943 builtin_builder::_bitCount(const glsl_type
*type
)
4945 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4946 glsl_type::ivec(type
->vector_elements
), type
);
4949 ir_function_signature
*
4950 builtin_builder::_findLSB(const glsl_type
*type
)
4952 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4953 glsl_type::ivec(type
->vector_elements
), type
);
4956 ir_function_signature
*
4957 builtin_builder::_findMSB(const glsl_type
*type
)
4959 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4960 glsl_type::ivec(type
->vector_elements
), type
);
4963 ir_function_signature
*
4964 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4966 ir_variable
*a
= in_var(type
, "a");
4967 ir_variable
*b
= in_var(type
, "b");
4968 ir_variable
*c
= in_var(type
, "c");
4969 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4971 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4976 ir_function_signature
*
4977 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4979 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
,
4980 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
4983 ir_function_signature
*
4984 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4986 ir_variable
*x
= in_var(x_type
, "x");
4987 ir_variable
*exponent
= out_var(exp_type
, "exp");
4988 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4990 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4992 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4996 ir_function_signature
*
4997 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4999 ir_variable
*x
= in_var(x_type
, "x");
5000 ir_variable
*exponent
= out_var(exp_type
, "exp");
5001 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
5003 const unsigned vec_elem
= x_type
->vector_elements
;
5004 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5005 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5007 /* Single-precision floating-point values are stored as
5012 * An exponent shift of 23 will shift the mantissa out, leaving only the
5013 * exponent and sign bit (which itself may be zero, if the absolute value
5014 * was taken before the bitcast and shift.
5016 ir_constant
*exponent_shift
= imm(23);
5017 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5019 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5021 /* Exponent of floating-point values in the range [0.5, 1.0). */
5022 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5024 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5025 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5027 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5028 * to unsigned integers to ensure that 1 bits aren't shifted in.
5030 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5031 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5032 imm(0, vec_elem
)))));
5034 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5035 body
.emit(assign(bits
, bitcast_f2u(x
)));
5036 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5037 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5038 imm(0u, vec_elem
)))));
5039 body
.emit(ret(bitcast_u2f(bits
)));
5044 ir_function_signature
*
5045 builtin_builder::_uaddCarry(const glsl_type
*type
)
5047 ir_variable
*x
= in_var(type
, "x");
5048 ir_variable
*y
= in_var(type
, "y");
5049 ir_variable
*carry
= out_var(type
, "carry");
5050 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
5052 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5053 body
.emit(ret(add(x
, y
)));
5058 ir_function_signature
*
5059 builtin_builder::_usubBorrow(const glsl_type
*type
)
5061 ir_variable
*x
= in_var(type
, "x");
5062 ir_variable
*y
= in_var(type
, "y");
5063 ir_variable
*borrow
= out_var(type
, "borrow");
5064 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
5066 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5067 body
.emit(ret(sub(x
, y
)));
5073 * For both imulExtended() and umulExtended() built-ins.
5075 ir_function_signature
*
5076 builtin_builder::_mulExtended(const glsl_type
*type
)
5078 ir_variable
*x
= in_var(type
, "x");
5079 ir_variable
*y
= in_var(type
, "y");
5080 ir_variable
*msb
= out_var(type
, "msb");
5081 ir_variable
*lsb
= out_var(type
, "lsb");
5082 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5084 body
.emit(assign(msb
, imul_high(x
, y
)));
5085 body
.emit(assign(lsb
, mul(x
, y
)));
5090 ir_function_signature
*
5091 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5093 ir_variable
*interpolant
= in_var(type
, "interpolant");
5094 interpolant
->data
.must_be_shader_input
= 1;
5095 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
5097 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5102 ir_function_signature
*
5103 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5105 ir_variable
*interpolant
= in_var(type
, "interpolant");
5106 interpolant
->data
.must_be_shader_input
= 1;
5107 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5108 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
5110 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5115 ir_function_signature
*
5116 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5118 ir_variable
*interpolant
= in_var(type
, "interpolant");
5119 interpolant
->data
.must_be_shader_input
= 1;
5120 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5121 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
5123 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5128 ir_function_signature
*
5129 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5131 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5132 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5136 ir_function_signature
*
5137 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5138 const glsl_type
*type
)
5140 ir_variable
*atomic
= in_var(type
, "atomic");
5141 ir_variable
*data
= in_var(type
, "data");
5142 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5146 ir_function_signature
*
5147 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5148 const glsl_type
*type
)
5150 ir_variable
*atomic
= in_var(type
, "atomic");
5151 ir_variable
*data1
= in_var(type
, "data1");
5152 ir_variable
*data2
= in_var(type
, "data2");
5153 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5157 ir_function_signature
*
5158 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5159 builtin_available_predicate avail
)
5161 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5162 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5164 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5165 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5167 body
.emit(ret(retval
));
5171 ir_function_signature
*
5172 builtin_builder::_atomic_op2(const char *intrinsic
,
5173 builtin_available_predicate avail
,
5174 const glsl_type
*type
)
5176 ir_variable
*atomic
= in_var(type
, "atomic_var");
5177 ir_variable
*data
= in_var(type
, "atomic_data");
5178 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5180 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5181 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5183 body
.emit(ret(retval
));
5187 ir_function_signature
*
5188 builtin_builder::_atomic_op3(const char *intrinsic
,
5189 builtin_available_predicate avail
,
5190 const glsl_type
*type
)
5192 ir_variable
*atomic
= in_var(type
, "atomic_var");
5193 ir_variable
*data1
= in_var(type
, "atomic_data1");
5194 ir_variable
*data2
= in_var(type
, "atomic_data2");
5195 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5197 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5198 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5200 body
.emit(ret(retval
));
5204 ir_function_signature
*
5205 builtin_builder::_min3(const glsl_type
*type
)
5207 ir_variable
*x
= in_var(type
, "x");
5208 ir_variable
*y
= in_var(type
, "y");
5209 ir_variable
*z
= in_var(type
, "z");
5210 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5212 ir_expression
*min3
= min2(x
, min2(y
,z
));
5213 body
.emit(ret(min3
));
5218 ir_function_signature
*
5219 builtin_builder::_max3(const glsl_type
*type
)
5221 ir_variable
*x
= in_var(type
, "x");
5222 ir_variable
*y
= in_var(type
, "y");
5223 ir_variable
*z
= in_var(type
, "z");
5224 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5226 ir_expression
*max3
= max2(x
, max2(y
,z
));
5227 body
.emit(ret(max3
));
5232 ir_function_signature
*
5233 builtin_builder::_mid3(const glsl_type
*type
)
5235 ir_variable
*x
= in_var(type
, "x");
5236 ir_variable
*y
= in_var(type
, "y");
5237 ir_variable
*z
= in_var(type
, "z");
5238 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5240 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5241 body
.emit(ret(mid3
));
5246 static builtin_available_predicate
5247 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5249 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5250 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5251 return shader_image_atomic_exchange_float
;
5253 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5254 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5255 return shader_image_atomic
;
5258 return shader_image_load_store
;
5261 ir_function_signature
*
5262 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5263 unsigned num_arguments
,
5266 const glsl_type
*data_type
= glsl_type::get_instance(
5267 image_type
->sampled_type
,
5268 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5270 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5271 glsl_type::void_type
: data_type
);
5273 /* Addressing arguments that are always present. */
5274 ir_variable
*image
= in_var(image_type
, "image");
5275 ir_variable
*coord
= in_var(
5276 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5278 ir_function_signature
*sig
= new_sig(
5279 ret_type
, get_image_available_predicate(image_type
, flags
),
5282 /* Sample index for multisample images. */
5283 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5284 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5286 /* Data arguments. */
5287 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5288 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5289 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5290 ralloc_free(arg_name
);
5293 /* Set the maximal set of qualifiers allowed for this image
5294 * built-in. Function calls with arguments having fewer
5295 * qualifiers than present in the prototype are allowed by the
5296 * spec, but not with more, i.e. this will make the compiler
5297 * accept everything that needs to be accepted, and reject cases
5298 * like loads from write-only or stores to read-only images.
5300 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5301 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5302 image
->data
.image_coherent
= true;
5303 image
->data
.image_volatile
= true;
5304 image
->data
.image_restrict
= true;
5309 ir_function_signature
*
5310 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5311 unsigned /* num_arguments */,
5312 unsigned /* flags */)
5314 const glsl_type
*ret_type
;
5315 unsigned num_components
= image_type
->coordinate_components();
5317 /* From the ARB_shader_image_size extension:
5318 * "Cube images return the dimensions of one face."
5320 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5321 !image_type
->sampler_array
) {
5325 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5326 * supported by mesa.
5328 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5330 ir_variable
*image
= in_var(image_type
, "image");
5331 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5333 /* Set the maximal set of qualifiers allowed for this image
5334 * built-in. Function calls with arguments having fewer
5335 * qualifiers than present in the prototype are allowed by the
5336 * spec, but not with more, i.e. this will make the compiler
5337 * accept everything that needs to be accepted, and reject cases
5338 * like loads from write-only or stores to read-only images.
5340 image
->data
.image_read_only
= true;
5341 image
->data
.image_write_only
= true;
5342 image
->data
.image_coherent
= true;
5343 image
->data
.image_volatile
= true;
5344 image
->data
.image_restrict
= true;
5349 ir_function_signature
*
5350 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5351 unsigned /* num_arguments */,
5352 unsigned /* flags */)
5354 ir_variable
*image
= in_var(image_type
, "image");
5355 ir_function_signature
*sig
=
5356 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5358 /* Set the maximal set of qualifiers allowed for this image
5359 * built-in. Function calls with arguments having fewer
5360 * qualifiers than present in the prototype are allowed by the
5361 * spec, but not with more, i.e. this will make the compiler
5362 * accept everything that needs to be accepted, and reject cases
5363 * like loads from write-only or stores to read-only images.
5365 image
->data
.image_read_only
= true;
5366 image
->data
.image_write_only
= true;
5367 image
->data
.image_coherent
= true;
5368 image
->data
.image_volatile
= true;
5369 image
->data
.image_restrict
= true;
5374 ir_function_signature
*
5375 builtin_builder::_image(image_prototype_ctr prototype
,
5376 const glsl_type
*image_type
,
5377 const char *intrinsic_name
,
5378 unsigned num_arguments
,
5381 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5382 num_arguments
, flags
);
5384 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5385 ir_factory
body(&sig
->body
, mem_ctx
);
5386 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5388 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5389 body
.emit(call(f
, NULL
, sig
->parameters
));
5391 ir_variable
*ret_val
=
5392 body
.make_temp(sig
->return_type
, "_ret_val");
5393 body
.emit(call(f
, ret_val
, sig
->parameters
));
5394 body
.emit(ret(ret_val
));
5397 sig
->is_defined
= true;
5400 sig
->is_intrinsic
= true;
5406 ir_function_signature
*
5407 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5409 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5413 ir_function_signature
*
5414 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5415 builtin_available_predicate avail
)
5417 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5418 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5419 NULL
, sig
->parameters
));
5423 ir_function_signature
*
5424 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5425 const glsl_type
*type
)
5427 MAKE_INTRINSIC(type
, avail
, 0);
5431 ir_function_signature
*
5432 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5433 const glsl_type
*type
)
5435 MAKE_SIG(type
, avail
, 0);
5437 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5439 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5440 retval
, sig
->parameters
));
5441 body
.emit(ret(retval
));
5447 /******************************************************************************/
5449 /* The singleton instance of builtin_builder. */
5450 static builtin_builder builtins
;
5451 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5454 * External API (exposing the built-in module to the rest of the compiler):
5458 _mesa_glsl_initialize_builtin_functions()
5460 mtx_lock(&builtins_lock
);
5461 builtins
.initialize();
5462 mtx_unlock(&builtins_lock
);
5466 _mesa_glsl_release_builtin_functions()
5468 mtx_lock(&builtins_lock
);
5470 mtx_unlock(&builtins_lock
);
5473 ir_function_signature
*
5474 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5475 const char *name
, exec_list
*actual_parameters
)
5477 ir_function_signature
* s
;
5478 mtx_lock(&builtins_lock
);
5479 s
= builtins
.find(state
, name
, actual_parameters
);
5480 mtx_unlock(&builtins_lock
);
5485 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5488 mtx_lock(&builtins_lock
);
5489 f
= builtins
.shader
->symbols
->get_function(name
);
5490 mtx_unlock(&builtins_lock
);
5495 _mesa_glsl_get_builtin_function_shader()
5497 return builtins
.shader
;
5502 * Get the function signature for main from a shader
5504 ir_function_signature
*
5505 _mesa_get_main_function_signature(gl_shader
*sh
)
5507 ir_function
*const f
= sh
->symbols
->get_function("main");
5509 exec_list void_parameters
;
5511 /* Look for the 'void main()' signature and ensure that it's defined.
5512 * This keeps the linker from accidentally pick a shader that just
5513 * contains a prototype for main.
5515 * We don't have to check for multiple definitions of main (in multiple
5516 * shaders) because that would have already been caught above.
5518 ir_function_signature
*sig
=
5519 f
->matching_signature(NULL
, &void_parameters
, false);
5520 if ((sig
!= NULL
) && sig
->is_defined
) {