2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 #define M_PIf ((float) M_PI)
66 #define M_PI_2f ((float) M_PI_2)
67 #define M_PI_4f ((float) M_PI_4)
69 using namespace ir_builder
;
72 * Availability predicates:
76 always_available(const _mesa_glsl_parse_state
*)
82 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
84 return state
->stage
== MESA_SHADER_VERTEX
&&
85 state
->language_version
<= 130 &&
90 fs_only(const _mesa_glsl_parse_state
*state
)
92 return state
->stage
== MESA_SHADER_FRAGMENT
;
96 gs_only(const _mesa_glsl_parse_state
*state
)
98 return state
->stage
== MESA_SHADER_GEOMETRY
;
102 v110(const _mesa_glsl_parse_state
*state
)
104 return !state
->es_shader
;
108 v110_fs_only(const _mesa_glsl_parse_state
*state
)
110 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
114 v120(const _mesa_glsl_parse_state
*state
)
116 return state
->is_version(120, 300);
120 v130(const _mesa_glsl_parse_state
*state
)
122 return state
->is_version(130, 300);
126 v130_fs_only(const _mesa_glsl_parse_state
*state
)
128 return state
->is_version(130, 300) &&
129 state
->stage
== MESA_SHADER_FRAGMENT
;
133 v140(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 0);
139 v400_fs_only(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(400, 0) &&
142 state
->stage
== MESA_SHADER_FRAGMENT
;
146 es31(const _mesa_glsl_parse_state
*state
)
148 return state
->is_version(0, 310);
152 texture_rectangle(const _mesa_glsl_parse_state
*state
)
154 return state
->ARB_texture_rectangle_enable
;
158 texture_external(const _mesa_glsl_parse_state
*state
)
160 return state
->OES_EGL_image_external_enable
;
163 /** True if texturing functions with explicit LOD are allowed. */
165 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
167 /* Texturing functions with "Lod" in their name exist:
168 * - In the vertex shader stage (for all languages)
169 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
170 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
172 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
173 * don't need to explicitly check state->es_shader.
175 return state
->stage
== MESA_SHADER_VERTEX
||
176 state
->is_version(130, 300) ||
177 state
->ARB_shader_texture_lod_enable
;
181 v110_lod(const _mesa_glsl_parse_state
*state
)
183 return !state
->es_shader
&& lod_exists_in_stage(state
);
187 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
189 return state
->ARB_shader_texture_lod_enable
;
193 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
195 return state
->ARB_shader_texture_lod_enable
&&
196 state
->ARB_texture_rectangle_enable
;
200 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
202 return state
->is_version(330, 300) ||
203 state
->ARB_shader_bit_encoding_enable
||
204 state
->ARB_gpu_shader5_enable
;
208 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
210 return state
->is_version(450, 310) ||
211 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
215 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->is_version(420, 300);
222 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
224 return state
->ARB_shading_language_packing_enable
||
225 state
->ARB_gpu_shader5_enable
||
226 state
->is_version(400, 300);
230 gpu_shader5(const _mesa_glsl_parse_state
*state
)
232 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
236 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
242 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
244 return state
->ARB_shading_language_packing_enable
||
245 state
->ARB_gpu_shader5_enable
||
246 state
->is_version(400, 310);
250 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
252 return state
->stage
== MESA_SHADER_FRAGMENT
&&
253 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
258 texture_array_lod(const _mesa_glsl_parse_state
*state
)
260 return lod_exists_in_stage(state
) &&
261 state
->EXT_texture_array_enable
;
265 fs_texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->stage
== MESA_SHADER_FRAGMENT
&&
268 state
->EXT_texture_array_enable
;
272 texture_array(const _mesa_glsl_parse_state
*state
)
274 return state
->EXT_texture_array_enable
;
278 texture_multisample(const _mesa_glsl_parse_state
*state
)
280 return state
->is_version(150, 310) ||
281 state
->ARB_texture_multisample_enable
;
285 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(150, 320) ||
288 state
->ARB_texture_multisample_enable
||
289 state
->OES_texture_storage_multisample_2d_array_enable
;
293 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
295 return state
->stage
== MESA_SHADER_FRAGMENT
&&
296 (state
->is_version(400, 0) ||
297 state
->ARB_texture_cube_map_array_enable
);
301 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
303 return state
->is_version(400, 0) ||
304 state
->ARB_texture_cube_map_array_enable
;
308 texture_query_levels(const _mesa_glsl_parse_state
*state
)
310 return state
->is_version(430, 0) ||
311 state
->ARB_texture_query_levels_enable
;
315 texture_query_lod(const _mesa_glsl_parse_state
*state
)
317 return state
->stage
== MESA_SHADER_FRAGMENT
&&
318 state
->ARB_texture_query_lod_enable
;
322 texture_gather(const _mesa_glsl_parse_state
*state
)
324 return state
->is_version(400, 0) ||
325 state
->ARB_texture_gather_enable
||
326 state
->ARB_gpu_shader5_enable
;
330 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
332 return state
->is_version(400, 310) ||
333 state
->ARB_texture_gather_enable
||
334 state
->ARB_gpu_shader5_enable
;
337 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
338 * used for relaxation of const offset requirements.
341 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
343 return !state
->is_version(400, 0) &&
344 !state
->ARB_gpu_shader5_enable
&&
345 (state
->ARB_texture_gather_enable
||
346 state
->is_version(0, 310));
349 /* Desktop GL or OES_standard_derivatives + fragment shader only */
351 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
353 return state
->stage
== MESA_SHADER_FRAGMENT
&&
354 (state
->is_version(110, 300) ||
355 state
->OES_standard_derivatives_enable
);
359 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
361 return state
->stage
== MESA_SHADER_FRAGMENT
&&
362 (state
->is_version(450, 0) ||
363 state
->ARB_derivative_control_enable
);
367 tex1d_lod(const _mesa_glsl_parse_state
*state
)
369 return !state
->es_shader
&& lod_exists_in_stage(state
);
372 /** True if sampler3D exists */
374 tex3d(const _mesa_glsl_parse_state
*state
)
376 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
377 * OES_texture_3D extension, and in GLSL ES 3.00.
379 return !state
->es_shader
||
380 state
->OES_texture_3D_enable
||
381 state
->language_version
>= 300;
385 fs_tex3d(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
392 tex3d_lod(const _mesa_glsl_parse_state
*state
)
394 return tex3d(state
) && lod_exists_in_stage(state
);
398 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
400 return state
->has_atomic_counters();
404 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
406 return state
->AMD_shader_trinary_minmax_enable
;
410 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
412 return (state
->is_version(420, 310) ||
413 state
->ARB_shader_image_load_store_enable
);
417 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
419 return (state
->is_version(420, 0) ||
420 state
->ARB_shader_image_load_store_enable
);
424 shader_image_size(const _mesa_glsl_parse_state
*state
)
426 return state
->is_version(430, 310) ||
427 state
->ARB_shader_image_size_enable
;
431 shader_samples(const _mesa_glsl_parse_state
*state
)
433 return state
->is_version(450, 0) ||
434 state
->ARB_shader_texture_image_samples_enable
;
438 gs_streams(const _mesa_glsl_parse_state
*state
)
440 return gpu_shader5(state
) && gs_only(state
);
444 fp64(const _mesa_glsl_parse_state
*state
)
446 return state
->has_double();
450 barrier_supported(const _mesa_glsl_parse_state
*state
)
452 return state
->stage
== MESA_SHADER_COMPUTE
||
453 state
->stage
== MESA_SHADER_TESS_CTRL
;
458 /******************************************************************************/
463 * builtin_builder: A singleton object representing the core of the built-in
466 * It generates IR for every built-in function signature, and organizes them
469 class builtin_builder
{
476 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
477 const char *name
, exec_list
*actual_parameters
);
480 * A shader to hold all the built-in signatures; created by this module.
482 * This includes signatures for every built-in, regardless of version or
483 * enabled extensions. The availability predicate associated with each
484 * signature allows matching_signature() to filter out the irrelevant ones.
491 /** Global variables used by built-in functions. */
492 ir_variable
*gl_ModelViewProjectionMatrix
;
493 ir_variable
*gl_Vertex
;
495 void create_shader();
496 void create_intrinsics();
497 void create_builtins();
500 * IR builder helpers:
502 * These convenience functions assist in emitting IR, but don't necessarily
503 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
506 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
507 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
508 ir_constant
*imm(float f
, unsigned vector_elements
=1);
509 ir_constant
*imm(int i
, unsigned vector_elements
=1);
510 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
511 ir_constant
*imm(double d
, unsigned vector_elements
=1);
512 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
513 ir_dereference_variable
*var_ref(ir_variable
*var
);
514 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
515 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
517 ir_expression
*asin_expr(ir_variable
*x
);
518 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
521 * Call function \param f with parameters specified as the linked
522 * list \param params of \c ir_variable objects. \param ret should
523 * point to the ir_variable that will hold the function return
524 * value, or be \c NULL if the function has void return type.
526 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
528 /** Create a new function and add the given signatures. */
529 void add_function(const char *name
, ...);
531 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
532 unsigned num_arguments
,
535 enum image_function_flags
{
536 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
537 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
538 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
539 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
540 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
541 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
542 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
543 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
547 * Create a new image built-in function for all known image types.
548 * \p flags is a bitfield of \c image_function_flags flags.
550 void add_image_function(const char *name
,
551 const char *intrinsic_name
,
552 image_prototype_ctr prototype
,
553 unsigned num_arguments
,
557 * Create new functions for all known image built-ins and types.
558 * If \p glsl is \c true, use the GLSL built-in names and emit code
559 * to call into the actual compiler intrinsic. If \p glsl is
560 * false, emit a function prototype with no body for each image
563 void add_image_functions(bool glsl
);
565 ir_function_signature
*new_sig(const glsl_type
*return_type
,
566 builtin_available_predicate avail
,
567 int num_params
, ...);
570 * Function signature generators:
573 ir_function_signature
*unop(builtin_available_predicate avail
,
574 ir_expression_operation opcode
,
575 const glsl_type
*return_type
,
576 const glsl_type
*param_type
);
577 ir_function_signature
*binop(ir_expression_operation opcode
,
578 builtin_available_predicate avail
,
579 const glsl_type
*return_type
,
580 const glsl_type
*param0_type
,
581 const glsl_type
*param1_type
);
583 #define B0(X) ir_function_signature *_##X();
584 #define B1(X) ir_function_signature *_##X(const glsl_type *);
585 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
586 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
587 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
588 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
625 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
626 const glsl_type
*val_type
,
627 const glsl_type
*blend_type
);
636 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
637 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
638 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
639 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
640 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
641 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
642 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
643 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
644 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
645 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
646 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
647 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
660 BA1(determinant_mat2
);
661 BA1(determinant_mat3
);
662 BA1(determinant_mat4
);
670 BA1(greaterThanEqual
);
679 /** Flags to _texture() */
680 #define TEX_PROJECT 1
682 #define TEX_COMPONENT 4
683 #define TEX_OFFSET_NONCONST 8
684 #define TEX_OFFSET_ARRAY 16
686 ir_function_signature
*_texture(ir_texture_opcode opcode
,
687 builtin_available_predicate avail
,
688 const glsl_type
*return_type
,
689 const glsl_type
*sampler_type
,
690 const glsl_type
*coord_type
,
692 B0(textureCubeArrayShadow
);
693 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
694 const glsl_type
*return_type
,
695 const glsl_type
*sampler_type
,
696 const glsl_type
*coord_type
,
697 const glsl_type
*offset_type
= NULL
);
701 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
702 const glsl_type
*stream_type
);
703 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
704 const glsl_type
*stream_type
);
707 BA2(textureQueryLod
);
708 B1(textureQueryLevels
);
736 B1(interpolateAtCentroid
)
737 B1(interpolateAtOffset
)
738 B1(interpolateAtSample
)
740 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
741 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
742 builtin_available_predicate avail
);
748 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
749 unsigned num_arguments
,
751 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
752 unsigned num_arguments
,
754 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
755 unsigned num_arguments
,
757 ir_function_signature
*_image(image_prototype_ctr prototype
,
758 const glsl_type
*image_type
,
759 const char *intrinsic_name
,
760 unsigned num_arguments
,
763 ir_function_signature
*_memory_barrier_intrinsic(
764 builtin_available_predicate avail
);
765 ir_function_signature
*_memory_barrier(
766 builtin_available_predicate avail
);
777 } /* anonymous namespace */
780 * Core builtin_builder functionality:
783 builtin_builder::builtin_builder()
785 gl_ModelViewProjectionMatrix(NULL
),
791 builtin_builder::~builtin_builder()
793 ralloc_free(mem_ctx
);
796 ir_function_signature
*
797 builtin_builder::find(_mesa_glsl_parse_state
*state
,
798 const char *name
, exec_list
*actual_parameters
)
800 /* The shader currently being compiled requested a built-in function;
801 * it needs to link against builtin_builder::shader in order to get them.
803 * Even if we don't find a matching signature, we still need to do this so
804 * that the "no matching signature" error will list potential candidates
805 * from the available built-ins.
807 state
->uses_builtin_functions
= true;
809 ir_function
*f
= shader
->symbols
->get_function(name
);
813 ir_function_signature
*sig
=
814 f
->matching_signature(state
, actual_parameters
, true);
822 builtin_builder::initialize()
824 /* If already initialized, don't do it again. */
828 mem_ctx
= ralloc_context(NULL
);
835 builtin_builder::release()
837 ralloc_free(mem_ctx
);
845 builtin_builder::create_shader()
847 /* The target doesn't actually matter. There's no target for generic
848 * GLSL utility code that could be linked against any stage, so just
849 * arbitrarily pick GL_VERTEX_SHADER.
851 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
852 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
854 gl_ModelViewProjectionMatrix
=
855 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
856 "gl_ModelViewProjectionMatrix",
859 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
861 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
862 shader
->symbols
->add_variable(gl_Vertex
);
868 * Create ir_function and ir_function_signature objects for each
872 builtin_builder::create_intrinsics()
874 add_function("__intrinsic_atomic_read",
875 _atomic_counter_intrinsic(shader_atomic_counters
),
877 add_function("__intrinsic_atomic_increment",
878 _atomic_counter_intrinsic(shader_atomic_counters
),
880 add_function("__intrinsic_atomic_predecrement",
881 _atomic_counter_intrinsic(shader_atomic_counters
),
884 add_image_functions(false);
886 add_function("__intrinsic_memory_barrier",
887 _memory_barrier_intrinsic(shader_image_load_store
),
892 * Create ir_function and ir_function_signature objects for each built-in.
894 * Contains a list of every available built-in.
897 builtin_builder::create_builtins()
900 add_function(#NAME, \
901 _##NAME(glsl_type::float_type), \
902 _##NAME(glsl_type::vec2_type), \
903 _##NAME(glsl_type::vec3_type), \
904 _##NAME(glsl_type::vec4_type), \
908 add_function(#NAME, \
909 _##NAME(always_available, glsl_type::float_type), \
910 _##NAME(always_available, glsl_type::vec2_type), \
911 _##NAME(always_available, glsl_type::vec3_type), \
912 _##NAME(always_available, glsl_type::vec4_type), \
913 _##NAME(fp64, glsl_type::double_type), \
914 _##NAME(fp64, glsl_type::dvec2_type), \
915 _##NAME(fp64, glsl_type::dvec3_type), \
916 _##NAME(fp64, glsl_type::dvec4_type), \
919 #define FD130(NAME) \
920 add_function(#NAME, \
921 _##NAME(v130, glsl_type::float_type), \
922 _##NAME(v130, glsl_type::vec2_type), \
923 _##NAME(v130, glsl_type::vec3_type), \
924 _##NAME(v130, glsl_type::vec4_type), \
925 _##NAME(fp64, glsl_type::double_type), \
926 _##NAME(fp64, glsl_type::dvec2_type), \
927 _##NAME(fp64, glsl_type::dvec3_type), \
928 _##NAME(fp64, glsl_type::dvec4_type), \
931 #define FDGS5(NAME) \
932 add_function(#NAME, \
933 _##NAME(gpu_shader5, glsl_type::float_type), \
934 _##NAME(gpu_shader5, glsl_type::vec2_type), \
935 _##NAME(gpu_shader5, glsl_type::vec3_type), \
936 _##NAME(gpu_shader5, glsl_type::vec4_type), \
937 _##NAME(fp64, glsl_type::double_type), \
938 _##NAME(fp64, glsl_type::dvec2_type), \
939 _##NAME(fp64, glsl_type::dvec3_type), \
940 _##NAME(fp64, glsl_type::dvec4_type), \
944 add_function(#NAME, \
945 _##NAME(glsl_type::float_type), \
946 _##NAME(glsl_type::vec2_type), \
947 _##NAME(glsl_type::vec3_type), \
948 _##NAME(glsl_type::vec4_type), \
949 _##NAME(glsl_type::int_type), \
950 _##NAME(glsl_type::ivec2_type), \
951 _##NAME(glsl_type::ivec3_type), \
952 _##NAME(glsl_type::ivec4_type), \
956 add_function(#NAME, \
957 _##NAME(always_available, glsl_type::float_type), \
958 _##NAME(always_available, glsl_type::vec2_type), \
959 _##NAME(always_available, glsl_type::vec3_type), \
960 _##NAME(always_available, glsl_type::vec4_type), \
961 _##NAME(always_available, glsl_type::int_type), \
962 _##NAME(always_available, glsl_type::ivec2_type), \
963 _##NAME(always_available, glsl_type::ivec3_type), \
964 _##NAME(always_available, glsl_type::ivec4_type), \
965 _##NAME(fp64, glsl_type::double_type), \
966 _##NAME(fp64, glsl_type::dvec2_type), \
967 _##NAME(fp64, glsl_type::dvec3_type), \
968 _##NAME(fp64, glsl_type::dvec4_type), \
972 add_function(#NAME, \
973 _##NAME(always_available, glsl_type::float_type), \
974 _##NAME(always_available, glsl_type::vec2_type), \
975 _##NAME(always_available, glsl_type::vec3_type), \
976 _##NAME(always_available, glsl_type::vec4_type), \
978 _##NAME(always_available, glsl_type::int_type), \
979 _##NAME(always_available, glsl_type::ivec2_type), \
980 _##NAME(always_available, glsl_type::ivec3_type), \
981 _##NAME(always_available, glsl_type::ivec4_type), \
983 _##NAME(v130, glsl_type::uint_type), \
984 _##NAME(v130, glsl_type::uvec2_type), \
985 _##NAME(v130, glsl_type::uvec3_type), \
986 _##NAME(v130, glsl_type::uvec4_type), \
987 _##NAME(fp64, glsl_type::double_type), \
988 _##NAME(fp64, glsl_type::dvec2_type), \
989 _##NAME(fp64, glsl_type::dvec3_type), \
990 _##NAME(fp64, glsl_type::dvec4_type), \
994 add_function(#NAME, \
995 _##NAME(glsl_type::int_type), \
996 _##NAME(glsl_type::ivec2_type), \
997 _##NAME(glsl_type::ivec3_type), \
998 _##NAME(glsl_type::ivec4_type), \
1000 _##NAME(glsl_type::uint_type), \
1001 _##NAME(glsl_type::uvec2_type), \
1002 _##NAME(glsl_type::uvec3_type), \
1003 _##NAME(glsl_type::uvec4_type), \
1006 #define FIUBD(NAME) \
1007 add_function(#NAME, \
1008 _##NAME(always_available, glsl_type::float_type), \
1009 _##NAME(always_available, glsl_type::vec2_type), \
1010 _##NAME(always_available, glsl_type::vec3_type), \
1011 _##NAME(always_available, glsl_type::vec4_type), \
1013 _##NAME(always_available, glsl_type::int_type), \
1014 _##NAME(always_available, glsl_type::ivec2_type), \
1015 _##NAME(always_available, glsl_type::ivec3_type), \
1016 _##NAME(always_available, glsl_type::ivec4_type), \
1018 _##NAME(v130, glsl_type::uint_type), \
1019 _##NAME(v130, glsl_type::uvec2_type), \
1020 _##NAME(v130, glsl_type::uvec3_type), \
1021 _##NAME(v130, glsl_type::uvec4_type), \
1023 _##NAME(always_available, glsl_type::bool_type), \
1024 _##NAME(always_available, glsl_type::bvec2_type), \
1025 _##NAME(always_available, glsl_type::bvec3_type), \
1026 _##NAME(always_available, glsl_type::bvec4_type), \
1028 _##NAME(fp64, glsl_type::double_type), \
1029 _##NAME(fp64, glsl_type::dvec2_type), \
1030 _##NAME(fp64, glsl_type::dvec3_type), \
1031 _##NAME(fp64, glsl_type::dvec4_type), \
1034 #define FIUD2_MIXED(NAME) \
1035 add_function(#NAME, \
1036 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1037 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1038 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1039 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1041 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1042 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1043 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1045 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1046 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1047 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1048 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1050 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1051 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1052 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1054 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1055 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1056 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1057 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1059 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1060 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1061 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1063 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1064 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1065 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1066 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1067 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1068 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1069 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1080 add_function("atan",
1081 _atan(glsl_type::float_type
),
1082 _atan(glsl_type::vec2_type
),
1083 _atan(glsl_type::vec3_type
),
1084 _atan(glsl_type::vec4_type
),
1085 _atan2(glsl_type::float_type
),
1086 _atan2(glsl_type::vec2_type
),
1087 _atan2(glsl_type::vec3_type
),
1088 _atan2(glsl_type::vec4_type
),
1114 _mod(glsl_type::float_type
, glsl_type::float_type
),
1115 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1116 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1117 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1119 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1120 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1121 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1123 _mod(glsl_type::double_type
, glsl_type::double_type
),
1124 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1125 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1126 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1128 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1129 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1130 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1140 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1141 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1142 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1143 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1145 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1146 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1147 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1149 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1150 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1151 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1152 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1154 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1155 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1156 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1158 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1159 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1160 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1161 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1163 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1164 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1165 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1166 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1168 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1169 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1170 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1171 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1173 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1174 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1175 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1176 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1178 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1179 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1180 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1181 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1184 add_function("step",
1185 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1186 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1187 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1188 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1190 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1191 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1192 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1193 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1194 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1195 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1196 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1198 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1199 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1200 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1203 add_function("smoothstep",
1204 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1205 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1206 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1207 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1209 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1210 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1211 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1212 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1213 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1214 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1215 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1217 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1218 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1219 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1227 add_function("intBitsToFloat",
1228 _intBitsToFloat(glsl_type::int_type
),
1229 _intBitsToFloat(glsl_type::ivec2_type
),
1230 _intBitsToFloat(glsl_type::ivec3_type
),
1231 _intBitsToFloat(glsl_type::ivec4_type
),
1233 add_function("uintBitsToFloat",
1234 _uintBitsToFloat(glsl_type::uint_type
),
1235 _uintBitsToFloat(glsl_type::uvec2_type
),
1236 _uintBitsToFloat(glsl_type::uvec3_type
),
1237 _uintBitsToFloat(glsl_type::uvec4_type
),
1240 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1241 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1242 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1243 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1244 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1245 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1246 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1247 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1248 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1249 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1250 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1251 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1258 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1259 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1262 add_function("ftransform", _ftransform(), NULL
);
1267 add_function("matrixCompMult",
1268 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1269 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1270 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1271 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1272 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1273 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1274 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1275 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1276 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1277 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1278 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1279 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1280 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1281 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1282 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1283 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1284 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1285 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1287 add_function("outerProduct",
1288 _outerProduct(v120
, glsl_type::mat2_type
),
1289 _outerProduct(v120
, glsl_type::mat3_type
),
1290 _outerProduct(v120
, glsl_type::mat4_type
),
1291 _outerProduct(v120
, glsl_type::mat2x3_type
),
1292 _outerProduct(v120
, glsl_type::mat2x4_type
),
1293 _outerProduct(v120
, glsl_type::mat3x2_type
),
1294 _outerProduct(v120
, glsl_type::mat3x4_type
),
1295 _outerProduct(v120
, glsl_type::mat4x2_type
),
1296 _outerProduct(v120
, glsl_type::mat4x3_type
),
1297 _outerProduct(fp64
, glsl_type::dmat2_type
),
1298 _outerProduct(fp64
, glsl_type::dmat3_type
),
1299 _outerProduct(fp64
, glsl_type::dmat4_type
),
1300 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1301 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1302 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1303 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1304 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1305 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1307 add_function("determinant",
1308 _determinant_mat2(v120
, glsl_type::mat2_type
),
1309 _determinant_mat3(v120
, glsl_type::mat3_type
),
1310 _determinant_mat4(v120
, glsl_type::mat4_type
),
1311 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1312 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1313 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1316 add_function("inverse",
1317 _inverse_mat2(v120
, glsl_type::mat2_type
),
1318 _inverse_mat3(v120
, glsl_type::mat3_type
),
1319 _inverse_mat4(v120
, glsl_type::mat4_type
),
1320 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1321 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1322 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1324 add_function("transpose",
1325 _transpose(v120
, glsl_type::mat2_type
),
1326 _transpose(v120
, glsl_type::mat3_type
),
1327 _transpose(v120
, glsl_type::mat4_type
),
1328 _transpose(v120
, glsl_type::mat2x3_type
),
1329 _transpose(v120
, glsl_type::mat2x4_type
),
1330 _transpose(v120
, glsl_type::mat3x2_type
),
1331 _transpose(v120
, glsl_type::mat3x4_type
),
1332 _transpose(v120
, glsl_type::mat4x2_type
),
1333 _transpose(v120
, glsl_type::mat4x3_type
),
1334 _transpose(fp64
, glsl_type::dmat2_type
),
1335 _transpose(fp64
, glsl_type::dmat3_type
),
1336 _transpose(fp64
, glsl_type::dmat4_type
),
1337 _transpose(fp64
, glsl_type::dmat2x3_type
),
1338 _transpose(fp64
, glsl_type::dmat2x4_type
),
1339 _transpose(fp64
, glsl_type::dmat3x2_type
),
1340 _transpose(fp64
, glsl_type::dmat3x4_type
),
1341 _transpose(fp64
, glsl_type::dmat4x2_type
),
1342 _transpose(fp64
, glsl_type::dmat4x3_type
),
1347 FIUD(greaterThanEqual
)
1352 _any(glsl_type::bvec2_type
),
1353 _any(glsl_type::bvec3_type
),
1354 _any(glsl_type::bvec4_type
),
1358 _all(glsl_type::bvec2_type
),
1359 _all(glsl_type::bvec3_type
),
1360 _all(glsl_type::bvec4_type
),
1364 _not(glsl_type::bvec2_type
),
1365 _not(glsl_type::bvec3_type
),
1366 _not(glsl_type::bvec4_type
),
1369 add_function("textureSize",
1370 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1371 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1372 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1374 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1375 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1376 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1378 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1379 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1380 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1382 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1383 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1384 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1386 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1387 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1388 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1390 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1391 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1392 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1393 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1394 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1395 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1397 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1398 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1400 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1401 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1402 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1403 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1405 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1406 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1407 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1408 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1410 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1411 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1412 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1413 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1414 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1415 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1417 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1418 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1419 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1422 add_function("textureSamples",
1423 _textureSamples(glsl_type::sampler2DMS_type
),
1424 _textureSamples(glsl_type::isampler2DMS_type
),
1425 _textureSamples(glsl_type::usampler2DMS_type
),
1427 _textureSamples(glsl_type::sampler2DMSArray_type
),
1428 _textureSamples(glsl_type::isampler2DMSArray_type
),
1429 _textureSamples(glsl_type::usampler2DMSArray_type
),
1432 add_function("texture",
1433 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1434 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1435 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1437 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1438 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1439 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1441 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1442 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1443 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1445 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1446 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1447 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1449 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1450 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1451 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1453 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1454 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1455 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1457 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1458 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1459 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1461 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1462 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1463 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1465 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1466 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1467 /* samplerCubeArrayShadow is special; it has an extra parameter
1468 * for the shadow comparitor since there is no vec5 type.
1470 _textureCubeArrayShadow(),
1472 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1473 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1474 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1476 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1478 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1479 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1480 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1482 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1483 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1484 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1486 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1487 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1488 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1490 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1491 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1492 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1494 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1495 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1496 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1498 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1499 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1500 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1502 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1503 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1504 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1506 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1507 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1508 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1510 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1513 add_function("textureLod",
1514 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1515 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1516 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1518 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1519 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1520 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1522 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1523 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1524 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1526 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1527 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1528 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1530 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1531 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1533 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1534 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1535 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1537 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1538 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1539 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1541 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1542 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1543 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1545 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1548 add_function("textureOffset",
1549 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1550 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1551 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1553 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1554 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1555 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1557 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1558 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1559 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1561 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1562 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1563 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1565 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1567 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1568 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1570 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1571 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1572 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1574 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1575 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1576 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1578 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1580 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1581 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1582 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1584 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1585 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1586 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1588 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1589 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1590 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1592 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1593 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1595 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1596 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1597 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1599 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1600 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1601 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1603 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1606 add_function("textureProj",
1607 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1608 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1609 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1610 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1611 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1612 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1614 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1615 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1616 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1617 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1618 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1619 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1621 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1622 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1623 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1625 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1626 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1628 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1629 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1630 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1631 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1632 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1633 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1635 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1637 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1638 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1639 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1640 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1641 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1642 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1644 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1645 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1646 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1647 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1648 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1649 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1651 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1652 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1653 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1655 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1656 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1659 add_function("texelFetch",
1660 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1661 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1662 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1664 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1665 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1666 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1668 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1669 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1670 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1672 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1673 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1674 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1676 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1677 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1678 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1680 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1681 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1682 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1684 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1685 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1686 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1688 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1689 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1690 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1692 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1693 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1694 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1697 add_function("texelFetchOffset",
1698 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1699 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1700 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1702 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1703 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1704 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1706 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1707 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1708 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1710 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1711 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1712 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1714 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1715 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1716 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1718 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1719 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1720 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1724 add_function("textureProjOffset",
1725 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1726 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1727 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1728 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1729 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1730 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1732 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1733 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1734 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1735 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1736 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1737 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1739 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1740 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1741 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1743 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1744 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1746 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1747 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1748 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1749 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1750 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1751 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1753 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1755 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1756 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1757 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1758 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1759 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1760 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1762 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1763 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1764 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1765 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1766 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1767 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1769 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1770 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1771 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1773 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1774 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1777 add_function("textureLodOffset",
1778 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1779 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1780 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1782 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1783 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1784 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1786 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1787 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1788 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1790 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1791 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1793 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1794 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1795 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1797 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1798 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1799 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1801 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1804 add_function("textureProjLod",
1805 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1806 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1807 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1808 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1809 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1810 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1812 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1813 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1814 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1815 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1816 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1817 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1819 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1820 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1821 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1823 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1824 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1827 add_function("textureProjLodOffset",
1828 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1829 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1830 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1831 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1832 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1833 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1835 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1836 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1837 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1838 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1839 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1840 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1842 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1843 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1844 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1846 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1847 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1850 add_function("textureGrad",
1851 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1852 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1853 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1855 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1856 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1857 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1859 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1860 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1861 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1863 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1864 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1865 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1867 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1868 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1869 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1871 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1873 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1874 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1875 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1877 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1878 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1879 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1881 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1882 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1883 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1885 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1886 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1887 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1889 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1890 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1893 add_function("textureGradOffset",
1894 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1895 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1896 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1898 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1899 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1900 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1902 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1903 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1904 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1906 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1907 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1908 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1910 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1912 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1913 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1915 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1916 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1917 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1919 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1920 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1921 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1923 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1924 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1927 add_function("textureProjGrad",
1928 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1929 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1930 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1931 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1932 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1933 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1935 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1936 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1937 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1938 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1939 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1940 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1942 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1943 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1944 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1946 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1947 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1948 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1949 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1950 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1951 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1953 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1955 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1956 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1959 add_function("textureProjGradOffset",
1960 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1962 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1963 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1965 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1967 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1969 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1971 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1972 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1974 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1975 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1976 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1978 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1979 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1980 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1981 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1982 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1983 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1985 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1987 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1988 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1991 add_function("EmitVertex", _EmitVertex(), NULL
);
1992 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1993 add_function("EmitStreamVertex",
1994 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1995 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1997 add_function("EndStreamPrimitive",
1998 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1999 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2001 add_function("barrier", _barrier(), NULL
);
2003 add_function("textureQueryLOD",
2004 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2005 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2006 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2008 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2009 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2010 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2012 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2013 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2014 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2016 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2017 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2018 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2020 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2021 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2022 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2024 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2025 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2026 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2028 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2029 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2030 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2032 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2033 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2034 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2035 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2036 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2037 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2040 add_function("textureQueryLod",
2041 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2042 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2043 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2045 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2046 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2047 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2049 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2050 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2051 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2053 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2054 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2055 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2057 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2058 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2059 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2061 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2062 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2063 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2065 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2066 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2067 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2069 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2070 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2071 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2072 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2073 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2074 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2077 add_function("textureQueryLevels",
2078 _textureQueryLevels(glsl_type::sampler1D_type
),
2079 _textureQueryLevels(glsl_type::sampler2D_type
),
2080 _textureQueryLevels(glsl_type::sampler3D_type
),
2081 _textureQueryLevels(glsl_type::samplerCube_type
),
2082 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2083 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2084 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2085 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2086 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2087 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2088 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2089 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2090 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2092 _textureQueryLevels(glsl_type::isampler1D_type
),
2093 _textureQueryLevels(glsl_type::isampler2D_type
),
2094 _textureQueryLevels(glsl_type::isampler3D_type
),
2095 _textureQueryLevels(glsl_type::isamplerCube_type
),
2096 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2097 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2098 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2100 _textureQueryLevels(glsl_type::usampler1D_type
),
2101 _textureQueryLevels(glsl_type::usampler2D_type
),
2102 _textureQueryLevels(glsl_type::usampler3D_type
),
2103 _textureQueryLevels(glsl_type::usamplerCube_type
),
2104 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2105 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2106 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2110 add_function("texture1D",
2111 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2112 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2115 add_function("texture1DArray",
2116 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2117 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2120 add_function("texture1DProj",
2121 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2122 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2123 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2124 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2127 add_function("texture1DLod",
2128 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2131 add_function("texture1DArrayLod",
2132 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2135 add_function("texture1DProjLod",
2136 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2137 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2140 add_function("texture2D",
2141 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2142 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2143 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2146 add_function("texture2DArray",
2147 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2148 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2151 add_function("texture2DProj",
2152 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2153 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2154 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2155 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2156 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2157 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2160 add_function("texture2DLod",
2161 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2164 add_function("texture2DArrayLod",
2165 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2168 add_function("texture2DProjLod",
2169 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2170 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2173 add_function("texture3D",
2174 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2175 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2178 add_function("texture3DProj",
2179 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2180 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2183 add_function("texture3DLod",
2184 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2187 add_function("texture3DProjLod",
2188 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2191 add_function("textureCube",
2192 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2193 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2196 add_function("textureCubeLod",
2197 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2200 add_function("texture2DRect",
2201 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2204 add_function("texture2DRectProj",
2205 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2206 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2209 add_function("shadow1D",
2210 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2211 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2214 add_function("shadow1DArray",
2215 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2216 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2219 add_function("shadow2D",
2220 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2221 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2224 add_function("shadow2DArray",
2225 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2226 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2229 add_function("shadow1DProj",
2230 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2231 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2234 add_function("shadow2DProj",
2235 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2236 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2239 add_function("shadow1DLod",
2240 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2243 add_function("shadow2DLod",
2244 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2247 add_function("shadow1DArrayLod",
2248 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2251 add_function("shadow1DProjLod",
2252 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2255 add_function("shadow2DProjLod",
2256 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2259 add_function("shadow2DRect",
2260 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2263 add_function("shadow2DRectProj",
2264 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2267 add_function("texture1DGradARB",
2268 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2271 add_function("texture1DProjGradARB",
2272 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2273 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2276 add_function("texture2DGradARB",
2277 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2280 add_function("texture2DProjGradARB",
2281 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2282 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2285 add_function("texture3DGradARB",
2286 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2289 add_function("texture3DProjGradARB",
2290 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2293 add_function("textureCubeGradARB",
2294 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2297 add_function("shadow1DGradARB",
2298 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2301 add_function("shadow1DProjGradARB",
2302 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2305 add_function("shadow2DGradARB",
2306 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2309 add_function("shadow2DProjGradARB",
2310 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2313 add_function("texture2DRectGradARB",
2314 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2317 add_function("texture2DRectProjGradARB",
2318 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2319 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2322 add_function("shadow2DRectGradARB",
2323 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2326 add_function("shadow2DRectProjGradARB",
2327 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2330 add_function("textureGather",
2331 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2332 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2333 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2335 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2336 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2337 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2339 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2340 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2341 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2343 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2344 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2345 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2347 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2348 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2349 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2351 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2352 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2353 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2355 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2356 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2357 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2359 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2360 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2361 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2363 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2364 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2365 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2367 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2368 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2369 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2371 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2372 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2373 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2374 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2375 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2378 add_function("textureGatherOffset",
2379 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2380 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2381 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2383 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2384 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2385 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2387 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2388 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2389 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2391 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2392 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2393 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2395 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2396 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2397 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2399 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2400 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2401 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2403 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2404 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2405 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2407 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2408 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2409 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2411 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2412 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2413 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2415 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2416 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2417 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2419 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2420 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2421 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2423 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2424 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2427 add_function("textureGatherOffsets",
2428 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2429 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2430 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2432 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2433 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2434 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2436 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2437 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2438 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2440 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2441 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2442 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2444 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2445 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2446 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2448 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2449 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2450 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2452 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2453 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2454 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2479 add_function("ldexp",
2480 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2481 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2482 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2483 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2484 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2485 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2486 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2487 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2490 add_function("frexp",
2491 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2492 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2493 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2494 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2495 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2496 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2497 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2498 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2500 add_function("uaddCarry",
2501 _uaddCarry(glsl_type::uint_type
),
2502 _uaddCarry(glsl_type::uvec2_type
),
2503 _uaddCarry(glsl_type::uvec3_type
),
2504 _uaddCarry(glsl_type::uvec4_type
),
2506 add_function("usubBorrow",
2507 _usubBorrow(glsl_type::uint_type
),
2508 _usubBorrow(glsl_type::uvec2_type
),
2509 _usubBorrow(glsl_type::uvec3_type
),
2510 _usubBorrow(glsl_type::uvec4_type
),
2512 add_function("imulExtended",
2513 _mulExtended(glsl_type::int_type
),
2514 _mulExtended(glsl_type::ivec2_type
),
2515 _mulExtended(glsl_type::ivec3_type
),
2516 _mulExtended(glsl_type::ivec4_type
),
2518 add_function("umulExtended",
2519 _mulExtended(glsl_type::uint_type
),
2520 _mulExtended(glsl_type::uvec2_type
),
2521 _mulExtended(glsl_type::uvec3_type
),
2522 _mulExtended(glsl_type::uvec4_type
),
2524 add_function("interpolateAtCentroid",
2525 _interpolateAtCentroid(glsl_type::float_type
),
2526 _interpolateAtCentroid(glsl_type::vec2_type
),
2527 _interpolateAtCentroid(glsl_type::vec3_type
),
2528 _interpolateAtCentroid(glsl_type::vec4_type
),
2530 add_function("interpolateAtOffset",
2531 _interpolateAtOffset(glsl_type::float_type
),
2532 _interpolateAtOffset(glsl_type::vec2_type
),
2533 _interpolateAtOffset(glsl_type::vec3_type
),
2534 _interpolateAtOffset(glsl_type::vec4_type
),
2536 add_function("interpolateAtSample",
2537 _interpolateAtSample(glsl_type::float_type
),
2538 _interpolateAtSample(glsl_type::vec2_type
),
2539 _interpolateAtSample(glsl_type::vec3_type
),
2540 _interpolateAtSample(glsl_type::vec4_type
),
2543 add_function("atomicCounter",
2544 _atomic_counter_op("__intrinsic_atomic_read",
2545 shader_atomic_counters
),
2547 add_function("atomicCounterIncrement",
2548 _atomic_counter_op("__intrinsic_atomic_increment",
2549 shader_atomic_counters
),
2551 add_function("atomicCounterDecrement",
2552 _atomic_counter_op("__intrinsic_atomic_predecrement",
2553 shader_atomic_counters
),
2556 add_function("min3",
2557 _min3(glsl_type::float_type
),
2558 _min3(glsl_type::vec2_type
),
2559 _min3(glsl_type::vec3_type
),
2560 _min3(glsl_type::vec4_type
),
2562 _min3(glsl_type::int_type
),
2563 _min3(glsl_type::ivec2_type
),
2564 _min3(glsl_type::ivec3_type
),
2565 _min3(glsl_type::ivec4_type
),
2567 _min3(glsl_type::uint_type
),
2568 _min3(glsl_type::uvec2_type
),
2569 _min3(glsl_type::uvec3_type
),
2570 _min3(glsl_type::uvec4_type
),
2573 add_function("max3",
2574 _max3(glsl_type::float_type
),
2575 _max3(glsl_type::vec2_type
),
2576 _max3(glsl_type::vec3_type
),
2577 _max3(glsl_type::vec4_type
),
2579 _max3(glsl_type::int_type
),
2580 _max3(glsl_type::ivec2_type
),
2581 _max3(glsl_type::ivec3_type
),
2582 _max3(glsl_type::ivec4_type
),
2584 _max3(glsl_type::uint_type
),
2585 _max3(glsl_type::uvec2_type
),
2586 _max3(glsl_type::uvec3_type
),
2587 _max3(glsl_type::uvec4_type
),
2590 add_function("mid3",
2591 _mid3(glsl_type::float_type
),
2592 _mid3(glsl_type::vec2_type
),
2593 _mid3(glsl_type::vec3_type
),
2594 _mid3(glsl_type::vec4_type
),
2596 _mid3(glsl_type::int_type
),
2597 _mid3(glsl_type::ivec2_type
),
2598 _mid3(glsl_type::ivec3_type
),
2599 _mid3(glsl_type::ivec4_type
),
2601 _mid3(glsl_type::uint_type
),
2602 _mid3(glsl_type::uvec2_type
),
2603 _mid3(glsl_type::uvec3_type
),
2604 _mid3(glsl_type::uvec4_type
),
2607 add_image_functions(true);
2609 add_function("memoryBarrier",
2610 _memory_barrier(shader_image_load_store
),
2621 builtin_builder::add_function(const char *name
, ...)
2625 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2629 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2635 stuff
.push_tail(sig
);
2636 validate_ir_tree(&stuff
);
2639 f
->add_signature(sig
);
2643 shader
->symbols
->add_function(f
);
2647 builtin_builder::add_image_function(const char *name
,
2648 const char *intrinsic_name
,
2649 image_prototype_ctr prototype
,
2650 unsigned num_arguments
,
2653 static const glsl_type
*const types
[] = {
2654 glsl_type::image1D_type
,
2655 glsl_type::image2D_type
,
2656 glsl_type::image3D_type
,
2657 glsl_type::image2DRect_type
,
2658 glsl_type::imageCube_type
,
2659 glsl_type::imageBuffer_type
,
2660 glsl_type::image1DArray_type
,
2661 glsl_type::image2DArray_type
,
2662 glsl_type::imageCubeArray_type
,
2663 glsl_type::image2DMS_type
,
2664 glsl_type::image2DMSArray_type
,
2665 glsl_type::iimage1D_type
,
2666 glsl_type::iimage2D_type
,
2667 glsl_type::iimage3D_type
,
2668 glsl_type::iimage2DRect_type
,
2669 glsl_type::iimageCube_type
,
2670 glsl_type::iimageBuffer_type
,
2671 glsl_type::iimage1DArray_type
,
2672 glsl_type::iimage2DArray_type
,
2673 glsl_type::iimageCubeArray_type
,
2674 glsl_type::iimage2DMS_type
,
2675 glsl_type::iimage2DMSArray_type
,
2676 glsl_type::uimage1D_type
,
2677 glsl_type::uimage2D_type
,
2678 glsl_type::uimage3D_type
,
2679 glsl_type::uimage2DRect_type
,
2680 glsl_type::uimageCube_type
,
2681 glsl_type::uimageBuffer_type
,
2682 glsl_type::uimage1DArray_type
,
2683 glsl_type::uimage2DArray_type
,
2684 glsl_type::uimageCubeArray_type
,
2685 glsl_type::uimage2DMS_type
,
2686 glsl_type::uimage2DMSArray_type
2689 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2691 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2692 if ((types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2693 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2694 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2695 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2696 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2697 num_arguments
, flags
));
2700 shader
->symbols
->add_function(f
);
2704 builtin_builder::add_image_functions(bool glsl
)
2706 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2708 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2709 "__intrinsic_image_load",
2710 &builtin_builder::_image_prototype
, 0,
2711 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2712 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2713 IMAGE_FUNCTION_READ_ONLY
));
2715 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2716 "__intrinsic_image_store",
2717 &builtin_builder::_image_prototype
, 1,
2718 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2719 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2720 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2721 IMAGE_FUNCTION_WRITE_ONLY
));
2723 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2725 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2726 "__intrinsic_image_atomic_add",
2727 &builtin_builder::_image_prototype
, 1, atom_flags
);
2729 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2730 "__intrinsic_image_atomic_min",
2731 &builtin_builder::_image_prototype
, 1, atom_flags
);
2733 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2734 "__intrinsic_image_atomic_max",
2735 &builtin_builder::_image_prototype
, 1, atom_flags
);
2737 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2738 "__intrinsic_image_atomic_and",
2739 &builtin_builder::_image_prototype
, 1, atom_flags
);
2741 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2742 "__intrinsic_image_atomic_or",
2743 &builtin_builder::_image_prototype
, 1, atom_flags
);
2745 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2746 "__intrinsic_image_atomic_xor",
2747 &builtin_builder::_image_prototype
, 1, atom_flags
);
2749 add_image_function((glsl
? "imageAtomicExchange" :
2750 "__intrinsic_image_atomic_exchange"),
2751 "__intrinsic_image_atomic_exchange",
2752 &builtin_builder::_image_prototype
, 1, atom_flags
);
2754 add_image_function((glsl
? "imageAtomicCompSwap" :
2755 "__intrinsic_image_atomic_comp_swap"),
2756 "__intrinsic_image_atomic_comp_swap",
2757 &builtin_builder::_image_prototype
, 2, atom_flags
);
2759 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2760 "__intrinsic_image_size",
2761 &builtin_builder::_image_size_prototype
, 1,
2762 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2764 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
2765 "__intrinsic_image_samples",
2766 &builtin_builder::_image_samples_prototype
, 1,
2767 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2768 IMAGE_FUNCTION_MS_ONLY
);
2772 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2774 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2778 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2780 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2784 builtin_builder::imm(float f
, unsigned vector_elements
)
2786 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2790 builtin_builder::imm(int i
, unsigned vector_elements
)
2792 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2796 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2798 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2802 builtin_builder::imm(double d
, unsigned vector_elements
)
2804 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2808 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2810 return new(mem_ctx
) ir_constant(type
, &data
);
2813 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2815 ir_dereference_variable
*
2816 builtin_builder::var_ref(ir_variable
*var
)
2818 return new(mem_ctx
) ir_dereference_variable(var
);
2821 ir_dereference_array
*
2822 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2824 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2827 /** Return an element of a matrix */
2829 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2831 return swizzle(array_ref(var
, column
), row
, 1);
2835 * Implementations of built-in functions:
2838 ir_function_signature
*
2839 builtin_builder::new_sig(const glsl_type
*return_type
,
2840 builtin_available_predicate avail
,
2846 ir_function_signature
*sig
=
2847 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2850 va_start(ap
, num_params
);
2851 for (int i
= 0; i
< num_params
; i
++) {
2852 plist
.push_tail(va_arg(ap
, ir_variable
*));
2856 sig
->replace_parameters(&plist
);
2860 #define MAKE_SIG(return_type, avail, ...) \
2861 ir_function_signature *sig = \
2862 new_sig(return_type, avail, __VA_ARGS__); \
2863 ir_factory body(&sig->body, mem_ctx); \
2864 sig->is_defined = true;
2866 #define MAKE_INTRINSIC(return_type, avail, ...) \
2867 ir_function_signature *sig = \
2868 new_sig(return_type, avail, __VA_ARGS__); \
2869 sig->is_intrinsic = true;
2871 ir_function_signature
*
2872 builtin_builder::unop(builtin_available_predicate avail
,
2873 ir_expression_operation opcode
,
2874 const glsl_type
*return_type
,
2875 const glsl_type
*param_type
)
2877 ir_variable
*x
= in_var(param_type
, "x");
2878 MAKE_SIG(return_type
, avail
, 1, x
);
2879 body
.emit(ret(expr(opcode
, x
)));
2883 #define UNOP(NAME, OPCODE, AVAIL) \
2884 ir_function_signature * \
2885 builtin_builder::_##NAME(const glsl_type *type) \
2887 return unop(&AVAIL, OPCODE, type, type); \
2890 #define UNOPA(NAME, OPCODE) \
2891 ir_function_signature * \
2892 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
2894 return unop(avail, OPCODE, type, type); \
2897 ir_function_signature
*
2898 builtin_builder::binop(ir_expression_operation opcode
,
2899 builtin_available_predicate avail
,
2900 const glsl_type
*return_type
,
2901 const glsl_type
*param0_type
,
2902 const glsl_type
*param1_type
)
2904 ir_variable
*x
= in_var(param0_type
, "x");
2905 ir_variable
*y
= in_var(param1_type
, "y");
2906 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2907 body
.emit(ret(expr(opcode
, x
, y
)));
2911 #define BINOP(NAME, OPCODE, AVAIL) \
2912 ir_function_signature * \
2913 builtin_builder::_##NAME(const glsl_type *return_type, \
2914 const glsl_type *param0_type, \
2915 const glsl_type *param1_type) \
2917 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2921 * Angle and Trigonometry Functions @{
2924 ir_function_signature
*
2925 builtin_builder::_radians(const glsl_type
*type
)
2927 ir_variable
*degrees
= in_var(type
, "degrees");
2928 MAKE_SIG(type
, always_available
, 1, degrees
);
2929 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2933 ir_function_signature
*
2934 builtin_builder::_degrees(const glsl_type
*type
)
2936 ir_variable
*radians
= in_var(type
, "radians");
2937 MAKE_SIG(type
, always_available
, 1, radians
);
2938 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2942 UNOP(sin
, ir_unop_sin
, always_available
)
2943 UNOP(cos
, ir_unop_cos
, always_available
)
2945 ir_function_signature
*
2946 builtin_builder::_tan(const glsl_type
*type
)
2948 ir_variable
*theta
= in_var(type
, "theta");
2949 MAKE_SIG(type
, always_available
, 1, theta
);
2950 body
.emit(ret(div(sin(theta
), cos(theta
))));
2955 builtin_builder::asin_expr(ir_variable
*x
)
2959 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2962 add(imm(M_PI_4f
- 1.0f
),
2964 add(imm(0.086566724f
),
2965 mul(abs(x
), imm(-0.03102955f
))))))))));
2969 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2971 exec_list actual_params
;
2973 foreach_in_list(ir_variable
, var
, ¶ms
) {
2974 actual_params
.push_tail(var_ref(var
));
2977 ir_function_signature
*sig
=
2978 f
->exact_matching_signature(NULL
, &actual_params
);
2982 ir_dereference_variable
*deref
=
2983 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2985 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2988 ir_function_signature
*
2989 builtin_builder::_asin(const glsl_type
*type
)
2991 ir_variable
*x
= in_var(type
, "x");
2992 MAKE_SIG(type
, always_available
, 1, x
);
2994 body
.emit(ret(asin_expr(x
)));
2999 ir_function_signature
*
3000 builtin_builder::_acos(const glsl_type
*type
)
3002 ir_variable
*x
= in_var(type
, "x");
3003 MAKE_SIG(type
, always_available
, 1, x
);
3005 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3010 ir_function_signature
*
3011 builtin_builder::_atan2(const glsl_type
*type
)
3013 ir_variable
*vec_y
= in_var(type
, "vec_y");
3014 ir_variable
*vec_x
= in_var(type
, "vec_x");
3015 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3017 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3018 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3019 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3020 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3021 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3022 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3023 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3025 /* If |x| >= 1.0e-8 * |y|: */
3027 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3029 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3031 /* Then...call atan(y/x) */
3032 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3034 /* ...and fix it up: */
3035 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3036 inner_if
->then_instructions
.push_tail(
3037 if_tree(gequal(y
, imm(0.0f
)),
3038 assign(r
, add(r
, imm(M_PIf
))),
3039 assign(r
, sub(r
, imm(M_PIf
)))));
3040 outer_then
.emit(inner_if
);
3043 outer_if
->else_instructions
.push_tail(
3044 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3046 body
.emit(outer_if
);
3048 body
.emit(assign(vec_result
, r
, 1 << i
));
3050 body
.emit(ret(vec_result
));
3056 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3059 * range-reduction, first step:
3061 * / y_over_x if |y_over_x| <= 1.0;
3063 * \ 1.0 / y_over_x otherwise
3065 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3066 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3072 * approximate atan by evaluating polynomial:
3074 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3075 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3076 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3078 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3079 body
.emit(assign(tmp
, mul(x
, x
)));
3080 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3082 imm(0.0536813784310406f
)),
3084 imm(0.1173503194786851f
)),
3086 imm(0.1938924977115610f
)),
3088 imm(0.3326756418091246f
)),
3090 imm(0.9999793128310355f
)),
3093 /* range-reduction fixup */
3094 body
.emit(assign(tmp
, add(tmp
,
3095 mul(b2f(greater(abs(y_over_x
),
3096 imm(1.0f
, type
->components()))),
3102 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3105 ir_function_signature
*
3106 builtin_builder::_atan(const glsl_type
*type
)
3108 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3109 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3111 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3112 do_atan(body
, type
, tmp
, y_over_x
);
3113 body
.emit(ret(tmp
));
3118 ir_function_signature
*
3119 builtin_builder::_sinh(const glsl_type
*type
)
3121 ir_variable
*x
= in_var(type
, "x");
3122 MAKE_SIG(type
, v130
, 1, x
);
3124 /* 0.5 * (e^x - e^(-x)) */
3125 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3130 ir_function_signature
*
3131 builtin_builder::_cosh(const glsl_type
*type
)
3133 ir_variable
*x
= in_var(type
, "x");
3134 MAKE_SIG(type
, v130
, 1, x
);
3136 /* 0.5 * (e^x + e^(-x)) */
3137 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3142 ir_function_signature
*
3143 builtin_builder::_tanh(const glsl_type
*type
)
3145 ir_variable
*x
= in_var(type
, "x");
3146 MAKE_SIG(type
, v130
, 1, x
);
3148 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3149 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3150 add(exp(x
), exp(neg(x
))))));
3155 ir_function_signature
*
3156 builtin_builder::_asinh(const glsl_type
*type
)
3158 ir_variable
*x
= in_var(type
, "x");
3159 MAKE_SIG(type
, v130
, 1, x
);
3161 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3166 ir_function_signature
*
3167 builtin_builder::_acosh(const glsl_type
*type
)
3169 ir_variable
*x
= in_var(type
, "x");
3170 MAKE_SIG(type
, v130
, 1, x
);
3172 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3176 ir_function_signature
*
3177 builtin_builder::_atanh(const glsl_type
*type
)
3179 ir_variable
*x
= in_var(type
, "x");
3180 MAKE_SIG(type
, v130
, 1, x
);
3182 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3183 sub(imm(1.0f
), x
))))));
3189 * Exponential Functions @{
3192 ir_function_signature
*
3193 builtin_builder::_pow(const glsl_type
*type
)
3195 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3198 UNOP(exp
, ir_unop_exp
, always_available
)
3199 UNOP(log
, ir_unop_log
, always_available
)
3200 UNOP(exp2
, ir_unop_exp2
, always_available
)
3201 UNOP(log2
, ir_unop_log2
, always_available
)
3202 UNOPA(sqrt
, ir_unop_sqrt
)
3203 UNOPA(inversesqrt
, ir_unop_rsq
)
3207 UNOPA(abs
, ir_unop_abs
)
3208 UNOPA(sign
, ir_unop_sign
)
3209 UNOPA(floor
, ir_unop_floor
)
3210 UNOPA(trunc
, ir_unop_trunc
)
3211 UNOPA(round
, ir_unop_round_even
)
3212 UNOPA(roundEven
, ir_unop_round_even
)
3213 UNOPA(ceil
, ir_unop_ceil
)
3214 UNOPA(fract
, ir_unop_fract
)
3216 ir_function_signature
*
3217 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3219 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3222 ir_function_signature
*
3223 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3225 ir_variable
*x
= in_var(type
, "x");
3226 ir_variable
*i
= out_var(type
, "i");
3227 MAKE_SIG(type
, avail
, 2, x
, i
);
3229 ir_variable
*t
= body
.make_temp(type
, "t");
3230 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3231 body
.emit(assign(i
, t
));
3232 body
.emit(ret(sub(x
, t
)));
3237 ir_function_signature
*
3238 builtin_builder::_min(builtin_available_predicate avail
,
3239 const glsl_type
*x_type
, const glsl_type
*y_type
)
3241 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3244 ir_function_signature
*
3245 builtin_builder::_max(builtin_available_predicate avail
,
3246 const glsl_type
*x_type
, const glsl_type
*y_type
)
3248 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3251 ir_function_signature
*
3252 builtin_builder::_clamp(builtin_available_predicate avail
,
3253 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3255 ir_variable
*x
= in_var(val_type
, "x");
3256 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3257 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3258 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3260 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3265 ir_function_signature
*
3266 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3268 ir_variable
*x
= in_var(val_type
, "x");
3269 ir_variable
*y
= in_var(val_type
, "y");
3270 ir_variable
*a
= in_var(blend_type
, "a");
3271 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3273 body
.emit(ret(lrp(x
, y
, a
)));
3278 ir_function_signature
*
3279 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3280 const glsl_type
*val_type
,
3281 const glsl_type
*blend_type
)
3283 ir_variable
*x
= in_var(val_type
, "x");
3284 ir_variable
*y
= in_var(val_type
, "y");
3285 ir_variable
*a
= in_var(blend_type
, "a");
3286 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3288 /* csel matches the ternary operator in that a selector of true choses the
3289 * first argument. This differs from mix(x, y, false) which choses the
3290 * second argument (to remain consistent with the interpolating version of
3291 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3293 * To handle the behavior mismatch, reverse the x and y arguments.
3295 body
.emit(ret(csel(a
, y
, x
)));
3300 ir_function_signature
*
3301 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3303 ir_variable
*edge
= in_var(edge_type
, "edge");
3304 ir_variable
*x
= in_var(x_type
, "x");
3305 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3307 ir_variable
*t
= body
.make_temp(x_type
, "t");
3308 if (x_type
->vector_elements
== 1) {
3309 /* Both are floats */
3310 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3311 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3313 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3314 } else if (edge_type
->vector_elements
== 1) {
3315 /* x is a vector but edge is a float */
3316 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3317 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3318 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3320 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3323 /* Both are vectors */
3324 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3325 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3326 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3329 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3339 ir_function_signature
*
3340 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3342 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3343 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3344 ir_variable
*x
= in_var(x_type
, "x");
3345 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3347 /* From the GLSL 1.10 specification:
3350 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3351 * return t * t * (3 - 2 * t);
3354 ir_variable
*t
= body
.make_temp(x_type
, "t");
3355 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3356 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3358 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3363 ir_function_signature
*
3364 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3366 ir_variable
*x
= in_var(type
, "x");
3367 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3369 body
.emit(ret(nequal(x
, x
)));
3374 ir_function_signature
*
3375 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3377 ir_variable
*x
= in_var(type
, "x");
3378 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3380 ir_constant_data infinities
;
3381 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3382 infinities
.f
[i
] = INFINITY
;
3385 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3390 ir_function_signature
*
3391 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3393 ir_variable
*x
= in_var(type
, "x");
3394 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3395 body
.emit(ret(bitcast_f2i(x
)));
3399 ir_function_signature
*
3400 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3402 ir_variable
*x
= in_var(type
, "x");
3403 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3404 body
.emit(ret(bitcast_f2u(x
)));
3408 ir_function_signature
*
3409 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3411 ir_variable
*x
= in_var(type
, "x");
3412 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3413 body
.emit(ret(bitcast_i2f(x
)));
3417 ir_function_signature
*
3418 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3420 ir_variable
*x
= in_var(type
, "x");
3421 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3422 body
.emit(ret(bitcast_u2f(x
)));
3426 ir_function_signature
*
3427 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3429 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3430 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3431 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3435 ir_function_signature
*
3436 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3438 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3439 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3440 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3444 ir_function_signature
*
3445 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3447 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3448 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3449 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3453 ir_function_signature
*
3454 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3456 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3457 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3458 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3462 ir_function_signature
*
3463 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3465 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3466 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3467 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3471 ir_function_signature
*
3472 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3474 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3475 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3476 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3481 ir_function_signature
*
3482 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3484 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3485 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3486 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3490 ir_function_signature
*
3491 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3493 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3494 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3495 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3499 ir_function_signature
*
3500 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3502 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3503 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3504 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3508 ir_function_signature
*
3509 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3511 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3512 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3513 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3517 ir_function_signature
*
3518 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3520 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3521 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3522 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3526 ir_function_signature
*
3527 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3529 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3530 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3531 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3535 ir_function_signature
*
3536 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3538 ir_variable
*x
= in_var(type
, "x");
3539 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3541 body
.emit(ret(sqrt(dot(x
, x
))));
3546 ir_function_signature
*
3547 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3549 ir_variable
*p0
= in_var(type
, "p0");
3550 ir_variable
*p1
= in_var(type
, "p1");
3551 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3553 if (type
->vector_elements
== 1) {
3554 body
.emit(ret(abs(sub(p0
, p1
))));
3556 ir_variable
*p
= body
.make_temp(type
, "p");
3557 body
.emit(assign(p
, sub(p0
, p1
)));
3558 body
.emit(ret(sqrt(dot(p
, p
))));
3564 ir_function_signature
*
3565 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3567 if (type
->vector_elements
== 1)
3568 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3570 return binop(ir_binop_dot
, avail
,
3571 type
->get_base_type(), type
, type
);
3574 ir_function_signature
*
3575 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3577 ir_variable
*a
= in_var(type
, "a");
3578 ir_variable
*b
= in_var(type
, "b");
3579 MAKE_SIG(type
, avail
, 2, a
, b
);
3581 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3582 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3584 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3585 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3590 ir_function_signature
*
3591 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3593 ir_variable
*x
= in_var(type
, "x");
3594 MAKE_SIG(type
, avail
, 1, x
);
3596 if (type
->vector_elements
== 1) {
3597 body
.emit(ret(sign(x
)));
3599 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3605 ir_function_signature
*
3606 builtin_builder::_ftransform()
3608 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3610 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3611 glsl_type::vec4_type
,
3612 var_ref(gl_ModelViewProjectionMatrix
),
3613 var_ref(gl_Vertex
))));
3615 /* FINISHME: Once the ir_expression() constructor handles type inference
3616 * for matrix operations, we can simplify this to:
3618 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3623 ir_function_signature
*
3624 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3626 ir_variable
*N
= in_var(type
, "N");
3627 ir_variable
*I
= in_var(type
, "I");
3628 ir_variable
*Nref
= in_var(type
, "Nref");
3629 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3631 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3632 ret(N
), ret(neg(N
))));
3637 ir_function_signature
*
3638 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3640 ir_variable
*I
= in_var(type
, "I");
3641 ir_variable
*N
= in_var(type
, "N");
3642 MAKE_SIG(type
, avail
, 2, I
, N
);
3644 /* I - 2 * dot(N, I) * N */
3645 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3650 ir_function_signature
*
3651 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3653 ir_variable
*I
= in_var(type
, "I");
3654 ir_variable
*N
= in_var(type
, "N");
3655 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3656 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3658 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3659 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3661 /* From the GLSL 1.10 specification:
3662 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3664 * return genType(0.0)
3666 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3668 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3669 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3670 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3671 mul(n_dot_i
, n_dot_i
)))))));
3672 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3673 ret(ir_constant::zero(mem_ctx
, type
)),
3674 ret(sub(mul(eta
, I
),
3675 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3680 ir_function_signature
*
3681 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3683 ir_variable
*x
= in_var(type
, "x");
3684 ir_variable
*y
= in_var(type
, "y");
3685 MAKE_SIG(type
, avail
, 2, x
, y
);
3687 ir_variable
*z
= body
.make_temp(type
, "z");
3688 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3689 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3696 ir_function_signature
*
3697 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3702 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3703 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3704 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3706 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3707 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3709 MAKE_SIG(type
, avail
, 2, c
, r
);
3711 ir_variable
*m
= body
.make_temp(type
, "m");
3712 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3713 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3720 ir_function_signature
*
3721 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3723 const glsl_type
*transpose_type
=
3724 glsl_type::get_instance(orig_type
->base_type
,
3725 orig_type
->matrix_columns
,
3726 orig_type
->vector_elements
);
3728 ir_variable
*m
= in_var(orig_type
, "m");
3729 MAKE_SIG(transpose_type
, avail
, 1, m
);
3731 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3732 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3733 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3734 body
.emit(assign(array_ref(t
, j
),
3735 matrix_elt(m
, i
, j
),
3744 ir_function_signature
*
3745 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3747 ir_variable
*m
= in_var(type
, "m");
3748 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3750 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3751 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3756 ir_function_signature
*
3757 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3759 ir_variable
*m
= in_var(type
, "m");
3760 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3763 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3764 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3767 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3768 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3771 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3772 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3774 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3775 mul(matrix_elt(m
, 0, 1), f2
)),
3776 mul(matrix_elt(m
, 0, 2), f3
))));
3781 ir_function_signature
*
3782 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3784 ir_variable
*m
= in_var(type
, "m");
3785 const glsl_type
*btype
= type
->get_base_type();
3786 MAKE_SIG(btype
, avail
, 1, m
);
3788 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3789 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3790 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3791 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3792 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3793 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3794 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3795 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3796 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3797 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3798 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3799 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3800 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3801 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3802 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3803 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3804 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3805 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3806 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3808 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)))));
3809 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)))));
3810 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)))));
3811 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)))));
3812 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)))));
3813 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)))));
3814 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)))));
3815 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)))));
3816 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)))));
3817 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)))));
3818 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)))));
3819 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)))));
3820 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)))));
3821 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)))));
3822 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)))));
3823 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)))));
3824 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)))));
3825 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)))));
3826 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)))));
3828 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3830 body
.emit(assign(adj_0
,
3831 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3832 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3833 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3835 body
.emit(assign(adj_0
, neg(
3836 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3837 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3838 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3840 body
.emit(assign(adj_0
,
3841 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3842 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3843 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3845 body
.emit(assign(adj_0
, neg(
3846 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3847 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3848 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3851 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3856 ir_function_signature
*
3857 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3859 ir_variable
*m
= in_var(type
, "m");
3860 MAKE_SIG(type
, avail
, 1, m
);
3862 ir_variable
*adj
= body
.make_temp(type
, "adj");
3863 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3864 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3865 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3866 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3868 ir_expression
*det
=
3869 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3870 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3872 body
.emit(ret(div(adj
, det
)));
3876 ir_function_signature
*
3877 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3879 ir_variable
*m
= in_var(type
, "m");
3880 const glsl_type
*btype
= type
->get_base_type();
3881 MAKE_SIG(type
, avail
, 1, m
);
3883 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
3884 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
3885 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
3887 body
.emit(assign(f11_22_21_12
,
3888 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3889 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3890 body
.emit(assign(f10_22_20_12
,
3891 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3892 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3893 body
.emit(assign(f10_21_20_11
,
3894 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3895 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3897 ir_variable
*adj
= body
.make_temp(type
, "adj");
3898 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3899 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3900 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3902 body
.emit(assign(array_ref(adj
, 0), neg(
3903 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3904 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3906 body
.emit(assign(array_ref(adj
, 1),
3907 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3908 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3910 body
.emit(assign(array_ref(adj
, 2), neg(
3911 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3912 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3915 body
.emit(assign(array_ref(adj
, 0),
3916 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3917 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3919 body
.emit(assign(array_ref(adj
, 1), neg(
3920 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3921 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3923 body
.emit(assign(array_ref(adj
, 2),
3924 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3925 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3928 ir_expression
*det
=
3929 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3930 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3931 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3933 body
.emit(ret(div(adj
, det
)));
3938 ir_function_signature
*
3939 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3941 ir_variable
*m
= in_var(type
, "m");
3942 const glsl_type
*btype
= type
->get_base_type();
3943 MAKE_SIG(type
, avail
, 1, m
);
3945 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3946 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3947 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3948 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3949 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3950 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3951 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3952 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3953 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3954 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3955 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3956 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3957 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3958 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3959 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3960 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3961 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3962 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3963 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3965 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)))));
3966 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)))));
3967 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)))));
3968 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)))));
3969 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)))));
3970 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)))));
3971 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)))));
3972 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)))));
3973 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)))));
3974 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)))));
3975 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)))));
3976 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)))));
3977 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)))));
3978 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)))));
3979 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)))));
3980 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)))));
3981 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)))));
3982 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)))));
3983 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)))));
3985 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
3986 body
.emit(assign(array_ref(adj
, 0),
3987 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3988 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3989 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3991 body
.emit(assign(array_ref(adj
, 1), neg(
3992 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3993 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3994 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3996 body
.emit(assign(array_ref(adj
, 2),
3997 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3998 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3999 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4001 body
.emit(assign(array_ref(adj
, 3), neg(
4002 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4003 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4004 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4007 body
.emit(assign(array_ref(adj
, 0), neg(
4008 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4009 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4010 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4012 body
.emit(assign(array_ref(adj
, 1),
4013 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4014 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4015 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4017 body
.emit(assign(array_ref(adj
, 2), neg(
4018 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4019 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4020 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4022 body
.emit(assign(array_ref(adj
, 3),
4023 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4024 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4025 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4028 body
.emit(assign(array_ref(adj
, 0),
4029 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4030 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4031 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4033 body
.emit(assign(array_ref(adj
, 1), neg(
4034 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4035 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4036 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4038 body
.emit(assign(array_ref(adj
, 2),
4039 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4040 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4041 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4043 body
.emit(assign(array_ref(adj
, 3), neg(
4044 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4045 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4046 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4049 body
.emit(assign(array_ref(adj
, 0), neg(
4050 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4051 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4052 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4054 body
.emit(assign(array_ref(adj
, 1),
4055 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4056 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4057 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4059 body
.emit(assign(array_ref(adj
, 2), neg(
4060 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4061 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4062 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4064 body
.emit(assign(array_ref(adj
, 3),
4065 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4066 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4067 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4070 ir_expression
*det
=
4071 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4072 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4073 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4074 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4076 body
.emit(ret(div(adj
, det
)));
4082 ir_function_signature
*
4083 builtin_builder::_lessThan(builtin_available_predicate avail
,
4084 const glsl_type
*type
)
4086 return binop(ir_binop_less
, avail
,
4087 glsl_type::bvec(type
->vector_elements
), type
, type
);
4090 ir_function_signature
*
4091 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4092 const glsl_type
*type
)
4094 return binop(ir_binop_lequal
, avail
,
4095 glsl_type::bvec(type
->vector_elements
), type
, type
);
4098 ir_function_signature
*
4099 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4100 const glsl_type
*type
)
4102 return binop(ir_binop_greater
, avail
,
4103 glsl_type::bvec(type
->vector_elements
), type
, type
);
4106 ir_function_signature
*
4107 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4108 const glsl_type
*type
)
4110 return binop(ir_binop_gequal
, avail
,
4111 glsl_type::bvec(type
->vector_elements
), type
, type
);
4114 ir_function_signature
*
4115 builtin_builder::_equal(builtin_available_predicate avail
,
4116 const glsl_type
*type
)
4118 return binop(ir_binop_equal
, avail
,
4119 glsl_type::bvec(type
->vector_elements
), type
, type
);
4122 ir_function_signature
*
4123 builtin_builder::_notEqual(builtin_available_predicate avail
,
4124 const glsl_type
*type
)
4126 return binop(ir_binop_nequal
, avail
,
4127 glsl_type::bvec(type
->vector_elements
), type
, type
);
4130 ir_function_signature
*
4131 builtin_builder::_any(const glsl_type
*type
)
4133 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4136 ir_function_signature
*
4137 builtin_builder::_all(const glsl_type
*type
)
4139 ir_variable
*v
= in_var(type
, "v");
4140 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4142 switch (type
->vector_elements
) {
4144 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4147 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4151 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4160 UNOP(not, ir_unop_logic_not
, always_available
)
4163 has_lod(const glsl_type
*sampler_type
)
4165 assert(sampler_type
->is_sampler());
4167 switch (sampler_type
->sampler_dimensionality
) {
4168 case GLSL_SAMPLER_DIM_RECT
:
4169 case GLSL_SAMPLER_DIM_BUF
:
4170 case GLSL_SAMPLER_DIM_MS
:
4177 ir_function_signature
*
4178 builtin_builder::_textureSize(builtin_available_predicate avail
,
4179 const glsl_type
*return_type
,
4180 const glsl_type
*sampler_type
)
4182 ir_variable
*s
= in_var(sampler_type
, "sampler");
4183 /* The sampler always exists; add optional lod later. */
4184 MAKE_SIG(return_type
, avail
, 1, s
);
4186 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4187 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4189 if (has_lod(sampler_type
)) {
4190 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4191 sig
->parameters
.push_tail(lod
);
4192 tex
->lod_info
.lod
= var_ref(lod
);
4194 tex
->lod_info
.lod
= imm(0u);
4197 body
.emit(ret(tex
));
4202 ir_function_signature
*
4203 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4205 ir_variable
*s
= in_var(sampler_type
, "sampler");
4206 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4208 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4209 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4210 body
.emit(ret(tex
));
4215 ir_function_signature
*
4216 builtin_builder::_texture(ir_texture_opcode opcode
,
4217 builtin_available_predicate avail
,
4218 const glsl_type
*return_type
,
4219 const glsl_type
*sampler_type
,
4220 const glsl_type
*coord_type
,
4223 ir_variable
*s
= in_var(sampler_type
, "sampler");
4224 ir_variable
*P
= in_var(coord_type
, "P");
4225 /* The sampler and coordinate always exist; add optional parameters later. */
4226 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4228 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4229 tex
->set_sampler(var_ref(s
), return_type
);
4231 const int coord_size
= sampler_type
->coordinate_components();
4233 if (coord_size
== coord_type
->vector_elements
) {
4234 tex
->coordinate
= var_ref(P
);
4236 /* The incoming coordinate also has the projector or shadow comparitor,
4237 * so we need to swizzle those away.
4239 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4242 /* The projector is always in the last component. */
4243 if (flags
& TEX_PROJECT
)
4244 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4246 if (sampler_type
->sampler_shadow
) {
4247 if (opcode
== ir_tg4
) {
4248 /* gather has refz as a separate parameter, immediately after the
4251 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4252 sig
->parameters
.push_tail(refz
);
4253 tex
->shadow_comparitor
= var_ref(refz
);
4255 /* The shadow comparitor is normally in the Z component, but a few types
4256 * have sufficiently large coordinates that it's in W.
4258 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4262 if (opcode
== ir_txl
) {
4263 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4264 sig
->parameters
.push_tail(lod
);
4265 tex
->lod_info
.lod
= var_ref(lod
);
4266 } else if (opcode
== ir_txd
) {
4267 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4268 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4269 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4270 sig
->parameters
.push_tail(dPdx
);
4271 sig
->parameters
.push_tail(dPdy
);
4272 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4273 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4276 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4277 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4278 ir_variable
*offset
=
4279 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4280 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4281 sig
->parameters
.push_tail(offset
);
4282 tex
->offset
= var_ref(offset
);
4285 if (flags
& TEX_OFFSET_ARRAY
) {
4286 ir_variable
*offsets
=
4287 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4288 "offsets", ir_var_const_in
);
4289 sig
->parameters
.push_tail(offsets
);
4290 tex
->offset
= var_ref(offsets
);
4293 if (opcode
== ir_tg4
) {
4294 if (flags
& TEX_COMPONENT
) {
4295 ir_variable
*component
=
4296 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4297 sig
->parameters
.push_tail(component
);
4298 tex
->lod_info
.component
= var_ref(component
);
4301 tex
->lod_info
.component
= imm(0);
4305 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4306 * inconsistent with both textureLodOffset and textureGradOffset.
4308 if (opcode
== ir_txb
) {
4309 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4310 sig
->parameters
.push_tail(bias
);
4311 tex
->lod_info
.bias
= var_ref(bias
);
4314 body
.emit(ret(tex
));
4319 ir_function_signature
*
4320 builtin_builder::_textureCubeArrayShadow()
4322 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4323 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4324 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4325 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4327 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4328 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4330 tex
->coordinate
= var_ref(P
);
4331 tex
->shadow_comparitor
= var_ref(compare
);
4333 body
.emit(ret(tex
));
4338 ir_function_signature
*
4339 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4340 const glsl_type
*return_type
,
4341 const glsl_type
*sampler_type
,
4342 const glsl_type
*coord_type
,
4343 const glsl_type
*offset_type
)
4345 ir_variable
*s
= in_var(sampler_type
, "sampler");
4346 ir_variable
*P
= in_var(coord_type
, "P");
4347 /* The sampler and coordinate always exist; add optional parameters later. */
4348 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4350 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4351 tex
->coordinate
= var_ref(P
);
4352 tex
->set_sampler(var_ref(s
), return_type
);
4354 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4355 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4356 sig
->parameters
.push_tail(sample
);
4357 tex
->lod_info
.sample_index
= var_ref(sample
);
4358 tex
->op
= ir_txf_ms
;
4359 } else if (has_lod(sampler_type
)) {
4360 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4361 sig
->parameters
.push_tail(lod
);
4362 tex
->lod_info
.lod
= var_ref(lod
);
4364 tex
->lod_info
.lod
= imm(0u);
4367 if (offset_type
!= NULL
) {
4368 ir_variable
*offset
=
4369 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4370 sig
->parameters
.push_tail(offset
);
4371 tex
->offset
= var_ref(offset
);
4374 body
.emit(ret(tex
));
4379 ir_function_signature
*
4380 builtin_builder::_EmitVertex()
4382 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4384 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4385 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4390 ir_function_signature
*
4391 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4392 const glsl_type
*stream_type
)
4394 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4396 * "Emit the current values of output variables to the current output
4397 * primitive on stream stream. The argument to stream must be a constant
4398 * integral expression."
4400 ir_variable
*stream
=
4401 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4403 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4405 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4410 ir_function_signature
*
4411 builtin_builder::_EndPrimitive()
4413 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4415 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4416 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4421 ir_function_signature
*
4422 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4423 const glsl_type
*stream_type
)
4425 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4427 * "Completes the current output primitive on stream stream and starts
4428 * a new one. The argument to stream must be a constant integral
4431 ir_variable
*stream
=
4432 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4434 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4436 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4441 ir_function_signature
*
4442 builtin_builder::_barrier()
4444 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4446 body
.emit(new(mem_ctx
) ir_barrier());
4450 ir_function_signature
*
4451 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4452 const glsl_type
*sampler_type
,
4453 const glsl_type
*coord_type
)
4455 ir_variable
*s
= in_var(sampler_type
, "sampler");
4456 ir_variable
*coord
= in_var(coord_type
, "coord");
4457 /* The sampler and coordinate always exist; add optional parameters later. */
4458 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4460 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4461 tex
->coordinate
= var_ref(coord
);
4462 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4464 body
.emit(ret(tex
));
4469 ir_function_signature
*
4470 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4472 ir_variable
*s
= in_var(sampler_type
, "sampler");
4473 const glsl_type
*return_type
= glsl_type::int_type
;
4474 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4476 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4477 tex
->set_sampler(var_ref(s
), return_type
);
4479 body
.emit(ret(tex
));
4484 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4485 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4486 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4487 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4488 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4489 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4491 ir_function_signature
*
4492 builtin_builder::_fwidth(const glsl_type
*type
)
4494 ir_variable
*p
= in_var(type
, "p");
4495 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4497 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4502 ir_function_signature
*
4503 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4505 ir_variable
*p
= in_var(type
, "p");
4506 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4508 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4509 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4514 ir_function_signature
*
4515 builtin_builder::_fwidthFine(const glsl_type
*type
)
4517 ir_variable
*p
= in_var(type
, "p");
4518 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4520 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4521 abs(expr(ir_unop_dFdy_fine
, p
)))));
4526 ir_function_signature
*
4527 builtin_builder::_noise1(const glsl_type
*type
)
4529 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4532 ir_function_signature
*
4533 builtin_builder::_noise2(const glsl_type
*type
)
4535 ir_variable
*p
= in_var(type
, "p");
4536 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4538 ir_constant_data b_offset
;
4539 b_offset
.f
[0] = 601.0f
;
4540 b_offset
.f
[1] = 313.0f
;
4541 b_offset
.f
[2] = 29.0f
;
4542 b_offset
.f
[3] = 277.0f
;
4544 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4545 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4546 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4547 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4548 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4549 body
.emit(assign(t
, a
, WRITEMASK_X
));
4550 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4556 ir_function_signature
*
4557 builtin_builder::_noise3(const glsl_type
*type
)
4559 ir_variable
*p
= in_var(type
, "p");
4560 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4562 ir_constant_data b_offset
;
4563 b_offset
.f
[0] = 601.0f
;
4564 b_offset
.f
[1] = 313.0f
;
4565 b_offset
.f
[2] = 29.0f
;
4566 b_offset
.f
[3] = 277.0f
;
4568 ir_constant_data c_offset
;
4569 c_offset
.f
[0] = 1559.0f
;
4570 c_offset
.f
[1] = 113.0f
;
4571 c_offset
.f
[2] = 1861.0f
;
4572 c_offset
.f
[3] = 797.0f
;
4574 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4575 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4576 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4577 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4578 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4579 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4580 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4581 body
.emit(assign(t
, a
, WRITEMASK_X
));
4582 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4583 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4589 ir_function_signature
*
4590 builtin_builder::_noise4(const glsl_type
*type
)
4592 ir_variable
*p
= in_var(type
, "p");
4593 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4595 ir_variable
*_p
= body
.make_temp(type
, "_p");
4597 ir_constant_data p_offset
;
4598 p_offset
.f
[0] = 1559.0f
;
4599 p_offset
.f
[1] = 113.0f
;
4600 p_offset
.f
[2] = 1861.0f
;
4601 p_offset
.f
[3] = 797.0f
;
4603 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4605 ir_constant_data offset
;
4606 offset
.f
[0] = 601.0f
;
4607 offset
.f
[1] = 313.0f
;
4608 offset
.f
[2] = 29.0f
;
4609 offset
.f
[3] = 277.0f
;
4611 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4612 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4613 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4614 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4615 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4616 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4617 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4618 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4619 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4620 body
.emit(assign(t
, a
, WRITEMASK_X
));
4621 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4622 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4623 body
.emit(assign(t
, d
, WRITEMASK_W
));
4629 ir_function_signature
*
4630 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4632 ir_variable
*value
= in_var(type
, "value");
4633 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4634 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4635 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4637 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4642 ir_function_signature
*
4643 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4645 ir_variable
*base
= in_var(type
, "base");
4646 ir_variable
*insert
= in_var(type
, "insert");
4647 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4648 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4649 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4651 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4656 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4658 ir_function_signature
*
4659 builtin_builder::_bitCount(const glsl_type
*type
)
4661 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4662 glsl_type::ivec(type
->vector_elements
), type
);
4665 ir_function_signature
*
4666 builtin_builder::_findLSB(const glsl_type
*type
)
4668 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4669 glsl_type::ivec(type
->vector_elements
), type
);
4672 ir_function_signature
*
4673 builtin_builder::_findMSB(const glsl_type
*type
)
4675 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4676 glsl_type::ivec(type
->vector_elements
), type
);
4679 ir_function_signature
*
4680 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4682 ir_variable
*a
= in_var(type
, "a");
4683 ir_variable
*b
= in_var(type
, "b");
4684 ir_variable
*c
= in_var(type
, "c");
4685 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4687 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4692 ir_function_signature
*
4693 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4695 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4698 ir_function_signature
*
4699 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4701 ir_variable
*x
= in_var(x_type
, "x");
4702 ir_variable
*exponent
= out_var(exp_type
, "exp");
4703 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4705 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4707 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4711 ir_function_signature
*
4712 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4714 ir_variable
*x
= in_var(x_type
, "x");
4715 ir_variable
*exponent
= out_var(exp_type
, "exp");
4716 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4718 const unsigned vec_elem
= x_type
->vector_elements
;
4719 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4720 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4722 /* Single-precision floating-point values are stored as
4727 * An exponent shift of 23 will shift the mantissa out, leaving only the
4728 * exponent and sign bit (which itself may be zero, if the absolute value
4729 * was taken before the bitcast and shift.
4731 ir_constant
*exponent_shift
= imm(23);
4732 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4734 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4736 /* Exponent of floating-point values in the range [0.5, 1.0). */
4737 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4739 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4740 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4742 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4743 * to unsigned integers to ensure that 1 bits aren't shifted in.
4745 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4746 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4747 imm(0, vec_elem
)))));
4749 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4750 body
.emit(assign(bits
, bitcast_f2u(x
)));
4751 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4752 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4753 imm(0u, vec_elem
)))));
4754 body
.emit(ret(bitcast_u2f(bits
)));
4759 ir_function_signature
*
4760 builtin_builder::_uaddCarry(const glsl_type
*type
)
4762 ir_variable
*x
= in_var(type
, "x");
4763 ir_variable
*y
= in_var(type
, "y");
4764 ir_variable
*carry
= out_var(type
, "carry");
4765 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4767 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4768 body
.emit(ret(add(x
, y
)));
4773 ir_function_signature
*
4774 builtin_builder::_usubBorrow(const glsl_type
*type
)
4776 ir_variable
*x
= in_var(type
, "x");
4777 ir_variable
*y
= in_var(type
, "y");
4778 ir_variable
*borrow
= out_var(type
, "borrow");
4779 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4781 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4782 body
.emit(ret(sub(x
, y
)));
4788 * For both imulExtended() and umulExtended() built-ins.
4790 ir_function_signature
*
4791 builtin_builder::_mulExtended(const glsl_type
*type
)
4793 ir_variable
*x
= in_var(type
, "x");
4794 ir_variable
*y
= in_var(type
, "y");
4795 ir_variable
*msb
= out_var(type
, "msb");
4796 ir_variable
*lsb
= out_var(type
, "lsb");
4797 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
4799 body
.emit(assign(msb
, imul_high(x
, y
)));
4800 body
.emit(assign(lsb
, mul(x
, y
)));
4805 ir_function_signature
*
4806 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4808 ir_variable
*interpolant
= in_var(type
, "interpolant");
4809 interpolant
->data
.must_be_shader_input
= 1;
4810 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4812 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4817 ir_function_signature
*
4818 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4820 ir_variable
*interpolant
= in_var(type
, "interpolant");
4821 interpolant
->data
.must_be_shader_input
= 1;
4822 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4823 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4825 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4830 ir_function_signature
*
4831 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4833 ir_variable
*interpolant
= in_var(type
, "interpolant");
4834 interpolant
->data
.must_be_shader_input
= 1;
4835 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4836 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4838 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4843 ir_function_signature
*
4844 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
4846 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4847 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4851 ir_function_signature
*
4852 builtin_builder::_atomic_counter_op(const char *intrinsic
,
4853 builtin_available_predicate avail
)
4855 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4856 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4858 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4859 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4861 body
.emit(ret(retval
));
4865 ir_function_signature
*
4866 builtin_builder::_min3(const glsl_type
*type
)
4868 ir_variable
*x
= in_var(type
, "x");
4869 ir_variable
*y
= in_var(type
, "y");
4870 ir_variable
*z
= in_var(type
, "z");
4871 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4873 ir_expression
*min3
= min2(x
, min2(y
,z
));
4874 body
.emit(ret(min3
));
4879 ir_function_signature
*
4880 builtin_builder::_max3(const glsl_type
*type
)
4882 ir_variable
*x
= in_var(type
, "x");
4883 ir_variable
*y
= in_var(type
, "y");
4884 ir_variable
*z
= in_var(type
, "z");
4885 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4887 ir_expression
*max3
= max2(x
, max2(y
,z
));
4888 body
.emit(ret(max3
));
4893 ir_function_signature
*
4894 builtin_builder::_mid3(const glsl_type
*type
)
4896 ir_variable
*x
= in_var(type
, "x");
4897 ir_variable
*y
= in_var(type
, "y");
4898 ir_variable
*z
= in_var(type
, "z");
4899 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4901 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4902 body
.emit(ret(mid3
));
4907 ir_function_signature
*
4908 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4909 unsigned num_arguments
,
4912 const glsl_type
*data_type
= glsl_type::get_instance(
4913 image_type
->sampler_type
,
4914 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4916 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4917 glsl_type::void_type
: data_type
);
4919 /* Addressing arguments that are always present. */
4920 ir_variable
*image
= in_var(image_type
, "image");
4921 ir_variable
*coord
= in_var(
4922 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4924 const builtin_available_predicate avail
=
4925 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
4926 shader_image_load_store
);
4927 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
4929 /* Sample index for multisample images. */
4930 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4931 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4933 /* Data arguments. */
4934 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
4935 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
4936 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
4937 ralloc_free(arg_name
);
4940 /* Set the maximal set of qualifiers allowed for this image
4941 * built-in. Function calls with arguments having fewer
4942 * qualifiers than present in the prototype are allowed by the
4943 * spec, but not with more, i.e. this will make the compiler
4944 * accept everything that needs to be accepted, and reject cases
4945 * like loads from write-only or stores to read-only images.
4947 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
4948 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
4949 image
->data
.image_coherent
= true;
4950 image
->data
.image_volatile
= true;
4951 image
->data
.image_restrict
= true;
4956 ir_function_signature
*
4957 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
4958 unsigned /* num_arguments */,
4959 unsigned /* flags */)
4961 const glsl_type
*ret_type
;
4962 unsigned num_components
= image_type
->coordinate_components();
4964 /* From the ARB_shader_image_size extension:
4965 * "Cube images return the dimensions of one face."
4967 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
4968 !image_type
->sampler_array
) {
4972 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
4973 * supported by mesa.
4975 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
4977 ir_variable
*image
= in_var(image_type
, "image");
4978 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
4980 /* Set the maximal set of qualifiers allowed for this image
4981 * built-in. Function calls with arguments having fewer
4982 * qualifiers than present in the prototype are allowed by the
4983 * spec, but not with more, i.e. this will make the compiler
4984 * accept everything that needs to be accepted, and reject cases
4985 * like loads from write-only or stores to read-only images.
4987 image
->data
.image_read_only
= true;
4988 image
->data
.image_write_only
= true;
4989 image
->data
.image_coherent
= true;
4990 image
->data
.image_volatile
= true;
4991 image
->data
.image_restrict
= true;
4996 ir_function_signature
*
4997 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
4998 unsigned num_arguments
,
5001 ir_variable
*image
= in_var(image_type
, "image");
5002 ir_function_signature
*sig
=
5003 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5005 /* Set the maximal set of qualifiers allowed for this image
5006 * built-in. Function calls with arguments having fewer
5007 * qualifiers than present in the prototype are allowed by the
5008 * spec, but not with more, i.e. this will make the compiler
5009 * accept everything that needs to be accepted, and reject cases
5010 * like loads from write-only or stores to read-only images.
5012 image
->data
.image_read_only
= true;
5013 image
->data
.image_write_only
= true;
5014 image
->data
.image_coherent
= true;
5015 image
->data
.image_volatile
= true;
5016 image
->data
.image_restrict
= true;
5021 ir_function_signature
*
5022 builtin_builder::_image(image_prototype_ctr prototype
,
5023 const glsl_type
*image_type
,
5024 const char *intrinsic_name
,
5025 unsigned num_arguments
,
5028 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5029 num_arguments
, flags
);
5031 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5032 ir_factory
body(&sig
->body
, mem_ctx
);
5033 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5035 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5036 body
.emit(call(f
, NULL
, sig
->parameters
));
5038 ir_variable
*ret_val
=
5039 body
.make_temp(sig
->return_type
, "_ret_val");
5040 body
.emit(call(f
, ret_val
, sig
->parameters
));
5041 body
.emit(ret(ret_val
));
5044 sig
->is_defined
= true;
5047 sig
->is_intrinsic
= true;
5053 ir_function_signature
*
5054 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5056 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5060 ir_function_signature
*
5061 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
5063 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5064 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
5065 NULL
, sig
->parameters
));
5071 /******************************************************************************/
5073 /* The singleton instance of builtin_builder. */
5074 static builtin_builder builtins
;
5075 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5078 * External API (exposing the built-in module to the rest of the compiler):
5082 _mesa_glsl_initialize_builtin_functions()
5084 mtx_lock(&builtins_lock
);
5085 builtins
.initialize();
5086 mtx_unlock(&builtins_lock
);
5090 _mesa_glsl_release_builtin_functions()
5092 mtx_lock(&builtins_lock
);
5094 mtx_unlock(&builtins_lock
);
5097 ir_function_signature
*
5098 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5099 const char *name
, exec_list
*actual_parameters
)
5101 ir_function_signature
* s
;
5102 mtx_lock(&builtins_lock
);
5103 s
= builtins
.find(state
, name
, actual_parameters
);
5104 mtx_unlock(&builtins_lock
);
5109 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5112 mtx_lock(&builtins_lock
);
5113 f
= builtins
.shader
->symbols
->get_function(name
);
5114 mtx_unlock(&builtins_lock
);
5119 _mesa_glsl_get_builtin_function_shader()
5121 return builtins
.shader
;
5126 * Get the function signature for main from a shader
5128 ir_function_signature
*
5129 _mesa_get_main_function_signature(gl_shader
*sh
)
5131 ir_function
*const f
= sh
->symbols
->get_function("main");
5133 exec_list void_parameters
;
5135 /* Look for the 'void main()' signature and ensure that it's defined.
5136 * This keeps the linker from accidentally pick a shader that just
5137 * contains a prototype for main.
5139 * We don't have to check for multiple definitions of main (in multiple
5140 * shaders) because that would have already been caught above.
5142 ir_function_signature
*sig
=
5143 f
->matching_signature(NULL
, &void_parameters
, false);
5144 if ((sig
!= NULL
) && sig
->is_defined
) {