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 es31(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(0, 310);
145 texture_rectangle(const _mesa_glsl_parse_state
*state
)
147 return state
->ARB_texture_rectangle_enable
;
151 texture_external(const _mesa_glsl_parse_state
*state
)
153 return state
->OES_EGL_image_external_enable
;
156 /** True if texturing functions with explicit LOD are allowed. */
158 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
160 /* Texturing functions with "Lod" in their name exist:
161 * - In the vertex shader stage (for all languages)
162 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
163 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
165 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
166 * don't need to explicitly check state->es_shader.
168 return state
->stage
== MESA_SHADER_VERTEX
||
169 state
->is_version(130, 300) ||
170 state
->ARB_shader_texture_lod_enable
;
174 v110_lod(const _mesa_glsl_parse_state
*state
)
176 return !state
->es_shader
&& lod_exists_in_stage(state
);
180 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_shader_texture_lod_enable
;
186 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
188 return state
->ARB_shader_texture_lod_enable
&&
189 state
->ARB_texture_rectangle_enable
;
193 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
195 return state
->is_version(330, 300) ||
196 state
->ARB_shader_bit_encoding_enable
||
197 state
->ARB_gpu_shader5_enable
;
201 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
203 return state
->is_version(450, 310) ||
204 v130(state
) && state
->EXT_shader_integer_mix_enable
;
208 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
210 return state
->ARB_shading_language_packing_enable
||
211 state
->is_version(420, 300);
215 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->ARB_gpu_shader5_enable
||
219 state
->is_version(400, 300);
223 gpu_shader5(const _mesa_glsl_parse_state
*state
)
225 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
229 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
231 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
235 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
237 return state
->ARB_shading_language_packing_enable
||
238 state
->ARB_gpu_shader5_enable
||
239 state
->is_version(400, 310);
243 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
245 return state
->stage
== MESA_SHADER_FRAGMENT
&&
246 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
251 texture_array_lod(const _mesa_glsl_parse_state
*state
)
253 return lod_exists_in_stage(state
) &&
254 state
->EXT_texture_array_enable
;
258 fs_texture_array(const _mesa_glsl_parse_state
*state
)
260 return state
->stage
== MESA_SHADER_FRAGMENT
&&
261 state
->EXT_texture_array_enable
;
265 texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->EXT_texture_array_enable
;
271 texture_multisample(const _mesa_glsl_parse_state
*state
)
273 return state
->is_version(150, 0) ||
274 state
->ARB_texture_multisample_enable
;
278 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
280 return state
->stage
== MESA_SHADER_FRAGMENT
&&
281 (state
->is_version(400, 0) ||
282 state
->ARB_texture_cube_map_array_enable
);
286 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
288 return state
->is_version(400, 0) ||
289 state
->ARB_texture_cube_map_array_enable
;
293 texture_query_levels(const _mesa_glsl_parse_state
*state
)
295 return state
->is_version(430, 0) ||
296 state
->ARB_texture_query_levels_enable
;
300 texture_query_lod(const _mesa_glsl_parse_state
*state
)
302 return state
->stage
== MESA_SHADER_FRAGMENT
&&
303 state
->ARB_texture_query_lod_enable
;
307 texture_gather(const _mesa_glsl_parse_state
*state
)
309 return state
->is_version(400, 0) ||
310 state
->ARB_texture_gather_enable
||
311 state
->ARB_gpu_shader5_enable
;
315 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
317 return state
->is_version(400, 310) ||
318 state
->ARB_texture_gather_enable
||
319 state
->ARB_gpu_shader5_enable
;
322 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
323 * used for relaxation of const offset requirements.
326 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
328 return !state
->is_version(400, 0) &&
329 !state
->ARB_gpu_shader5_enable
&&
330 (state
->ARB_texture_gather_enable
||
331 state
->is_version(0, 310));
334 /* Desktop GL or OES_standard_derivatives + fragment shader only */
336 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
338 return state
->stage
== MESA_SHADER_FRAGMENT
&&
339 (state
->is_version(110, 300) ||
340 state
->OES_standard_derivatives_enable
);
344 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
346 return state
->stage
== MESA_SHADER_FRAGMENT
&&
347 (state
->is_version(450, 0) ||
348 state
->ARB_derivative_control_enable
);
352 tex1d_lod(const _mesa_glsl_parse_state
*state
)
354 return !state
->es_shader
&& lod_exists_in_stage(state
);
357 /** True if sampler3D exists */
359 tex3d(const _mesa_glsl_parse_state
*state
)
361 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
362 * OES_texture_3D extension, and in GLSL ES 3.00.
364 return !state
->es_shader
||
365 state
->OES_texture_3D_enable
||
366 state
->language_version
>= 300;
370 fs_tex3d(const _mesa_glsl_parse_state
*state
)
372 return state
->stage
== MESA_SHADER_FRAGMENT
&&
373 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
377 tex3d_lod(const _mesa_glsl_parse_state
*state
)
379 return tex3d(state
) && lod_exists_in_stage(state
);
383 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
385 return state
->has_atomic_counters();
389 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
391 return state
->AMD_shader_trinary_minmax_enable
;
395 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
397 return (state
->is_version(420, 0) ||
398 state
->ARB_shader_image_load_store_enable
);
402 gs_streams(const _mesa_glsl_parse_state
*state
)
404 return gpu_shader5(state
) && gs_only(state
);
408 fp64(const _mesa_glsl_parse_state
*state
)
410 return state
->has_double();
415 /******************************************************************************/
420 * builtin_builder: A singleton object representing the core of the built-in
423 * It generates IR for every built-in function signature, and organizes them
426 class builtin_builder
{
433 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
434 const char *name
, exec_list
*actual_parameters
);
437 * A shader to hold all the built-in signatures; created by this module.
439 * This includes signatures for every built-in, regardless of version or
440 * enabled extensions. The availability predicate associated with each
441 * signature allows matching_signature() to filter out the irrelevant ones.
448 /** Global variables used by built-in functions. */
449 ir_variable
*gl_ModelViewProjectionMatrix
;
450 ir_variable
*gl_Vertex
;
452 void create_shader();
453 void create_intrinsics();
454 void create_builtins();
457 * IR builder helpers:
459 * These convenience functions assist in emitting IR, but don't necessarily
460 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
463 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
464 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
465 ir_constant
*imm(float f
, unsigned vector_elements
=1);
466 ir_constant
*imm(int i
, unsigned vector_elements
=1);
467 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
468 ir_constant
*imm(double d
, unsigned vector_elements
=1);
469 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
470 ir_dereference_variable
*var_ref(ir_variable
*var
);
471 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
472 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
474 ir_expression
*asin_expr(ir_variable
*x
);
475 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
478 * Call function \param f with parameters specified as the linked
479 * list \param params of \c ir_variable objects. \param ret should
480 * point to the ir_variable that will hold the function return
481 * value, or be \c NULL if the function has void return type.
483 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
485 /** Create a new function and add the given signatures. */
486 void add_function(const char *name
, ...);
488 enum image_function_flags
{
489 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
490 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
491 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
492 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
493 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
494 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5)
498 * Create a new image built-in function for all known image types.
499 * \p flags is a bitfield of \c image_function_flags flags.
501 void add_image_function(const char *name
,
502 const char *intrinsic_name
,
503 unsigned num_arguments
,
507 * Create new functions for all known image built-ins and types.
508 * If \p glsl is \c true, use the GLSL built-in names and emit code
509 * to call into the actual compiler intrinsic. If \p glsl is
510 * false, emit a function prototype with no body for each image
513 void add_image_functions(bool glsl
);
515 ir_function_signature
*new_sig(const glsl_type
*return_type
,
516 builtin_available_predicate avail
,
517 int num_params
, ...);
520 * Function signature generators:
523 ir_function_signature
*unop(builtin_available_predicate avail
,
524 ir_expression_operation opcode
,
525 const glsl_type
*return_type
,
526 const glsl_type
*param_type
);
527 ir_function_signature
*binop(ir_expression_operation opcode
,
528 builtin_available_predicate avail
,
529 const glsl_type
*return_type
,
530 const glsl_type
*param0_type
,
531 const glsl_type
*param1_type
);
533 #define B0(X) ir_function_signature *_##X();
534 #define B1(X) ir_function_signature *_##X(const glsl_type *);
535 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
536 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
537 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
538 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
575 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
576 const glsl_type
*val_type
,
577 const glsl_type
*blend_type
);
586 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
587 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
588 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
589 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
590 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
591 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
592 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
593 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
594 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
595 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
596 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
597 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
610 BA1(determinant_mat2
);
611 BA1(determinant_mat3
);
612 BA1(determinant_mat4
);
620 BA1(greaterThanEqual
);
627 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
628 const glsl_type
*return_type
,
629 const glsl_type
*sampler_type
);
631 /** Flags to _texture() */
632 #define TEX_PROJECT 1
634 #define TEX_COMPONENT 4
635 #define TEX_OFFSET_NONCONST 8
636 #define TEX_OFFSET_ARRAY 16
638 ir_function_signature
*_texture(ir_texture_opcode opcode
,
639 builtin_available_predicate avail
,
640 const glsl_type
*return_type
,
641 const glsl_type
*sampler_type
,
642 const glsl_type
*coord_type
,
644 B0(textureCubeArrayShadow
);
645 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
646 const glsl_type
*return_type
,
647 const glsl_type
*sampler_type
,
648 const glsl_type
*coord_type
,
649 const glsl_type
*offset_type
= NULL
);
653 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
654 const glsl_type
*stream_type
);
655 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
656 const glsl_type
*stream_type
);
659 B1(textureQueryLevels
);
687 B1(interpolateAtCentroid
)
688 B1(interpolateAtOffset
)
689 B1(interpolateAtSample
)
691 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
692 ir_function_signature
*_atomic_op(const char *intrinsic
,
693 builtin_available_predicate avail
);
699 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
700 const char *intrinsic_name
,
701 unsigned num_arguments
,
703 ir_function_signature
*_image(const glsl_type
*image_type
,
704 const char *intrinsic_name
,
705 unsigned num_arguments
,
708 ir_function_signature
*_memory_barrier_intrinsic(
709 builtin_available_predicate avail
);
710 ir_function_signature
*_memory_barrier(
711 builtin_available_predicate avail
);
722 } /* anonymous namespace */
725 * Core builtin_builder functionality:
728 builtin_builder::builtin_builder()
730 gl_ModelViewProjectionMatrix(NULL
),
736 builtin_builder::~builtin_builder()
738 ralloc_free(mem_ctx
);
741 ir_function_signature
*
742 builtin_builder::find(_mesa_glsl_parse_state
*state
,
743 const char *name
, exec_list
*actual_parameters
)
745 /* The shader currently being compiled requested a built-in function;
746 * it needs to link against builtin_builder::shader in order to get them.
748 * Even if we don't find a matching signature, we still need to do this so
749 * that the "no matching signature" error will list potential candidates
750 * from the available built-ins.
752 state
->uses_builtin_functions
= true;
754 ir_function
*f
= shader
->symbols
->get_function(name
);
758 ir_function_signature
*sig
=
759 f
->matching_signature(state
, actual_parameters
, true);
767 builtin_builder::initialize()
769 /* If already initialized, don't do it again. */
773 mem_ctx
= ralloc_context(NULL
);
780 builtin_builder::release()
782 ralloc_free(mem_ctx
);
790 builtin_builder::create_shader()
792 /* The target doesn't actually matter. There's no target for generic
793 * GLSL utility code that could be linked against any stage, so just
794 * arbitrarily pick GL_VERTEX_SHADER.
796 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
797 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
799 gl_ModelViewProjectionMatrix
=
800 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
801 "gl_ModelViewProjectionMatrix",
804 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
806 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
807 shader
->symbols
->add_variable(gl_Vertex
);
813 * Create ir_function and ir_function_signature objects for each
817 builtin_builder::create_intrinsics()
819 add_function("__intrinsic_atomic_read",
820 _atomic_intrinsic(shader_atomic_counters
),
822 add_function("__intrinsic_atomic_increment",
823 _atomic_intrinsic(shader_atomic_counters
),
825 add_function("__intrinsic_atomic_predecrement",
826 _atomic_intrinsic(shader_atomic_counters
),
829 add_image_functions(false);
831 add_function("__intrinsic_memory_barrier",
832 _memory_barrier_intrinsic(shader_image_load_store
),
837 * Create ir_function and ir_function_signature objects for each built-in.
839 * Contains a list of every available built-in.
842 builtin_builder::create_builtins()
845 add_function(#NAME, \
846 _##NAME(glsl_type::float_type), \
847 _##NAME(glsl_type::vec2_type), \
848 _##NAME(glsl_type::vec3_type), \
849 _##NAME(glsl_type::vec4_type), \
853 add_function(#NAME, \
854 _##NAME(always_available, glsl_type::float_type), \
855 _##NAME(always_available, glsl_type::vec2_type), \
856 _##NAME(always_available, glsl_type::vec3_type), \
857 _##NAME(always_available, glsl_type::vec4_type), \
858 _##NAME(fp64, glsl_type::double_type), \
859 _##NAME(fp64, glsl_type::dvec2_type), \
860 _##NAME(fp64, glsl_type::dvec3_type), \
861 _##NAME(fp64, glsl_type::dvec4_type), \
864 #define FD130(NAME) \
865 add_function(#NAME, \
866 _##NAME(v130, glsl_type::float_type), \
867 _##NAME(v130, glsl_type::vec2_type), \
868 _##NAME(v130, glsl_type::vec3_type), \
869 _##NAME(v130, glsl_type::vec4_type), \
870 _##NAME(fp64, glsl_type::double_type), \
871 _##NAME(fp64, glsl_type::dvec2_type), \
872 _##NAME(fp64, glsl_type::dvec3_type), \
873 _##NAME(fp64, glsl_type::dvec4_type), \
876 #define FDGS5(NAME) \
877 add_function(#NAME, \
878 _##NAME(gpu_shader5, glsl_type::float_type), \
879 _##NAME(gpu_shader5, glsl_type::vec2_type), \
880 _##NAME(gpu_shader5, glsl_type::vec3_type), \
881 _##NAME(gpu_shader5, glsl_type::vec4_type), \
882 _##NAME(fp64, glsl_type::double_type), \
883 _##NAME(fp64, glsl_type::dvec2_type), \
884 _##NAME(fp64, glsl_type::dvec3_type), \
885 _##NAME(fp64, glsl_type::dvec4_type), \
889 add_function(#NAME, \
890 _##NAME(glsl_type::float_type), \
891 _##NAME(glsl_type::vec2_type), \
892 _##NAME(glsl_type::vec3_type), \
893 _##NAME(glsl_type::vec4_type), \
894 _##NAME(glsl_type::int_type), \
895 _##NAME(glsl_type::ivec2_type), \
896 _##NAME(glsl_type::ivec3_type), \
897 _##NAME(glsl_type::ivec4_type), \
901 add_function(#NAME, \
902 _##NAME(always_available, glsl_type::float_type), \
903 _##NAME(always_available, glsl_type::vec2_type), \
904 _##NAME(always_available, glsl_type::vec3_type), \
905 _##NAME(always_available, glsl_type::vec4_type), \
906 _##NAME(always_available, glsl_type::int_type), \
907 _##NAME(always_available, glsl_type::ivec2_type), \
908 _##NAME(always_available, glsl_type::ivec3_type), \
909 _##NAME(always_available, glsl_type::ivec4_type), \
910 _##NAME(fp64, glsl_type::double_type), \
911 _##NAME(fp64, glsl_type::dvec2_type), \
912 _##NAME(fp64, glsl_type::dvec3_type), \
913 _##NAME(fp64, glsl_type::dvec4_type), \
917 add_function(#NAME, \
918 _##NAME(always_available, glsl_type::float_type), \
919 _##NAME(always_available, glsl_type::vec2_type), \
920 _##NAME(always_available, glsl_type::vec3_type), \
921 _##NAME(always_available, glsl_type::vec4_type), \
923 _##NAME(always_available, glsl_type::int_type), \
924 _##NAME(always_available, glsl_type::ivec2_type), \
925 _##NAME(always_available, glsl_type::ivec3_type), \
926 _##NAME(always_available, glsl_type::ivec4_type), \
928 _##NAME(v130, glsl_type::uint_type), \
929 _##NAME(v130, glsl_type::uvec2_type), \
930 _##NAME(v130, glsl_type::uvec3_type), \
931 _##NAME(v130, glsl_type::uvec4_type), \
932 _##NAME(fp64, glsl_type::double_type), \
933 _##NAME(fp64, glsl_type::dvec2_type), \
934 _##NAME(fp64, glsl_type::dvec3_type), \
935 _##NAME(fp64, glsl_type::dvec4_type), \
939 add_function(#NAME, \
940 _##NAME(glsl_type::int_type), \
941 _##NAME(glsl_type::ivec2_type), \
942 _##NAME(glsl_type::ivec3_type), \
943 _##NAME(glsl_type::ivec4_type), \
945 _##NAME(glsl_type::uint_type), \
946 _##NAME(glsl_type::uvec2_type), \
947 _##NAME(glsl_type::uvec3_type), \
948 _##NAME(glsl_type::uvec4_type), \
951 #define FIUBD(NAME) \
952 add_function(#NAME, \
953 _##NAME(always_available, glsl_type::float_type), \
954 _##NAME(always_available, glsl_type::vec2_type), \
955 _##NAME(always_available, glsl_type::vec3_type), \
956 _##NAME(always_available, glsl_type::vec4_type), \
958 _##NAME(always_available, glsl_type::int_type), \
959 _##NAME(always_available, glsl_type::ivec2_type), \
960 _##NAME(always_available, glsl_type::ivec3_type), \
961 _##NAME(always_available, glsl_type::ivec4_type), \
963 _##NAME(v130, glsl_type::uint_type), \
964 _##NAME(v130, glsl_type::uvec2_type), \
965 _##NAME(v130, glsl_type::uvec3_type), \
966 _##NAME(v130, glsl_type::uvec4_type), \
968 _##NAME(always_available, glsl_type::bool_type), \
969 _##NAME(always_available, glsl_type::bvec2_type), \
970 _##NAME(always_available, glsl_type::bvec3_type), \
971 _##NAME(always_available, glsl_type::bvec4_type), \
973 _##NAME(fp64, glsl_type::double_type), \
974 _##NAME(fp64, glsl_type::dvec2_type), \
975 _##NAME(fp64, glsl_type::dvec3_type), \
976 _##NAME(fp64, glsl_type::dvec4_type), \
979 #define FIUD2_MIXED(NAME) \
980 add_function(#NAME, \
981 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
982 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
983 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
984 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
986 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
987 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
988 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
990 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
991 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
992 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
993 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
995 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
996 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
997 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
999 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1000 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1001 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1002 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1004 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1005 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1006 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1008 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1009 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1010 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1011 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1012 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1013 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1014 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1025 add_function("atan",
1026 _atan(glsl_type::float_type
),
1027 _atan(glsl_type::vec2_type
),
1028 _atan(glsl_type::vec3_type
),
1029 _atan(glsl_type::vec4_type
),
1030 _atan2(glsl_type::float_type
),
1031 _atan2(glsl_type::vec2_type
),
1032 _atan2(glsl_type::vec3_type
),
1033 _atan2(glsl_type::vec4_type
),
1059 _mod(glsl_type::float_type
, glsl_type::float_type
),
1060 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1061 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1062 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1064 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1065 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1066 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1068 _mod(glsl_type::double_type
, glsl_type::double_type
),
1069 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1070 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1071 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1073 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1074 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1075 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1085 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1086 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1087 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1088 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1090 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1091 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1092 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1094 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1095 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1096 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1097 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1099 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1100 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1101 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1103 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1104 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1105 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1106 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1108 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1109 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1110 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1111 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1113 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1114 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1115 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1116 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1118 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1119 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1120 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1121 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1123 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1124 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1125 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1126 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1129 add_function("step",
1130 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1131 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1132 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1133 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1135 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1136 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1137 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1138 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1139 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1140 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1141 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1143 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1144 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1145 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1148 add_function("smoothstep",
1149 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1150 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1151 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1152 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1154 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1155 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1156 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1157 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1158 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1159 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1160 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1162 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1163 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1164 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1172 add_function("intBitsToFloat",
1173 _intBitsToFloat(glsl_type::int_type
),
1174 _intBitsToFloat(glsl_type::ivec2_type
),
1175 _intBitsToFloat(glsl_type::ivec3_type
),
1176 _intBitsToFloat(glsl_type::ivec4_type
),
1178 add_function("uintBitsToFloat",
1179 _uintBitsToFloat(glsl_type::uint_type
),
1180 _uintBitsToFloat(glsl_type::uvec2_type
),
1181 _uintBitsToFloat(glsl_type::uvec3_type
),
1182 _uintBitsToFloat(glsl_type::uvec4_type
),
1185 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1186 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1187 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1188 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1189 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1190 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1191 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1192 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1193 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1194 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1195 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1196 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1203 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1204 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1207 add_function("ftransform", _ftransform(), NULL
);
1212 add_function("matrixCompMult",
1213 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1214 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1215 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1216 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1217 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1218 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1219 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1220 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1221 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1222 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1223 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1224 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1225 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1226 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1227 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1228 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1229 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1230 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1232 add_function("outerProduct",
1233 _outerProduct(v120
, glsl_type::mat2_type
),
1234 _outerProduct(v120
, glsl_type::mat3_type
),
1235 _outerProduct(v120
, glsl_type::mat4_type
),
1236 _outerProduct(v120
, glsl_type::mat2x3_type
),
1237 _outerProduct(v120
, glsl_type::mat2x4_type
),
1238 _outerProduct(v120
, glsl_type::mat3x2_type
),
1239 _outerProduct(v120
, glsl_type::mat3x4_type
),
1240 _outerProduct(v120
, glsl_type::mat4x2_type
),
1241 _outerProduct(v120
, glsl_type::mat4x3_type
),
1242 _outerProduct(fp64
, glsl_type::dmat2_type
),
1243 _outerProduct(fp64
, glsl_type::dmat3_type
),
1244 _outerProduct(fp64
, glsl_type::dmat4_type
),
1245 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1246 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1247 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1248 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1249 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1250 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1252 add_function("determinant",
1253 _determinant_mat2(v120
, glsl_type::mat2_type
),
1254 _determinant_mat3(v120
, glsl_type::mat3_type
),
1255 _determinant_mat4(v120
, glsl_type::mat4_type
),
1256 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1257 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1258 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1261 add_function("inverse",
1262 _inverse_mat2(v120
, glsl_type::mat2_type
),
1263 _inverse_mat3(v120
, glsl_type::mat3_type
),
1264 _inverse_mat4(v120
, glsl_type::mat4_type
),
1265 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1266 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1267 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1269 add_function("transpose",
1270 _transpose(v120
, glsl_type::mat2_type
),
1271 _transpose(v120
, glsl_type::mat3_type
),
1272 _transpose(v120
, glsl_type::mat4_type
),
1273 _transpose(v120
, glsl_type::mat2x3_type
),
1274 _transpose(v120
, glsl_type::mat2x4_type
),
1275 _transpose(v120
, glsl_type::mat3x2_type
),
1276 _transpose(v120
, glsl_type::mat3x4_type
),
1277 _transpose(v120
, glsl_type::mat4x2_type
),
1278 _transpose(v120
, glsl_type::mat4x3_type
),
1279 _transpose(fp64
, glsl_type::dmat2_type
),
1280 _transpose(fp64
, glsl_type::dmat3_type
),
1281 _transpose(fp64
, glsl_type::dmat4_type
),
1282 _transpose(fp64
, glsl_type::dmat2x3_type
),
1283 _transpose(fp64
, glsl_type::dmat2x4_type
),
1284 _transpose(fp64
, glsl_type::dmat3x2_type
),
1285 _transpose(fp64
, glsl_type::dmat3x4_type
),
1286 _transpose(fp64
, glsl_type::dmat4x2_type
),
1287 _transpose(fp64
, glsl_type::dmat4x3_type
),
1292 FIUD(greaterThanEqual
)
1297 _any(glsl_type::bvec2_type
),
1298 _any(glsl_type::bvec3_type
),
1299 _any(glsl_type::bvec4_type
),
1303 _all(glsl_type::bvec2_type
),
1304 _all(glsl_type::bvec3_type
),
1305 _all(glsl_type::bvec4_type
),
1309 _not(glsl_type::bvec2_type
),
1310 _not(glsl_type::bvec3_type
),
1311 _not(glsl_type::bvec4_type
),
1314 add_function("textureSize",
1315 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1316 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1317 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1319 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1320 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1321 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1323 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1324 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1325 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1327 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1328 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1329 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1331 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1332 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1333 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1335 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1336 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1337 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1338 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1339 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1340 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1342 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1343 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1345 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1346 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1347 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1348 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1350 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1351 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1352 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1353 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1355 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1356 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1357 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1358 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1359 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1360 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1362 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1363 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1364 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1367 add_function("texture",
1368 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1369 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1370 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1372 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1373 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1374 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1376 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1377 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1378 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1380 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1381 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1382 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1384 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1385 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1386 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1388 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1389 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1390 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1392 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1393 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1394 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1396 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1397 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1398 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1400 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1401 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1402 /* samplerCubeArrayShadow is special; it has an extra parameter
1403 * for the shadow comparitor since there is no vec5 type.
1405 _textureCubeArrayShadow(),
1407 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1408 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1409 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1411 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1413 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1414 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1415 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1417 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1418 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1419 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1421 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1422 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1423 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1425 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1426 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1427 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1429 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1430 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1431 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1433 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1434 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1435 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1437 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1438 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1439 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1441 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1442 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1443 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1445 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1448 add_function("textureLod",
1449 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1450 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1451 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1453 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1454 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1455 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1457 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1458 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1459 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1461 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1462 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1463 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1465 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1466 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1468 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1469 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1470 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1472 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1473 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1474 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1476 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1477 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1478 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1480 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1483 add_function("textureOffset",
1484 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1485 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1486 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1488 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1489 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1490 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1492 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1493 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1494 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1496 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1497 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1498 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1500 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1502 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1503 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1505 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1506 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1507 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1509 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1510 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1511 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1513 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1515 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1516 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1517 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1519 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1520 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1521 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1523 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1524 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1525 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1527 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1528 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1530 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1531 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1532 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1534 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1535 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1536 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1538 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1541 add_function("textureProj",
1542 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1543 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1544 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1545 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1546 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1547 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1549 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1550 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1551 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1552 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1553 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1554 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1556 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1557 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1558 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1560 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1561 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1563 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1564 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1565 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1566 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1567 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1568 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1570 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1572 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1573 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1574 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1575 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1576 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1577 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1579 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1580 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1581 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1582 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1583 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1584 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1586 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1587 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1588 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1590 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1591 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1594 add_function("texelFetch",
1595 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1596 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1597 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1599 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1600 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1601 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1603 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1604 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1605 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1607 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1608 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1609 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1611 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1612 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1613 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1615 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1616 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1617 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1619 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1620 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1621 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1623 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1624 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1625 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1627 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1628 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1629 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1632 add_function("texelFetchOffset",
1633 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1634 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1635 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1637 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1638 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1639 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1641 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1642 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1643 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1645 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1646 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1647 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1649 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1650 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1651 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1653 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1654 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1655 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1659 add_function("textureProjOffset",
1660 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1661 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1662 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1663 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1664 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1665 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1667 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1668 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1669 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1670 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1671 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1672 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1674 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1675 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1676 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1678 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1679 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1681 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1682 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1683 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1684 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1685 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1686 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1688 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1690 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1691 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1692 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1693 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1694 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1695 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1697 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1698 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1699 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1700 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1701 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1702 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1704 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1705 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1706 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1708 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1709 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1712 add_function("textureLodOffset",
1713 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1714 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1715 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1717 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1718 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1719 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1721 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1722 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1723 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1725 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1726 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1728 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1729 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1730 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1732 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1733 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1734 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1736 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1739 add_function("textureProjLod",
1740 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1741 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1742 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1743 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1744 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1745 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1747 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1748 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1749 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1750 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1751 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1752 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1754 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1755 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1756 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1758 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1759 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 add_function("textureProjLodOffset",
1763 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1764 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1765 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1766 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1767 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1768 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1770 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1771 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1772 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1773 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1774 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1775 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1777 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1778 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1779 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1781 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1782 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1785 add_function("textureGrad",
1786 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1787 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1788 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1790 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1791 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1792 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1794 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1795 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1796 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1798 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1799 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1800 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1802 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1803 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1804 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1806 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1808 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1809 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1810 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1812 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1813 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1814 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1816 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1817 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1818 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1820 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1821 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1822 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1824 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1825 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1828 add_function("textureGradOffset",
1829 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1830 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1831 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1833 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1834 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1835 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1837 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1838 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1839 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1841 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1842 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1843 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1845 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1847 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1848 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1850 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1851 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1852 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1854 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1855 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1856 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1858 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1859 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1862 add_function("textureProjGrad",
1863 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1864 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1865 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1866 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1867 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1868 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1870 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1871 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1872 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1873 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1874 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1875 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1877 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1878 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1879 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1881 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1882 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1883 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1884 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1885 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1886 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1888 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1890 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1891 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1894 add_function("textureProjGradOffset",
1895 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1896 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1897 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1898 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1899 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1900 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1902 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1903 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1904 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1905 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1906 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1907 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1909 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1910 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1911 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1914 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1915 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1916 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1918 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1920 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1922 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1923 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1926 add_function("EmitVertex", _EmitVertex(), NULL
);
1927 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1928 add_function("EmitStreamVertex",
1929 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1930 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1932 add_function("EndStreamPrimitive",
1933 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1934 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
1937 add_function("textureQueryLOD",
1938 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1939 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1940 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1942 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1943 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1944 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1946 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1947 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1948 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1950 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1951 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1952 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1954 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1955 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1956 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1958 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1959 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1960 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1962 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1963 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1964 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1966 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1967 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1968 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1969 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1970 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1971 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1974 add_function("textureQueryLevels",
1975 _textureQueryLevels(glsl_type::sampler1D_type
),
1976 _textureQueryLevels(glsl_type::sampler2D_type
),
1977 _textureQueryLevels(glsl_type::sampler3D_type
),
1978 _textureQueryLevels(glsl_type::samplerCube_type
),
1979 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1980 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1981 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1982 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1983 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1984 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1985 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1986 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1987 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1989 _textureQueryLevels(glsl_type::isampler1D_type
),
1990 _textureQueryLevels(glsl_type::isampler2D_type
),
1991 _textureQueryLevels(glsl_type::isampler3D_type
),
1992 _textureQueryLevels(glsl_type::isamplerCube_type
),
1993 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1994 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1995 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1997 _textureQueryLevels(glsl_type::usampler1D_type
),
1998 _textureQueryLevels(glsl_type::usampler2D_type
),
1999 _textureQueryLevels(glsl_type::usampler3D_type
),
2000 _textureQueryLevels(glsl_type::usamplerCube_type
),
2001 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2002 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2003 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2007 add_function("texture1D",
2008 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2009 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2012 add_function("texture1DArray",
2013 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2014 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2017 add_function("texture1DProj",
2018 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2019 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2020 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2021 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2024 add_function("texture1DLod",
2025 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2028 add_function("texture1DArrayLod",
2029 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2032 add_function("texture1DProjLod",
2033 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2034 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2037 add_function("texture2D",
2038 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2039 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2040 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2043 add_function("texture2DArray",
2044 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2045 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2048 add_function("texture2DProj",
2049 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2050 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2051 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2052 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2053 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2054 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2057 add_function("texture2DLod",
2058 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2061 add_function("texture2DArrayLod",
2062 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2065 add_function("texture2DProjLod",
2066 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2067 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2070 add_function("texture3D",
2071 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2072 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2075 add_function("texture3DProj",
2076 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2077 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2080 add_function("texture3DLod",
2081 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2084 add_function("texture3DProjLod",
2085 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2088 add_function("textureCube",
2089 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2090 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2093 add_function("textureCubeLod",
2094 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2097 add_function("texture2DRect",
2098 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2101 add_function("texture2DRectProj",
2102 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2103 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2106 add_function("shadow1D",
2107 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2108 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2111 add_function("shadow1DArray",
2112 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2113 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2116 add_function("shadow2D",
2117 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2118 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2121 add_function("shadow2DArray",
2122 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2123 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2126 add_function("shadow1DProj",
2127 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2128 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2131 add_function("shadow2DProj",
2132 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2133 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2136 add_function("shadow1DLod",
2137 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2140 add_function("shadow2DLod",
2141 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2144 add_function("shadow1DArrayLod",
2145 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2148 add_function("shadow1DProjLod",
2149 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2152 add_function("shadow2DProjLod",
2153 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2156 add_function("shadow2DRect",
2157 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2160 add_function("shadow2DRectProj",
2161 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2164 add_function("texture1DGradARB",
2165 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2168 add_function("texture1DProjGradARB",
2169 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2170 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2173 add_function("texture2DGradARB",
2174 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2177 add_function("texture2DProjGradARB",
2178 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2179 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2182 add_function("texture3DGradARB",
2183 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2186 add_function("texture3DProjGradARB",
2187 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2190 add_function("textureCubeGradARB",
2191 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2194 add_function("shadow1DGradARB",
2195 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2198 add_function("shadow1DProjGradARB",
2199 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2202 add_function("shadow2DGradARB",
2203 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2206 add_function("shadow2DProjGradARB",
2207 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2210 add_function("texture2DRectGradARB",
2211 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2214 add_function("texture2DRectProjGradARB",
2215 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2216 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2219 add_function("shadow2DRectGradARB",
2220 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2223 add_function("shadow2DRectProjGradARB",
2224 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2227 add_function("textureGather",
2228 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2229 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2230 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2232 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2233 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2234 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2236 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2237 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2238 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2240 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2241 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2242 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2244 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2245 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2246 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2248 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2249 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2250 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2252 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2253 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2254 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2256 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2257 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2258 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2260 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2261 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2262 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2264 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2265 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2266 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2268 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2269 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2270 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2271 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2272 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2275 add_function("textureGatherOffset",
2276 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2277 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2278 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2280 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2281 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2282 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2284 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2285 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2286 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2288 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2289 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2290 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2292 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2293 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2294 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2296 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2297 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2298 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2300 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2301 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2302 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2304 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2305 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2306 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2308 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2309 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2310 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2312 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2313 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2314 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2316 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2317 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2318 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2320 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2321 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2324 add_function("textureGatherOffsets",
2325 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2326 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2327 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2329 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2330 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2331 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2333 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2334 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2335 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2337 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2338 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2339 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2341 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2342 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2343 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2345 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2346 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2347 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2349 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2350 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2351 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2376 add_function("ldexp",
2377 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2378 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2379 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2380 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2381 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2382 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2383 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2384 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2387 add_function("frexp",
2388 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2389 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2390 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2391 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2392 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2393 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2394 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2395 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2397 add_function("uaddCarry",
2398 _uaddCarry(glsl_type::uint_type
),
2399 _uaddCarry(glsl_type::uvec2_type
),
2400 _uaddCarry(glsl_type::uvec3_type
),
2401 _uaddCarry(glsl_type::uvec4_type
),
2403 add_function("usubBorrow",
2404 _usubBorrow(glsl_type::uint_type
),
2405 _usubBorrow(glsl_type::uvec2_type
),
2406 _usubBorrow(glsl_type::uvec3_type
),
2407 _usubBorrow(glsl_type::uvec4_type
),
2409 add_function("imulExtended",
2410 _mulExtended(glsl_type::int_type
),
2411 _mulExtended(glsl_type::ivec2_type
),
2412 _mulExtended(glsl_type::ivec3_type
),
2413 _mulExtended(glsl_type::ivec4_type
),
2415 add_function("umulExtended",
2416 _mulExtended(glsl_type::uint_type
),
2417 _mulExtended(glsl_type::uvec2_type
),
2418 _mulExtended(glsl_type::uvec3_type
),
2419 _mulExtended(glsl_type::uvec4_type
),
2421 add_function("interpolateAtCentroid",
2422 _interpolateAtCentroid(glsl_type::float_type
),
2423 _interpolateAtCentroid(glsl_type::vec2_type
),
2424 _interpolateAtCentroid(glsl_type::vec3_type
),
2425 _interpolateAtCentroid(glsl_type::vec4_type
),
2427 add_function("interpolateAtOffset",
2428 _interpolateAtOffset(glsl_type::float_type
),
2429 _interpolateAtOffset(glsl_type::vec2_type
),
2430 _interpolateAtOffset(glsl_type::vec3_type
),
2431 _interpolateAtOffset(glsl_type::vec4_type
),
2433 add_function("interpolateAtSample",
2434 _interpolateAtSample(glsl_type::float_type
),
2435 _interpolateAtSample(glsl_type::vec2_type
),
2436 _interpolateAtSample(glsl_type::vec3_type
),
2437 _interpolateAtSample(glsl_type::vec4_type
),
2440 add_function("atomicCounter",
2441 _atomic_op("__intrinsic_atomic_read",
2442 shader_atomic_counters
),
2444 add_function("atomicCounterIncrement",
2445 _atomic_op("__intrinsic_atomic_increment",
2446 shader_atomic_counters
),
2448 add_function("atomicCounterDecrement",
2449 _atomic_op("__intrinsic_atomic_predecrement",
2450 shader_atomic_counters
),
2453 add_function("min3",
2454 _min3(glsl_type::float_type
),
2455 _min3(glsl_type::vec2_type
),
2456 _min3(glsl_type::vec3_type
),
2457 _min3(glsl_type::vec4_type
),
2459 _min3(glsl_type::int_type
),
2460 _min3(glsl_type::ivec2_type
),
2461 _min3(glsl_type::ivec3_type
),
2462 _min3(glsl_type::ivec4_type
),
2464 _min3(glsl_type::uint_type
),
2465 _min3(glsl_type::uvec2_type
),
2466 _min3(glsl_type::uvec3_type
),
2467 _min3(glsl_type::uvec4_type
),
2470 add_function("max3",
2471 _max3(glsl_type::float_type
),
2472 _max3(glsl_type::vec2_type
),
2473 _max3(glsl_type::vec3_type
),
2474 _max3(glsl_type::vec4_type
),
2476 _max3(glsl_type::int_type
),
2477 _max3(glsl_type::ivec2_type
),
2478 _max3(glsl_type::ivec3_type
),
2479 _max3(glsl_type::ivec4_type
),
2481 _max3(glsl_type::uint_type
),
2482 _max3(glsl_type::uvec2_type
),
2483 _max3(glsl_type::uvec3_type
),
2484 _max3(glsl_type::uvec4_type
),
2487 add_function("mid3",
2488 _mid3(glsl_type::float_type
),
2489 _mid3(glsl_type::vec2_type
),
2490 _mid3(glsl_type::vec3_type
),
2491 _mid3(glsl_type::vec4_type
),
2493 _mid3(glsl_type::int_type
),
2494 _mid3(glsl_type::ivec2_type
),
2495 _mid3(glsl_type::ivec3_type
),
2496 _mid3(glsl_type::ivec4_type
),
2498 _mid3(glsl_type::uint_type
),
2499 _mid3(glsl_type::uvec2_type
),
2500 _mid3(glsl_type::uvec3_type
),
2501 _mid3(glsl_type::uvec4_type
),
2504 add_image_functions(true);
2506 add_function("memoryBarrier",
2507 _memory_barrier(shader_image_load_store
),
2518 builtin_builder::add_function(const char *name
, ...)
2522 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2526 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2532 stuff
.push_tail(sig
);
2533 validate_ir_tree(&stuff
);
2536 f
->add_signature(sig
);
2540 shader
->symbols
->add_function(f
);
2544 builtin_builder::add_image_function(const char *name
,
2545 const char *intrinsic_name
,
2546 unsigned num_arguments
,
2549 static const glsl_type
*const types
[] = {
2550 glsl_type::image1D_type
,
2551 glsl_type::image2D_type
,
2552 glsl_type::image3D_type
,
2553 glsl_type::image2DRect_type
,
2554 glsl_type::imageCube_type
,
2555 glsl_type::imageBuffer_type
,
2556 glsl_type::image1DArray_type
,
2557 glsl_type::image2DArray_type
,
2558 glsl_type::imageCubeArray_type
,
2559 glsl_type::image2DMS_type
,
2560 glsl_type::image2DMSArray_type
,
2561 glsl_type::iimage1D_type
,
2562 glsl_type::iimage2D_type
,
2563 glsl_type::iimage3D_type
,
2564 glsl_type::iimage2DRect_type
,
2565 glsl_type::iimageCube_type
,
2566 glsl_type::iimageBuffer_type
,
2567 glsl_type::iimage1DArray_type
,
2568 glsl_type::iimage2DArray_type
,
2569 glsl_type::iimageCubeArray_type
,
2570 glsl_type::iimage2DMS_type
,
2571 glsl_type::iimage2DMSArray_type
,
2572 glsl_type::uimage1D_type
,
2573 glsl_type::uimage2D_type
,
2574 glsl_type::uimage3D_type
,
2575 glsl_type::uimage2DRect_type
,
2576 glsl_type::uimageCube_type
,
2577 glsl_type::uimageBuffer_type
,
2578 glsl_type::uimage1DArray_type
,
2579 glsl_type::uimage2DArray_type
,
2580 glsl_type::uimageCubeArray_type
,
2581 glsl_type::uimage2DMS_type
,
2582 glsl_type::uimage2DMSArray_type
2584 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2586 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2587 if (types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2588 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
))
2589 f
->add_signature(_image(types
[i
], intrinsic_name
,
2590 num_arguments
, flags
));
2593 shader
->symbols
->add_function(f
);
2597 builtin_builder::add_image_functions(bool glsl
)
2599 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2601 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2602 "__intrinsic_image_load", 0,
2603 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2604 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2605 IMAGE_FUNCTION_READ_ONLY
));
2607 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2608 "__intrinsic_image_store", 1,
2609 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2610 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2611 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2612 IMAGE_FUNCTION_WRITE_ONLY
));
2614 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2615 "__intrinsic_image_atomic_add", 1, flags
);
2617 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2618 "__intrinsic_image_atomic_min", 1, flags
);
2620 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2621 "__intrinsic_image_atomic_max", 1, flags
);
2623 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2624 "__intrinsic_image_atomic_and", 1, flags
);
2626 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2627 "__intrinsic_image_atomic_or", 1, flags
);
2629 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2630 "__intrinsic_image_atomic_xor", 1, flags
);
2632 add_image_function((glsl
? "imageAtomicExchange" :
2633 "__intrinsic_image_atomic_exchange"),
2634 "__intrinsic_image_atomic_exchange", 1, flags
);
2636 add_image_function((glsl
? "imageAtomicCompSwap" :
2637 "__intrinsic_image_atomic_comp_swap"),
2638 "__intrinsic_image_atomic_comp_swap", 2, flags
);
2642 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2644 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2648 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2650 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2654 builtin_builder::imm(float f
, unsigned vector_elements
)
2656 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2660 builtin_builder::imm(int i
, unsigned vector_elements
)
2662 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2666 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2668 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2672 builtin_builder::imm(double d
, unsigned vector_elements
)
2674 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2678 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2680 return new(mem_ctx
) ir_constant(type
, &data
);
2683 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2685 ir_dereference_variable
*
2686 builtin_builder::var_ref(ir_variable
*var
)
2688 return new(mem_ctx
) ir_dereference_variable(var
);
2691 ir_dereference_array
*
2692 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2694 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2697 /** Return an element of a matrix */
2699 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2701 return swizzle(array_ref(var
, column
), row
, 1);
2705 * Implementations of built-in functions:
2708 ir_function_signature
*
2709 builtin_builder::new_sig(const glsl_type
*return_type
,
2710 builtin_available_predicate avail
,
2716 ir_function_signature
*sig
=
2717 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2720 va_start(ap
, num_params
);
2721 for (int i
= 0; i
< num_params
; i
++) {
2722 plist
.push_tail(va_arg(ap
, ir_variable
*));
2726 sig
->replace_parameters(&plist
);
2730 #define MAKE_SIG(return_type, avail, ...) \
2731 ir_function_signature *sig = \
2732 new_sig(return_type, avail, __VA_ARGS__); \
2733 ir_factory body(&sig->body, mem_ctx); \
2734 sig->is_defined = true;
2736 #define MAKE_INTRINSIC(return_type, avail, ...) \
2737 ir_function_signature *sig = \
2738 new_sig(return_type, avail, __VA_ARGS__); \
2739 sig->is_intrinsic = true;
2741 ir_function_signature
*
2742 builtin_builder::unop(builtin_available_predicate avail
,
2743 ir_expression_operation opcode
,
2744 const glsl_type
*return_type
,
2745 const glsl_type
*param_type
)
2747 ir_variable
*x
= in_var(param_type
, "x");
2748 MAKE_SIG(return_type
, avail
, 1, x
);
2749 body
.emit(ret(expr(opcode
, x
)));
2753 #define UNOP(NAME, OPCODE, AVAIL) \
2754 ir_function_signature * \
2755 builtin_builder::_##NAME(const glsl_type *type) \
2757 return unop(&AVAIL, OPCODE, type, type); \
2760 #define UNOPA(NAME, OPCODE) \
2761 ir_function_signature * \
2762 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
2764 return unop(avail, OPCODE, type, type); \
2767 ir_function_signature
*
2768 builtin_builder::binop(ir_expression_operation opcode
,
2769 builtin_available_predicate avail
,
2770 const glsl_type
*return_type
,
2771 const glsl_type
*param0_type
,
2772 const glsl_type
*param1_type
)
2774 ir_variable
*x
= in_var(param0_type
, "x");
2775 ir_variable
*y
= in_var(param1_type
, "y");
2776 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2777 body
.emit(ret(expr(opcode
, x
, y
)));
2781 #define BINOP(NAME, OPCODE, AVAIL) \
2782 ir_function_signature * \
2783 builtin_builder::_##NAME(const glsl_type *return_type, \
2784 const glsl_type *param0_type, \
2785 const glsl_type *param1_type) \
2787 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2791 * Angle and Trigonometry Functions @{
2794 ir_function_signature
*
2795 builtin_builder::_radians(const glsl_type
*type
)
2797 ir_variable
*degrees
= in_var(type
, "degrees");
2798 MAKE_SIG(type
, always_available
, 1, degrees
);
2799 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2803 ir_function_signature
*
2804 builtin_builder::_degrees(const glsl_type
*type
)
2806 ir_variable
*radians
= in_var(type
, "radians");
2807 MAKE_SIG(type
, always_available
, 1, radians
);
2808 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2812 UNOP(sin
, ir_unop_sin
, always_available
)
2813 UNOP(cos
, ir_unop_cos
, always_available
)
2815 ir_function_signature
*
2816 builtin_builder::_tan(const glsl_type
*type
)
2818 ir_variable
*theta
= in_var(type
, "theta");
2819 MAKE_SIG(type
, always_available
, 1, theta
);
2820 body
.emit(ret(div(sin(theta
), cos(theta
))));
2825 builtin_builder::asin_expr(ir_variable
*x
)
2829 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2832 add(imm(M_PI_4f
- 1.0f
),
2834 add(imm(0.086566724f
),
2835 mul(abs(x
), imm(-0.03102955f
))))))))));
2839 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2841 exec_list actual_params
;
2843 foreach_in_list(ir_variable
, var
, ¶ms
) {
2844 actual_params
.push_tail(var_ref(var
));
2847 ir_function_signature
*sig
=
2848 f
->exact_matching_signature(NULL
, &actual_params
);
2852 ir_dereference_variable
*deref
=
2853 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2855 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2858 ir_function_signature
*
2859 builtin_builder::_asin(const glsl_type
*type
)
2861 ir_variable
*x
= in_var(type
, "x");
2862 MAKE_SIG(type
, always_available
, 1, x
);
2864 body
.emit(ret(asin_expr(x
)));
2869 ir_function_signature
*
2870 builtin_builder::_acos(const glsl_type
*type
)
2872 ir_variable
*x
= in_var(type
, "x");
2873 MAKE_SIG(type
, always_available
, 1, x
);
2875 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
2880 ir_function_signature
*
2881 builtin_builder::_atan2(const glsl_type
*type
)
2883 ir_variable
*vec_y
= in_var(type
, "vec_y");
2884 ir_variable
*vec_x
= in_var(type
, "vec_x");
2885 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2887 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2888 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2889 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2890 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2891 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2892 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2893 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2895 /* If |x| >= 1.0e-8 * |y|: */
2897 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2899 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2901 /* Then...call atan(y/x) */
2902 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
2904 /* ...and fix it up: */
2905 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2906 inner_if
->then_instructions
.push_tail(
2907 if_tree(gequal(y
, imm(0.0f
)),
2908 assign(r
, add(r
, imm(M_PIf
))),
2909 assign(r
, sub(r
, imm(M_PIf
)))));
2910 outer_then
.emit(inner_if
);
2913 outer_if
->else_instructions
.push_tail(
2914 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
2916 body
.emit(outer_if
);
2918 body
.emit(assign(vec_result
, r
, 1 << i
));
2920 body
.emit(ret(vec_result
));
2926 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
2929 * range-reduction, first step:
2931 * / y_over_x if |y_over_x| <= 1.0;
2933 * \ 1.0 / y_over_x otherwise
2935 ir_variable
*x
= body
.make_temp(type
, "atan_x");
2936 body
.emit(assign(x
, div(min2(abs(y_over_x
),
2942 * approximate atan by evaluating polynomial:
2944 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
2945 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
2946 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
2948 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
2949 body
.emit(assign(tmp
, mul(x
, x
)));
2950 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
2952 imm(0.0536813784310406f
)),
2954 imm(0.1173503194786851f
)),
2956 imm(0.1938924977115610f
)),
2958 imm(0.3326756418091246f
)),
2960 imm(0.9999793128310355f
)),
2963 /* range-reduction fixup */
2964 body
.emit(assign(tmp
, add(tmp
,
2965 mul(b2f(greater(abs(y_over_x
),
2966 imm(1.0f
, type
->components()))),
2972 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
2975 ir_function_signature
*
2976 builtin_builder::_atan(const glsl_type
*type
)
2978 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2979 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2981 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
2982 do_atan(body
, type
, tmp
, y_over_x
);
2983 body
.emit(ret(tmp
));
2988 ir_function_signature
*
2989 builtin_builder::_sinh(const glsl_type
*type
)
2991 ir_variable
*x
= in_var(type
, "x");
2992 MAKE_SIG(type
, v130
, 1, x
);
2994 /* 0.5 * (e^x - e^(-x)) */
2995 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3000 ir_function_signature
*
3001 builtin_builder::_cosh(const glsl_type
*type
)
3003 ir_variable
*x
= in_var(type
, "x");
3004 MAKE_SIG(type
, v130
, 1, x
);
3006 /* 0.5 * (e^x + e^(-x)) */
3007 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3012 ir_function_signature
*
3013 builtin_builder::_tanh(const glsl_type
*type
)
3015 ir_variable
*x
= in_var(type
, "x");
3016 MAKE_SIG(type
, v130
, 1, x
);
3018 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3019 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3020 add(exp(x
), exp(neg(x
))))));
3025 ir_function_signature
*
3026 builtin_builder::_asinh(const glsl_type
*type
)
3028 ir_variable
*x
= in_var(type
, "x");
3029 MAKE_SIG(type
, v130
, 1, x
);
3031 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3036 ir_function_signature
*
3037 builtin_builder::_acosh(const glsl_type
*type
)
3039 ir_variable
*x
= in_var(type
, "x");
3040 MAKE_SIG(type
, v130
, 1, x
);
3042 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3046 ir_function_signature
*
3047 builtin_builder::_atanh(const glsl_type
*type
)
3049 ir_variable
*x
= in_var(type
, "x");
3050 MAKE_SIG(type
, v130
, 1, x
);
3052 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3053 sub(imm(1.0f
), x
))))));
3059 * Exponential Functions @{
3062 ir_function_signature
*
3063 builtin_builder::_pow(const glsl_type
*type
)
3065 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3068 UNOP(exp
, ir_unop_exp
, always_available
)
3069 UNOP(log
, ir_unop_log
, always_available
)
3070 UNOP(exp2
, ir_unop_exp2
, always_available
)
3071 UNOP(log2
, ir_unop_log2
, always_available
)
3072 UNOPA(sqrt
, ir_unop_sqrt
)
3073 UNOPA(inversesqrt
, ir_unop_rsq
)
3077 UNOPA(abs
, ir_unop_abs
)
3078 UNOPA(sign
, ir_unop_sign
)
3079 UNOPA(floor
, ir_unop_floor
)
3080 UNOPA(trunc
, ir_unop_trunc
)
3081 UNOPA(round
, ir_unop_round_even
)
3082 UNOPA(roundEven
, ir_unop_round_even
)
3083 UNOPA(ceil
, ir_unop_ceil
)
3084 UNOPA(fract
, ir_unop_fract
)
3086 ir_function_signature
*
3087 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3089 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3092 ir_function_signature
*
3093 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3095 ir_variable
*x
= in_var(type
, "x");
3096 ir_variable
*i
= out_var(type
, "i");
3097 MAKE_SIG(type
, avail
, 2, x
, i
);
3099 ir_variable
*t
= body
.make_temp(type
, "t");
3100 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3101 body
.emit(assign(i
, t
));
3102 body
.emit(ret(sub(x
, t
)));
3107 ir_function_signature
*
3108 builtin_builder::_min(builtin_available_predicate avail
,
3109 const glsl_type
*x_type
, const glsl_type
*y_type
)
3111 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3114 ir_function_signature
*
3115 builtin_builder::_max(builtin_available_predicate avail
,
3116 const glsl_type
*x_type
, const glsl_type
*y_type
)
3118 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3121 ir_function_signature
*
3122 builtin_builder::_clamp(builtin_available_predicate avail
,
3123 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3125 ir_variable
*x
= in_var(val_type
, "x");
3126 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3127 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3128 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3130 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3135 ir_function_signature
*
3136 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3138 ir_variable
*x
= in_var(val_type
, "x");
3139 ir_variable
*y
= in_var(val_type
, "y");
3140 ir_variable
*a
= in_var(blend_type
, "a");
3141 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3143 body
.emit(ret(lrp(x
, y
, a
)));
3148 ir_function_signature
*
3149 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3150 const glsl_type
*val_type
,
3151 const glsl_type
*blend_type
)
3153 ir_variable
*x
= in_var(val_type
, "x");
3154 ir_variable
*y
= in_var(val_type
, "y");
3155 ir_variable
*a
= in_var(blend_type
, "a");
3156 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3158 /* csel matches the ternary operator in that a selector of true choses the
3159 * first argument. This differs from mix(x, y, false) which choses the
3160 * second argument (to remain consistent with the interpolating version of
3161 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3163 * To handle the behavior mismatch, reverse the x and y arguments.
3165 body
.emit(ret(csel(a
, y
, x
)));
3170 ir_function_signature
*
3171 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3173 ir_variable
*edge
= in_var(edge_type
, "edge");
3174 ir_variable
*x
= in_var(x_type
, "x");
3175 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3177 ir_variable
*t
= body
.make_temp(x_type
, "t");
3178 if (x_type
->vector_elements
== 1) {
3179 /* Both are floats */
3180 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3181 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3183 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3184 } else if (edge_type
->vector_elements
== 1) {
3185 /* x is a vector but edge is a float */
3186 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3187 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3188 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3190 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3193 /* Both are vectors */
3194 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3195 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3196 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3199 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3209 ir_function_signature
*
3210 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3212 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3213 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3214 ir_variable
*x
= in_var(x_type
, "x");
3215 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3217 /* From the GLSL 1.10 specification:
3220 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3221 * return t * t * (3 - 2 * t);
3224 ir_variable
*t
= body
.make_temp(x_type
, "t");
3225 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3226 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3228 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3233 ir_function_signature
*
3234 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3236 ir_variable
*x
= in_var(type
, "x");
3237 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3239 body
.emit(ret(nequal(x
, x
)));
3244 ir_function_signature
*
3245 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3247 ir_variable
*x
= in_var(type
, "x");
3248 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3250 ir_constant_data infinities
;
3251 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3252 infinities
.f
[i
] = INFINITY
;
3255 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3260 ir_function_signature
*
3261 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3263 ir_variable
*x
= in_var(type
, "x");
3264 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3265 body
.emit(ret(bitcast_f2i(x
)));
3269 ir_function_signature
*
3270 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3272 ir_variable
*x
= in_var(type
, "x");
3273 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3274 body
.emit(ret(bitcast_f2u(x
)));
3278 ir_function_signature
*
3279 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3281 ir_variable
*x
= in_var(type
, "x");
3282 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3283 body
.emit(ret(bitcast_i2f(x
)));
3287 ir_function_signature
*
3288 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3290 ir_variable
*x
= in_var(type
, "x");
3291 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3292 body
.emit(ret(bitcast_u2f(x
)));
3296 ir_function_signature
*
3297 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3299 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3300 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3301 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3305 ir_function_signature
*
3306 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3308 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3309 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3310 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3314 ir_function_signature
*
3315 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3317 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3318 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3319 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3323 ir_function_signature
*
3324 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3326 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3327 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3328 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3332 ir_function_signature
*
3333 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3335 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3336 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3337 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3341 ir_function_signature
*
3342 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3344 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3345 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3346 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3351 ir_function_signature
*
3352 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3354 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3355 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3356 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3360 ir_function_signature
*
3361 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3363 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3364 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3365 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3369 ir_function_signature
*
3370 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3372 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3373 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3374 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3378 ir_function_signature
*
3379 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3381 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3382 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3383 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3387 ir_function_signature
*
3388 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3390 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3391 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3392 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3396 ir_function_signature
*
3397 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3399 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3400 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3401 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3405 ir_function_signature
*
3406 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3408 ir_variable
*x
= in_var(type
, "x");
3409 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3411 body
.emit(ret(sqrt(dot(x
, x
))));
3416 ir_function_signature
*
3417 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3419 ir_variable
*p0
= in_var(type
, "p0");
3420 ir_variable
*p1
= in_var(type
, "p1");
3421 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3423 if (type
->vector_elements
== 1) {
3424 body
.emit(ret(abs(sub(p0
, p1
))));
3426 ir_variable
*p
= body
.make_temp(type
, "p");
3427 body
.emit(assign(p
, sub(p0
, p1
)));
3428 body
.emit(ret(sqrt(dot(p
, p
))));
3434 ir_function_signature
*
3435 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3437 if (type
->vector_elements
== 1)
3438 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3440 return binop(ir_binop_dot
, avail
,
3441 type
->get_base_type(), type
, type
);
3444 ir_function_signature
*
3445 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3447 ir_variable
*a
= in_var(type
, "a");
3448 ir_variable
*b
= in_var(type
, "b");
3449 MAKE_SIG(type
, avail
, 2, a
, b
);
3451 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3452 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3454 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3455 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3460 ir_function_signature
*
3461 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3463 ir_variable
*x
= in_var(type
, "x");
3464 MAKE_SIG(type
, avail
, 1, x
);
3466 if (type
->vector_elements
== 1) {
3467 body
.emit(ret(sign(x
)));
3469 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3475 ir_function_signature
*
3476 builtin_builder::_ftransform()
3478 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3480 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3481 glsl_type::vec4_type
,
3482 var_ref(gl_ModelViewProjectionMatrix
),
3483 var_ref(gl_Vertex
))));
3485 /* FINISHME: Once the ir_expression() constructor handles type inference
3486 * for matrix operations, we can simplify this to:
3488 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3493 ir_function_signature
*
3494 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3496 ir_variable
*N
= in_var(type
, "N");
3497 ir_variable
*I
= in_var(type
, "I");
3498 ir_variable
*Nref
= in_var(type
, "Nref");
3499 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3501 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3502 ret(N
), ret(neg(N
))));
3507 ir_function_signature
*
3508 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3510 ir_variable
*I
= in_var(type
, "I");
3511 ir_variable
*N
= in_var(type
, "N");
3512 MAKE_SIG(type
, avail
, 2, I
, N
);
3514 /* I - 2 * dot(N, I) * N */
3515 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3520 ir_function_signature
*
3521 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3523 ir_variable
*I
= in_var(type
, "I");
3524 ir_variable
*N
= in_var(type
, "N");
3525 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3526 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3528 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3529 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3531 /* From the GLSL 1.10 specification:
3532 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3534 * return genType(0.0)
3536 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3538 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3539 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3540 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3541 mul(n_dot_i
, n_dot_i
)))))));
3542 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3543 ret(ir_constant::zero(mem_ctx
, type
)),
3544 ret(sub(mul(eta
, I
),
3545 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3550 ir_function_signature
*
3551 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3553 ir_variable
*x
= in_var(type
, "x");
3554 ir_variable
*y
= in_var(type
, "y");
3555 MAKE_SIG(type
, avail
, 2, x
, y
);
3557 ir_variable
*z
= body
.make_temp(type
, "z");
3558 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3559 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3566 ir_function_signature
*
3567 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3572 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3573 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3574 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3576 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3577 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3579 MAKE_SIG(type
, avail
, 2, c
, r
);
3581 ir_variable
*m
= body
.make_temp(type
, "m");
3582 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3583 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3590 ir_function_signature
*
3591 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3593 const glsl_type
*transpose_type
=
3594 glsl_type::get_instance(orig_type
->base_type
,
3595 orig_type
->matrix_columns
,
3596 orig_type
->vector_elements
);
3598 ir_variable
*m
= in_var(orig_type
, "m");
3599 MAKE_SIG(transpose_type
, avail
, 1, m
);
3601 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3602 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3603 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3604 body
.emit(assign(array_ref(t
, j
),
3605 matrix_elt(m
, i
, j
),
3614 ir_function_signature
*
3615 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3617 ir_variable
*m
= in_var(type
, "m");
3618 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3620 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3621 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3626 ir_function_signature
*
3627 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3629 ir_variable
*m
= in_var(type
, "m");
3630 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3633 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3634 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3637 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3638 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3641 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3642 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3644 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3645 mul(matrix_elt(m
, 0, 1), f2
)),
3646 mul(matrix_elt(m
, 0, 2), f3
))));
3651 ir_function_signature
*
3652 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3654 ir_variable
*m
= in_var(type
, "m");
3655 const glsl_type
*btype
= type
->get_base_type();
3656 MAKE_SIG(btype
, avail
, 1, m
);
3658 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3659 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3660 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3661 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3662 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3663 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3664 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3665 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3666 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3667 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3668 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3669 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3670 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3671 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3672 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3673 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3674 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3675 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3676 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3678 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)))));
3679 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)))));
3680 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)))));
3681 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)))));
3682 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)))));
3683 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)))));
3684 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)))));
3685 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)))));
3686 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)))));
3687 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)))));
3688 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)))));
3689 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)))));
3690 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)))));
3691 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)))));
3692 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)))));
3693 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)))));
3694 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)))));
3695 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)))));
3696 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)))));
3698 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3700 body
.emit(assign(adj_0
,
3701 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3702 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3703 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3705 body
.emit(assign(adj_0
, neg(
3706 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3707 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3708 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3710 body
.emit(assign(adj_0
,
3711 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3712 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3713 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3715 body
.emit(assign(adj_0
, neg(
3716 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3717 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3718 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3721 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3726 ir_function_signature
*
3727 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3729 ir_variable
*m
= in_var(type
, "m");
3730 MAKE_SIG(type
, avail
, 1, m
);
3732 ir_variable
*adj
= body
.make_temp(type
, "adj");
3733 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3734 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3735 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3736 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3738 ir_expression
*det
=
3739 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3740 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3742 body
.emit(ret(div(adj
, det
)));
3746 ir_function_signature
*
3747 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3749 ir_variable
*m
= in_var(type
, "m");
3750 const glsl_type
*btype
= type
->get_base_type();
3751 MAKE_SIG(type
, avail
, 1, m
);
3753 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
3754 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
3755 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
3757 body
.emit(assign(f11_22_21_12
,
3758 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3759 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3760 body
.emit(assign(f10_22_20_12
,
3761 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3762 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3763 body
.emit(assign(f10_21_20_11
,
3764 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3765 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3767 ir_variable
*adj
= body
.make_temp(type
, "adj");
3768 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3769 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3770 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3772 body
.emit(assign(array_ref(adj
, 0), neg(
3773 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3774 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3776 body
.emit(assign(array_ref(adj
, 1),
3777 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3778 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3780 body
.emit(assign(array_ref(adj
, 2), neg(
3781 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3782 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3785 body
.emit(assign(array_ref(adj
, 0),
3786 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3787 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3789 body
.emit(assign(array_ref(adj
, 1), neg(
3790 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3791 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3793 body
.emit(assign(array_ref(adj
, 2),
3794 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3795 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3798 ir_expression
*det
=
3799 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3800 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3801 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3803 body
.emit(ret(div(adj
, det
)));
3808 ir_function_signature
*
3809 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3811 ir_variable
*m
= in_var(type
, "m");
3812 const glsl_type
*btype
= type
->get_base_type();
3813 MAKE_SIG(type
, avail
, 1, m
);
3815 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3816 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3817 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3818 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3819 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3820 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3821 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3822 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3823 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3824 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3825 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3826 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3827 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3828 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3829 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3830 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3831 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3832 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3833 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3835 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)))));
3836 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)))));
3837 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)))));
3838 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)))));
3839 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)))));
3840 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)))));
3841 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)))));
3842 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)))));
3843 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)))));
3844 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)))));
3845 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)))));
3846 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)))));
3847 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)))));
3848 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)))));
3849 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)))));
3850 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)))));
3851 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)))));
3852 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)))));
3853 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)))));
3855 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
3856 body
.emit(assign(array_ref(adj
, 0),
3857 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3858 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3859 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3861 body
.emit(assign(array_ref(adj
, 1), neg(
3862 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3863 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3864 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3866 body
.emit(assign(array_ref(adj
, 2),
3867 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3868 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3869 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3871 body
.emit(assign(array_ref(adj
, 3), neg(
3872 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3873 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3874 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3877 body
.emit(assign(array_ref(adj
, 0), neg(
3878 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3879 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3880 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3882 body
.emit(assign(array_ref(adj
, 1),
3883 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3884 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3885 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3887 body
.emit(assign(array_ref(adj
, 2), neg(
3888 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3889 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3890 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3892 body
.emit(assign(array_ref(adj
, 3),
3893 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3894 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3895 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3898 body
.emit(assign(array_ref(adj
, 0),
3899 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3900 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3901 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3903 body
.emit(assign(array_ref(adj
, 1), neg(
3904 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3905 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3906 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3908 body
.emit(assign(array_ref(adj
, 2),
3909 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3910 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3911 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3913 body
.emit(assign(array_ref(adj
, 3), neg(
3914 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3915 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3916 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3919 body
.emit(assign(array_ref(adj
, 0), neg(
3920 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3921 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3922 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3924 body
.emit(assign(array_ref(adj
, 1),
3925 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3926 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3927 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3929 body
.emit(assign(array_ref(adj
, 2), neg(
3930 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3931 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3932 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3934 body
.emit(assign(array_ref(adj
, 3),
3935 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3936 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3937 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3940 ir_expression
*det
=
3941 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3942 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3943 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3944 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3946 body
.emit(ret(div(adj
, det
)));
3952 ir_function_signature
*
3953 builtin_builder::_lessThan(builtin_available_predicate avail
,
3954 const glsl_type
*type
)
3956 return binop(ir_binop_less
, avail
,
3957 glsl_type::bvec(type
->vector_elements
), type
, type
);
3960 ir_function_signature
*
3961 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3962 const glsl_type
*type
)
3964 return binop(ir_binop_lequal
, avail
,
3965 glsl_type::bvec(type
->vector_elements
), type
, type
);
3968 ir_function_signature
*
3969 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3970 const glsl_type
*type
)
3972 return binop(ir_binop_greater
, avail
,
3973 glsl_type::bvec(type
->vector_elements
), type
, type
);
3976 ir_function_signature
*
3977 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3978 const glsl_type
*type
)
3980 return binop(ir_binop_gequal
, avail
,
3981 glsl_type::bvec(type
->vector_elements
), type
, type
);
3984 ir_function_signature
*
3985 builtin_builder::_equal(builtin_available_predicate avail
,
3986 const glsl_type
*type
)
3988 return binop(ir_binop_equal
, avail
,
3989 glsl_type::bvec(type
->vector_elements
), type
, type
);
3992 ir_function_signature
*
3993 builtin_builder::_notEqual(builtin_available_predicate avail
,
3994 const glsl_type
*type
)
3996 return binop(ir_binop_nequal
, avail
,
3997 glsl_type::bvec(type
->vector_elements
), type
, type
);
4000 ir_function_signature
*
4001 builtin_builder::_any(const glsl_type
*type
)
4003 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4006 ir_function_signature
*
4007 builtin_builder::_all(const glsl_type
*type
)
4009 ir_variable
*v
= in_var(type
, "v");
4010 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4012 switch (type
->vector_elements
) {
4014 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4017 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4021 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4030 UNOP(not, ir_unop_logic_not
, always_available
)
4033 has_lod(const glsl_type
*sampler_type
)
4035 assert(sampler_type
->is_sampler());
4037 switch (sampler_type
->sampler_dimensionality
) {
4038 case GLSL_SAMPLER_DIM_RECT
:
4039 case GLSL_SAMPLER_DIM_BUF
:
4040 case GLSL_SAMPLER_DIM_MS
:
4047 ir_function_signature
*
4048 builtin_builder::_textureSize(builtin_available_predicate avail
,
4049 const glsl_type
*return_type
,
4050 const glsl_type
*sampler_type
)
4052 ir_variable
*s
= in_var(sampler_type
, "sampler");
4053 /* The sampler always exists; add optional lod later. */
4054 MAKE_SIG(return_type
, avail
, 1, s
);
4056 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4057 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4059 if (has_lod(sampler_type
)) {
4060 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4061 sig
->parameters
.push_tail(lod
);
4062 tex
->lod_info
.lod
= var_ref(lod
);
4064 tex
->lod_info
.lod
= imm(0u);
4067 body
.emit(ret(tex
));
4072 ir_function_signature
*
4073 builtin_builder::_texture(ir_texture_opcode opcode
,
4074 builtin_available_predicate avail
,
4075 const glsl_type
*return_type
,
4076 const glsl_type
*sampler_type
,
4077 const glsl_type
*coord_type
,
4080 ir_variable
*s
= in_var(sampler_type
, "sampler");
4081 ir_variable
*P
= in_var(coord_type
, "P");
4082 /* The sampler and coordinate always exist; add optional parameters later. */
4083 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4085 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4086 tex
->set_sampler(var_ref(s
), return_type
);
4088 const int coord_size
= sampler_type
->coordinate_components();
4090 if (coord_size
== coord_type
->vector_elements
) {
4091 tex
->coordinate
= var_ref(P
);
4093 /* The incoming coordinate also has the projector or shadow comparitor,
4094 * so we need to swizzle those away.
4096 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4099 /* The projector is always in the last component. */
4100 if (flags
& TEX_PROJECT
)
4101 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4103 if (sampler_type
->sampler_shadow
) {
4104 if (opcode
== ir_tg4
) {
4105 /* gather has refz as a separate parameter, immediately after the
4108 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4109 sig
->parameters
.push_tail(refz
);
4110 tex
->shadow_comparitor
= var_ref(refz
);
4112 /* The shadow comparitor is normally in the Z component, but a few types
4113 * have sufficiently large coordinates that it's in W.
4115 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4119 if (opcode
== ir_txl
) {
4120 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4121 sig
->parameters
.push_tail(lod
);
4122 tex
->lod_info
.lod
= var_ref(lod
);
4123 } else if (opcode
== ir_txd
) {
4124 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4125 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4126 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4127 sig
->parameters
.push_tail(dPdx
);
4128 sig
->parameters
.push_tail(dPdy
);
4129 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4130 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4133 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4134 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4135 ir_variable
*offset
=
4136 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4137 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4138 sig
->parameters
.push_tail(offset
);
4139 tex
->offset
= var_ref(offset
);
4142 if (flags
& TEX_OFFSET_ARRAY
) {
4143 ir_variable
*offsets
=
4144 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4145 "offsets", ir_var_const_in
);
4146 sig
->parameters
.push_tail(offsets
);
4147 tex
->offset
= var_ref(offsets
);
4150 if (opcode
== ir_tg4
) {
4151 if (flags
& TEX_COMPONENT
) {
4152 ir_variable
*component
=
4153 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4154 sig
->parameters
.push_tail(component
);
4155 tex
->lod_info
.component
= var_ref(component
);
4158 tex
->lod_info
.component
= imm(0);
4162 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4163 * inconsistent with both textureLodOffset and textureGradOffset.
4165 if (opcode
== ir_txb
) {
4166 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4167 sig
->parameters
.push_tail(bias
);
4168 tex
->lod_info
.bias
= var_ref(bias
);
4171 body
.emit(ret(tex
));
4176 ir_function_signature
*
4177 builtin_builder::_textureCubeArrayShadow()
4179 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4180 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4181 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4182 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4184 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4185 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4187 tex
->coordinate
= var_ref(P
);
4188 tex
->shadow_comparitor
= var_ref(compare
);
4190 body
.emit(ret(tex
));
4195 ir_function_signature
*
4196 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4197 const glsl_type
*return_type
,
4198 const glsl_type
*sampler_type
,
4199 const glsl_type
*coord_type
,
4200 const glsl_type
*offset_type
)
4202 ir_variable
*s
= in_var(sampler_type
, "sampler");
4203 ir_variable
*P
= in_var(coord_type
, "P");
4204 /* The sampler and coordinate always exist; add optional parameters later. */
4205 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4207 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4208 tex
->coordinate
= var_ref(P
);
4209 tex
->set_sampler(var_ref(s
), return_type
);
4211 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4212 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4213 sig
->parameters
.push_tail(sample
);
4214 tex
->lod_info
.sample_index
= var_ref(sample
);
4215 tex
->op
= ir_txf_ms
;
4216 } else if (has_lod(sampler_type
)) {
4217 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4218 sig
->parameters
.push_tail(lod
);
4219 tex
->lod_info
.lod
= var_ref(lod
);
4221 tex
->lod_info
.lod
= imm(0u);
4224 if (offset_type
!= NULL
) {
4225 ir_variable
*offset
=
4226 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4227 sig
->parameters
.push_tail(offset
);
4228 tex
->offset
= var_ref(offset
);
4231 body
.emit(ret(tex
));
4236 ir_function_signature
*
4237 builtin_builder::_EmitVertex()
4239 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4241 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4242 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4247 ir_function_signature
*
4248 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4249 const glsl_type
*stream_type
)
4251 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4253 * "Emit the current values of output variables to the current output
4254 * primitive on stream stream. The argument to stream must be a constant
4255 * integral expression."
4257 ir_variable
*stream
=
4258 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4260 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4262 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4267 ir_function_signature
*
4268 builtin_builder::_EndPrimitive()
4270 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4272 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4273 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4278 ir_function_signature
*
4279 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4280 const glsl_type
*stream_type
)
4282 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4284 * "Completes the current output primitive on stream stream and starts
4285 * a new one. The argument to stream must be a constant integral
4288 ir_variable
*stream
=
4289 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4291 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4293 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4298 ir_function_signature
*
4299 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
4300 const glsl_type
*coord_type
)
4302 ir_variable
*s
= in_var(sampler_type
, "sampler");
4303 ir_variable
*coord
= in_var(coord_type
, "coord");
4304 /* The sampler and coordinate always exist; add optional parameters later. */
4305 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
4307 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4308 tex
->coordinate
= var_ref(coord
);
4309 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4311 body
.emit(ret(tex
));
4316 ir_function_signature
*
4317 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4319 ir_variable
*s
= in_var(sampler_type
, "sampler");
4320 const glsl_type
*return_type
= glsl_type::int_type
;
4321 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4323 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4324 tex
->set_sampler(var_ref(s
), return_type
);
4326 body
.emit(ret(tex
));
4331 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4332 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4333 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4334 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4335 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4336 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4338 ir_function_signature
*
4339 builtin_builder::_fwidth(const glsl_type
*type
)
4341 ir_variable
*p
= in_var(type
, "p");
4342 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4344 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4349 ir_function_signature
*
4350 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4352 ir_variable
*p
= in_var(type
, "p");
4353 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4355 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4356 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4361 ir_function_signature
*
4362 builtin_builder::_fwidthFine(const glsl_type
*type
)
4364 ir_variable
*p
= in_var(type
, "p");
4365 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4367 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4368 abs(expr(ir_unop_dFdy_fine
, p
)))));
4373 ir_function_signature
*
4374 builtin_builder::_noise1(const glsl_type
*type
)
4376 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4379 ir_function_signature
*
4380 builtin_builder::_noise2(const glsl_type
*type
)
4382 ir_variable
*p
= in_var(type
, "p");
4383 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4385 ir_constant_data b_offset
;
4386 b_offset
.f
[0] = 601.0f
;
4387 b_offset
.f
[1] = 313.0f
;
4388 b_offset
.f
[2] = 29.0f
;
4389 b_offset
.f
[3] = 277.0f
;
4391 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4392 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4393 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4394 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4395 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4396 body
.emit(assign(t
, a
, WRITEMASK_X
));
4397 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4403 ir_function_signature
*
4404 builtin_builder::_noise3(const glsl_type
*type
)
4406 ir_variable
*p
= in_var(type
, "p");
4407 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4409 ir_constant_data b_offset
;
4410 b_offset
.f
[0] = 601.0f
;
4411 b_offset
.f
[1] = 313.0f
;
4412 b_offset
.f
[2] = 29.0f
;
4413 b_offset
.f
[3] = 277.0f
;
4415 ir_constant_data c_offset
;
4416 c_offset
.f
[0] = 1559.0f
;
4417 c_offset
.f
[1] = 113.0f
;
4418 c_offset
.f
[2] = 1861.0f
;
4419 c_offset
.f
[3] = 797.0f
;
4421 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4422 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4423 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4424 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4425 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4426 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4427 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4428 body
.emit(assign(t
, a
, WRITEMASK_X
));
4429 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4430 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4436 ir_function_signature
*
4437 builtin_builder::_noise4(const glsl_type
*type
)
4439 ir_variable
*p
= in_var(type
, "p");
4440 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4442 ir_variable
*_p
= body
.make_temp(type
, "_p");
4444 ir_constant_data p_offset
;
4445 p_offset
.f
[0] = 1559.0f
;
4446 p_offset
.f
[1] = 113.0f
;
4447 p_offset
.f
[2] = 1861.0f
;
4448 p_offset
.f
[3] = 797.0f
;
4450 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4452 ir_constant_data offset
;
4453 offset
.f
[0] = 601.0f
;
4454 offset
.f
[1] = 313.0f
;
4455 offset
.f
[2] = 29.0f
;
4456 offset
.f
[3] = 277.0f
;
4458 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4459 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4460 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4461 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4462 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4463 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4464 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4465 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4466 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4467 body
.emit(assign(t
, a
, WRITEMASK_X
));
4468 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4469 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4470 body
.emit(assign(t
, d
, WRITEMASK_W
));
4476 ir_function_signature
*
4477 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4479 ir_variable
*value
= in_var(type
, "value");
4480 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4481 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4482 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
4484 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4489 ir_function_signature
*
4490 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4492 ir_variable
*base
= in_var(type
, "base");
4493 ir_variable
*insert
= in_var(type
, "insert");
4494 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4495 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4496 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
4498 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4503 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
4505 ir_function_signature
*
4506 builtin_builder::_bitCount(const glsl_type
*type
)
4508 return unop(gpu_shader5
, ir_unop_bit_count
,
4509 glsl_type::ivec(type
->vector_elements
), type
);
4512 ir_function_signature
*
4513 builtin_builder::_findLSB(const glsl_type
*type
)
4515 return unop(gpu_shader5
, ir_unop_find_lsb
,
4516 glsl_type::ivec(type
->vector_elements
), type
);
4519 ir_function_signature
*
4520 builtin_builder::_findMSB(const glsl_type
*type
)
4522 return unop(gpu_shader5
, ir_unop_find_msb
,
4523 glsl_type::ivec(type
->vector_elements
), type
);
4526 ir_function_signature
*
4527 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4529 ir_variable
*a
= in_var(type
, "a");
4530 ir_variable
*b
= in_var(type
, "b");
4531 ir_variable
*c
= in_var(type
, "c");
4532 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4534 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4539 ir_function_signature
*
4540 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4542 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5
, x_type
, x_type
, exp_type
);
4545 ir_function_signature
*
4546 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4548 ir_variable
*x
= in_var(x_type
, "x");
4549 ir_variable
*exponent
= out_var(exp_type
, "exp");
4550 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4552 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4554 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4558 ir_function_signature
*
4559 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4561 ir_variable
*x
= in_var(x_type
, "x");
4562 ir_variable
*exponent
= out_var(exp_type
, "exp");
4563 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
4565 const unsigned vec_elem
= x_type
->vector_elements
;
4566 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4567 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4569 /* Single-precision floating-point values are stored as
4574 * An exponent shift of 23 will shift the mantissa out, leaving only the
4575 * exponent and sign bit (which itself may be zero, if the absolute value
4576 * was taken before the bitcast and shift.
4578 ir_constant
*exponent_shift
= imm(23);
4579 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4581 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4583 /* Exponent of floating-point values in the range [0.5, 1.0). */
4584 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4586 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4587 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4589 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4590 * to unsigned integers to ensure that 1 bits aren't shifted in.
4592 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4593 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4594 imm(0, vec_elem
)))));
4596 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4597 body
.emit(assign(bits
, bitcast_f2u(x
)));
4598 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4599 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4600 imm(0u, vec_elem
)))));
4601 body
.emit(ret(bitcast_u2f(bits
)));
4606 ir_function_signature
*
4607 builtin_builder::_uaddCarry(const glsl_type
*type
)
4609 ir_variable
*x
= in_var(type
, "x");
4610 ir_variable
*y
= in_var(type
, "y");
4611 ir_variable
*carry
= out_var(type
, "carry");
4612 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
4614 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4615 body
.emit(ret(add(x
, y
)));
4620 ir_function_signature
*
4621 builtin_builder::_usubBorrow(const glsl_type
*type
)
4623 ir_variable
*x
= in_var(type
, "x");
4624 ir_variable
*y
= in_var(type
, "y");
4625 ir_variable
*borrow
= out_var(type
, "borrow");
4626 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
4628 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4629 body
.emit(ret(sub(x
, y
)));
4635 * For both imulExtended() and umulExtended() built-ins.
4637 ir_function_signature
*
4638 builtin_builder::_mulExtended(const glsl_type
*type
)
4640 ir_variable
*x
= in_var(type
, "x");
4641 ir_variable
*y
= in_var(type
, "y");
4642 ir_variable
*msb
= out_var(type
, "msb");
4643 ir_variable
*lsb
= out_var(type
, "lsb");
4644 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
4646 body
.emit(assign(msb
, imul_high(x
, y
)));
4647 body
.emit(assign(lsb
, mul(x
, y
)));
4652 ir_function_signature
*
4653 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4655 ir_variable
*interpolant
= in_var(type
, "interpolant");
4656 interpolant
->data
.must_be_shader_input
= 1;
4657 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4659 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4664 ir_function_signature
*
4665 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4667 ir_variable
*interpolant
= in_var(type
, "interpolant");
4668 interpolant
->data
.must_be_shader_input
= 1;
4669 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4670 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4672 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4677 ir_function_signature
*
4678 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4680 ir_variable
*interpolant
= in_var(type
, "interpolant");
4681 interpolant
->data
.must_be_shader_input
= 1;
4682 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4683 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4685 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4690 ir_function_signature
*
4691 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4693 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4694 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4698 ir_function_signature
*
4699 builtin_builder::_atomic_op(const char *intrinsic
,
4700 builtin_available_predicate avail
)
4702 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4703 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4705 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4706 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4708 body
.emit(ret(retval
));
4712 ir_function_signature
*
4713 builtin_builder::_min3(const glsl_type
*type
)
4715 ir_variable
*x
= in_var(type
, "x");
4716 ir_variable
*y
= in_var(type
, "y");
4717 ir_variable
*z
= in_var(type
, "z");
4718 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4720 ir_expression
*min3
= min2(x
, min2(y
,z
));
4721 body
.emit(ret(min3
));
4726 ir_function_signature
*
4727 builtin_builder::_max3(const glsl_type
*type
)
4729 ir_variable
*x
= in_var(type
, "x");
4730 ir_variable
*y
= in_var(type
, "y");
4731 ir_variable
*z
= in_var(type
, "z");
4732 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4734 ir_expression
*max3
= max2(x
, max2(y
,z
));
4735 body
.emit(ret(max3
));
4740 ir_function_signature
*
4741 builtin_builder::_mid3(const glsl_type
*type
)
4743 ir_variable
*x
= in_var(type
, "x");
4744 ir_variable
*y
= in_var(type
, "y");
4745 ir_variable
*z
= in_var(type
, "z");
4746 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4748 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4749 body
.emit(ret(mid3
));
4754 ir_function_signature
*
4755 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4756 const char *intrinsic_name
,
4757 unsigned num_arguments
,
4760 const glsl_type
*data_type
= glsl_type::get_instance(
4761 image_type
->sampler_type
,
4762 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4764 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4765 glsl_type::void_type
: data_type
);
4767 /* Addressing arguments that are always present. */
4768 ir_variable
*image
= in_var(image_type
, "image");
4769 ir_variable
*coord
= in_var(
4770 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4772 ir_function_signature
*sig
= new_sig(
4773 ret_type
, shader_image_load_store
, 2, image
, coord
);
4775 /* Sample index for multisample images. */
4776 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4777 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4779 /* Data arguments. */
4780 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
4781 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
4782 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
4783 ralloc_free(arg_name
);
4786 /* Set the maximal set of qualifiers allowed for this image
4787 * built-in. Function calls with arguments having fewer
4788 * qualifiers than present in the prototype are allowed by the
4789 * spec, but not with more, i.e. this will make the compiler
4790 * accept everything that needs to be accepted, and reject cases
4791 * like loads from write-only or stores to read-only images.
4793 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
4794 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
4795 image
->data
.image_coherent
= true;
4796 image
->data
.image_volatile
= true;
4797 image
->data
.image_restrict
= true;
4802 ir_function_signature
*
4803 builtin_builder::_image(const glsl_type
*image_type
,
4804 const char *intrinsic_name
,
4805 unsigned num_arguments
,
4808 ir_function_signature
*sig
= _image_prototype(image_type
, intrinsic_name
,
4809 num_arguments
, flags
);
4811 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
4812 ir_factory
body(&sig
->body
, mem_ctx
);
4813 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
4815 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
4816 body
.emit(call(f
, NULL
, sig
->parameters
));
4818 ir_variable
*ret_val
=
4819 body
.make_temp(sig
->return_type
, "_ret_val");
4820 body
.emit(call(f
, ret_val
, sig
->parameters
));
4821 body
.emit(ret(ret_val
));
4824 sig
->is_defined
= true;
4827 sig
->is_intrinsic
= true;
4833 ir_function_signature
*
4834 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
4836 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
4840 ir_function_signature
*
4841 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
4843 MAKE_SIG(glsl_type::void_type
, avail
, 0);
4844 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
4845 NULL
, sig
->parameters
));
4851 /******************************************************************************/
4853 /* The singleton instance of builtin_builder. */
4854 static builtin_builder builtins
;
4855 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
4858 * External API (exposing the built-in module to the rest of the compiler):
4862 _mesa_glsl_initialize_builtin_functions()
4864 mtx_lock(&builtins_lock
);
4865 builtins
.initialize();
4866 mtx_unlock(&builtins_lock
);
4870 _mesa_glsl_release_builtin_functions()
4872 mtx_lock(&builtins_lock
);
4874 mtx_unlock(&builtins_lock
);
4877 ir_function_signature
*
4878 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4879 const char *name
, exec_list
*actual_parameters
)
4881 ir_function_signature
* s
;
4882 mtx_lock(&builtins_lock
);
4883 s
= builtins
.find(state
, name
, actual_parameters
);
4884 mtx_unlock(&builtins_lock
);
4889 _mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state
*state
,
4893 mtx_lock(&builtins_lock
);
4894 f
= builtins
.shader
->symbols
->get_function(name
);
4895 mtx_unlock(&builtins_lock
);
4900 _mesa_glsl_get_builtin_function_shader()
4902 return builtins
.shader
;