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, 0) ||
288 state
->ARB_texture_multisample_enable
;
292 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
294 return state
->stage
== MESA_SHADER_FRAGMENT
&&
295 (state
->is_version(400, 0) ||
296 state
->ARB_texture_cube_map_array_enable
);
300 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
302 return state
->is_version(400, 0) ||
303 state
->ARB_texture_cube_map_array_enable
;
307 texture_query_levels(const _mesa_glsl_parse_state
*state
)
309 return state
->is_version(430, 0) ||
310 state
->ARB_texture_query_levels_enable
;
314 texture_query_lod(const _mesa_glsl_parse_state
*state
)
316 return state
->stage
== MESA_SHADER_FRAGMENT
&&
317 state
->ARB_texture_query_lod_enable
;
321 texture_gather(const _mesa_glsl_parse_state
*state
)
323 return state
->is_version(400, 0) ||
324 state
->ARB_texture_gather_enable
||
325 state
->ARB_gpu_shader5_enable
;
329 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
331 return state
->is_version(400, 310) ||
332 state
->ARB_texture_gather_enable
||
333 state
->ARB_gpu_shader5_enable
;
336 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
337 * used for relaxation of const offset requirements.
340 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
342 return !state
->is_version(400, 0) &&
343 !state
->ARB_gpu_shader5_enable
&&
344 (state
->ARB_texture_gather_enable
||
345 state
->is_version(0, 310));
348 /* Desktop GL or OES_standard_derivatives + fragment shader only */
350 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
352 return state
->stage
== MESA_SHADER_FRAGMENT
&&
353 (state
->is_version(110, 300) ||
354 state
->OES_standard_derivatives_enable
);
358 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
360 return state
->stage
== MESA_SHADER_FRAGMENT
&&
361 (state
->is_version(450, 0) ||
362 state
->ARB_derivative_control_enable
);
366 tex1d_lod(const _mesa_glsl_parse_state
*state
)
368 return !state
->es_shader
&& lod_exists_in_stage(state
);
371 /** True if sampler3D exists */
373 tex3d(const _mesa_glsl_parse_state
*state
)
375 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
376 * OES_texture_3D extension, and in GLSL ES 3.00.
378 return !state
->es_shader
||
379 state
->OES_texture_3D_enable
||
380 state
->language_version
>= 300;
384 fs_tex3d(const _mesa_glsl_parse_state
*state
)
386 return state
->stage
== MESA_SHADER_FRAGMENT
&&
387 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
391 tex3d_lod(const _mesa_glsl_parse_state
*state
)
393 return tex3d(state
) && lod_exists_in_stage(state
);
397 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
399 return state
->has_atomic_counters();
403 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
405 return state
->AMD_shader_trinary_minmax_enable
;
409 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
411 return (state
->is_version(420, 310) ||
412 state
->ARB_shader_image_load_store_enable
);
416 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
418 return (state
->is_version(420, 0) ||
419 state
->ARB_shader_image_load_store_enable
);
423 shader_image_size(const _mesa_glsl_parse_state
*state
)
425 return state
->is_version(430, 310) ||
426 state
->ARB_shader_image_size_enable
;
430 gs_streams(const _mesa_glsl_parse_state
*state
)
432 return gpu_shader5(state
) && gs_only(state
);
436 fp64(const _mesa_glsl_parse_state
*state
)
438 return state
->has_double();
442 barrier_supported(const _mesa_glsl_parse_state
*state
)
444 return state
->stage
== MESA_SHADER_COMPUTE
||
445 state
->stage
== MESA_SHADER_TESS_CTRL
;
450 /******************************************************************************/
455 * builtin_builder: A singleton object representing the core of the built-in
458 * It generates IR for every built-in function signature, and organizes them
461 class builtin_builder
{
468 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
469 const char *name
, exec_list
*actual_parameters
);
472 * A shader to hold all the built-in signatures; created by this module.
474 * This includes signatures for every built-in, regardless of version or
475 * enabled extensions. The availability predicate associated with each
476 * signature allows matching_signature() to filter out the irrelevant ones.
483 /** Global variables used by built-in functions. */
484 ir_variable
*gl_ModelViewProjectionMatrix
;
485 ir_variable
*gl_Vertex
;
487 void create_shader();
488 void create_intrinsics();
489 void create_builtins();
492 * IR builder helpers:
494 * These convenience functions assist in emitting IR, but don't necessarily
495 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
498 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
499 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
500 ir_constant
*imm(float f
, unsigned vector_elements
=1);
501 ir_constant
*imm(int i
, unsigned vector_elements
=1);
502 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
503 ir_constant
*imm(double d
, unsigned vector_elements
=1);
504 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
505 ir_dereference_variable
*var_ref(ir_variable
*var
);
506 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
507 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
509 ir_expression
*asin_expr(ir_variable
*x
);
510 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
513 * Call function \param f with parameters specified as the linked
514 * list \param params of \c ir_variable objects. \param ret should
515 * point to the ir_variable that will hold the function return
516 * value, or be \c NULL if the function has void return type.
518 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
520 /** Create a new function and add the given signatures. */
521 void add_function(const char *name
, ...);
523 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
524 const char *intrinsic_name
,
525 unsigned num_arguments
,
528 enum image_function_flags
{
529 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
530 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
531 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
532 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
533 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
534 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
535 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6)
539 * Create a new image built-in function for all known image types.
540 * \p flags is a bitfield of \c image_function_flags flags.
542 void add_image_function(const char *name
,
543 const char *intrinsic_name
,
544 image_prototype_ctr prototype
,
545 unsigned num_arguments
,
549 * Create new functions for all known image built-ins and types.
550 * If \p glsl is \c true, use the GLSL built-in names and emit code
551 * to call into the actual compiler intrinsic. If \p glsl is
552 * false, emit a function prototype with no body for each image
555 void add_image_functions(bool glsl
);
557 ir_function_signature
*new_sig(const glsl_type
*return_type
,
558 builtin_available_predicate avail
,
559 int num_params
, ...);
562 * Function signature generators:
565 ir_function_signature
*unop(builtin_available_predicate avail
,
566 ir_expression_operation opcode
,
567 const glsl_type
*return_type
,
568 const glsl_type
*param_type
);
569 ir_function_signature
*binop(ir_expression_operation opcode
,
570 builtin_available_predicate avail
,
571 const glsl_type
*return_type
,
572 const glsl_type
*param0_type
,
573 const glsl_type
*param1_type
);
575 #define B0(X) ir_function_signature *_##X();
576 #define B1(X) ir_function_signature *_##X(const glsl_type *);
577 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
578 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
579 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
580 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
617 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
618 const glsl_type
*val_type
,
619 const glsl_type
*blend_type
);
628 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
629 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
630 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
631 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
632 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
633 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
634 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
635 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
636 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
637 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
638 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
639 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
652 BA1(determinant_mat2
);
653 BA1(determinant_mat3
);
654 BA1(determinant_mat4
);
662 BA1(greaterThanEqual
);
669 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
670 const glsl_type
*return_type
,
671 const glsl_type
*sampler_type
);
673 /** Flags to _texture() */
674 #define TEX_PROJECT 1
676 #define TEX_COMPONENT 4
677 #define TEX_OFFSET_NONCONST 8
678 #define TEX_OFFSET_ARRAY 16
680 ir_function_signature
*_texture(ir_texture_opcode opcode
,
681 builtin_available_predicate avail
,
682 const glsl_type
*return_type
,
683 const glsl_type
*sampler_type
,
684 const glsl_type
*coord_type
,
686 B0(textureCubeArrayShadow
);
687 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
688 const glsl_type
*return_type
,
689 const glsl_type
*sampler_type
,
690 const glsl_type
*coord_type
,
691 const glsl_type
*offset_type
= NULL
);
695 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
696 const glsl_type
*stream_type
);
697 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
698 const glsl_type
*stream_type
);
701 BA2(textureQueryLod
);
702 B1(textureQueryLevels
);
730 B1(interpolateAtCentroid
)
731 B1(interpolateAtOffset
)
732 B1(interpolateAtSample
)
734 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
735 ir_function_signature
*_atomic_op(const char *intrinsic
,
736 builtin_available_predicate avail
);
742 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
743 const char *intrinsic_name
,
744 unsigned num_arguments
,
746 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
747 const char *intrinsic_name
,
748 unsigned num_arguments
,
750 ir_function_signature
*_image(image_prototype_ctr prototype
,
751 const glsl_type
*image_type
,
752 const char *intrinsic_name
,
753 unsigned num_arguments
,
756 ir_function_signature
*_memory_barrier_intrinsic(
757 builtin_available_predicate avail
);
758 ir_function_signature
*_memory_barrier(
759 builtin_available_predicate avail
);
770 } /* anonymous namespace */
773 * Core builtin_builder functionality:
776 builtin_builder::builtin_builder()
778 gl_ModelViewProjectionMatrix(NULL
),
784 builtin_builder::~builtin_builder()
786 ralloc_free(mem_ctx
);
789 ir_function_signature
*
790 builtin_builder::find(_mesa_glsl_parse_state
*state
,
791 const char *name
, exec_list
*actual_parameters
)
793 /* The shader currently being compiled requested a built-in function;
794 * it needs to link against builtin_builder::shader in order to get them.
796 * Even if we don't find a matching signature, we still need to do this so
797 * that the "no matching signature" error will list potential candidates
798 * from the available built-ins.
800 state
->uses_builtin_functions
= true;
802 ir_function
*f
= shader
->symbols
->get_function(name
);
806 ir_function_signature
*sig
=
807 f
->matching_signature(state
, actual_parameters
, true);
815 builtin_builder::initialize()
817 /* If already initialized, don't do it again. */
821 mem_ctx
= ralloc_context(NULL
);
828 builtin_builder::release()
830 ralloc_free(mem_ctx
);
838 builtin_builder::create_shader()
840 /* The target doesn't actually matter. There's no target for generic
841 * GLSL utility code that could be linked against any stage, so just
842 * arbitrarily pick GL_VERTEX_SHADER.
844 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
845 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
847 gl_ModelViewProjectionMatrix
=
848 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
849 "gl_ModelViewProjectionMatrix",
852 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
854 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
855 shader
->symbols
->add_variable(gl_Vertex
);
861 * Create ir_function and ir_function_signature objects for each
865 builtin_builder::create_intrinsics()
867 add_function("__intrinsic_atomic_read",
868 _atomic_intrinsic(shader_atomic_counters
),
870 add_function("__intrinsic_atomic_increment",
871 _atomic_intrinsic(shader_atomic_counters
),
873 add_function("__intrinsic_atomic_predecrement",
874 _atomic_intrinsic(shader_atomic_counters
),
877 add_image_functions(false);
879 add_function("__intrinsic_memory_barrier",
880 _memory_barrier_intrinsic(shader_image_load_store
),
885 * Create ir_function and ir_function_signature objects for each built-in.
887 * Contains a list of every available built-in.
890 builtin_builder::create_builtins()
893 add_function(#NAME, \
894 _##NAME(glsl_type::float_type), \
895 _##NAME(glsl_type::vec2_type), \
896 _##NAME(glsl_type::vec3_type), \
897 _##NAME(glsl_type::vec4_type), \
901 add_function(#NAME, \
902 _##NAME(always_available, glsl_type::float_type), \
903 _##NAME(always_available, glsl_type::vec2_type), \
904 _##NAME(always_available, glsl_type::vec3_type), \
905 _##NAME(always_available, glsl_type::vec4_type), \
906 _##NAME(fp64, glsl_type::double_type), \
907 _##NAME(fp64, glsl_type::dvec2_type), \
908 _##NAME(fp64, glsl_type::dvec3_type), \
909 _##NAME(fp64, glsl_type::dvec4_type), \
912 #define FD130(NAME) \
913 add_function(#NAME, \
914 _##NAME(v130, glsl_type::float_type), \
915 _##NAME(v130, glsl_type::vec2_type), \
916 _##NAME(v130, glsl_type::vec3_type), \
917 _##NAME(v130, glsl_type::vec4_type), \
918 _##NAME(fp64, glsl_type::double_type), \
919 _##NAME(fp64, glsl_type::dvec2_type), \
920 _##NAME(fp64, glsl_type::dvec3_type), \
921 _##NAME(fp64, glsl_type::dvec4_type), \
924 #define FDGS5(NAME) \
925 add_function(#NAME, \
926 _##NAME(gpu_shader5, glsl_type::float_type), \
927 _##NAME(gpu_shader5, glsl_type::vec2_type), \
928 _##NAME(gpu_shader5, glsl_type::vec3_type), \
929 _##NAME(gpu_shader5, glsl_type::vec4_type), \
930 _##NAME(fp64, glsl_type::double_type), \
931 _##NAME(fp64, glsl_type::dvec2_type), \
932 _##NAME(fp64, glsl_type::dvec3_type), \
933 _##NAME(fp64, glsl_type::dvec4_type), \
937 add_function(#NAME, \
938 _##NAME(glsl_type::float_type), \
939 _##NAME(glsl_type::vec2_type), \
940 _##NAME(glsl_type::vec3_type), \
941 _##NAME(glsl_type::vec4_type), \
942 _##NAME(glsl_type::int_type), \
943 _##NAME(glsl_type::ivec2_type), \
944 _##NAME(glsl_type::ivec3_type), \
945 _##NAME(glsl_type::ivec4_type), \
949 add_function(#NAME, \
950 _##NAME(always_available, glsl_type::float_type), \
951 _##NAME(always_available, glsl_type::vec2_type), \
952 _##NAME(always_available, glsl_type::vec3_type), \
953 _##NAME(always_available, glsl_type::vec4_type), \
954 _##NAME(always_available, glsl_type::int_type), \
955 _##NAME(always_available, glsl_type::ivec2_type), \
956 _##NAME(always_available, glsl_type::ivec3_type), \
957 _##NAME(always_available, glsl_type::ivec4_type), \
958 _##NAME(fp64, glsl_type::double_type), \
959 _##NAME(fp64, glsl_type::dvec2_type), \
960 _##NAME(fp64, glsl_type::dvec3_type), \
961 _##NAME(fp64, glsl_type::dvec4_type), \
965 add_function(#NAME, \
966 _##NAME(always_available, glsl_type::float_type), \
967 _##NAME(always_available, glsl_type::vec2_type), \
968 _##NAME(always_available, glsl_type::vec3_type), \
969 _##NAME(always_available, glsl_type::vec4_type), \
971 _##NAME(always_available, glsl_type::int_type), \
972 _##NAME(always_available, glsl_type::ivec2_type), \
973 _##NAME(always_available, glsl_type::ivec3_type), \
974 _##NAME(always_available, glsl_type::ivec4_type), \
976 _##NAME(v130, glsl_type::uint_type), \
977 _##NAME(v130, glsl_type::uvec2_type), \
978 _##NAME(v130, glsl_type::uvec3_type), \
979 _##NAME(v130, glsl_type::uvec4_type), \
980 _##NAME(fp64, glsl_type::double_type), \
981 _##NAME(fp64, glsl_type::dvec2_type), \
982 _##NAME(fp64, glsl_type::dvec3_type), \
983 _##NAME(fp64, glsl_type::dvec4_type), \
987 add_function(#NAME, \
988 _##NAME(glsl_type::int_type), \
989 _##NAME(glsl_type::ivec2_type), \
990 _##NAME(glsl_type::ivec3_type), \
991 _##NAME(glsl_type::ivec4_type), \
993 _##NAME(glsl_type::uint_type), \
994 _##NAME(glsl_type::uvec2_type), \
995 _##NAME(glsl_type::uvec3_type), \
996 _##NAME(glsl_type::uvec4_type), \
999 #define FIUBD(NAME) \
1000 add_function(#NAME, \
1001 _##NAME(always_available, glsl_type::float_type), \
1002 _##NAME(always_available, glsl_type::vec2_type), \
1003 _##NAME(always_available, glsl_type::vec3_type), \
1004 _##NAME(always_available, glsl_type::vec4_type), \
1006 _##NAME(always_available, glsl_type::int_type), \
1007 _##NAME(always_available, glsl_type::ivec2_type), \
1008 _##NAME(always_available, glsl_type::ivec3_type), \
1009 _##NAME(always_available, glsl_type::ivec4_type), \
1011 _##NAME(v130, glsl_type::uint_type), \
1012 _##NAME(v130, glsl_type::uvec2_type), \
1013 _##NAME(v130, glsl_type::uvec3_type), \
1014 _##NAME(v130, glsl_type::uvec4_type), \
1016 _##NAME(always_available, glsl_type::bool_type), \
1017 _##NAME(always_available, glsl_type::bvec2_type), \
1018 _##NAME(always_available, glsl_type::bvec3_type), \
1019 _##NAME(always_available, glsl_type::bvec4_type), \
1021 _##NAME(fp64, glsl_type::double_type), \
1022 _##NAME(fp64, glsl_type::dvec2_type), \
1023 _##NAME(fp64, glsl_type::dvec3_type), \
1024 _##NAME(fp64, glsl_type::dvec4_type), \
1027 #define FIUD2_MIXED(NAME) \
1028 add_function(#NAME, \
1029 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1030 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1031 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1032 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1034 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1035 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1036 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1038 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1039 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1040 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1041 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1043 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1044 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1045 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1047 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1048 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1049 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1050 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1052 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1053 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1054 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1056 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1057 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1058 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1059 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1060 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1061 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1062 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1073 add_function("atan",
1074 _atan(glsl_type::float_type
),
1075 _atan(glsl_type::vec2_type
),
1076 _atan(glsl_type::vec3_type
),
1077 _atan(glsl_type::vec4_type
),
1078 _atan2(glsl_type::float_type
),
1079 _atan2(glsl_type::vec2_type
),
1080 _atan2(glsl_type::vec3_type
),
1081 _atan2(glsl_type::vec4_type
),
1107 _mod(glsl_type::float_type
, glsl_type::float_type
),
1108 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1109 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1110 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1112 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1113 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1114 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1116 _mod(glsl_type::double_type
, glsl_type::double_type
),
1117 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1118 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1119 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1121 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1122 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1123 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1133 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1134 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1135 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1136 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1138 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1139 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1140 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1142 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1143 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1144 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1145 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1147 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1148 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1149 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1151 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1152 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1153 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1154 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1156 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1157 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1158 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1159 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1161 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1162 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1163 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1164 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1166 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1167 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1168 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1169 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1171 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1172 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1173 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1174 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1177 add_function("step",
1178 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1179 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1180 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1181 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1183 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1184 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1185 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1186 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1187 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1188 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1189 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1191 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1192 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1193 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1196 add_function("smoothstep",
1197 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1198 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1199 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1200 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1202 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1203 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1204 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1205 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1206 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1207 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1208 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1210 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1211 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1212 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1220 add_function("intBitsToFloat",
1221 _intBitsToFloat(glsl_type::int_type
),
1222 _intBitsToFloat(glsl_type::ivec2_type
),
1223 _intBitsToFloat(glsl_type::ivec3_type
),
1224 _intBitsToFloat(glsl_type::ivec4_type
),
1226 add_function("uintBitsToFloat",
1227 _uintBitsToFloat(glsl_type::uint_type
),
1228 _uintBitsToFloat(glsl_type::uvec2_type
),
1229 _uintBitsToFloat(glsl_type::uvec3_type
),
1230 _uintBitsToFloat(glsl_type::uvec4_type
),
1233 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1234 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1235 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1236 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1237 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1238 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1239 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1240 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1241 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1242 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1243 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1244 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1251 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1252 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1255 add_function("ftransform", _ftransform(), NULL
);
1260 add_function("matrixCompMult",
1261 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1262 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1263 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1264 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1265 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1266 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1267 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1268 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1269 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1270 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1271 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1272 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1273 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1274 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1275 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1276 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1277 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1278 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1280 add_function("outerProduct",
1281 _outerProduct(v120
, glsl_type::mat2_type
),
1282 _outerProduct(v120
, glsl_type::mat3_type
),
1283 _outerProduct(v120
, glsl_type::mat4_type
),
1284 _outerProduct(v120
, glsl_type::mat2x3_type
),
1285 _outerProduct(v120
, glsl_type::mat2x4_type
),
1286 _outerProduct(v120
, glsl_type::mat3x2_type
),
1287 _outerProduct(v120
, glsl_type::mat3x4_type
),
1288 _outerProduct(v120
, glsl_type::mat4x2_type
),
1289 _outerProduct(v120
, glsl_type::mat4x3_type
),
1290 _outerProduct(fp64
, glsl_type::dmat2_type
),
1291 _outerProduct(fp64
, glsl_type::dmat3_type
),
1292 _outerProduct(fp64
, glsl_type::dmat4_type
),
1293 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1294 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1295 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1296 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1297 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1298 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1300 add_function("determinant",
1301 _determinant_mat2(v120
, glsl_type::mat2_type
),
1302 _determinant_mat3(v120
, glsl_type::mat3_type
),
1303 _determinant_mat4(v120
, glsl_type::mat4_type
),
1304 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1305 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1306 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1309 add_function("inverse",
1310 _inverse_mat2(v120
, glsl_type::mat2_type
),
1311 _inverse_mat3(v120
, glsl_type::mat3_type
),
1312 _inverse_mat4(v120
, glsl_type::mat4_type
),
1313 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1314 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1315 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1317 add_function("transpose",
1318 _transpose(v120
, glsl_type::mat2_type
),
1319 _transpose(v120
, glsl_type::mat3_type
),
1320 _transpose(v120
, glsl_type::mat4_type
),
1321 _transpose(v120
, glsl_type::mat2x3_type
),
1322 _transpose(v120
, glsl_type::mat2x4_type
),
1323 _transpose(v120
, glsl_type::mat3x2_type
),
1324 _transpose(v120
, glsl_type::mat3x4_type
),
1325 _transpose(v120
, glsl_type::mat4x2_type
),
1326 _transpose(v120
, glsl_type::mat4x3_type
),
1327 _transpose(fp64
, glsl_type::dmat2_type
),
1328 _transpose(fp64
, glsl_type::dmat3_type
),
1329 _transpose(fp64
, glsl_type::dmat4_type
),
1330 _transpose(fp64
, glsl_type::dmat2x3_type
),
1331 _transpose(fp64
, glsl_type::dmat2x4_type
),
1332 _transpose(fp64
, glsl_type::dmat3x2_type
),
1333 _transpose(fp64
, glsl_type::dmat3x4_type
),
1334 _transpose(fp64
, glsl_type::dmat4x2_type
),
1335 _transpose(fp64
, glsl_type::dmat4x3_type
),
1340 FIUD(greaterThanEqual
)
1345 _any(glsl_type::bvec2_type
),
1346 _any(glsl_type::bvec3_type
),
1347 _any(glsl_type::bvec4_type
),
1351 _all(glsl_type::bvec2_type
),
1352 _all(glsl_type::bvec3_type
),
1353 _all(glsl_type::bvec4_type
),
1357 _not(glsl_type::bvec2_type
),
1358 _not(glsl_type::bvec3_type
),
1359 _not(glsl_type::bvec4_type
),
1362 add_function("textureSize",
1363 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1364 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1365 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1367 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1368 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1369 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1371 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1372 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1373 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1375 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1376 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1377 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1379 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1380 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1381 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1383 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1384 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1385 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1386 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1387 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1388 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1390 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1391 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1393 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1394 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1395 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1396 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1398 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1399 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1400 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1401 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1403 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1404 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1405 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1406 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1407 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1408 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1410 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1411 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1412 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1415 add_function("texture",
1416 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1417 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1418 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1420 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1421 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1422 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1424 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1425 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1426 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1428 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1429 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1430 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1432 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1433 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1434 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1436 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1437 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1438 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1440 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1441 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1442 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1444 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1445 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1446 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1448 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1449 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1450 /* samplerCubeArrayShadow is special; it has an extra parameter
1451 * for the shadow comparitor since there is no vec5 type.
1453 _textureCubeArrayShadow(),
1455 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1456 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1457 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1459 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1461 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1462 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1463 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1465 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1466 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1467 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1469 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1470 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1471 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1473 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1474 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1475 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1477 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1478 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1479 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1481 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1482 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1483 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1485 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1486 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1487 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1489 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1490 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1491 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1493 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1496 add_function("textureLod",
1497 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1498 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1499 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1501 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1502 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1503 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1505 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1506 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1507 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1509 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1510 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1511 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1513 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1514 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1516 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1517 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1518 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1520 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1521 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1522 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1524 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1525 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1526 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1528 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1531 add_function("textureOffset",
1532 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1533 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1534 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1536 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1537 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1538 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1540 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1541 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1542 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1544 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1545 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1546 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1548 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1550 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1551 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1553 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1554 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1555 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1557 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1558 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1559 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1561 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1563 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1564 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1565 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1567 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1568 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1569 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1571 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1572 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1573 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1575 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1576 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1578 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1579 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1580 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1582 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1583 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1584 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1586 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1589 add_function("textureProj",
1590 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1591 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1592 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1593 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1594 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1595 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1597 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1598 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1599 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1600 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1601 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1602 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1604 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1605 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1606 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1608 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1609 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1611 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1612 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1613 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1614 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1615 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1616 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1618 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1620 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1621 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1622 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1623 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1624 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1625 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1627 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1628 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1629 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1630 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1631 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1632 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1634 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1635 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1636 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1638 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1639 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1642 add_function("texelFetch",
1643 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1644 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1645 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1647 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1648 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1649 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1651 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1652 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1653 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1655 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1656 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1657 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1659 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1660 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1661 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1663 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1664 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1665 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1667 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1668 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1669 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1671 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1672 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1673 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1675 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1676 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1677 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1680 add_function("texelFetchOffset",
1681 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1682 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1683 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1685 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1686 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1687 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1689 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1690 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1691 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1693 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1694 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1695 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1697 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1698 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1699 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1701 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1702 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1703 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1707 add_function("textureProjOffset",
1708 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1709 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1710 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1711 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1712 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1713 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1715 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1716 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1717 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1718 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1719 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1720 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1722 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1723 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1724 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1726 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1727 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1729 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1730 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1731 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1732 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1733 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1734 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1736 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1738 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1739 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1740 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1741 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1742 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1743 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1745 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1746 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1747 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1748 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1749 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1750 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1752 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1753 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1754 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1756 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1757 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1760 add_function("textureLodOffset",
1761 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1762 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1763 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1765 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1766 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1767 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1769 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1770 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1771 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1773 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1774 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1776 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1777 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1778 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1780 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1781 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1782 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1784 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1787 add_function("textureProjLod",
1788 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1789 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1790 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1791 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1792 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1793 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1795 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1796 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1797 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1798 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1799 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1800 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1802 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1803 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1804 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1806 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1807 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1810 add_function("textureProjLodOffset",
1811 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1812 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1813 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1814 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1815 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1816 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1818 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1819 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1820 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1821 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1822 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1823 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1825 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1826 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1827 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1829 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1830 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1833 add_function("textureGrad",
1834 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1835 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1836 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1838 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1839 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1840 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1842 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1843 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1844 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1846 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1847 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1848 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1850 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1851 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1852 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1854 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1856 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1857 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1858 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1860 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1861 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1862 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1864 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1865 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1866 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1868 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1869 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1870 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1872 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1873 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1876 add_function("textureGradOffset",
1877 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1878 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1879 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1881 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1882 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1883 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1885 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1886 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1887 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1889 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1890 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1891 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1893 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1895 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1896 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1898 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1899 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1900 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1902 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1903 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1904 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1906 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1907 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1910 add_function("textureProjGrad",
1911 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1912 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1913 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1914 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1915 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1916 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1918 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1919 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1920 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1921 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1922 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1923 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1925 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1926 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1927 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1929 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1930 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1931 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1932 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1933 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1934 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1936 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1938 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1939 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1942 add_function("textureProjGradOffset",
1943 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1944 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1945 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1946 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1947 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1948 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1950 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1951 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1952 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1953 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1954 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1955 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1957 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1958 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1959 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1962 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1963 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1965 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1966 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1971 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1974 add_function("EmitVertex", _EmitVertex(), NULL
);
1975 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1976 add_function("EmitStreamVertex",
1977 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1978 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1980 add_function("EndStreamPrimitive",
1981 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1982 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
1984 add_function("barrier", _barrier(), NULL
);
1986 add_function("textureQueryLOD",
1987 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1988 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1989 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1991 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1992 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1993 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1995 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1996 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1997 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1999 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2000 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2001 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2003 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2004 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2005 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2007 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2008 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2009 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2011 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2012 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2013 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2015 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2016 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2017 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2018 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2019 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2020 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2023 add_function("textureQueryLod",
2024 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2025 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2026 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2028 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2029 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2030 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2032 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2033 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2034 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2036 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2037 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2038 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2040 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2041 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2042 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2044 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2045 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2046 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2048 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2049 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2050 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2052 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2053 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2054 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2055 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2056 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2057 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2060 add_function("textureQueryLevels",
2061 _textureQueryLevels(glsl_type::sampler1D_type
),
2062 _textureQueryLevels(glsl_type::sampler2D_type
),
2063 _textureQueryLevels(glsl_type::sampler3D_type
),
2064 _textureQueryLevels(glsl_type::samplerCube_type
),
2065 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2066 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2067 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2068 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2069 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2070 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2071 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2072 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2073 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2075 _textureQueryLevels(glsl_type::isampler1D_type
),
2076 _textureQueryLevels(glsl_type::isampler2D_type
),
2077 _textureQueryLevels(glsl_type::isampler3D_type
),
2078 _textureQueryLevels(glsl_type::isamplerCube_type
),
2079 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2080 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2081 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2083 _textureQueryLevels(glsl_type::usampler1D_type
),
2084 _textureQueryLevels(glsl_type::usampler2D_type
),
2085 _textureQueryLevels(glsl_type::usampler3D_type
),
2086 _textureQueryLevels(glsl_type::usamplerCube_type
),
2087 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2088 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2089 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2093 add_function("texture1D",
2094 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2095 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2098 add_function("texture1DArray",
2099 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2100 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2103 add_function("texture1DProj",
2104 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2105 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2106 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2107 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2110 add_function("texture1DLod",
2111 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2114 add_function("texture1DArrayLod",
2115 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2118 add_function("texture1DProjLod",
2119 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2120 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2123 add_function("texture2D",
2124 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2125 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2126 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2129 add_function("texture2DArray",
2130 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2131 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2134 add_function("texture2DProj",
2135 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2136 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2137 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2138 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2139 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2140 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2143 add_function("texture2DLod",
2144 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2147 add_function("texture2DArrayLod",
2148 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2151 add_function("texture2DProjLod",
2152 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2153 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2156 add_function("texture3D",
2157 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2158 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2161 add_function("texture3DProj",
2162 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2163 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2166 add_function("texture3DLod",
2167 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2170 add_function("texture3DProjLod",
2171 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2174 add_function("textureCube",
2175 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2176 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2179 add_function("textureCubeLod",
2180 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2183 add_function("texture2DRect",
2184 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2187 add_function("texture2DRectProj",
2188 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2189 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2192 add_function("shadow1D",
2193 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2194 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2197 add_function("shadow1DArray",
2198 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2199 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2202 add_function("shadow2D",
2203 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2204 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2207 add_function("shadow2DArray",
2208 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2209 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2212 add_function("shadow1DProj",
2213 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2214 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2217 add_function("shadow2DProj",
2218 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2219 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2222 add_function("shadow1DLod",
2223 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2226 add_function("shadow2DLod",
2227 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2230 add_function("shadow1DArrayLod",
2231 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2234 add_function("shadow1DProjLod",
2235 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2238 add_function("shadow2DProjLod",
2239 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2242 add_function("shadow2DRect",
2243 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2246 add_function("shadow2DRectProj",
2247 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2250 add_function("texture1DGradARB",
2251 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2254 add_function("texture1DProjGradARB",
2255 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2256 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2259 add_function("texture2DGradARB",
2260 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2263 add_function("texture2DProjGradARB",
2264 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2265 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2268 add_function("texture3DGradARB",
2269 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2272 add_function("texture3DProjGradARB",
2273 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2276 add_function("textureCubeGradARB",
2277 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2280 add_function("shadow1DGradARB",
2281 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2284 add_function("shadow1DProjGradARB",
2285 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2288 add_function("shadow2DGradARB",
2289 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2292 add_function("shadow2DProjGradARB",
2293 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2296 add_function("texture2DRectGradARB",
2297 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2300 add_function("texture2DRectProjGradARB",
2301 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2302 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2305 add_function("shadow2DRectGradARB",
2306 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2309 add_function("shadow2DRectProjGradARB",
2310 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2313 add_function("textureGather",
2314 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2315 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2316 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2318 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2319 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2320 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2322 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2323 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2324 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2326 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2327 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2328 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2330 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2331 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2332 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2334 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2335 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2336 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2338 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2339 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2340 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2342 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2343 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2344 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2346 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2347 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2348 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2350 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2351 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2352 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2354 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2355 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2356 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2357 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2358 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2361 add_function("textureGatherOffset",
2362 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2363 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2364 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2366 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2367 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2368 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2370 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2371 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2372 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2374 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2375 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2376 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2378 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2379 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2380 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2382 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2383 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2384 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2386 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2387 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2388 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2390 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2391 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2392 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2394 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2395 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2396 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2398 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2399 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2400 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2402 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2403 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2404 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2406 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2407 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2410 add_function("textureGatherOffsets",
2411 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2412 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2413 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2415 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2416 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2417 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2419 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2420 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2421 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2423 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2424 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2425 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2427 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2428 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2429 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2431 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2432 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2433 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2435 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2436 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2437 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2462 add_function("ldexp",
2463 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2464 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2465 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2466 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2467 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2468 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2469 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2470 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2473 add_function("frexp",
2474 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2475 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2476 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2477 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2478 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2479 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2480 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2481 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2483 add_function("uaddCarry",
2484 _uaddCarry(glsl_type::uint_type
),
2485 _uaddCarry(glsl_type::uvec2_type
),
2486 _uaddCarry(glsl_type::uvec3_type
),
2487 _uaddCarry(glsl_type::uvec4_type
),
2489 add_function("usubBorrow",
2490 _usubBorrow(glsl_type::uint_type
),
2491 _usubBorrow(glsl_type::uvec2_type
),
2492 _usubBorrow(glsl_type::uvec3_type
),
2493 _usubBorrow(glsl_type::uvec4_type
),
2495 add_function("imulExtended",
2496 _mulExtended(glsl_type::int_type
),
2497 _mulExtended(glsl_type::ivec2_type
),
2498 _mulExtended(glsl_type::ivec3_type
),
2499 _mulExtended(glsl_type::ivec4_type
),
2501 add_function("umulExtended",
2502 _mulExtended(glsl_type::uint_type
),
2503 _mulExtended(glsl_type::uvec2_type
),
2504 _mulExtended(glsl_type::uvec3_type
),
2505 _mulExtended(glsl_type::uvec4_type
),
2507 add_function("interpolateAtCentroid",
2508 _interpolateAtCentroid(glsl_type::float_type
),
2509 _interpolateAtCentroid(glsl_type::vec2_type
),
2510 _interpolateAtCentroid(glsl_type::vec3_type
),
2511 _interpolateAtCentroid(glsl_type::vec4_type
),
2513 add_function("interpolateAtOffset",
2514 _interpolateAtOffset(glsl_type::float_type
),
2515 _interpolateAtOffset(glsl_type::vec2_type
),
2516 _interpolateAtOffset(glsl_type::vec3_type
),
2517 _interpolateAtOffset(glsl_type::vec4_type
),
2519 add_function("interpolateAtSample",
2520 _interpolateAtSample(glsl_type::float_type
),
2521 _interpolateAtSample(glsl_type::vec2_type
),
2522 _interpolateAtSample(glsl_type::vec3_type
),
2523 _interpolateAtSample(glsl_type::vec4_type
),
2526 add_function("atomicCounter",
2527 _atomic_op("__intrinsic_atomic_read",
2528 shader_atomic_counters
),
2530 add_function("atomicCounterIncrement",
2531 _atomic_op("__intrinsic_atomic_increment",
2532 shader_atomic_counters
),
2534 add_function("atomicCounterDecrement",
2535 _atomic_op("__intrinsic_atomic_predecrement",
2536 shader_atomic_counters
),
2539 add_function("min3",
2540 _min3(glsl_type::float_type
),
2541 _min3(glsl_type::vec2_type
),
2542 _min3(glsl_type::vec3_type
),
2543 _min3(glsl_type::vec4_type
),
2545 _min3(glsl_type::int_type
),
2546 _min3(glsl_type::ivec2_type
),
2547 _min3(glsl_type::ivec3_type
),
2548 _min3(glsl_type::ivec4_type
),
2550 _min3(glsl_type::uint_type
),
2551 _min3(glsl_type::uvec2_type
),
2552 _min3(glsl_type::uvec3_type
),
2553 _min3(glsl_type::uvec4_type
),
2556 add_function("max3",
2557 _max3(glsl_type::float_type
),
2558 _max3(glsl_type::vec2_type
),
2559 _max3(glsl_type::vec3_type
),
2560 _max3(glsl_type::vec4_type
),
2562 _max3(glsl_type::int_type
),
2563 _max3(glsl_type::ivec2_type
),
2564 _max3(glsl_type::ivec3_type
),
2565 _max3(glsl_type::ivec4_type
),
2567 _max3(glsl_type::uint_type
),
2568 _max3(glsl_type::uvec2_type
),
2569 _max3(glsl_type::uvec3_type
),
2570 _max3(glsl_type::uvec4_type
),
2573 add_function("mid3",
2574 _mid3(glsl_type::float_type
),
2575 _mid3(glsl_type::vec2_type
),
2576 _mid3(glsl_type::vec3_type
),
2577 _mid3(glsl_type::vec4_type
),
2579 _mid3(glsl_type::int_type
),
2580 _mid3(glsl_type::ivec2_type
),
2581 _mid3(glsl_type::ivec3_type
),
2582 _mid3(glsl_type::ivec4_type
),
2584 _mid3(glsl_type::uint_type
),
2585 _mid3(glsl_type::uvec2_type
),
2586 _mid3(glsl_type::uvec3_type
),
2587 _mid3(glsl_type::uvec4_type
),
2590 add_image_functions(true);
2592 add_function("memoryBarrier",
2593 _memory_barrier(shader_image_load_store
),
2604 builtin_builder::add_function(const char *name
, ...)
2608 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2612 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2618 stuff
.push_tail(sig
);
2619 validate_ir_tree(&stuff
);
2622 f
->add_signature(sig
);
2626 shader
->symbols
->add_function(f
);
2630 builtin_builder::add_image_function(const char *name
,
2631 const char *intrinsic_name
,
2632 image_prototype_ctr prototype
,
2633 unsigned num_arguments
,
2636 static const glsl_type
*const types
[] = {
2637 glsl_type::image1D_type
,
2638 glsl_type::image2D_type
,
2639 glsl_type::image3D_type
,
2640 glsl_type::image2DRect_type
,
2641 glsl_type::imageCube_type
,
2642 glsl_type::imageBuffer_type
,
2643 glsl_type::image1DArray_type
,
2644 glsl_type::image2DArray_type
,
2645 glsl_type::imageCubeArray_type
,
2646 glsl_type::image2DMS_type
,
2647 glsl_type::image2DMSArray_type
,
2648 glsl_type::iimage1D_type
,
2649 glsl_type::iimage2D_type
,
2650 glsl_type::iimage3D_type
,
2651 glsl_type::iimage2DRect_type
,
2652 glsl_type::iimageCube_type
,
2653 glsl_type::iimageBuffer_type
,
2654 glsl_type::iimage1DArray_type
,
2655 glsl_type::iimage2DArray_type
,
2656 glsl_type::iimageCubeArray_type
,
2657 glsl_type::iimage2DMS_type
,
2658 glsl_type::iimage2DMSArray_type
,
2659 glsl_type::uimage1D_type
,
2660 glsl_type::uimage2D_type
,
2661 glsl_type::uimage3D_type
,
2662 glsl_type::uimage2DRect_type
,
2663 glsl_type::uimageCube_type
,
2664 glsl_type::uimageBuffer_type
,
2665 glsl_type::uimage1DArray_type
,
2666 glsl_type::uimage2DArray_type
,
2667 glsl_type::uimageCubeArray_type
,
2668 glsl_type::uimage2DMS_type
,
2669 glsl_type::uimage2DMSArray_type
2672 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2674 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2675 if (types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2676 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
))
2677 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2678 num_arguments
, flags
));
2681 shader
->symbols
->add_function(f
);
2685 builtin_builder::add_image_functions(bool glsl
)
2687 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2689 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2690 "__intrinsic_image_load",
2691 &builtin_builder::_image_prototype
, 0,
2692 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2693 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2694 IMAGE_FUNCTION_READ_ONLY
));
2696 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2697 "__intrinsic_image_store",
2698 &builtin_builder::_image_prototype
, 1,
2699 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2700 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2701 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2702 IMAGE_FUNCTION_WRITE_ONLY
));
2704 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2706 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2707 "__intrinsic_image_atomic_add",
2708 &builtin_builder::_image_prototype
, 1, atom_flags
);
2710 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2711 "__intrinsic_image_atomic_min",
2712 &builtin_builder::_image_prototype
, 1, atom_flags
);
2714 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2715 "__intrinsic_image_atomic_max",
2716 &builtin_builder::_image_prototype
, 1, atom_flags
);
2718 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2719 "__intrinsic_image_atomic_and",
2720 &builtin_builder::_image_prototype
, 1, atom_flags
);
2722 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2723 "__intrinsic_image_atomic_or",
2724 &builtin_builder::_image_prototype
, 1, atom_flags
);
2726 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2727 "__intrinsic_image_atomic_xor",
2728 &builtin_builder::_image_prototype
, 1, atom_flags
);
2730 add_image_function((glsl
? "imageAtomicExchange" :
2731 "__intrinsic_image_atomic_exchange"),
2732 "__intrinsic_image_atomic_exchange",
2733 &builtin_builder::_image_prototype
, 1, atom_flags
);
2735 add_image_function((glsl
? "imageAtomicCompSwap" :
2736 "__intrinsic_image_atomic_comp_swap"),
2737 "__intrinsic_image_atomic_comp_swap",
2738 &builtin_builder::_image_prototype
, 2, atom_flags
);
2740 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2741 "__intrinsic_image_size",
2742 &builtin_builder::_image_size_prototype
, 1,
2743 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2747 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2749 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2753 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2755 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2759 builtin_builder::imm(float f
, unsigned vector_elements
)
2761 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2765 builtin_builder::imm(int i
, unsigned vector_elements
)
2767 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2771 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2773 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2777 builtin_builder::imm(double d
, unsigned vector_elements
)
2779 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2783 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2785 return new(mem_ctx
) ir_constant(type
, &data
);
2788 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2790 ir_dereference_variable
*
2791 builtin_builder::var_ref(ir_variable
*var
)
2793 return new(mem_ctx
) ir_dereference_variable(var
);
2796 ir_dereference_array
*
2797 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2799 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2802 /** Return an element of a matrix */
2804 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2806 return swizzle(array_ref(var
, column
), row
, 1);
2810 * Implementations of built-in functions:
2813 ir_function_signature
*
2814 builtin_builder::new_sig(const glsl_type
*return_type
,
2815 builtin_available_predicate avail
,
2821 ir_function_signature
*sig
=
2822 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2825 va_start(ap
, num_params
);
2826 for (int i
= 0; i
< num_params
; i
++) {
2827 plist
.push_tail(va_arg(ap
, ir_variable
*));
2831 sig
->replace_parameters(&plist
);
2835 #define MAKE_SIG(return_type, avail, ...) \
2836 ir_function_signature *sig = \
2837 new_sig(return_type, avail, __VA_ARGS__); \
2838 ir_factory body(&sig->body, mem_ctx); \
2839 sig->is_defined = true;
2841 #define MAKE_INTRINSIC(return_type, avail, ...) \
2842 ir_function_signature *sig = \
2843 new_sig(return_type, avail, __VA_ARGS__); \
2844 sig->is_intrinsic = true;
2846 ir_function_signature
*
2847 builtin_builder::unop(builtin_available_predicate avail
,
2848 ir_expression_operation opcode
,
2849 const glsl_type
*return_type
,
2850 const glsl_type
*param_type
)
2852 ir_variable
*x
= in_var(param_type
, "x");
2853 MAKE_SIG(return_type
, avail
, 1, x
);
2854 body
.emit(ret(expr(opcode
, x
)));
2858 #define UNOP(NAME, OPCODE, AVAIL) \
2859 ir_function_signature * \
2860 builtin_builder::_##NAME(const glsl_type *type) \
2862 return unop(&AVAIL, OPCODE, type, type); \
2865 #define UNOPA(NAME, OPCODE) \
2866 ir_function_signature * \
2867 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
2869 return unop(avail, OPCODE, type, type); \
2872 ir_function_signature
*
2873 builtin_builder::binop(ir_expression_operation opcode
,
2874 builtin_available_predicate avail
,
2875 const glsl_type
*return_type
,
2876 const glsl_type
*param0_type
,
2877 const glsl_type
*param1_type
)
2879 ir_variable
*x
= in_var(param0_type
, "x");
2880 ir_variable
*y
= in_var(param1_type
, "y");
2881 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2882 body
.emit(ret(expr(opcode
, x
, y
)));
2886 #define BINOP(NAME, OPCODE, AVAIL) \
2887 ir_function_signature * \
2888 builtin_builder::_##NAME(const glsl_type *return_type, \
2889 const glsl_type *param0_type, \
2890 const glsl_type *param1_type) \
2892 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2896 * Angle and Trigonometry Functions @{
2899 ir_function_signature
*
2900 builtin_builder::_radians(const glsl_type
*type
)
2902 ir_variable
*degrees
= in_var(type
, "degrees");
2903 MAKE_SIG(type
, always_available
, 1, degrees
);
2904 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2908 ir_function_signature
*
2909 builtin_builder::_degrees(const glsl_type
*type
)
2911 ir_variable
*radians
= in_var(type
, "radians");
2912 MAKE_SIG(type
, always_available
, 1, radians
);
2913 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2917 UNOP(sin
, ir_unop_sin
, always_available
)
2918 UNOP(cos
, ir_unop_cos
, always_available
)
2920 ir_function_signature
*
2921 builtin_builder::_tan(const glsl_type
*type
)
2923 ir_variable
*theta
= in_var(type
, "theta");
2924 MAKE_SIG(type
, always_available
, 1, theta
);
2925 body
.emit(ret(div(sin(theta
), cos(theta
))));
2930 builtin_builder::asin_expr(ir_variable
*x
)
2934 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2937 add(imm(M_PI_4f
- 1.0f
),
2939 add(imm(0.086566724f
),
2940 mul(abs(x
), imm(-0.03102955f
))))))))));
2944 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2946 exec_list actual_params
;
2948 foreach_in_list(ir_variable
, var
, ¶ms
) {
2949 actual_params
.push_tail(var_ref(var
));
2952 ir_function_signature
*sig
=
2953 f
->exact_matching_signature(NULL
, &actual_params
);
2957 ir_dereference_variable
*deref
=
2958 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2960 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2963 ir_function_signature
*
2964 builtin_builder::_asin(const glsl_type
*type
)
2966 ir_variable
*x
= in_var(type
, "x");
2967 MAKE_SIG(type
, always_available
, 1, x
);
2969 body
.emit(ret(asin_expr(x
)));
2974 ir_function_signature
*
2975 builtin_builder::_acos(const glsl_type
*type
)
2977 ir_variable
*x
= in_var(type
, "x");
2978 MAKE_SIG(type
, always_available
, 1, x
);
2980 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
2985 ir_function_signature
*
2986 builtin_builder::_atan2(const glsl_type
*type
)
2988 ir_variable
*vec_y
= in_var(type
, "vec_y");
2989 ir_variable
*vec_x
= in_var(type
, "vec_x");
2990 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2992 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2993 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2994 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2995 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2996 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2997 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2998 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3000 /* If |x| >= 1.0e-8 * |y|: */
3002 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3004 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3006 /* Then...call atan(y/x) */
3007 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3009 /* ...and fix it up: */
3010 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3011 inner_if
->then_instructions
.push_tail(
3012 if_tree(gequal(y
, imm(0.0f
)),
3013 assign(r
, add(r
, imm(M_PIf
))),
3014 assign(r
, sub(r
, imm(M_PIf
)))));
3015 outer_then
.emit(inner_if
);
3018 outer_if
->else_instructions
.push_tail(
3019 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3021 body
.emit(outer_if
);
3023 body
.emit(assign(vec_result
, r
, 1 << i
));
3025 body
.emit(ret(vec_result
));
3031 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3034 * range-reduction, first step:
3036 * / y_over_x if |y_over_x| <= 1.0;
3038 * \ 1.0 / y_over_x otherwise
3040 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3041 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3047 * approximate atan by evaluating polynomial:
3049 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3050 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3051 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3053 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3054 body
.emit(assign(tmp
, mul(x
, x
)));
3055 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3057 imm(0.0536813784310406f
)),
3059 imm(0.1173503194786851f
)),
3061 imm(0.1938924977115610f
)),
3063 imm(0.3326756418091246f
)),
3065 imm(0.9999793128310355f
)),
3068 /* range-reduction fixup */
3069 body
.emit(assign(tmp
, add(tmp
,
3070 mul(b2f(greater(abs(y_over_x
),
3071 imm(1.0f
, type
->components()))),
3077 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3080 ir_function_signature
*
3081 builtin_builder::_atan(const glsl_type
*type
)
3083 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3084 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3086 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3087 do_atan(body
, type
, tmp
, y_over_x
);
3088 body
.emit(ret(tmp
));
3093 ir_function_signature
*
3094 builtin_builder::_sinh(const glsl_type
*type
)
3096 ir_variable
*x
= in_var(type
, "x");
3097 MAKE_SIG(type
, v130
, 1, x
);
3099 /* 0.5 * (e^x - e^(-x)) */
3100 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3105 ir_function_signature
*
3106 builtin_builder::_cosh(const glsl_type
*type
)
3108 ir_variable
*x
= in_var(type
, "x");
3109 MAKE_SIG(type
, v130
, 1, x
);
3111 /* 0.5 * (e^x + e^(-x)) */
3112 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3117 ir_function_signature
*
3118 builtin_builder::_tanh(const glsl_type
*type
)
3120 ir_variable
*x
= in_var(type
, "x");
3121 MAKE_SIG(type
, v130
, 1, x
);
3123 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3124 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3125 add(exp(x
), exp(neg(x
))))));
3130 ir_function_signature
*
3131 builtin_builder::_asinh(const glsl_type
*type
)
3133 ir_variable
*x
= in_var(type
, "x");
3134 MAKE_SIG(type
, v130
, 1, x
);
3136 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3141 ir_function_signature
*
3142 builtin_builder::_acosh(const glsl_type
*type
)
3144 ir_variable
*x
= in_var(type
, "x");
3145 MAKE_SIG(type
, v130
, 1, x
);
3147 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3151 ir_function_signature
*
3152 builtin_builder::_atanh(const glsl_type
*type
)
3154 ir_variable
*x
= in_var(type
, "x");
3155 MAKE_SIG(type
, v130
, 1, x
);
3157 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3158 sub(imm(1.0f
), x
))))));
3164 * Exponential Functions @{
3167 ir_function_signature
*
3168 builtin_builder::_pow(const glsl_type
*type
)
3170 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3173 UNOP(exp
, ir_unop_exp
, always_available
)
3174 UNOP(log
, ir_unop_log
, always_available
)
3175 UNOP(exp2
, ir_unop_exp2
, always_available
)
3176 UNOP(log2
, ir_unop_log2
, always_available
)
3177 UNOPA(sqrt
, ir_unop_sqrt
)
3178 UNOPA(inversesqrt
, ir_unop_rsq
)
3182 UNOPA(abs
, ir_unop_abs
)
3183 UNOPA(sign
, ir_unop_sign
)
3184 UNOPA(floor
, ir_unop_floor
)
3185 UNOPA(trunc
, ir_unop_trunc
)
3186 UNOPA(round
, ir_unop_round_even
)
3187 UNOPA(roundEven
, ir_unop_round_even
)
3188 UNOPA(ceil
, ir_unop_ceil
)
3189 UNOPA(fract
, ir_unop_fract
)
3191 ir_function_signature
*
3192 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3194 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3197 ir_function_signature
*
3198 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3200 ir_variable
*x
= in_var(type
, "x");
3201 ir_variable
*i
= out_var(type
, "i");
3202 MAKE_SIG(type
, avail
, 2, x
, i
);
3204 ir_variable
*t
= body
.make_temp(type
, "t");
3205 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3206 body
.emit(assign(i
, t
));
3207 body
.emit(ret(sub(x
, t
)));
3212 ir_function_signature
*
3213 builtin_builder::_min(builtin_available_predicate avail
,
3214 const glsl_type
*x_type
, const glsl_type
*y_type
)
3216 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3219 ir_function_signature
*
3220 builtin_builder::_max(builtin_available_predicate avail
,
3221 const glsl_type
*x_type
, const glsl_type
*y_type
)
3223 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3226 ir_function_signature
*
3227 builtin_builder::_clamp(builtin_available_predicate avail
,
3228 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3230 ir_variable
*x
= in_var(val_type
, "x");
3231 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3232 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3233 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3235 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3240 ir_function_signature
*
3241 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3243 ir_variable
*x
= in_var(val_type
, "x");
3244 ir_variable
*y
= in_var(val_type
, "y");
3245 ir_variable
*a
= in_var(blend_type
, "a");
3246 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3248 body
.emit(ret(lrp(x
, y
, a
)));
3253 ir_function_signature
*
3254 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3255 const glsl_type
*val_type
,
3256 const glsl_type
*blend_type
)
3258 ir_variable
*x
= in_var(val_type
, "x");
3259 ir_variable
*y
= in_var(val_type
, "y");
3260 ir_variable
*a
= in_var(blend_type
, "a");
3261 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3263 /* csel matches the ternary operator in that a selector of true choses the
3264 * first argument. This differs from mix(x, y, false) which choses the
3265 * second argument (to remain consistent with the interpolating version of
3266 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3268 * To handle the behavior mismatch, reverse the x and y arguments.
3270 body
.emit(ret(csel(a
, y
, x
)));
3275 ir_function_signature
*
3276 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3278 ir_variable
*edge
= in_var(edge_type
, "edge");
3279 ir_variable
*x
= in_var(x_type
, "x");
3280 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3282 ir_variable
*t
= body
.make_temp(x_type
, "t");
3283 if (x_type
->vector_elements
== 1) {
3284 /* Both are floats */
3285 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3286 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3288 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3289 } else if (edge_type
->vector_elements
== 1) {
3290 /* x is a vector but edge is a float */
3291 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3292 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3293 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3295 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3298 /* Both are vectors */
3299 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3300 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3301 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3304 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3314 ir_function_signature
*
3315 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3317 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3318 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3319 ir_variable
*x
= in_var(x_type
, "x");
3320 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3322 /* From the GLSL 1.10 specification:
3325 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3326 * return t * t * (3 - 2 * t);
3329 ir_variable
*t
= body
.make_temp(x_type
, "t");
3330 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3331 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3333 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3338 ir_function_signature
*
3339 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3341 ir_variable
*x
= in_var(type
, "x");
3342 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3344 body
.emit(ret(nequal(x
, x
)));
3349 ir_function_signature
*
3350 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3352 ir_variable
*x
= in_var(type
, "x");
3353 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3355 ir_constant_data infinities
;
3356 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3357 infinities
.f
[i
] = INFINITY
;
3360 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3365 ir_function_signature
*
3366 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3368 ir_variable
*x
= in_var(type
, "x");
3369 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3370 body
.emit(ret(bitcast_f2i(x
)));
3374 ir_function_signature
*
3375 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3377 ir_variable
*x
= in_var(type
, "x");
3378 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3379 body
.emit(ret(bitcast_f2u(x
)));
3383 ir_function_signature
*
3384 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3386 ir_variable
*x
= in_var(type
, "x");
3387 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3388 body
.emit(ret(bitcast_i2f(x
)));
3392 ir_function_signature
*
3393 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3395 ir_variable
*x
= in_var(type
, "x");
3396 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3397 body
.emit(ret(bitcast_u2f(x
)));
3401 ir_function_signature
*
3402 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3404 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3405 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3406 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3410 ir_function_signature
*
3411 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3413 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3414 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3415 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3419 ir_function_signature
*
3420 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3422 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3423 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3424 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3428 ir_function_signature
*
3429 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3431 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3432 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3433 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3437 ir_function_signature
*
3438 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3440 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3441 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3442 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3446 ir_function_signature
*
3447 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3449 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3450 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3451 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3456 ir_function_signature
*
3457 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3459 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3460 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3461 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3465 ir_function_signature
*
3466 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3468 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3469 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3470 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3474 ir_function_signature
*
3475 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3477 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3478 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3479 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3483 ir_function_signature
*
3484 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3486 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3487 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3488 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3492 ir_function_signature
*
3493 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3495 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3496 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3497 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3501 ir_function_signature
*
3502 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3504 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3505 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3506 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3510 ir_function_signature
*
3511 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3513 ir_variable
*x
= in_var(type
, "x");
3514 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3516 body
.emit(ret(sqrt(dot(x
, x
))));
3521 ir_function_signature
*
3522 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3524 ir_variable
*p0
= in_var(type
, "p0");
3525 ir_variable
*p1
= in_var(type
, "p1");
3526 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3528 if (type
->vector_elements
== 1) {
3529 body
.emit(ret(abs(sub(p0
, p1
))));
3531 ir_variable
*p
= body
.make_temp(type
, "p");
3532 body
.emit(assign(p
, sub(p0
, p1
)));
3533 body
.emit(ret(sqrt(dot(p
, p
))));
3539 ir_function_signature
*
3540 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3542 if (type
->vector_elements
== 1)
3543 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3545 return binop(ir_binop_dot
, avail
,
3546 type
->get_base_type(), type
, type
);
3549 ir_function_signature
*
3550 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3552 ir_variable
*a
= in_var(type
, "a");
3553 ir_variable
*b
= in_var(type
, "b");
3554 MAKE_SIG(type
, avail
, 2, a
, b
);
3556 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3557 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3559 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3560 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3565 ir_function_signature
*
3566 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3568 ir_variable
*x
= in_var(type
, "x");
3569 MAKE_SIG(type
, avail
, 1, x
);
3571 if (type
->vector_elements
== 1) {
3572 body
.emit(ret(sign(x
)));
3574 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3580 ir_function_signature
*
3581 builtin_builder::_ftransform()
3583 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3585 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3586 glsl_type::vec4_type
,
3587 var_ref(gl_ModelViewProjectionMatrix
),
3588 var_ref(gl_Vertex
))));
3590 /* FINISHME: Once the ir_expression() constructor handles type inference
3591 * for matrix operations, we can simplify this to:
3593 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3598 ir_function_signature
*
3599 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3601 ir_variable
*N
= in_var(type
, "N");
3602 ir_variable
*I
= in_var(type
, "I");
3603 ir_variable
*Nref
= in_var(type
, "Nref");
3604 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3606 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3607 ret(N
), ret(neg(N
))));
3612 ir_function_signature
*
3613 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3615 ir_variable
*I
= in_var(type
, "I");
3616 ir_variable
*N
= in_var(type
, "N");
3617 MAKE_SIG(type
, avail
, 2, I
, N
);
3619 /* I - 2 * dot(N, I) * N */
3620 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3625 ir_function_signature
*
3626 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3628 ir_variable
*I
= in_var(type
, "I");
3629 ir_variable
*N
= in_var(type
, "N");
3630 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3631 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3633 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3634 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3636 /* From the GLSL 1.10 specification:
3637 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3639 * return genType(0.0)
3641 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3643 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3644 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3645 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3646 mul(n_dot_i
, n_dot_i
)))))));
3647 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3648 ret(ir_constant::zero(mem_ctx
, type
)),
3649 ret(sub(mul(eta
, I
),
3650 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3655 ir_function_signature
*
3656 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3658 ir_variable
*x
= in_var(type
, "x");
3659 ir_variable
*y
= in_var(type
, "y");
3660 MAKE_SIG(type
, avail
, 2, x
, y
);
3662 ir_variable
*z
= body
.make_temp(type
, "z");
3663 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3664 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3671 ir_function_signature
*
3672 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3677 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3678 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3679 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3681 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3682 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3684 MAKE_SIG(type
, avail
, 2, c
, r
);
3686 ir_variable
*m
= body
.make_temp(type
, "m");
3687 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3688 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3695 ir_function_signature
*
3696 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3698 const glsl_type
*transpose_type
=
3699 glsl_type::get_instance(orig_type
->base_type
,
3700 orig_type
->matrix_columns
,
3701 orig_type
->vector_elements
);
3703 ir_variable
*m
= in_var(orig_type
, "m");
3704 MAKE_SIG(transpose_type
, avail
, 1, m
);
3706 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3707 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3708 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3709 body
.emit(assign(array_ref(t
, j
),
3710 matrix_elt(m
, i
, j
),
3719 ir_function_signature
*
3720 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3722 ir_variable
*m
= in_var(type
, "m");
3723 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3725 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3726 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3731 ir_function_signature
*
3732 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3734 ir_variable
*m
= in_var(type
, "m");
3735 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3738 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3739 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3742 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3743 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3746 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3747 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3749 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3750 mul(matrix_elt(m
, 0, 1), f2
)),
3751 mul(matrix_elt(m
, 0, 2), f3
))));
3756 ir_function_signature
*
3757 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3759 ir_variable
*m
= in_var(type
, "m");
3760 const glsl_type
*btype
= type
->get_base_type();
3761 MAKE_SIG(btype
, avail
, 1, m
);
3763 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3764 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3765 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3766 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3767 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3768 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3769 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3770 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3771 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3772 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3773 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3774 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3775 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3776 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3777 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3778 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3779 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3780 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3781 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3783 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)))));
3784 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)))));
3785 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)))));
3786 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)))));
3787 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)))));
3788 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)))));
3789 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)))));
3790 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)))));
3791 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)))));
3792 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)))));
3793 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)))));
3794 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)))));
3795 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)))));
3796 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)))));
3797 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)))));
3798 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)))));
3799 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)))));
3800 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)))));
3801 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)))));
3803 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3805 body
.emit(assign(adj_0
,
3806 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3807 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3808 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3810 body
.emit(assign(adj_0
, neg(
3811 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3812 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3813 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3815 body
.emit(assign(adj_0
,
3816 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3817 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3818 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3820 body
.emit(assign(adj_0
, neg(
3821 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3822 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3823 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3826 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3831 ir_function_signature
*
3832 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3834 ir_variable
*m
= in_var(type
, "m");
3835 MAKE_SIG(type
, avail
, 1, m
);
3837 ir_variable
*adj
= body
.make_temp(type
, "adj");
3838 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3839 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3840 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3841 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3843 ir_expression
*det
=
3844 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3845 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3847 body
.emit(ret(div(adj
, det
)));
3851 ir_function_signature
*
3852 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3854 ir_variable
*m
= in_var(type
, "m");
3855 const glsl_type
*btype
= type
->get_base_type();
3856 MAKE_SIG(type
, avail
, 1, m
);
3858 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
3859 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
3860 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
3862 body
.emit(assign(f11_22_21_12
,
3863 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3864 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3865 body
.emit(assign(f10_22_20_12
,
3866 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3867 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3868 body
.emit(assign(f10_21_20_11
,
3869 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3870 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3872 ir_variable
*adj
= body
.make_temp(type
, "adj");
3873 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3874 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3875 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3877 body
.emit(assign(array_ref(adj
, 0), neg(
3878 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3879 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3881 body
.emit(assign(array_ref(adj
, 1),
3882 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3883 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3885 body
.emit(assign(array_ref(adj
, 2), neg(
3886 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3887 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3890 body
.emit(assign(array_ref(adj
, 0),
3891 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3892 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3894 body
.emit(assign(array_ref(adj
, 1), neg(
3895 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3896 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3898 body
.emit(assign(array_ref(adj
, 2),
3899 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3900 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3903 ir_expression
*det
=
3904 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3905 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3906 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3908 body
.emit(ret(div(adj
, det
)));
3913 ir_function_signature
*
3914 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3916 ir_variable
*m
= in_var(type
, "m");
3917 const glsl_type
*btype
= type
->get_base_type();
3918 MAKE_SIG(type
, avail
, 1, m
);
3920 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3921 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3922 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3923 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3924 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3925 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3926 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3927 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3928 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3929 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3930 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3931 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3932 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3933 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3934 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3935 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3936 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3937 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3938 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3940 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)))));
3941 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)))));
3942 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)))));
3943 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)))));
3944 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)))));
3945 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)))));
3946 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)))));
3947 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)))));
3948 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)))));
3949 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)))));
3950 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)))));
3951 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)))));
3952 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)))));
3953 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)))));
3954 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)))));
3955 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)))));
3956 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)))));
3957 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)))));
3958 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)))));
3960 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
3961 body
.emit(assign(array_ref(adj
, 0),
3962 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3963 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3964 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3966 body
.emit(assign(array_ref(adj
, 1), neg(
3967 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3968 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3969 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3971 body
.emit(assign(array_ref(adj
, 2),
3972 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3973 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3974 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3976 body
.emit(assign(array_ref(adj
, 3), neg(
3977 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3978 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3979 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3982 body
.emit(assign(array_ref(adj
, 0), neg(
3983 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3984 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3985 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3987 body
.emit(assign(array_ref(adj
, 1),
3988 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3989 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3990 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3992 body
.emit(assign(array_ref(adj
, 2), neg(
3993 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3994 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3995 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3997 body
.emit(assign(array_ref(adj
, 3),
3998 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3999 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4000 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4003 body
.emit(assign(array_ref(adj
, 0),
4004 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4005 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4006 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4008 body
.emit(assign(array_ref(adj
, 1), neg(
4009 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4010 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4011 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4013 body
.emit(assign(array_ref(adj
, 2),
4014 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4015 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4016 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4018 body
.emit(assign(array_ref(adj
, 3), neg(
4019 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4020 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4021 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4024 body
.emit(assign(array_ref(adj
, 0), neg(
4025 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4026 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4027 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4029 body
.emit(assign(array_ref(adj
, 1),
4030 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4031 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4032 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4034 body
.emit(assign(array_ref(adj
, 2), neg(
4035 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4036 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4037 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4039 body
.emit(assign(array_ref(adj
, 3),
4040 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4041 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4042 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4045 ir_expression
*det
=
4046 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4047 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4048 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4049 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4051 body
.emit(ret(div(adj
, det
)));
4057 ir_function_signature
*
4058 builtin_builder::_lessThan(builtin_available_predicate avail
,
4059 const glsl_type
*type
)
4061 return binop(ir_binop_less
, avail
,
4062 glsl_type::bvec(type
->vector_elements
), type
, type
);
4065 ir_function_signature
*
4066 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4067 const glsl_type
*type
)
4069 return binop(ir_binop_lequal
, avail
,
4070 glsl_type::bvec(type
->vector_elements
), type
, type
);
4073 ir_function_signature
*
4074 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4075 const glsl_type
*type
)
4077 return binop(ir_binop_greater
, avail
,
4078 glsl_type::bvec(type
->vector_elements
), type
, type
);
4081 ir_function_signature
*
4082 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4083 const glsl_type
*type
)
4085 return binop(ir_binop_gequal
, avail
,
4086 glsl_type::bvec(type
->vector_elements
), type
, type
);
4089 ir_function_signature
*
4090 builtin_builder::_equal(builtin_available_predicate avail
,
4091 const glsl_type
*type
)
4093 return binop(ir_binop_equal
, avail
,
4094 glsl_type::bvec(type
->vector_elements
), type
, type
);
4097 ir_function_signature
*
4098 builtin_builder::_notEqual(builtin_available_predicate avail
,
4099 const glsl_type
*type
)
4101 return binop(ir_binop_nequal
, avail
,
4102 glsl_type::bvec(type
->vector_elements
), type
, type
);
4105 ir_function_signature
*
4106 builtin_builder::_any(const glsl_type
*type
)
4108 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4111 ir_function_signature
*
4112 builtin_builder::_all(const glsl_type
*type
)
4114 ir_variable
*v
= in_var(type
, "v");
4115 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4117 switch (type
->vector_elements
) {
4119 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4122 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4126 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4135 UNOP(not, ir_unop_logic_not
, always_available
)
4138 has_lod(const glsl_type
*sampler_type
)
4140 assert(sampler_type
->is_sampler());
4142 switch (sampler_type
->sampler_dimensionality
) {
4143 case GLSL_SAMPLER_DIM_RECT
:
4144 case GLSL_SAMPLER_DIM_BUF
:
4145 case GLSL_SAMPLER_DIM_MS
:
4152 ir_function_signature
*
4153 builtin_builder::_textureSize(builtin_available_predicate avail
,
4154 const glsl_type
*return_type
,
4155 const glsl_type
*sampler_type
)
4157 ir_variable
*s
= in_var(sampler_type
, "sampler");
4158 /* The sampler always exists; add optional lod later. */
4159 MAKE_SIG(return_type
, avail
, 1, s
);
4161 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4162 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4164 if (has_lod(sampler_type
)) {
4165 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4166 sig
->parameters
.push_tail(lod
);
4167 tex
->lod_info
.lod
= var_ref(lod
);
4169 tex
->lod_info
.lod
= imm(0u);
4172 body
.emit(ret(tex
));
4177 ir_function_signature
*
4178 builtin_builder::_texture(ir_texture_opcode opcode
,
4179 builtin_available_predicate avail
,
4180 const glsl_type
*return_type
,
4181 const glsl_type
*sampler_type
,
4182 const glsl_type
*coord_type
,
4185 ir_variable
*s
= in_var(sampler_type
, "sampler");
4186 ir_variable
*P
= in_var(coord_type
, "P");
4187 /* The sampler and coordinate always exist; add optional parameters later. */
4188 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4190 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4191 tex
->set_sampler(var_ref(s
), return_type
);
4193 const int coord_size
= sampler_type
->coordinate_components();
4195 if (coord_size
== coord_type
->vector_elements
) {
4196 tex
->coordinate
= var_ref(P
);
4198 /* The incoming coordinate also has the projector or shadow comparitor,
4199 * so we need to swizzle those away.
4201 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4204 /* The projector is always in the last component. */
4205 if (flags
& TEX_PROJECT
)
4206 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4208 if (sampler_type
->sampler_shadow
) {
4209 if (opcode
== ir_tg4
) {
4210 /* gather has refz as a separate parameter, immediately after the
4213 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4214 sig
->parameters
.push_tail(refz
);
4215 tex
->shadow_comparitor
= var_ref(refz
);
4217 /* The shadow comparitor is normally in the Z component, but a few types
4218 * have sufficiently large coordinates that it's in W.
4220 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4224 if (opcode
== ir_txl
) {
4225 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4226 sig
->parameters
.push_tail(lod
);
4227 tex
->lod_info
.lod
= var_ref(lod
);
4228 } else if (opcode
== ir_txd
) {
4229 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4230 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4231 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4232 sig
->parameters
.push_tail(dPdx
);
4233 sig
->parameters
.push_tail(dPdy
);
4234 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4235 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4238 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4239 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4240 ir_variable
*offset
=
4241 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4242 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4243 sig
->parameters
.push_tail(offset
);
4244 tex
->offset
= var_ref(offset
);
4247 if (flags
& TEX_OFFSET_ARRAY
) {
4248 ir_variable
*offsets
=
4249 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4250 "offsets", ir_var_const_in
);
4251 sig
->parameters
.push_tail(offsets
);
4252 tex
->offset
= var_ref(offsets
);
4255 if (opcode
== ir_tg4
) {
4256 if (flags
& TEX_COMPONENT
) {
4257 ir_variable
*component
=
4258 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4259 sig
->parameters
.push_tail(component
);
4260 tex
->lod_info
.component
= var_ref(component
);
4263 tex
->lod_info
.component
= imm(0);
4267 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4268 * inconsistent with both textureLodOffset and textureGradOffset.
4270 if (opcode
== ir_txb
) {
4271 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4272 sig
->parameters
.push_tail(bias
);
4273 tex
->lod_info
.bias
= var_ref(bias
);
4276 body
.emit(ret(tex
));
4281 ir_function_signature
*
4282 builtin_builder::_textureCubeArrayShadow()
4284 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4285 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4286 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4287 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4289 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4290 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4292 tex
->coordinate
= var_ref(P
);
4293 tex
->shadow_comparitor
= var_ref(compare
);
4295 body
.emit(ret(tex
));
4300 ir_function_signature
*
4301 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4302 const glsl_type
*return_type
,
4303 const glsl_type
*sampler_type
,
4304 const glsl_type
*coord_type
,
4305 const glsl_type
*offset_type
)
4307 ir_variable
*s
= in_var(sampler_type
, "sampler");
4308 ir_variable
*P
= in_var(coord_type
, "P");
4309 /* The sampler and coordinate always exist; add optional parameters later. */
4310 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4312 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4313 tex
->coordinate
= var_ref(P
);
4314 tex
->set_sampler(var_ref(s
), return_type
);
4316 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4317 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4318 sig
->parameters
.push_tail(sample
);
4319 tex
->lod_info
.sample_index
= var_ref(sample
);
4320 tex
->op
= ir_txf_ms
;
4321 } else if (has_lod(sampler_type
)) {
4322 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4323 sig
->parameters
.push_tail(lod
);
4324 tex
->lod_info
.lod
= var_ref(lod
);
4326 tex
->lod_info
.lod
= imm(0u);
4329 if (offset_type
!= NULL
) {
4330 ir_variable
*offset
=
4331 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4332 sig
->parameters
.push_tail(offset
);
4333 tex
->offset
= var_ref(offset
);
4336 body
.emit(ret(tex
));
4341 ir_function_signature
*
4342 builtin_builder::_EmitVertex()
4344 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4346 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4347 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4352 ir_function_signature
*
4353 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4354 const glsl_type
*stream_type
)
4356 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4358 * "Emit the current values of output variables to the current output
4359 * primitive on stream stream. The argument to stream must be a constant
4360 * integral expression."
4362 ir_variable
*stream
=
4363 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4365 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4367 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4372 ir_function_signature
*
4373 builtin_builder::_EndPrimitive()
4375 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4377 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4378 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4383 ir_function_signature
*
4384 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4385 const glsl_type
*stream_type
)
4387 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4389 * "Completes the current output primitive on stream stream and starts
4390 * a new one. The argument to stream must be a constant integral
4393 ir_variable
*stream
=
4394 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4396 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4398 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4403 ir_function_signature
*
4404 builtin_builder::_barrier()
4406 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4408 body
.emit(new(mem_ctx
) ir_barrier());
4412 ir_function_signature
*
4413 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4414 const glsl_type
*sampler_type
,
4415 const glsl_type
*coord_type
)
4417 ir_variable
*s
= in_var(sampler_type
, "sampler");
4418 ir_variable
*coord
= in_var(coord_type
, "coord");
4419 /* The sampler and coordinate always exist; add optional parameters later. */
4420 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4422 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4423 tex
->coordinate
= var_ref(coord
);
4424 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4426 body
.emit(ret(tex
));
4431 ir_function_signature
*
4432 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4434 ir_variable
*s
= in_var(sampler_type
, "sampler");
4435 const glsl_type
*return_type
= glsl_type::int_type
;
4436 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4438 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4439 tex
->set_sampler(var_ref(s
), return_type
);
4441 body
.emit(ret(tex
));
4446 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4447 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4448 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4449 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4450 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4451 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4453 ir_function_signature
*
4454 builtin_builder::_fwidth(const glsl_type
*type
)
4456 ir_variable
*p
= in_var(type
, "p");
4457 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4459 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4464 ir_function_signature
*
4465 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4467 ir_variable
*p
= in_var(type
, "p");
4468 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4470 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4471 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4476 ir_function_signature
*
4477 builtin_builder::_fwidthFine(const glsl_type
*type
)
4479 ir_variable
*p
= in_var(type
, "p");
4480 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4482 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4483 abs(expr(ir_unop_dFdy_fine
, p
)))));
4488 ir_function_signature
*
4489 builtin_builder::_noise1(const glsl_type
*type
)
4491 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4494 ir_function_signature
*
4495 builtin_builder::_noise2(const glsl_type
*type
)
4497 ir_variable
*p
= in_var(type
, "p");
4498 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4500 ir_constant_data b_offset
;
4501 b_offset
.f
[0] = 601.0f
;
4502 b_offset
.f
[1] = 313.0f
;
4503 b_offset
.f
[2] = 29.0f
;
4504 b_offset
.f
[3] = 277.0f
;
4506 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4507 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4508 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4509 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4510 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4511 body
.emit(assign(t
, a
, WRITEMASK_X
));
4512 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4518 ir_function_signature
*
4519 builtin_builder::_noise3(const glsl_type
*type
)
4521 ir_variable
*p
= in_var(type
, "p");
4522 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4524 ir_constant_data b_offset
;
4525 b_offset
.f
[0] = 601.0f
;
4526 b_offset
.f
[1] = 313.0f
;
4527 b_offset
.f
[2] = 29.0f
;
4528 b_offset
.f
[3] = 277.0f
;
4530 ir_constant_data c_offset
;
4531 c_offset
.f
[0] = 1559.0f
;
4532 c_offset
.f
[1] = 113.0f
;
4533 c_offset
.f
[2] = 1861.0f
;
4534 c_offset
.f
[3] = 797.0f
;
4536 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4537 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4538 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4539 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4540 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4541 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4542 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4543 body
.emit(assign(t
, a
, WRITEMASK_X
));
4544 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4545 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4551 ir_function_signature
*
4552 builtin_builder::_noise4(const glsl_type
*type
)
4554 ir_variable
*p
= in_var(type
, "p");
4555 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4557 ir_variable
*_p
= body
.make_temp(type
, "_p");
4559 ir_constant_data p_offset
;
4560 p_offset
.f
[0] = 1559.0f
;
4561 p_offset
.f
[1] = 113.0f
;
4562 p_offset
.f
[2] = 1861.0f
;
4563 p_offset
.f
[3] = 797.0f
;
4565 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4567 ir_constant_data offset
;
4568 offset
.f
[0] = 601.0f
;
4569 offset
.f
[1] = 313.0f
;
4570 offset
.f
[2] = 29.0f
;
4571 offset
.f
[3] = 277.0f
;
4573 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4574 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4575 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4576 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4577 ir_variable
*t
= body
.make_temp(glsl_type::vec4_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
, offset
)))));
4580 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4581 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4582 body
.emit(assign(t
, a
, WRITEMASK_X
));
4583 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4584 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4585 body
.emit(assign(t
, d
, WRITEMASK_W
));
4591 ir_function_signature
*
4592 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4594 ir_variable
*value
= in_var(type
, "value");
4595 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4596 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4597 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4599 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4604 ir_function_signature
*
4605 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4607 ir_variable
*base
= in_var(type
, "base");
4608 ir_variable
*insert
= in_var(type
, "insert");
4609 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4610 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4611 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4613 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4618 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4620 ir_function_signature
*
4621 builtin_builder::_bitCount(const glsl_type
*type
)
4623 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4624 glsl_type::ivec(type
->vector_elements
), type
);
4627 ir_function_signature
*
4628 builtin_builder::_findLSB(const glsl_type
*type
)
4630 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4631 glsl_type::ivec(type
->vector_elements
), type
);
4634 ir_function_signature
*
4635 builtin_builder::_findMSB(const glsl_type
*type
)
4637 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4638 glsl_type::ivec(type
->vector_elements
), type
);
4641 ir_function_signature
*
4642 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4644 ir_variable
*a
= in_var(type
, "a");
4645 ir_variable
*b
= in_var(type
, "b");
4646 ir_variable
*c
= in_var(type
, "c");
4647 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4649 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4654 ir_function_signature
*
4655 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4657 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4660 ir_function_signature
*
4661 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4663 ir_variable
*x
= in_var(x_type
, "x");
4664 ir_variable
*exponent
= out_var(exp_type
, "exp");
4665 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4667 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4669 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4673 ir_function_signature
*
4674 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4676 ir_variable
*x
= in_var(x_type
, "x");
4677 ir_variable
*exponent
= out_var(exp_type
, "exp");
4678 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4680 const unsigned vec_elem
= x_type
->vector_elements
;
4681 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4682 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4684 /* Single-precision floating-point values are stored as
4689 * An exponent shift of 23 will shift the mantissa out, leaving only the
4690 * exponent and sign bit (which itself may be zero, if the absolute value
4691 * was taken before the bitcast and shift.
4693 ir_constant
*exponent_shift
= imm(23);
4694 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4696 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4698 /* Exponent of floating-point values in the range [0.5, 1.0). */
4699 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4701 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4702 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4704 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4705 * to unsigned integers to ensure that 1 bits aren't shifted in.
4707 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4708 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4709 imm(0, vec_elem
)))));
4711 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4712 body
.emit(assign(bits
, bitcast_f2u(x
)));
4713 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4714 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4715 imm(0u, vec_elem
)))));
4716 body
.emit(ret(bitcast_u2f(bits
)));
4721 ir_function_signature
*
4722 builtin_builder::_uaddCarry(const glsl_type
*type
)
4724 ir_variable
*x
= in_var(type
, "x");
4725 ir_variable
*y
= in_var(type
, "y");
4726 ir_variable
*carry
= out_var(type
, "carry");
4727 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4729 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4730 body
.emit(ret(add(x
, y
)));
4735 ir_function_signature
*
4736 builtin_builder::_usubBorrow(const glsl_type
*type
)
4738 ir_variable
*x
= in_var(type
, "x");
4739 ir_variable
*y
= in_var(type
, "y");
4740 ir_variable
*borrow
= out_var(type
, "borrow");
4741 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4743 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4744 body
.emit(ret(sub(x
, y
)));
4750 * For both imulExtended() and umulExtended() built-ins.
4752 ir_function_signature
*
4753 builtin_builder::_mulExtended(const glsl_type
*type
)
4755 ir_variable
*x
= in_var(type
, "x");
4756 ir_variable
*y
= in_var(type
, "y");
4757 ir_variable
*msb
= out_var(type
, "msb");
4758 ir_variable
*lsb
= out_var(type
, "lsb");
4759 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
4761 body
.emit(assign(msb
, imul_high(x
, y
)));
4762 body
.emit(assign(lsb
, mul(x
, y
)));
4767 ir_function_signature
*
4768 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4770 ir_variable
*interpolant
= in_var(type
, "interpolant");
4771 interpolant
->data
.must_be_shader_input
= 1;
4772 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4774 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4779 ir_function_signature
*
4780 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4782 ir_variable
*interpolant
= in_var(type
, "interpolant");
4783 interpolant
->data
.must_be_shader_input
= 1;
4784 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4785 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4787 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4792 ir_function_signature
*
4793 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4795 ir_variable
*interpolant
= in_var(type
, "interpolant");
4796 interpolant
->data
.must_be_shader_input
= 1;
4797 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4798 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4800 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4805 ir_function_signature
*
4806 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4808 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4809 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4813 ir_function_signature
*
4814 builtin_builder::_atomic_op(const char *intrinsic
,
4815 builtin_available_predicate avail
)
4817 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4818 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4820 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4821 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4823 body
.emit(ret(retval
));
4827 ir_function_signature
*
4828 builtin_builder::_min3(const glsl_type
*type
)
4830 ir_variable
*x
= in_var(type
, "x");
4831 ir_variable
*y
= in_var(type
, "y");
4832 ir_variable
*z
= in_var(type
, "z");
4833 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4835 ir_expression
*min3
= min2(x
, min2(y
,z
));
4836 body
.emit(ret(min3
));
4841 ir_function_signature
*
4842 builtin_builder::_max3(const glsl_type
*type
)
4844 ir_variable
*x
= in_var(type
, "x");
4845 ir_variable
*y
= in_var(type
, "y");
4846 ir_variable
*z
= in_var(type
, "z");
4847 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4849 ir_expression
*max3
= max2(x
, max2(y
,z
));
4850 body
.emit(ret(max3
));
4855 ir_function_signature
*
4856 builtin_builder::_mid3(const glsl_type
*type
)
4858 ir_variable
*x
= in_var(type
, "x");
4859 ir_variable
*y
= in_var(type
, "y");
4860 ir_variable
*z
= in_var(type
, "z");
4861 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4863 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4864 body
.emit(ret(mid3
));
4869 ir_function_signature
*
4870 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4871 const char *intrinsic_name
,
4872 unsigned num_arguments
,
4875 const glsl_type
*data_type
= glsl_type::get_instance(
4876 image_type
->sampler_type
,
4877 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4879 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4880 glsl_type::void_type
: data_type
);
4882 /* Addressing arguments that are always present. */
4883 ir_variable
*image
= in_var(image_type
, "image");
4884 ir_variable
*coord
= in_var(
4885 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4887 const builtin_available_predicate avail
=
4888 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
4889 shader_image_load_store
);
4890 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
4892 /* Sample index for multisample images. */
4893 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4894 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4896 /* Data arguments. */
4897 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
4898 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
4899 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
4900 ralloc_free(arg_name
);
4903 /* Set the maximal set of qualifiers allowed for this image
4904 * built-in. Function calls with arguments having fewer
4905 * qualifiers than present in the prototype are allowed by the
4906 * spec, but not with more, i.e. this will make the compiler
4907 * accept everything that needs to be accepted, and reject cases
4908 * like loads from write-only or stores to read-only images.
4910 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
4911 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
4912 image
->data
.image_coherent
= true;
4913 image
->data
.image_volatile
= true;
4914 image
->data
.image_restrict
= true;
4919 ir_function_signature
*
4920 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
4921 const char *intrinsic_name
,
4922 unsigned num_arguments
,
4925 const glsl_type
*ret_type
;
4926 unsigned num_components
= image_type
->coordinate_components();
4928 /* From the ARB_shader_image_size extension:
4929 * "Cube images return the dimensions of one face."
4931 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
4932 !image_type
->sampler_array
) {
4936 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
4937 * supported by mesa.
4939 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
4941 ir_variable
*image
= in_var(image_type
, "image");
4942 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
4944 /* Set the maximal set of qualifiers allowed for this image
4945 * built-in. Function calls with arguments having fewer
4946 * qualifiers than present in the prototype are allowed by the
4947 * spec, but not with more, i.e. this will make the compiler
4948 * accept everything that needs to be accepted, and reject cases
4949 * like loads from write-only or stores to read-only images.
4951 image
->data
.image_read_only
= true;
4952 image
->data
.image_write_only
= true;
4953 image
->data
.image_coherent
= true;
4954 image
->data
.image_volatile
= true;
4955 image
->data
.image_restrict
= true;
4960 ir_function_signature
*
4961 builtin_builder::_image(image_prototype_ctr prototype
,
4962 const glsl_type
*image_type
,
4963 const char *intrinsic_name
,
4964 unsigned num_arguments
,
4967 ir_function_signature
*sig
= (this->*prototype
)(image_type
, intrinsic_name
,
4968 num_arguments
, flags
);
4970 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
4971 ir_factory
body(&sig
->body
, mem_ctx
);
4972 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
4974 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
4975 body
.emit(call(f
, NULL
, sig
->parameters
));
4977 ir_variable
*ret_val
=
4978 body
.make_temp(sig
->return_type
, "_ret_val");
4979 body
.emit(call(f
, ret_val
, sig
->parameters
));
4980 body
.emit(ret(ret_val
));
4983 sig
->is_defined
= true;
4986 sig
->is_intrinsic
= true;
4992 ir_function_signature
*
4993 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
4995 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
4999 ir_function_signature
*
5000 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
5002 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5003 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
5004 NULL
, sig
->parameters
));
5010 /******************************************************************************/
5012 /* The singleton instance of builtin_builder. */
5013 static builtin_builder builtins
;
5014 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5017 * External API (exposing the built-in module to the rest of the compiler):
5021 _mesa_glsl_initialize_builtin_functions()
5023 mtx_lock(&builtins_lock
);
5024 builtins
.initialize();
5025 mtx_unlock(&builtins_lock
);
5029 _mesa_glsl_release_builtin_functions()
5031 mtx_lock(&builtins_lock
);
5033 mtx_unlock(&builtins_lock
);
5036 ir_function_signature
*
5037 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5038 const char *name
, exec_list
*actual_parameters
)
5040 ir_function_signature
* s
;
5041 mtx_lock(&builtins_lock
);
5042 s
= builtins
.find(state
, name
, actual_parameters
);
5043 mtx_unlock(&builtins_lock
);
5048 _mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state
*state
,
5052 mtx_lock(&builtins_lock
);
5053 f
= builtins
.shader
->symbols
->get_function(name
);
5054 mtx_unlock(&builtins_lock
);
5059 _mesa_glsl_get_builtin_function_shader()
5061 return builtins
.shader
;