2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 #define M_PIf ((float) M_PI)
66 #define M_PI_2f ((float) M_PI_2)
67 #define M_PI_4f ((float) M_PI_4)
69 using namespace ir_builder
;
72 * Availability predicates:
76 always_available(const _mesa_glsl_parse_state
*)
82 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
84 return state
->stage
== MESA_SHADER_VERTEX
&&
85 state
->language_version
<= 130 &&
90 fs_only(const _mesa_glsl_parse_state
*state
)
92 return state
->stage
== MESA_SHADER_FRAGMENT
;
96 gs_only(const _mesa_glsl_parse_state
*state
)
98 return state
->stage
== MESA_SHADER_GEOMETRY
;
102 v110(const _mesa_glsl_parse_state
*state
)
104 return !state
->es_shader
;
108 v110_fs_only(const _mesa_glsl_parse_state
*state
)
110 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
114 v120(const _mesa_glsl_parse_state
*state
)
116 return state
->is_version(120, 300);
120 v130(const _mesa_glsl_parse_state
*state
)
122 return state
->is_version(130, 300);
126 v130_fs_only(const _mesa_glsl_parse_state
*state
)
128 return state
->is_version(130, 300) &&
129 state
->stage
== MESA_SHADER_FRAGMENT
;
133 v140(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 0);
139 es31(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(0, 310);
145 texture_rectangle(const _mesa_glsl_parse_state
*state
)
147 return state
->ARB_texture_rectangle_enable
;
151 texture_external(const _mesa_glsl_parse_state
*state
)
153 return state
->OES_EGL_image_external_enable
;
156 /** True if texturing functions with explicit LOD are allowed. */
158 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
160 /* Texturing functions with "Lod" in their name exist:
161 * - In the vertex shader stage (for all languages)
162 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
163 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
165 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
166 * don't need to explicitly check state->es_shader.
168 return state
->stage
== MESA_SHADER_VERTEX
||
169 state
->is_version(130, 300) ||
170 state
->ARB_shader_texture_lod_enable
;
174 v110_lod(const _mesa_glsl_parse_state
*state
)
176 return !state
->es_shader
&& lod_exists_in_stage(state
);
180 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_shader_texture_lod_enable
;
186 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
188 return state
->ARB_shader_texture_lod_enable
&&
189 state
->ARB_texture_rectangle_enable
;
193 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
195 return state
->is_version(330, 300) ||
196 state
->ARB_shader_bit_encoding_enable
||
197 state
->ARB_gpu_shader5_enable
;
201 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
203 return state
->is_version(450, 310) ||
204 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
208 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
210 return state
->ARB_shading_language_packing_enable
||
211 state
->is_version(420, 300);
215 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->ARB_gpu_shader5_enable
||
219 state
->is_version(400, 300);
223 gpu_shader5(const _mesa_glsl_parse_state
*state
)
225 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
229 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
231 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
235 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
237 return state
->ARB_shading_language_packing_enable
||
238 state
->ARB_gpu_shader5_enable
||
239 state
->is_version(400, 310);
243 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
245 return state
->stage
== MESA_SHADER_FRAGMENT
&&
246 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
251 texture_array_lod(const _mesa_glsl_parse_state
*state
)
253 return lod_exists_in_stage(state
) &&
254 state
->EXT_texture_array_enable
;
258 fs_texture_array(const _mesa_glsl_parse_state
*state
)
260 return state
->stage
== MESA_SHADER_FRAGMENT
&&
261 state
->EXT_texture_array_enable
;
265 texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->EXT_texture_array_enable
;
271 texture_multisample(const _mesa_glsl_parse_state
*state
)
273 return state
->is_version(150, 0) ||
274 state
->ARB_texture_multisample_enable
;
278 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
280 return state
->stage
== MESA_SHADER_FRAGMENT
&&
281 (state
->is_version(400, 0) ||
282 state
->ARB_texture_cube_map_array_enable
);
286 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
288 return state
->is_version(400, 0) ||
289 state
->ARB_texture_cube_map_array_enable
;
293 texture_query_levels(const _mesa_glsl_parse_state
*state
)
295 return state
->is_version(430, 0) ||
296 state
->ARB_texture_query_levels_enable
;
300 texture_query_lod(const _mesa_glsl_parse_state
*state
)
302 return state
->stage
== MESA_SHADER_FRAGMENT
&&
303 state
->ARB_texture_query_lod_enable
;
307 texture_gather(const _mesa_glsl_parse_state
*state
)
309 return state
->is_version(400, 0) ||
310 state
->ARB_texture_gather_enable
||
311 state
->ARB_gpu_shader5_enable
;
315 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
317 return state
->is_version(400, 310) ||
318 state
->ARB_texture_gather_enable
||
319 state
->ARB_gpu_shader5_enable
;
322 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
323 * used for relaxation of const offset requirements.
326 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
328 return !state
->is_version(400, 0) &&
329 !state
->ARB_gpu_shader5_enable
&&
330 (state
->ARB_texture_gather_enable
||
331 state
->is_version(0, 310));
334 /* Desktop GL or OES_standard_derivatives + fragment shader only */
336 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
338 return state
->stage
== MESA_SHADER_FRAGMENT
&&
339 (state
->is_version(110, 300) ||
340 state
->OES_standard_derivatives_enable
);
344 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
346 return state
->stage
== MESA_SHADER_FRAGMENT
&&
347 (state
->is_version(450, 0) ||
348 state
->ARB_derivative_control_enable
);
352 tex1d_lod(const _mesa_glsl_parse_state
*state
)
354 return !state
->es_shader
&& lod_exists_in_stage(state
);
357 /** True if sampler3D exists */
359 tex3d(const _mesa_glsl_parse_state
*state
)
361 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
362 * OES_texture_3D extension, and in GLSL ES 3.00.
364 return !state
->es_shader
||
365 state
->OES_texture_3D_enable
||
366 state
->language_version
>= 300;
370 fs_tex3d(const _mesa_glsl_parse_state
*state
)
372 return state
->stage
== MESA_SHADER_FRAGMENT
&&
373 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
377 tex3d_lod(const _mesa_glsl_parse_state
*state
)
379 return tex3d(state
) && lod_exists_in_stage(state
);
383 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
385 return state
->has_atomic_counters();
389 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
391 return state
->AMD_shader_trinary_minmax_enable
;
395 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
397 return (state
->is_version(420, 0) ||
398 state
->ARB_shader_image_load_store_enable
);
402 gs_streams(const _mesa_glsl_parse_state
*state
)
404 return gpu_shader5(state
) && gs_only(state
);
408 fp64(const _mesa_glsl_parse_state
*state
)
410 return state
->has_double();
414 barrier_supported(const _mesa_glsl_parse_state
*state
)
416 return state
->stage
== MESA_SHADER_COMPUTE
;
417 /* TODO: || stage->state == MESA_SHADER_TESS_CTRL; */
422 /******************************************************************************/
427 * builtin_builder: A singleton object representing the core of the built-in
430 * It generates IR for every built-in function signature, and organizes them
433 class builtin_builder
{
440 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
441 const char *name
, exec_list
*actual_parameters
);
444 * A shader to hold all the built-in signatures; created by this module.
446 * This includes signatures for every built-in, regardless of version or
447 * enabled extensions. The availability predicate associated with each
448 * signature allows matching_signature() to filter out the irrelevant ones.
455 /** Global variables used by built-in functions. */
456 ir_variable
*gl_ModelViewProjectionMatrix
;
457 ir_variable
*gl_Vertex
;
459 void create_shader();
460 void create_intrinsics();
461 void create_builtins();
464 * IR builder helpers:
466 * These convenience functions assist in emitting IR, but don't necessarily
467 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
470 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
471 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
472 ir_constant
*imm(float f
, unsigned vector_elements
=1);
473 ir_constant
*imm(int i
, unsigned vector_elements
=1);
474 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
475 ir_constant
*imm(double d
, unsigned vector_elements
=1);
476 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
477 ir_dereference_variable
*var_ref(ir_variable
*var
);
478 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
479 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
481 ir_expression
*asin_expr(ir_variable
*x
);
482 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
485 * Call function \param f with parameters specified as the linked
486 * list \param params of \c ir_variable objects. \param ret should
487 * point to the ir_variable that will hold the function return
488 * value, or be \c NULL if the function has void return type.
490 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
492 /** Create a new function and add the given signatures. */
493 void add_function(const char *name
, ...);
495 enum image_function_flags
{
496 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
497 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
498 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
499 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
500 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
501 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5)
505 * Create a new image built-in function for all known image types.
506 * \p flags is a bitfield of \c image_function_flags flags.
508 void add_image_function(const char *name
,
509 const char *intrinsic_name
,
510 unsigned num_arguments
,
514 * Create new functions for all known image built-ins and types.
515 * If \p glsl is \c true, use the GLSL built-in names and emit code
516 * to call into the actual compiler intrinsic. If \p glsl is
517 * false, emit a function prototype with no body for each image
520 void add_image_functions(bool glsl
);
522 ir_function_signature
*new_sig(const glsl_type
*return_type
,
523 builtin_available_predicate avail
,
524 int num_params
, ...);
527 * Function signature generators:
530 ir_function_signature
*unop(builtin_available_predicate avail
,
531 ir_expression_operation opcode
,
532 const glsl_type
*return_type
,
533 const glsl_type
*param_type
);
534 ir_function_signature
*binop(ir_expression_operation opcode
,
535 builtin_available_predicate avail
,
536 const glsl_type
*return_type
,
537 const glsl_type
*param0_type
,
538 const glsl_type
*param1_type
);
540 #define B0(X) ir_function_signature *_##X();
541 #define B1(X) ir_function_signature *_##X(const glsl_type *);
542 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
543 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
544 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
545 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
582 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
583 const glsl_type
*val_type
,
584 const glsl_type
*blend_type
);
593 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
594 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
595 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
596 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
597 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
598 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
599 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
600 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
601 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
602 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
603 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
604 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
617 BA1(determinant_mat2
);
618 BA1(determinant_mat3
);
619 BA1(determinant_mat4
);
627 BA1(greaterThanEqual
);
634 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
635 const glsl_type
*return_type
,
636 const glsl_type
*sampler_type
);
638 /** Flags to _texture() */
639 #define TEX_PROJECT 1
641 #define TEX_COMPONENT 4
642 #define TEX_OFFSET_NONCONST 8
643 #define TEX_OFFSET_ARRAY 16
645 ir_function_signature
*_texture(ir_texture_opcode opcode
,
646 builtin_available_predicate avail
,
647 const glsl_type
*return_type
,
648 const glsl_type
*sampler_type
,
649 const glsl_type
*coord_type
,
651 B0(textureCubeArrayShadow
);
652 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
653 const glsl_type
*return_type
,
654 const glsl_type
*sampler_type
,
655 const glsl_type
*coord_type
,
656 const glsl_type
*offset_type
= NULL
);
660 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
661 const glsl_type
*stream_type
);
662 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
663 const glsl_type
*stream_type
);
667 B1(textureQueryLevels
);
695 B1(interpolateAtCentroid
)
696 B1(interpolateAtOffset
)
697 B1(interpolateAtSample
)
699 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
700 ir_function_signature
*_atomic_op(const char *intrinsic
,
701 builtin_available_predicate avail
);
707 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
708 const char *intrinsic_name
,
709 unsigned num_arguments
,
711 ir_function_signature
*_image(const glsl_type
*image_type
,
712 const char *intrinsic_name
,
713 unsigned num_arguments
,
716 ir_function_signature
*_memory_barrier_intrinsic(
717 builtin_available_predicate avail
);
718 ir_function_signature
*_memory_barrier(
719 builtin_available_predicate avail
);
730 } /* anonymous namespace */
733 * Core builtin_builder functionality:
736 builtin_builder::builtin_builder()
738 gl_ModelViewProjectionMatrix(NULL
),
744 builtin_builder::~builtin_builder()
746 ralloc_free(mem_ctx
);
749 ir_function_signature
*
750 builtin_builder::find(_mesa_glsl_parse_state
*state
,
751 const char *name
, exec_list
*actual_parameters
)
753 /* The shader currently being compiled requested a built-in function;
754 * it needs to link against builtin_builder::shader in order to get them.
756 * Even if we don't find a matching signature, we still need to do this so
757 * that the "no matching signature" error will list potential candidates
758 * from the available built-ins.
760 state
->uses_builtin_functions
= true;
762 ir_function
*f
= shader
->symbols
->get_function(name
);
766 ir_function_signature
*sig
=
767 f
->matching_signature(state
, actual_parameters
, true);
775 builtin_builder::initialize()
777 /* If already initialized, don't do it again. */
781 mem_ctx
= ralloc_context(NULL
);
788 builtin_builder::release()
790 ralloc_free(mem_ctx
);
798 builtin_builder::create_shader()
800 /* The target doesn't actually matter. There's no target for generic
801 * GLSL utility code that could be linked against any stage, so just
802 * arbitrarily pick GL_VERTEX_SHADER.
804 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
805 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
807 gl_ModelViewProjectionMatrix
=
808 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
809 "gl_ModelViewProjectionMatrix",
812 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
814 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
815 shader
->symbols
->add_variable(gl_Vertex
);
821 * Create ir_function and ir_function_signature objects for each
825 builtin_builder::create_intrinsics()
827 add_function("__intrinsic_atomic_read",
828 _atomic_intrinsic(shader_atomic_counters
),
830 add_function("__intrinsic_atomic_increment",
831 _atomic_intrinsic(shader_atomic_counters
),
833 add_function("__intrinsic_atomic_predecrement",
834 _atomic_intrinsic(shader_atomic_counters
),
837 add_image_functions(false);
839 add_function("__intrinsic_memory_barrier",
840 _memory_barrier_intrinsic(shader_image_load_store
),
845 * Create ir_function and ir_function_signature objects for each built-in.
847 * Contains a list of every available built-in.
850 builtin_builder::create_builtins()
853 add_function(#NAME, \
854 _##NAME(glsl_type::float_type), \
855 _##NAME(glsl_type::vec2_type), \
856 _##NAME(glsl_type::vec3_type), \
857 _##NAME(glsl_type::vec4_type), \
861 add_function(#NAME, \
862 _##NAME(always_available, glsl_type::float_type), \
863 _##NAME(always_available, glsl_type::vec2_type), \
864 _##NAME(always_available, glsl_type::vec3_type), \
865 _##NAME(always_available, glsl_type::vec4_type), \
866 _##NAME(fp64, glsl_type::double_type), \
867 _##NAME(fp64, glsl_type::dvec2_type), \
868 _##NAME(fp64, glsl_type::dvec3_type), \
869 _##NAME(fp64, glsl_type::dvec4_type), \
872 #define FD130(NAME) \
873 add_function(#NAME, \
874 _##NAME(v130, glsl_type::float_type), \
875 _##NAME(v130, glsl_type::vec2_type), \
876 _##NAME(v130, glsl_type::vec3_type), \
877 _##NAME(v130, glsl_type::vec4_type), \
878 _##NAME(fp64, glsl_type::double_type), \
879 _##NAME(fp64, glsl_type::dvec2_type), \
880 _##NAME(fp64, glsl_type::dvec3_type), \
881 _##NAME(fp64, glsl_type::dvec4_type), \
884 #define FDGS5(NAME) \
885 add_function(#NAME, \
886 _##NAME(gpu_shader5, glsl_type::float_type), \
887 _##NAME(gpu_shader5, glsl_type::vec2_type), \
888 _##NAME(gpu_shader5, glsl_type::vec3_type), \
889 _##NAME(gpu_shader5, glsl_type::vec4_type), \
890 _##NAME(fp64, glsl_type::double_type), \
891 _##NAME(fp64, glsl_type::dvec2_type), \
892 _##NAME(fp64, glsl_type::dvec3_type), \
893 _##NAME(fp64, glsl_type::dvec4_type), \
897 add_function(#NAME, \
898 _##NAME(glsl_type::float_type), \
899 _##NAME(glsl_type::vec2_type), \
900 _##NAME(glsl_type::vec3_type), \
901 _##NAME(glsl_type::vec4_type), \
902 _##NAME(glsl_type::int_type), \
903 _##NAME(glsl_type::ivec2_type), \
904 _##NAME(glsl_type::ivec3_type), \
905 _##NAME(glsl_type::ivec4_type), \
909 add_function(#NAME, \
910 _##NAME(always_available, glsl_type::float_type), \
911 _##NAME(always_available, glsl_type::vec2_type), \
912 _##NAME(always_available, glsl_type::vec3_type), \
913 _##NAME(always_available, glsl_type::vec4_type), \
914 _##NAME(always_available, glsl_type::int_type), \
915 _##NAME(always_available, glsl_type::ivec2_type), \
916 _##NAME(always_available, glsl_type::ivec3_type), \
917 _##NAME(always_available, glsl_type::ivec4_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), \
925 add_function(#NAME, \
926 _##NAME(always_available, glsl_type::float_type), \
927 _##NAME(always_available, glsl_type::vec2_type), \
928 _##NAME(always_available, glsl_type::vec3_type), \
929 _##NAME(always_available, glsl_type::vec4_type), \
931 _##NAME(always_available, glsl_type::int_type), \
932 _##NAME(always_available, glsl_type::ivec2_type), \
933 _##NAME(always_available, glsl_type::ivec3_type), \
934 _##NAME(always_available, glsl_type::ivec4_type), \
936 _##NAME(v130, glsl_type::uint_type), \
937 _##NAME(v130, glsl_type::uvec2_type), \
938 _##NAME(v130, glsl_type::uvec3_type), \
939 _##NAME(v130, glsl_type::uvec4_type), \
940 _##NAME(fp64, glsl_type::double_type), \
941 _##NAME(fp64, glsl_type::dvec2_type), \
942 _##NAME(fp64, glsl_type::dvec3_type), \
943 _##NAME(fp64, glsl_type::dvec4_type), \
947 add_function(#NAME, \
948 _##NAME(glsl_type::int_type), \
949 _##NAME(glsl_type::ivec2_type), \
950 _##NAME(glsl_type::ivec3_type), \
951 _##NAME(glsl_type::ivec4_type), \
953 _##NAME(glsl_type::uint_type), \
954 _##NAME(glsl_type::uvec2_type), \
955 _##NAME(glsl_type::uvec3_type), \
956 _##NAME(glsl_type::uvec4_type), \
959 #define FIUBD(NAME) \
960 add_function(#NAME, \
961 _##NAME(always_available, glsl_type::float_type), \
962 _##NAME(always_available, glsl_type::vec2_type), \
963 _##NAME(always_available, glsl_type::vec3_type), \
964 _##NAME(always_available, glsl_type::vec4_type), \
966 _##NAME(always_available, glsl_type::int_type), \
967 _##NAME(always_available, glsl_type::ivec2_type), \
968 _##NAME(always_available, glsl_type::ivec3_type), \
969 _##NAME(always_available, glsl_type::ivec4_type), \
971 _##NAME(v130, glsl_type::uint_type), \
972 _##NAME(v130, glsl_type::uvec2_type), \
973 _##NAME(v130, glsl_type::uvec3_type), \
974 _##NAME(v130, glsl_type::uvec4_type), \
976 _##NAME(always_available, glsl_type::bool_type), \
977 _##NAME(always_available, glsl_type::bvec2_type), \
978 _##NAME(always_available, glsl_type::bvec3_type), \
979 _##NAME(always_available, glsl_type::bvec4_type), \
981 _##NAME(fp64, glsl_type::double_type), \
982 _##NAME(fp64, glsl_type::dvec2_type), \
983 _##NAME(fp64, glsl_type::dvec3_type), \
984 _##NAME(fp64, glsl_type::dvec4_type), \
987 #define FIUD2_MIXED(NAME) \
988 add_function(#NAME, \
989 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
990 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
991 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
992 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
994 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
995 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
996 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
998 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
999 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1000 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1001 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1003 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1004 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1005 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1007 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1008 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1009 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1010 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1012 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1013 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1014 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1016 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1017 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1018 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1019 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1020 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1021 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1022 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1033 add_function("atan",
1034 _atan(glsl_type::float_type
),
1035 _atan(glsl_type::vec2_type
),
1036 _atan(glsl_type::vec3_type
),
1037 _atan(glsl_type::vec4_type
),
1038 _atan2(glsl_type::float_type
),
1039 _atan2(glsl_type::vec2_type
),
1040 _atan2(glsl_type::vec3_type
),
1041 _atan2(glsl_type::vec4_type
),
1067 _mod(glsl_type::float_type
, glsl_type::float_type
),
1068 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1069 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1070 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1072 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1073 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1074 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1076 _mod(glsl_type::double_type
, glsl_type::double_type
),
1077 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1078 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1079 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1081 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1082 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1083 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1093 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1094 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1095 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1096 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1098 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1099 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1100 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1102 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1103 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1104 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1105 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1107 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1108 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1109 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1111 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1112 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1113 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1114 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1116 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1117 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1118 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1119 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1121 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1122 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1123 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1124 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1126 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1127 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1128 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1129 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1131 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1132 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1133 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1134 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1137 add_function("step",
1138 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1139 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1140 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1141 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1143 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1144 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1145 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1146 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1147 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1148 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1149 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1151 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1152 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1153 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1156 add_function("smoothstep",
1157 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1158 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1159 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1160 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1162 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1163 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1164 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1165 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1166 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1167 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1168 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1170 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1171 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1172 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1180 add_function("intBitsToFloat",
1181 _intBitsToFloat(glsl_type::int_type
),
1182 _intBitsToFloat(glsl_type::ivec2_type
),
1183 _intBitsToFloat(glsl_type::ivec3_type
),
1184 _intBitsToFloat(glsl_type::ivec4_type
),
1186 add_function("uintBitsToFloat",
1187 _uintBitsToFloat(glsl_type::uint_type
),
1188 _uintBitsToFloat(glsl_type::uvec2_type
),
1189 _uintBitsToFloat(glsl_type::uvec3_type
),
1190 _uintBitsToFloat(glsl_type::uvec4_type
),
1193 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1194 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1195 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1196 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1197 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1198 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1199 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1200 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1201 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1202 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1203 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1204 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1211 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1212 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1215 add_function("ftransform", _ftransform(), NULL
);
1220 add_function("matrixCompMult",
1221 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1222 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1223 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1224 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1225 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1226 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1227 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1228 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1229 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1230 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1231 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1232 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1233 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1234 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1235 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1236 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1237 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1238 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1240 add_function("outerProduct",
1241 _outerProduct(v120
, glsl_type::mat2_type
),
1242 _outerProduct(v120
, glsl_type::mat3_type
),
1243 _outerProduct(v120
, glsl_type::mat4_type
),
1244 _outerProduct(v120
, glsl_type::mat2x3_type
),
1245 _outerProduct(v120
, glsl_type::mat2x4_type
),
1246 _outerProduct(v120
, glsl_type::mat3x2_type
),
1247 _outerProduct(v120
, glsl_type::mat3x4_type
),
1248 _outerProduct(v120
, glsl_type::mat4x2_type
),
1249 _outerProduct(v120
, glsl_type::mat4x3_type
),
1250 _outerProduct(fp64
, glsl_type::dmat2_type
),
1251 _outerProduct(fp64
, glsl_type::dmat3_type
),
1252 _outerProduct(fp64
, glsl_type::dmat4_type
),
1253 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1254 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1255 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1256 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1257 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1258 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1260 add_function("determinant",
1261 _determinant_mat2(v120
, glsl_type::mat2_type
),
1262 _determinant_mat3(v120
, glsl_type::mat3_type
),
1263 _determinant_mat4(v120
, glsl_type::mat4_type
),
1264 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1265 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1266 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1269 add_function("inverse",
1270 _inverse_mat2(v120
, glsl_type::mat2_type
),
1271 _inverse_mat3(v120
, glsl_type::mat3_type
),
1272 _inverse_mat4(v120
, glsl_type::mat4_type
),
1273 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1274 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1275 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1277 add_function("transpose",
1278 _transpose(v120
, glsl_type::mat2_type
),
1279 _transpose(v120
, glsl_type::mat3_type
),
1280 _transpose(v120
, glsl_type::mat4_type
),
1281 _transpose(v120
, glsl_type::mat2x3_type
),
1282 _transpose(v120
, glsl_type::mat2x4_type
),
1283 _transpose(v120
, glsl_type::mat3x2_type
),
1284 _transpose(v120
, glsl_type::mat3x4_type
),
1285 _transpose(v120
, glsl_type::mat4x2_type
),
1286 _transpose(v120
, glsl_type::mat4x3_type
),
1287 _transpose(fp64
, glsl_type::dmat2_type
),
1288 _transpose(fp64
, glsl_type::dmat3_type
),
1289 _transpose(fp64
, glsl_type::dmat4_type
),
1290 _transpose(fp64
, glsl_type::dmat2x3_type
),
1291 _transpose(fp64
, glsl_type::dmat2x4_type
),
1292 _transpose(fp64
, glsl_type::dmat3x2_type
),
1293 _transpose(fp64
, glsl_type::dmat3x4_type
),
1294 _transpose(fp64
, glsl_type::dmat4x2_type
),
1295 _transpose(fp64
, glsl_type::dmat4x3_type
),
1300 FIUD(greaterThanEqual
)
1305 _any(glsl_type::bvec2_type
),
1306 _any(glsl_type::bvec3_type
),
1307 _any(glsl_type::bvec4_type
),
1311 _all(glsl_type::bvec2_type
),
1312 _all(glsl_type::bvec3_type
),
1313 _all(glsl_type::bvec4_type
),
1317 _not(glsl_type::bvec2_type
),
1318 _not(glsl_type::bvec3_type
),
1319 _not(glsl_type::bvec4_type
),
1322 add_function("textureSize",
1323 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1324 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1325 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1327 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1328 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1329 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1331 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1332 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1333 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1335 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1336 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1337 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1339 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1340 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1341 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1343 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1344 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1345 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1346 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1347 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1348 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1350 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1351 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1353 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1354 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1355 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1356 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1358 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1359 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1360 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1361 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1363 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1364 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1365 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1366 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1367 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1368 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1370 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1371 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1372 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1375 add_function("texture",
1376 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1377 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1378 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1380 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1381 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1382 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1384 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1385 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1386 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1388 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1389 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1390 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1392 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1393 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1394 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1396 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1397 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1398 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1400 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1401 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1402 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1404 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1405 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1406 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1408 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1409 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1410 /* samplerCubeArrayShadow is special; it has an extra parameter
1411 * for the shadow comparitor since there is no vec5 type.
1413 _textureCubeArrayShadow(),
1415 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1416 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1417 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1419 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1421 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1422 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1423 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1425 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1426 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1427 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1429 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1430 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1431 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1433 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1434 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1435 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1437 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1438 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1439 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1441 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1442 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1443 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1445 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1446 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1447 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1449 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1450 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1451 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1453 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1456 add_function("textureLod",
1457 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1458 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1459 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1461 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1462 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1463 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1465 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1466 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1467 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1469 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1470 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1471 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1473 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1474 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1476 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1477 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1478 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1480 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1481 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1482 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1484 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1485 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1486 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1488 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1491 add_function("textureOffset",
1492 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1493 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1494 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1496 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1497 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1498 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1500 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1501 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1502 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1504 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1505 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1506 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1508 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1510 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1511 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1513 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1514 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1515 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1517 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1518 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1519 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1521 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1523 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1524 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1525 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1527 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1528 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1529 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1531 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1532 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1533 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1535 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1536 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1538 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1539 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1540 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1542 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1543 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1544 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1546 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1549 add_function("textureProj",
1550 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1551 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1552 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1553 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1554 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1555 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1557 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1558 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1559 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1560 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1561 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1562 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1564 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1565 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1566 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1568 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1569 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1571 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1572 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1573 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1574 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1575 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1576 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1578 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1580 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1581 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1582 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1583 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1584 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1585 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1587 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1588 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1589 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1590 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1591 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1592 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1594 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1595 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1596 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1598 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1599 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1602 add_function("texelFetch",
1603 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1604 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1605 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1607 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1608 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1609 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1611 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1612 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1613 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1615 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1616 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1617 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1619 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1620 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1621 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1623 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1624 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1625 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1627 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1628 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1629 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1631 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1632 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1633 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1635 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1636 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1637 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1640 add_function("texelFetchOffset",
1641 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1642 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1643 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1645 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1646 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1647 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1649 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1650 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1651 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1653 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1654 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1655 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1657 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1658 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1659 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1661 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1662 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1663 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1667 add_function("textureProjOffset",
1668 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1669 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1670 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1671 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1672 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1673 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1675 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1676 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1677 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1678 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1679 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1680 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1682 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1683 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1684 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1686 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1687 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1689 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1690 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1691 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1692 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1693 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1694 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1696 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1698 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1699 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1700 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1701 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1702 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1703 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1705 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1706 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1707 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1708 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1709 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1710 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1712 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1713 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1714 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1716 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1717 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1720 add_function("textureLodOffset",
1721 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1722 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1723 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1725 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1726 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1727 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1729 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1730 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1731 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1733 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1734 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1736 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1737 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1738 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1740 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1741 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1742 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1744 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1747 add_function("textureProjLod",
1748 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1749 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1750 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1751 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1752 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1753 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1755 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1756 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1757 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1758 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1759 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1760 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1763 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1764 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1766 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1767 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1770 add_function("textureProjLodOffset",
1771 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1772 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1773 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1774 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1775 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1776 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1778 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1779 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1780 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1781 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1782 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1783 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1785 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1786 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1787 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1789 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1790 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1793 add_function("textureGrad",
1794 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1795 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1796 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1798 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1799 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1800 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1802 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1803 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1804 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1806 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1807 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1808 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1810 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1811 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1812 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1814 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1816 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1817 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1818 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1820 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1821 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1822 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1824 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1825 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1826 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1828 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1829 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1830 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1832 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1833 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1836 add_function("textureGradOffset",
1837 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1838 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1839 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1841 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1842 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1843 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1845 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1846 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1847 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1849 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1850 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1851 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1853 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1855 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1856 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1858 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1859 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1860 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1862 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1863 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1864 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1866 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1867 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1870 add_function("textureProjGrad",
1871 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1872 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1873 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1874 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1875 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1876 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1878 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1879 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1880 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1881 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1882 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1883 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1885 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1886 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1887 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1889 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1890 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1891 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1892 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1893 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1894 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1896 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1898 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1899 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1902 add_function("textureProjGradOffset",
1903 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1904 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1905 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1906 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1907 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1908 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1910 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1911 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1912 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1914 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1915 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1918 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1919 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1921 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1922 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1923 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1924 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1925 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1926 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1928 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1930 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1931 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1934 add_function("EmitVertex", _EmitVertex(), NULL
);
1935 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1936 add_function("EmitStreamVertex",
1937 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1938 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1940 add_function("EndStreamPrimitive",
1941 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1942 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
1944 add_function("barrier", _barrier(), NULL
);
1946 add_function("textureQueryLOD",
1947 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1948 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1949 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1951 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1952 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1953 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1955 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1956 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1957 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1959 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1960 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1961 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1963 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1964 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1965 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1967 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1968 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1969 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1971 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1972 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1973 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1975 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1976 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1977 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1978 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1979 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1980 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1983 add_function("textureQueryLevels",
1984 _textureQueryLevels(glsl_type::sampler1D_type
),
1985 _textureQueryLevels(glsl_type::sampler2D_type
),
1986 _textureQueryLevels(glsl_type::sampler3D_type
),
1987 _textureQueryLevels(glsl_type::samplerCube_type
),
1988 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1989 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1990 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1991 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1992 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1993 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1994 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1995 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1996 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1998 _textureQueryLevels(glsl_type::isampler1D_type
),
1999 _textureQueryLevels(glsl_type::isampler2D_type
),
2000 _textureQueryLevels(glsl_type::isampler3D_type
),
2001 _textureQueryLevels(glsl_type::isamplerCube_type
),
2002 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2003 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2004 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2006 _textureQueryLevels(glsl_type::usampler1D_type
),
2007 _textureQueryLevels(glsl_type::usampler2D_type
),
2008 _textureQueryLevels(glsl_type::usampler3D_type
),
2009 _textureQueryLevels(glsl_type::usamplerCube_type
),
2010 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2011 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2012 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2016 add_function("texture1D",
2017 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2018 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2021 add_function("texture1DArray",
2022 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2023 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2026 add_function("texture1DProj",
2027 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2028 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2029 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2030 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2033 add_function("texture1DLod",
2034 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2037 add_function("texture1DArrayLod",
2038 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2041 add_function("texture1DProjLod",
2042 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2043 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2046 add_function("texture2D",
2047 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2048 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2049 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2052 add_function("texture2DArray",
2053 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2054 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2057 add_function("texture2DProj",
2058 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2059 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2060 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2061 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2062 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2063 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2066 add_function("texture2DLod",
2067 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2070 add_function("texture2DArrayLod",
2071 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2074 add_function("texture2DProjLod",
2075 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2076 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2079 add_function("texture3D",
2080 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2081 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2084 add_function("texture3DProj",
2085 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2086 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2089 add_function("texture3DLod",
2090 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2093 add_function("texture3DProjLod",
2094 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2097 add_function("textureCube",
2098 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2099 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2102 add_function("textureCubeLod",
2103 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2106 add_function("texture2DRect",
2107 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2110 add_function("texture2DRectProj",
2111 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2112 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2115 add_function("shadow1D",
2116 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2117 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2120 add_function("shadow1DArray",
2121 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2122 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2125 add_function("shadow2D",
2126 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2127 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2130 add_function("shadow2DArray",
2131 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2132 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2135 add_function("shadow1DProj",
2136 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2137 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2140 add_function("shadow2DProj",
2141 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2142 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2145 add_function("shadow1DLod",
2146 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2149 add_function("shadow2DLod",
2150 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2153 add_function("shadow1DArrayLod",
2154 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2157 add_function("shadow1DProjLod",
2158 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2161 add_function("shadow2DProjLod",
2162 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2165 add_function("shadow2DRect",
2166 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2169 add_function("shadow2DRectProj",
2170 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2173 add_function("texture1DGradARB",
2174 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2177 add_function("texture1DProjGradARB",
2178 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2179 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2182 add_function("texture2DGradARB",
2183 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2186 add_function("texture2DProjGradARB",
2187 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2188 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2191 add_function("texture3DGradARB",
2192 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2195 add_function("texture3DProjGradARB",
2196 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2199 add_function("textureCubeGradARB",
2200 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2203 add_function("shadow1DGradARB",
2204 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2207 add_function("shadow1DProjGradARB",
2208 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2211 add_function("shadow2DGradARB",
2212 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2215 add_function("shadow2DProjGradARB",
2216 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2219 add_function("texture2DRectGradARB",
2220 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2223 add_function("texture2DRectProjGradARB",
2224 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2225 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2228 add_function("shadow2DRectGradARB",
2229 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2232 add_function("shadow2DRectProjGradARB",
2233 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2236 add_function("textureGather",
2237 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2238 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2239 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2241 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2242 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2243 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2245 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2246 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2247 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2249 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2250 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2251 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2253 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2254 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2255 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2257 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2258 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2259 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2261 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2262 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2263 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2265 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2266 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2267 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2269 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2270 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2271 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2273 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2274 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2275 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2277 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2278 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2279 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2280 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2281 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2284 add_function("textureGatherOffset",
2285 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2286 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2287 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2289 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2290 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2291 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2293 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2294 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2295 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2297 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2298 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2299 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2301 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2302 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2303 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2305 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2306 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2307 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2309 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2310 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2311 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2313 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2314 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2315 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2317 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2318 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2319 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2321 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2322 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2323 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2325 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2326 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2327 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2329 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2330 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2333 add_function("textureGatherOffsets",
2334 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2335 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2336 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2338 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2339 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2340 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2342 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2343 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2344 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2346 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2347 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2348 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2350 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2351 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2352 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2354 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2355 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2356 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2358 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2359 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2360 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2385 add_function("ldexp",
2386 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2387 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2388 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2389 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2390 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2391 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2392 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2393 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2396 add_function("frexp",
2397 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2398 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2399 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2400 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2401 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2402 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2403 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2404 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2406 add_function("uaddCarry",
2407 _uaddCarry(glsl_type::uint_type
),
2408 _uaddCarry(glsl_type::uvec2_type
),
2409 _uaddCarry(glsl_type::uvec3_type
),
2410 _uaddCarry(glsl_type::uvec4_type
),
2412 add_function("usubBorrow",
2413 _usubBorrow(glsl_type::uint_type
),
2414 _usubBorrow(glsl_type::uvec2_type
),
2415 _usubBorrow(glsl_type::uvec3_type
),
2416 _usubBorrow(glsl_type::uvec4_type
),
2418 add_function("imulExtended",
2419 _mulExtended(glsl_type::int_type
),
2420 _mulExtended(glsl_type::ivec2_type
),
2421 _mulExtended(glsl_type::ivec3_type
),
2422 _mulExtended(glsl_type::ivec4_type
),
2424 add_function("umulExtended",
2425 _mulExtended(glsl_type::uint_type
),
2426 _mulExtended(glsl_type::uvec2_type
),
2427 _mulExtended(glsl_type::uvec3_type
),
2428 _mulExtended(glsl_type::uvec4_type
),
2430 add_function("interpolateAtCentroid",
2431 _interpolateAtCentroid(glsl_type::float_type
),
2432 _interpolateAtCentroid(glsl_type::vec2_type
),
2433 _interpolateAtCentroid(glsl_type::vec3_type
),
2434 _interpolateAtCentroid(glsl_type::vec4_type
),
2436 add_function("interpolateAtOffset",
2437 _interpolateAtOffset(glsl_type::float_type
),
2438 _interpolateAtOffset(glsl_type::vec2_type
),
2439 _interpolateAtOffset(glsl_type::vec3_type
),
2440 _interpolateAtOffset(glsl_type::vec4_type
),
2442 add_function("interpolateAtSample",
2443 _interpolateAtSample(glsl_type::float_type
),
2444 _interpolateAtSample(glsl_type::vec2_type
),
2445 _interpolateAtSample(glsl_type::vec3_type
),
2446 _interpolateAtSample(glsl_type::vec4_type
),
2449 add_function("atomicCounter",
2450 _atomic_op("__intrinsic_atomic_read",
2451 shader_atomic_counters
),
2453 add_function("atomicCounterIncrement",
2454 _atomic_op("__intrinsic_atomic_increment",
2455 shader_atomic_counters
),
2457 add_function("atomicCounterDecrement",
2458 _atomic_op("__intrinsic_atomic_predecrement",
2459 shader_atomic_counters
),
2462 add_function("min3",
2463 _min3(glsl_type::float_type
),
2464 _min3(glsl_type::vec2_type
),
2465 _min3(glsl_type::vec3_type
),
2466 _min3(glsl_type::vec4_type
),
2468 _min3(glsl_type::int_type
),
2469 _min3(glsl_type::ivec2_type
),
2470 _min3(glsl_type::ivec3_type
),
2471 _min3(glsl_type::ivec4_type
),
2473 _min3(glsl_type::uint_type
),
2474 _min3(glsl_type::uvec2_type
),
2475 _min3(glsl_type::uvec3_type
),
2476 _min3(glsl_type::uvec4_type
),
2479 add_function("max3",
2480 _max3(glsl_type::float_type
),
2481 _max3(glsl_type::vec2_type
),
2482 _max3(glsl_type::vec3_type
),
2483 _max3(glsl_type::vec4_type
),
2485 _max3(glsl_type::int_type
),
2486 _max3(glsl_type::ivec2_type
),
2487 _max3(glsl_type::ivec3_type
),
2488 _max3(glsl_type::ivec4_type
),
2490 _max3(glsl_type::uint_type
),
2491 _max3(glsl_type::uvec2_type
),
2492 _max3(glsl_type::uvec3_type
),
2493 _max3(glsl_type::uvec4_type
),
2496 add_function("mid3",
2497 _mid3(glsl_type::float_type
),
2498 _mid3(glsl_type::vec2_type
),
2499 _mid3(glsl_type::vec3_type
),
2500 _mid3(glsl_type::vec4_type
),
2502 _mid3(glsl_type::int_type
),
2503 _mid3(glsl_type::ivec2_type
),
2504 _mid3(glsl_type::ivec3_type
),
2505 _mid3(glsl_type::ivec4_type
),
2507 _mid3(glsl_type::uint_type
),
2508 _mid3(glsl_type::uvec2_type
),
2509 _mid3(glsl_type::uvec3_type
),
2510 _mid3(glsl_type::uvec4_type
),
2513 add_image_functions(true);
2515 add_function("memoryBarrier",
2516 _memory_barrier(shader_image_load_store
),
2527 builtin_builder::add_function(const char *name
, ...)
2531 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2535 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2541 stuff
.push_tail(sig
);
2542 validate_ir_tree(&stuff
);
2545 f
->add_signature(sig
);
2549 shader
->symbols
->add_function(f
);
2553 builtin_builder::add_image_function(const char *name
,
2554 const char *intrinsic_name
,
2555 unsigned num_arguments
,
2558 static const glsl_type
*const types
[] = {
2559 glsl_type::image1D_type
,
2560 glsl_type::image2D_type
,
2561 glsl_type::image3D_type
,
2562 glsl_type::image2DRect_type
,
2563 glsl_type::imageCube_type
,
2564 glsl_type::imageBuffer_type
,
2565 glsl_type::image1DArray_type
,
2566 glsl_type::image2DArray_type
,
2567 glsl_type::imageCubeArray_type
,
2568 glsl_type::image2DMS_type
,
2569 glsl_type::image2DMSArray_type
,
2570 glsl_type::iimage1D_type
,
2571 glsl_type::iimage2D_type
,
2572 glsl_type::iimage3D_type
,
2573 glsl_type::iimage2DRect_type
,
2574 glsl_type::iimageCube_type
,
2575 glsl_type::iimageBuffer_type
,
2576 glsl_type::iimage1DArray_type
,
2577 glsl_type::iimage2DArray_type
,
2578 glsl_type::iimageCubeArray_type
,
2579 glsl_type::iimage2DMS_type
,
2580 glsl_type::iimage2DMSArray_type
,
2581 glsl_type::uimage1D_type
,
2582 glsl_type::uimage2D_type
,
2583 glsl_type::uimage3D_type
,
2584 glsl_type::uimage2DRect_type
,
2585 glsl_type::uimageCube_type
,
2586 glsl_type::uimageBuffer_type
,
2587 glsl_type::uimage1DArray_type
,
2588 glsl_type::uimage2DArray_type
,
2589 glsl_type::uimageCubeArray_type
,
2590 glsl_type::uimage2DMS_type
,
2591 glsl_type::uimage2DMSArray_type
2593 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2595 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2596 if (types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2597 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
))
2598 f
->add_signature(_image(types
[i
], intrinsic_name
,
2599 num_arguments
, flags
));
2602 shader
->symbols
->add_function(f
);
2606 builtin_builder::add_image_functions(bool glsl
)
2608 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2610 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2611 "__intrinsic_image_load", 0,
2612 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2613 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2614 IMAGE_FUNCTION_READ_ONLY
));
2616 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2617 "__intrinsic_image_store", 1,
2618 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2619 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2620 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2621 IMAGE_FUNCTION_WRITE_ONLY
));
2623 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2624 "__intrinsic_image_atomic_add", 1, flags
);
2626 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2627 "__intrinsic_image_atomic_min", 1, flags
);
2629 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2630 "__intrinsic_image_atomic_max", 1, flags
);
2632 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2633 "__intrinsic_image_atomic_and", 1, flags
);
2635 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2636 "__intrinsic_image_atomic_or", 1, flags
);
2638 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2639 "__intrinsic_image_atomic_xor", 1, flags
);
2641 add_image_function((glsl
? "imageAtomicExchange" :
2642 "__intrinsic_image_atomic_exchange"),
2643 "__intrinsic_image_atomic_exchange", 1, flags
);
2645 add_image_function((glsl
? "imageAtomicCompSwap" :
2646 "__intrinsic_image_atomic_comp_swap"),
2647 "__intrinsic_image_atomic_comp_swap", 2, flags
);
2651 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2653 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2657 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2659 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2663 builtin_builder::imm(float f
, unsigned vector_elements
)
2665 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2669 builtin_builder::imm(int i
, unsigned vector_elements
)
2671 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2675 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2677 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2681 builtin_builder::imm(double d
, unsigned vector_elements
)
2683 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2687 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2689 return new(mem_ctx
) ir_constant(type
, &data
);
2692 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2694 ir_dereference_variable
*
2695 builtin_builder::var_ref(ir_variable
*var
)
2697 return new(mem_ctx
) ir_dereference_variable(var
);
2700 ir_dereference_array
*
2701 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2703 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2706 /** Return an element of a matrix */
2708 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2710 return swizzle(array_ref(var
, column
), row
, 1);
2714 * Implementations of built-in functions:
2717 ir_function_signature
*
2718 builtin_builder::new_sig(const glsl_type
*return_type
,
2719 builtin_available_predicate avail
,
2725 ir_function_signature
*sig
=
2726 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2729 va_start(ap
, num_params
);
2730 for (int i
= 0; i
< num_params
; i
++) {
2731 plist
.push_tail(va_arg(ap
, ir_variable
*));
2735 sig
->replace_parameters(&plist
);
2739 #define MAKE_SIG(return_type, avail, ...) \
2740 ir_function_signature *sig = \
2741 new_sig(return_type, avail, __VA_ARGS__); \
2742 ir_factory body(&sig->body, mem_ctx); \
2743 sig->is_defined = true;
2745 #define MAKE_INTRINSIC(return_type, avail, ...) \
2746 ir_function_signature *sig = \
2747 new_sig(return_type, avail, __VA_ARGS__); \
2748 sig->is_intrinsic = true;
2750 ir_function_signature
*
2751 builtin_builder::unop(builtin_available_predicate avail
,
2752 ir_expression_operation opcode
,
2753 const glsl_type
*return_type
,
2754 const glsl_type
*param_type
)
2756 ir_variable
*x
= in_var(param_type
, "x");
2757 MAKE_SIG(return_type
, avail
, 1, x
);
2758 body
.emit(ret(expr(opcode
, x
)));
2762 #define UNOP(NAME, OPCODE, AVAIL) \
2763 ir_function_signature * \
2764 builtin_builder::_##NAME(const glsl_type *type) \
2766 return unop(&AVAIL, OPCODE, type, type); \
2769 #define UNOPA(NAME, OPCODE) \
2770 ir_function_signature * \
2771 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
2773 return unop(avail, OPCODE, type, type); \
2776 ir_function_signature
*
2777 builtin_builder::binop(ir_expression_operation opcode
,
2778 builtin_available_predicate avail
,
2779 const glsl_type
*return_type
,
2780 const glsl_type
*param0_type
,
2781 const glsl_type
*param1_type
)
2783 ir_variable
*x
= in_var(param0_type
, "x");
2784 ir_variable
*y
= in_var(param1_type
, "y");
2785 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2786 body
.emit(ret(expr(opcode
, x
, y
)));
2790 #define BINOP(NAME, OPCODE, AVAIL) \
2791 ir_function_signature * \
2792 builtin_builder::_##NAME(const glsl_type *return_type, \
2793 const glsl_type *param0_type, \
2794 const glsl_type *param1_type) \
2796 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2800 * Angle and Trigonometry Functions @{
2803 ir_function_signature
*
2804 builtin_builder::_radians(const glsl_type
*type
)
2806 ir_variable
*degrees
= in_var(type
, "degrees");
2807 MAKE_SIG(type
, always_available
, 1, degrees
);
2808 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2812 ir_function_signature
*
2813 builtin_builder::_degrees(const glsl_type
*type
)
2815 ir_variable
*radians
= in_var(type
, "radians");
2816 MAKE_SIG(type
, always_available
, 1, radians
);
2817 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2821 UNOP(sin
, ir_unop_sin
, always_available
)
2822 UNOP(cos
, ir_unop_cos
, always_available
)
2824 ir_function_signature
*
2825 builtin_builder::_tan(const glsl_type
*type
)
2827 ir_variable
*theta
= in_var(type
, "theta");
2828 MAKE_SIG(type
, always_available
, 1, theta
);
2829 body
.emit(ret(div(sin(theta
), cos(theta
))));
2834 builtin_builder::asin_expr(ir_variable
*x
)
2838 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2841 add(imm(M_PI_4f
- 1.0f
),
2843 add(imm(0.086566724f
),
2844 mul(abs(x
), imm(-0.03102955f
))))))))));
2848 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2850 exec_list actual_params
;
2852 foreach_in_list(ir_variable
, var
, ¶ms
) {
2853 actual_params
.push_tail(var_ref(var
));
2856 ir_function_signature
*sig
=
2857 f
->exact_matching_signature(NULL
, &actual_params
);
2861 ir_dereference_variable
*deref
=
2862 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2864 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2867 ir_function_signature
*
2868 builtin_builder::_asin(const glsl_type
*type
)
2870 ir_variable
*x
= in_var(type
, "x");
2871 MAKE_SIG(type
, always_available
, 1, x
);
2873 body
.emit(ret(asin_expr(x
)));
2878 ir_function_signature
*
2879 builtin_builder::_acos(const glsl_type
*type
)
2881 ir_variable
*x
= in_var(type
, "x");
2882 MAKE_SIG(type
, always_available
, 1, x
);
2884 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
2889 ir_function_signature
*
2890 builtin_builder::_atan2(const glsl_type
*type
)
2892 ir_variable
*vec_y
= in_var(type
, "vec_y");
2893 ir_variable
*vec_x
= in_var(type
, "vec_x");
2894 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2896 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2897 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2898 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2899 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2900 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2901 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2902 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2904 /* If |x| >= 1.0e-8 * |y|: */
2906 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2908 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2910 /* Then...call atan(y/x) */
2911 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
2913 /* ...and fix it up: */
2914 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2915 inner_if
->then_instructions
.push_tail(
2916 if_tree(gequal(y
, imm(0.0f
)),
2917 assign(r
, add(r
, imm(M_PIf
))),
2918 assign(r
, sub(r
, imm(M_PIf
)))));
2919 outer_then
.emit(inner_if
);
2922 outer_if
->else_instructions
.push_tail(
2923 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
2925 body
.emit(outer_if
);
2927 body
.emit(assign(vec_result
, r
, 1 << i
));
2929 body
.emit(ret(vec_result
));
2935 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
2938 * range-reduction, first step:
2940 * / y_over_x if |y_over_x| <= 1.0;
2942 * \ 1.0 / y_over_x otherwise
2944 ir_variable
*x
= body
.make_temp(type
, "atan_x");
2945 body
.emit(assign(x
, div(min2(abs(y_over_x
),
2951 * approximate atan by evaluating polynomial:
2953 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
2954 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
2955 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
2957 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
2958 body
.emit(assign(tmp
, mul(x
, x
)));
2959 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
2961 imm(0.0536813784310406f
)),
2963 imm(0.1173503194786851f
)),
2965 imm(0.1938924977115610f
)),
2967 imm(0.3326756418091246f
)),
2969 imm(0.9999793128310355f
)),
2972 /* range-reduction fixup */
2973 body
.emit(assign(tmp
, add(tmp
,
2974 mul(b2f(greater(abs(y_over_x
),
2975 imm(1.0f
, type
->components()))),
2981 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
2984 ir_function_signature
*
2985 builtin_builder::_atan(const glsl_type
*type
)
2987 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2988 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2990 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
2991 do_atan(body
, type
, tmp
, y_over_x
);
2992 body
.emit(ret(tmp
));
2997 ir_function_signature
*
2998 builtin_builder::_sinh(const glsl_type
*type
)
3000 ir_variable
*x
= in_var(type
, "x");
3001 MAKE_SIG(type
, v130
, 1, x
);
3003 /* 0.5 * (e^x - e^(-x)) */
3004 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3009 ir_function_signature
*
3010 builtin_builder::_cosh(const glsl_type
*type
)
3012 ir_variable
*x
= in_var(type
, "x");
3013 MAKE_SIG(type
, v130
, 1, x
);
3015 /* 0.5 * (e^x + e^(-x)) */
3016 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3021 ir_function_signature
*
3022 builtin_builder::_tanh(const glsl_type
*type
)
3024 ir_variable
*x
= in_var(type
, "x");
3025 MAKE_SIG(type
, v130
, 1, x
);
3027 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3028 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3029 add(exp(x
), exp(neg(x
))))));
3034 ir_function_signature
*
3035 builtin_builder::_asinh(const glsl_type
*type
)
3037 ir_variable
*x
= in_var(type
, "x");
3038 MAKE_SIG(type
, v130
, 1, x
);
3040 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3045 ir_function_signature
*
3046 builtin_builder::_acosh(const glsl_type
*type
)
3048 ir_variable
*x
= in_var(type
, "x");
3049 MAKE_SIG(type
, v130
, 1, x
);
3051 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3055 ir_function_signature
*
3056 builtin_builder::_atanh(const glsl_type
*type
)
3058 ir_variable
*x
= in_var(type
, "x");
3059 MAKE_SIG(type
, v130
, 1, x
);
3061 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3062 sub(imm(1.0f
), x
))))));
3068 * Exponential Functions @{
3071 ir_function_signature
*
3072 builtin_builder::_pow(const glsl_type
*type
)
3074 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3077 UNOP(exp
, ir_unop_exp
, always_available
)
3078 UNOP(log
, ir_unop_log
, always_available
)
3079 UNOP(exp2
, ir_unop_exp2
, always_available
)
3080 UNOP(log2
, ir_unop_log2
, always_available
)
3081 UNOPA(sqrt
, ir_unop_sqrt
)
3082 UNOPA(inversesqrt
, ir_unop_rsq
)
3086 UNOPA(abs
, ir_unop_abs
)
3087 UNOPA(sign
, ir_unop_sign
)
3088 UNOPA(floor
, ir_unop_floor
)
3089 UNOPA(trunc
, ir_unop_trunc
)
3090 UNOPA(round
, ir_unop_round_even
)
3091 UNOPA(roundEven
, ir_unop_round_even
)
3092 UNOPA(ceil
, ir_unop_ceil
)
3093 UNOPA(fract
, ir_unop_fract
)
3095 ir_function_signature
*
3096 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3098 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3101 ir_function_signature
*
3102 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3104 ir_variable
*x
= in_var(type
, "x");
3105 ir_variable
*i
= out_var(type
, "i");
3106 MAKE_SIG(type
, avail
, 2, x
, i
);
3108 ir_variable
*t
= body
.make_temp(type
, "t");
3109 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3110 body
.emit(assign(i
, t
));
3111 body
.emit(ret(sub(x
, t
)));
3116 ir_function_signature
*
3117 builtin_builder::_min(builtin_available_predicate avail
,
3118 const glsl_type
*x_type
, const glsl_type
*y_type
)
3120 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3123 ir_function_signature
*
3124 builtin_builder::_max(builtin_available_predicate avail
,
3125 const glsl_type
*x_type
, const glsl_type
*y_type
)
3127 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3130 ir_function_signature
*
3131 builtin_builder::_clamp(builtin_available_predicate avail
,
3132 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3134 ir_variable
*x
= in_var(val_type
, "x");
3135 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3136 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3137 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3139 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3144 ir_function_signature
*
3145 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3147 ir_variable
*x
= in_var(val_type
, "x");
3148 ir_variable
*y
= in_var(val_type
, "y");
3149 ir_variable
*a
= in_var(blend_type
, "a");
3150 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3152 body
.emit(ret(lrp(x
, y
, a
)));
3157 ir_function_signature
*
3158 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3159 const glsl_type
*val_type
,
3160 const glsl_type
*blend_type
)
3162 ir_variable
*x
= in_var(val_type
, "x");
3163 ir_variable
*y
= in_var(val_type
, "y");
3164 ir_variable
*a
= in_var(blend_type
, "a");
3165 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3167 /* csel matches the ternary operator in that a selector of true choses the
3168 * first argument. This differs from mix(x, y, false) which choses the
3169 * second argument (to remain consistent with the interpolating version of
3170 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3172 * To handle the behavior mismatch, reverse the x and y arguments.
3174 body
.emit(ret(csel(a
, y
, x
)));
3179 ir_function_signature
*
3180 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3182 ir_variable
*edge
= in_var(edge_type
, "edge");
3183 ir_variable
*x
= in_var(x_type
, "x");
3184 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3186 ir_variable
*t
= body
.make_temp(x_type
, "t");
3187 if (x_type
->vector_elements
== 1) {
3188 /* Both are floats */
3189 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3190 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3192 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3193 } else if (edge_type
->vector_elements
== 1) {
3194 /* x is a vector but edge is a float */
3195 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3196 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3197 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3199 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3202 /* Both are vectors */
3203 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3204 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3205 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3208 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3218 ir_function_signature
*
3219 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3221 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3222 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3223 ir_variable
*x
= in_var(x_type
, "x");
3224 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3226 /* From the GLSL 1.10 specification:
3229 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3230 * return t * t * (3 - 2 * t);
3233 ir_variable
*t
= body
.make_temp(x_type
, "t");
3234 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3235 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3237 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3242 ir_function_signature
*
3243 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3245 ir_variable
*x
= in_var(type
, "x");
3246 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3248 body
.emit(ret(nequal(x
, x
)));
3253 ir_function_signature
*
3254 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3256 ir_variable
*x
= in_var(type
, "x");
3257 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3259 ir_constant_data infinities
;
3260 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3261 infinities
.f
[i
] = INFINITY
;
3264 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3269 ir_function_signature
*
3270 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3272 ir_variable
*x
= in_var(type
, "x");
3273 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3274 body
.emit(ret(bitcast_f2i(x
)));
3278 ir_function_signature
*
3279 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3281 ir_variable
*x
= in_var(type
, "x");
3282 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3283 body
.emit(ret(bitcast_f2u(x
)));
3287 ir_function_signature
*
3288 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3290 ir_variable
*x
= in_var(type
, "x");
3291 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3292 body
.emit(ret(bitcast_i2f(x
)));
3296 ir_function_signature
*
3297 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3299 ir_variable
*x
= in_var(type
, "x");
3300 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3301 body
.emit(ret(bitcast_u2f(x
)));
3305 ir_function_signature
*
3306 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3308 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3309 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3310 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3314 ir_function_signature
*
3315 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3317 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3318 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3319 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3323 ir_function_signature
*
3324 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3326 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3327 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3328 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3332 ir_function_signature
*
3333 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3335 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3336 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3337 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3341 ir_function_signature
*
3342 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3344 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3345 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3346 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3350 ir_function_signature
*
3351 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3353 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3354 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3355 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3360 ir_function_signature
*
3361 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3363 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3364 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3365 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3369 ir_function_signature
*
3370 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3372 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3373 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3374 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3378 ir_function_signature
*
3379 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3381 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3382 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3383 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3387 ir_function_signature
*
3388 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3390 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3391 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3392 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3396 ir_function_signature
*
3397 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3399 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3400 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3401 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3405 ir_function_signature
*
3406 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3408 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3409 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3410 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3414 ir_function_signature
*
3415 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3417 ir_variable
*x
= in_var(type
, "x");
3418 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3420 body
.emit(ret(sqrt(dot(x
, x
))));
3425 ir_function_signature
*
3426 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3428 ir_variable
*p0
= in_var(type
, "p0");
3429 ir_variable
*p1
= in_var(type
, "p1");
3430 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3432 if (type
->vector_elements
== 1) {
3433 body
.emit(ret(abs(sub(p0
, p1
))));
3435 ir_variable
*p
= body
.make_temp(type
, "p");
3436 body
.emit(assign(p
, sub(p0
, p1
)));
3437 body
.emit(ret(sqrt(dot(p
, p
))));
3443 ir_function_signature
*
3444 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3446 if (type
->vector_elements
== 1)
3447 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3449 return binop(ir_binop_dot
, avail
,
3450 type
->get_base_type(), type
, type
);
3453 ir_function_signature
*
3454 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3456 ir_variable
*a
= in_var(type
, "a");
3457 ir_variable
*b
= in_var(type
, "b");
3458 MAKE_SIG(type
, avail
, 2, a
, b
);
3460 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3461 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3463 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3464 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3469 ir_function_signature
*
3470 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3472 ir_variable
*x
= in_var(type
, "x");
3473 MAKE_SIG(type
, avail
, 1, x
);
3475 if (type
->vector_elements
== 1) {
3476 body
.emit(ret(sign(x
)));
3478 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3484 ir_function_signature
*
3485 builtin_builder::_ftransform()
3487 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3489 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3490 glsl_type::vec4_type
,
3491 var_ref(gl_ModelViewProjectionMatrix
),
3492 var_ref(gl_Vertex
))));
3494 /* FINISHME: Once the ir_expression() constructor handles type inference
3495 * for matrix operations, we can simplify this to:
3497 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3502 ir_function_signature
*
3503 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3505 ir_variable
*N
= in_var(type
, "N");
3506 ir_variable
*I
= in_var(type
, "I");
3507 ir_variable
*Nref
= in_var(type
, "Nref");
3508 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3510 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3511 ret(N
), ret(neg(N
))));
3516 ir_function_signature
*
3517 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3519 ir_variable
*I
= in_var(type
, "I");
3520 ir_variable
*N
= in_var(type
, "N");
3521 MAKE_SIG(type
, avail
, 2, I
, N
);
3523 /* I - 2 * dot(N, I) * N */
3524 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3529 ir_function_signature
*
3530 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3532 ir_variable
*I
= in_var(type
, "I");
3533 ir_variable
*N
= in_var(type
, "N");
3534 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3535 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3537 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3538 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3540 /* From the GLSL 1.10 specification:
3541 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3543 * return genType(0.0)
3545 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3547 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3548 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3549 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3550 mul(n_dot_i
, n_dot_i
)))))));
3551 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3552 ret(ir_constant::zero(mem_ctx
, type
)),
3553 ret(sub(mul(eta
, I
),
3554 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3559 ir_function_signature
*
3560 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3562 ir_variable
*x
= in_var(type
, "x");
3563 ir_variable
*y
= in_var(type
, "y");
3564 MAKE_SIG(type
, avail
, 2, x
, y
);
3566 ir_variable
*z
= body
.make_temp(type
, "z");
3567 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3568 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3575 ir_function_signature
*
3576 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3581 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3582 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3583 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3585 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3586 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3588 MAKE_SIG(type
, avail
, 2, c
, r
);
3590 ir_variable
*m
= body
.make_temp(type
, "m");
3591 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3592 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3599 ir_function_signature
*
3600 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3602 const glsl_type
*transpose_type
=
3603 glsl_type::get_instance(orig_type
->base_type
,
3604 orig_type
->matrix_columns
,
3605 orig_type
->vector_elements
);
3607 ir_variable
*m
= in_var(orig_type
, "m");
3608 MAKE_SIG(transpose_type
, avail
, 1, m
);
3610 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3611 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3612 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3613 body
.emit(assign(array_ref(t
, j
),
3614 matrix_elt(m
, i
, j
),
3623 ir_function_signature
*
3624 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3626 ir_variable
*m
= in_var(type
, "m");
3627 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3629 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3630 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3635 ir_function_signature
*
3636 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3638 ir_variable
*m
= in_var(type
, "m");
3639 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3642 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3643 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3646 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3647 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3650 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3651 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3653 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3654 mul(matrix_elt(m
, 0, 1), f2
)),
3655 mul(matrix_elt(m
, 0, 2), f3
))));
3660 ir_function_signature
*
3661 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3663 ir_variable
*m
= in_var(type
, "m");
3664 const glsl_type
*btype
= type
->get_base_type();
3665 MAKE_SIG(btype
, avail
, 1, m
);
3667 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3668 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3669 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3670 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3671 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3672 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3673 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3674 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3675 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3676 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3677 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3678 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3679 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3680 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3681 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3682 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3683 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3684 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3685 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3687 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)))));
3688 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)))));
3689 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)))));
3690 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)))));
3691 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)))));
3692 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)))));
3693 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)))));
3694 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)))));
3695 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)))));
3696 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)))));
3697 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)))));
3698 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)))));
3699 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)))));
3700 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)))));
3701 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)))));
3702 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)))));
3703 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)))));
3704 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)))));
3705 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)))));
3707 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3709 body
.emit(assign(adj_0
,
3710 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3711 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3712 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3714 body
.emit(assign(adj_0
, neg(
3715 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3716 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3717 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3719 body
.emit(assign(adj_0
,
3720 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3721 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3722 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3724 body
.emit(assign(adj_0
, neg(
3725 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3726 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3727 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3730 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3735 ir_function_signature
*
3736 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3738 ir_variable
*m
= in_var(type
, "m");
3739 MAKE_SIG(type
, avail
, 1, m
);
3741 ir_variable
*adj
= body
.make_temp(type
, "adj");
3742 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3743 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3744 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3745 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3747 ir_expression
*det
=
3748 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3749 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3751 body
.emit(ret(div(adj
, det
)));
3755 ir_function_signature
*
3756 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3758 ir_variable
*m
= in_var(type
, "m");
3759 const glsl_type
*btype
= type
->get_base_type();
3760 MAKE_SIG(type
, avail
, 1, m
);
3762 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
3763 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
3764 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
3766 body
.emit(assign(f11_22_21_12
,
3767 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3768 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3769 body
.emit(assign(f10_22_20_12
,
3770 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3771 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3772 body
.emit(assign(f10_21_20_11
,
3773 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3774 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3776 ir_variable
*adj
= body
.make_temp(type
, "adj");
3777 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3778 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3779 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3781 body
.emit(assign(array_ref(adj
, 0), neg(
3782 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3783 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3785 body
.emit(assign(array_ref(adj
, 1),
3786 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3787 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3789 body
.emit(assign(array_ref(adj
, 2), neg(
3790 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3791 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3794 body
.emit(assign(array_ref(adj
, 0),
3795 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3796 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3798 body
.emit(assign(array_ref(adj
, 1), neg(
3799 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3800 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3802 body
.emit(assign(array_ref(adj
, 2),
3803 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3804 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3807 ir_expression
*det
=
3808 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3809 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3810 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3812 body
.emit(ret(div(adj
, det
)));
3817 ir_function_signature
*
3818 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3820 ir_variable
*m
= in_var(type
, "m");
3821 const glsl_type
*btype
= type
->get_base_type();
3822 MAKE_SIG(type
, avail
, 1, m
);
3824 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3825 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3826 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3827 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3828 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3829 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3830 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3831 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3832 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3833 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3834 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3835 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3836 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3837 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3838 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3839 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3840 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3841 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3842 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3844 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)))));
3845 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)))));
3846 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)))));
3847 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)))));
3848 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)))));
3849 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)))));
3850 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)))));
3851 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)))));
3852 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)))));
3853 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)))));
3854 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)))));
3855 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)))));
3856 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)))));
3857 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)))));
3858 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)))));
3859 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)))));
3860 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)))));
3861 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)))));
3862 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)))));
3864 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
3865 body
.emit(assign(array_ref(adj
, 0),
3866 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3867 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3868 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3870 body
.emit(assign(array_ref(adj
, 1), neg(
3871 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3872 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3873 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3875 body
.emit(assign(array_ref(adj
, 2),
3876 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3877 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3878 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3880 body
.emit(assign(array_ref(adj
, 3), neg(
3881 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3882 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3883 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3886 body
.emit(assign(array_ref(adj
, 0), neg(
3887 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3888 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3889 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3891 body
.emit(assign(array_ref(adj
, 1),
3892 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3893 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3894 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3896 body
.emit(assign(array_ref(adj
, 2), neg(
3897 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3898 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3899 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3901 body
.emit(assign(array_ref(adj
, 3),
3902 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3903 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3904 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3907 body
.emit(assign(array_ref(adj
, 0),
3908 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3909 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3910 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3912 body
.emit(assign(array_ref(adj
, 1), neg(
3913 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3914 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3915 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3917 body
.emit(assign(array_ref(adj
, 2),
3918 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3919 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3920 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3922 body
.emit(assign(array_ref(adj
, 3), neg(
3923 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3924 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3925 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3928 body
.emit(assign(array_ref(adj
, 0), neg(
3929 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3930 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3931 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3933 body
.emit(assign(array_ref(adj
, 1),
3934 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3935 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3936 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3938 body
.emit(assign(array_ref(adj
, 2), neg(
3939 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3940 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3941 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3943 body
.emit(assign(array_ref(adj
, 3),
3944 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3945 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3946 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3949 ir_expression
*det
=
3950 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3951 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3952 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3953 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3955 body
.emit(ret(div(adj
, det
)));
3961 ir_function_signature
*
3962 builtin_builder::_lessThan(builtin_available_predicate avail
,
3963 const glsl_type
*type
)
3965 return binop(ir_binop_less
, avail
,
3966 glsl_type::bvec(type
->vector_elements
), type
, type
);
3969 ir_function_signature
*
3970 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3971 const glsl_type
*type
)
3973 return binop(ir_binop_lequal
, avail
,
3974 glsl_type::bvec(type
->vector_elements
), type
, type
);
3977 ir_function_signature
*
3978 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3979 const glsl_type
*type
)
3981 return binop(ir_binop_greater
, avail
,
3982 glsl_type::bvec(type
->vector_elements
), type
, type
);
3985 ir_function_signature
*
3986 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3987 const glsl_type
*type
)
3989 return binop(ir_binop_gequal
, avail
,
3990 glsl_type::bvec(type
->vector_elements
), type
, type
);
3993 ir_function_signature
*
3994 builtin_builder::_equal(builtin_available_predicate avail
,
3995 const glsl_type
*type
)
3997 return binop(ir_binop_equal
, avail
,
3998 glsl_type::bvec(type
->vector_elements
), type
, type
);
4001 ir_function_signature
*
4002 builtin_builder::_notEqual(builtin_available_predicate avail
,
4003 const glsl_type
*type
)
4005 return binop(ir_binop_nequal
, avail
,
4006 glsl_type::bvec(type
->vector_elements
), type
, type
);
4009 ir_function_signature
*
4010 builtin_builder::_any(const glsl_type
*type
)
4012 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4015 ir_function_signature
*
4016 builtin_builder::_all(const glsl_type
*type
)
4018 ir_variable
*v
= in_var(type
, "v");
4019 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4021 switch (type
->vector_elements
) {
4023 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4026 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4030 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4039 UNOP(not, ir_unop_logic_not
, always_available
)
4042 has_lod(const glsl_type
*sampler_type
)
4044 assert(sampler_type
->is_sampler());
4046 switch (sampler_type
->sampler_dimensionality
) {
4047 case GLSL_SAMPLER_DIM_RECT
:
4048 case GLSL_SAMPLER_DIM_BUF
:
4049 case GLSL_SAMPLER_DIM_MS
:
4056 ir_function_signature
*
4057 builtin_builder::_textureSize(builtin_available_predicate avail
,
4058 const glsl_type
*return_type
,
4059 const glsl_type
*sampler_type
)
4061 ir_variable
*s
= in_var(sampler_type
, "sampler");
4062 /* The sampler always exists; add optional lod later. */
4063 MAKE_SIG(return_type
, avail
, 1, s
);
4065 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4066 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4068 if (has_lod(sampler_type
)) {
4069 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4070 sig
->parameters
.push_tail(lod
);
4071 tex
->lod_info
.lod
= var_ref(lod
);
4073 tex
->lod_info
.lod
= imm(0u);
4076 body
.emit(ret(tex
));
4081 ir_function_signature
*
4082 builtin_builder::_texture(ir_texture_opcode opcode
,
4083 builtin_available_predicate avail
,
4084 const glsl_type
*return_type
,
4085 const glsl_type
*sampler_type
,
4086 const glsl_type
*coord_type
,
4089 ir_variable
*s
= in_var(sampler_type
, "sampler");
4090 ir_variable
*P
= in_var(coord_type
, "P");
4091 /* The sampler and coordinate always exist; add optional parameters later. */
4092 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4094 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4095 tex
->set_sampler(var_ref(s
), return_type
);
4097 const int coord_size
= sampler_type
->coordinate_components();
4099 if (coord_size
== coord_type
->vector_elements
) {
4100 tex
->coordinate
= var_ref(P
);
4102 /* The incoming coordinate also has the projector or shadow comparitor,
4103 * so we need to swizzle those away.
4105 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4108 /* The projector is always in the last component. */
4109 if (flags
& TEX_PROJECT
)
4110 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4112 if (sampler_type
->sampler_shadow
) {
4113 if (opcode
== ir_tg4
) {
4114 /* gather has refz as a separate parameter, immediately after the
4117 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4118 sig
->parameters
.push_tail(refz
);
4119 tex
->shadow_comparitor
= var_ref(refz
);
4121 /* The shadow comparitor is normally in the Z component, but a few types
4122 * have sufficiently large coordinates that it's in W.
4124 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4128 if (opcode
== ir_txl
) {
4129 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4130 sig
->parameters
.push_tail(lod
);
4131 tex
->lod_info
.lod
= var_ref(lod
);
4132 } else if (opcode
== ir_txd
) {
4133 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4134 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4135 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4136 sig
->parameters
.push_tail(dPdx
);
4137 sig
->parameters
.push_tail(dPdy
);
4138 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4139 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4142 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4143 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4144 ir_variable
*offset
=
4145 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4146 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4147 sig
->parameters
.push_tail(offset
);
4148 tex
->offset
= var_ref(offset
);
4151 if (flags
& TEX_OFFSET_ARRAY
) {
4152 ir_variable
*offsets
=
4153 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4154 "offsets", ir_var_const_in
);
4155 sig
->parameters
.push_tail(offsets
);
4156 tex
->offset
= var_ref(offsets
);
4159 if (opcode
== ir_tg4
) {
4160 if (flags
& TEX_COMPONENT
) {
4161 ir_variable
*component
=
4162 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4163 sig
->parameters
.push_tail(component
);
4164 tex
->lod_info
.component
= var_ref(component
);
4167 tex
->lod_info
.component
= imm(0);
4171 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4172 * inconsistent with both textureLodOffset and textureGradOffset.
4174 if (opcode
== ir_txb
) {
4175 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4176 sig
->parameters
.push_tail(bias
);
4177 tex
->lod_info
.bias
= var_ref(bias
);
4180 body
.emit(ret(tex
));
4185 ir_function_signature
*
4186 builtin_builder::_textureCubeArrayShadow()
4188 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4189 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4190 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4191 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4193 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4194 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4196 tex
->coordinate
= var_ref(P
);
4197 tex
->shadow_comparitor
= var_ref(compare
);
4199 body
.emit(ret(tex
));
4204 ir_function_signature
*
4205 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4206 const glsl_type
*return_type
,
4207 const glsl_type
*sampler_type
,
4208 const glsl_type
*coord_type
,
4209 const glsl_type
*offset_type
)
4211 ir_variable
*s
= in_var(sampler_type
, "sampler");
4212 ir_variable
*P
= in_var(coord_type
, "P");
4213 /* The sampler and coordinate always exist; add optional parameters later. */
4214 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4216 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4217 tex
->coordinate
= var_ref(P
);
4218 tex
->set_sampler(var_ref(s
), return_type
);
4220 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4221 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4222 sig
->parameters
.push_tail(sample
);
4223 tex
->lod_info
.sample_index
= var_ref(sample
);
4224 tex
->op
= ir_txf_ms
;
4225 } else if (has_lod(sampler_type
)) {
4226 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4227 sig
->parameters
.push_tail(lod
);
4228 tex
->lod_info
.lod
= var_ref(lod
);
4230 tex
->lod_info
.lod
= imm(0u);
4233 if (offset_type
!= NULL
) {
4234 ir_variable
*offset
=
4235 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4236 sig
->parameters
.push_tail(offset
);
4237 tex
->offset
= var_ref(offset
);
4240 body
.emit(ret(tex
));
4245 ir_function_signature
*
4246 builtin_builder::_EmitVertex()
4248 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4250 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4251 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4256 ir_function_signature
*
4257 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4258 const glsl_type
*stream_type
)
4260 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4262 * "Emit the current values of output variables to the current output
4263 * primitive on stream stream. The argument to stream must be a constant
4264 * integral expression."
4266 ir_variable
*stream
=
4267 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4269 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4271 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4276 ir_function_signature
*
4277 builtin_builder::_EndPrimitive()
4279 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4281 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4282 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4287 ir_function_signature
*
4288 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4289 const glsl_type
*stream_type
)
4291 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4293 * "Completes the current output primitive on stream stream and starts
4294 * a new one. The argument to stream must be a constant integral
4297 ir_variable
*stream
=
4298 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4300 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4302 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4307 ir_function_signature
*
4308 builtin_builder::_barrier()
4310 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4312 body
.emit(new(mem_ctx
) ir_barrier());
4316 ir_function_signature
*
4317 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
4318 const glsl_type
*coord_type
)
4320 ir_variable
*s
= in_var(sampler_type
, "sampler");
4321 ir_variable
*coord
= in_var(coord_type
, "coord");
4322 /* The sampler and coordinate always exist; add optional parameters later. */
4323 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
4325 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4326 tex
->coordinate
= var_ref(coord
);
4327 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4329 body
.emit(ret(tex
));
4334 ir_function_signature
*
4335 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4337 ir_variable
*s
= in_var(sampler_type
, "sampler");
4338 const glsl_type
*return_type
= glsl_type::int_type
;
4339 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4341 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4342 tex
->set_sampler(var_ref(s
), return_type
);
4344 body
.emit(ret(tex
));
4349 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4350 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4351 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4352 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4353 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4354 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4356 ir_function_signature
*
4357 builtin_builder::_fwidth(const glsl_type
*type
)
4359 ir_variable
*p
= in_var(type
, "p");
4360 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4362 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4367 ir_function_signature
*
4368 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4370 ir_variable
*p
= in_var(type
, "p");
4371 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4373 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4374 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4379 ir_function_signature
*
4380 builtin_builder::_fwidthFine(const glsl_type
*type
)
4382 ir_variable
*p
= in_var(type
, "p");
4383 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4385 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4386 abs(expr(ir_unop_dFdy_fine
, p
)))));
4391 ir_function_signature
*
4392 builtin_builder::_noise1(const glsl_type
*type
)
4394 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4397 ir_function_signature
*
4398 builtin_builder::_noise2(const glsl_type
*type
)
4400 ir_variable
*p
= in_var(type
, "p");
4401 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4403 ir_constant_data b_offset
;
4404 b_offset
.f
[0] = 601.0f
;
4405 b_offset
.f
[1] = 313.0f
;
4406 b_offset
.f
[2] = 29.0f
;
4407 b_offset
.f
[3] = 277.0f
;
4409 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4410 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4411 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4412 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4413 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4414 body
.emit(assign(t
, a
, WRITEMASK_X
));
4415 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4421 ir_function_signature
*
4422 builtin_builder::_noise3(const glsl_type
*type
)
4424 ir_variable
*p
= in_var(type
, "p");
4425 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4427 ir_constant_data b_offset
;
4428 b_offset
.f
[0] = 601.0f
;
4429 b_offset
.f
[1] = 313.0f
;
4430 b_offset
.f
[2] = 29.0f
;
4431 b_offset
.f
[3] = 277.0f
;
4433 ir_constant_data c_offset
;
4434 c_offset
.f
[0] = 1559.0f
;
4435 c_offset
.f
[1] = 113.0f
;
4436 c_offset
.f
[2] = 1861.0f
;
4437 c_offset
.f
[3] = 797.0f
;
4439 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4440 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4441 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4442 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4443 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4444 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4445 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4446 body
.emit(assign(t
, a
, WRITEMASK_X
));
4447 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4448 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4454 ir_function_signature
*
4455 builtin_builder::_noise4(const glsl_type
*type
)
4457 ir_variable
*p
= in_var(type
, "p");
4458 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4460 ir_variable
*_p
= body
.make_temp(type
, "_p");
4462 ir_constant_data p_offset
;
4463 p_offset
.f
[0] = 1559.0f
;
4464 p_offset
.f
[1] = 113.0f
;
4465 p_offset
.f
[2] = 1861.0f
;
4466 p_offset
.f
[3] = 797.0f
;
4468 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4470 ir_constant_data offset
;
4471 offset
.f
[0] = 601.0f
;
4472 offset
.f
[1] = 313.0f
;
4473 offset
.f
[2] = 29.0f
;
4474 offset
.f
[3] = 277.0f
;
4476 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4477 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4478 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4479 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4480 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4481 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4482 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4483 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4484 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4485 body
.emit(assign(t
, a
, WRITEMASK_X
));
4486 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4487 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4488 body
.emit(assign(t
, d
, WRITEMASK_W
));
4494 ir_function_signature
*
4495 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4497 ir_variable
*value
= in_var(type
, "value");
4498 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4499 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4500 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4502 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4507 ir_function_signature
*
4508 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4510 ir_variable
*base
= in_var(type
, "base");
4511 ir_variable
*insert
= in_var(type
, "insert");
4512 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4513 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4514 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4516 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4521 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4523 ir_function_signature
*
4524 builtin_builder::_bitCount(const glsl_type
*type
)
4526 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4527 glsl_type::ivec(type
->vector_elements
), type
);
4530 ir_function_signature
*
4531 builtin_builder::_findLSB(const glsl_type
*type
)
4533 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4534 glsl_type::ivec(type
->vector_elements
), type
);
4537 ir_function_signature
*
4538 builtin_builder::_findMSB(const glsl_type
*type
)
4540 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4541 glsl_type::ivec(type
->vector_elements
), type
);
4544 ir_function_signature
*
4545 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4547 ir_variable
*a
= in_var(type
, "a");
4548 ir_variable
*b
= in_var(type
, "b");
4549 ir_variable
*c
= in_var(type
, "c");
4550 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4552 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4557 ir_function_signature
*
4558 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4560 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4563 ir_function_signature
*
4564 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4566 ir_variable
*x
= in_var(x_type
, "x");
4567 ir_variable
*exponent
= out_var(exp_type
, "exp");
4568 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4570 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4572 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4576 ir_function_signature
*
4577 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4579 ir_variable
*x
= in_var(x_type
, "x");
4580 ir_variable
*exponent
= out_var(exp_type
, "exp");
4581 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4583 const unsigned vec_elem
= x_type
->vector_elements
;
4584 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4585 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4587 /* Single-precision floating-point values are stored as
4592 * An exponent shift of 23 will shift the mantissa out, leaving only the
4593 * exponent and sign bit (which itself may be zero, if the absolute value
4594 * was taken before the bitcast and shift.
4596 ir_constant
*exponent_shift
= imm(23);
4597 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4599 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4601 /* Exponent of floating-point values in the range [0.5, 1.0). */
4602 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4604 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4605 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4607 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4608 * to unsigned integers to ensure that 1 bits aren't shifted in.
4610 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4611 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4612 imm(0, vec_elem
)))));
4614 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4615 body
.emit(assign(bits
, bitcast_f2u(x
)));
4616 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4617 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4618 imm(0u, vec_elem
)))));
4619 body
.emit(ret(bitcast_u2f(bits
)));
4624 ir_function_signature
*
4625 builtin_builder::_uaddCarry(const glsl_type
*type
)
4627 ir_variable
*x
= in_var(type
, "x");
4628 ir_variable
*y
= in_var(type
, "y");
4629 ir_variable
*carry
= out_var(type
, "carry");
4630 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4632 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4633 body
.emit(ret(add(x
, y
)));
4638 ir_function_signature
*
4639 builtin_builder::_usubBorrow(const glsl_type
*type
)
4641 ir_variable
*x
= in_var(type
, "x");
4642 ir_variable
*y
= in_var(type
, "y");
4643 ir_variable
*borrow
= out_var(type
, "borrow");
4644 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4646 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4647 body
.emit(ret(sub(x
, y
)));
4653 * For both imulExtended() and umulExtended() built-ins.
4655 ir_function_signature
*
4656 builtin_builder::_mulExtended(const glsl_type
*type
)
4658 ir_variable
*x
= in_var(type
, "x");
4659 ir_variable
*y
= in_var(type
, "y");
4660 ir_variable
*msb
= out_var(type
, "msb");
4661 ir_variable
*lsb
= out_var(type
, "lsb");
4662 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
4664 body
.emit(assign(msb
, imul_high(x
, y
)));
4665 body
.emit(assign(lsb
, mul(x
, y
)));
4670 ir_function_signature
*
4671 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4673 ir_variable
*interpolant
= in_var(type
, "interpolant");
4674 interpolant
->data
.must_be_shader_input
= 1;
4675 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4677 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4682 ir_function_signature
*
4683 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4685 ir_variable
*interpolant
= in_var(type
, "interpolant");
4686 interpolant
->data
.must_be_shader_input
= 1;
4687 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4688 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4690 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4695 ir_function_signature
*
4696 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4698 ir_variable
*interpolant
= in_var(type
, "interpolant");
4699 interpolant
->data
.must_be_shader_input
= 1;
4700 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4701 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4703 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4708 ir_function_signature
*
4709 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4711 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4712 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4716 ir_function_signature
*
4717 builtin_builder::_atomic_op(const char *intrinsic
,
4718 builtin_available_predicate avail
)
4720 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4721 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4723 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4724 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4726 body
.emit(ret(retval
));
4730 ir_function_signature
*
4731 builtin_builder::_min3(const glsl_type
*type
)
4733 ir_variable
*x
= in_var(type
, "x");
4734 ir_variable
*y
= in_var(type
, "y");
4735 ir_variable
*z
= in_var(type
, "z");
4736 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4738 ir_expression
*min3
= min2(x
, min2(y
,z
));
4739 body
.emit(ret(min3
));
4744 ir_function_signature
*
4745 builtin_builder::_max3(const glsl_type
*type
)
4747 ir_variable
*x
= in_var(type
, "x");
4748 ir_variable
*y
= in_var(type
, "y");
4749 ir_variable
*z
= in_var(type
, "z");
4750 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4752 ir_expression
*max3
= max2(x
, max2(y
,z
));
4753 body
.emit(ret(max3
));
4758 ir_function_signature
*
4759 builtin_builder::_mid3(const glsl_type
*type
)
4761 ir_variable
*x
= in_var(type
, "x");
4762 ir_variable
*y
= in_var(type
, "y");
4763 ir_variable
*z
= in_var(type
, "z");
4764 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4766 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4767 body
.emit(ret(mid3
));
4772 ir_function_signature
*
4773 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4774 const char *intrinsic_name
,
4775 unsigned num_arguments
,
4778 const glsl_type
*data_type
= glsl_type::get_instance(
4779 image_type
->sampler_type
,
4780 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4782 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4783 glsl_type::void_type
: data_type
);
4785 /* Addressing arguments that are always present. */
4786 ir_variable
*image
= in_var(image_type
, "image");
4787 ir_variable
*coord
= in_var(
4788 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4790 ir_function_signature
*sig
= new_sig(
4791 ret_type
, shader_image_load_store
, 2, image
, coord
);
4793 /* Sample index for multisample images. */
4794 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4795 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4797 /* Data arguments. */
4798 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
4799 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
4800 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
4801 ralloc_free(arg_name
);
4804 /* Set the maximal set of qualifiers allowed for this image
4805 * built-in. Function calls with arguments having fewer
4806 * qualifiers than present in the prototype are allowed by the
4807 * spec, but not with more, i.e. this will make the compiler
4808 * accept everything that needs to be accepted, and reject cases
4809 * like loads from write-only or stores to read-only images.
4811 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
4812 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
4813 image
->data
.image_coherent
= true;
4814 image
->data
.image_volatile
= true;
4815 image
->data
.image_restrict
= true;
4820 ir_function_signature
*
4821 builtin_builder::_image(const glsl_type
*image_type
,
4822 const char *intrinsic_name
,
4823 unsigned num_arguments
,
4826 ir_function_signature
*sig
= _image_prototype(image_type
, intrinsic_name
,
4827 num_arguments
, flags
);
4829 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
4830 ir_factory
body(&sig
->body
, mem_ctx
);
4831 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
4833 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
4834 body
.emit(call(f
, NULL
, sig
->parameters
));
4836 ir_variable
*ret_val
=
4837 body
.make_temp(sig
->return_type
, "_ret_val");
4838 body
.emit(call(f
, ret_val
, sig
->parameters
));
4839 body
.emit(ret(ret_val
));
4842 sig
->is_defined
= true;
4845 sig
->is_intrinsic
= true;
4851 ir_function_signature
*
4852 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
4854 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
4858 ir_function_signature
*
4859 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
4861 MAKE_SIG(glsl_type::void_type
, avail
, 0);
4862 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
4863 NULL
, sig
->parameters
));
4869 /******************************************************************************/
4871 /* The singleton instance of builtin_builder. */
4872 static builtin_builder builtins
;
4873 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
4876 * External API (exposing the built-in module to the rest of the compiler):
4880 _mesa_glsl_initialize_builtin_functions()
4882 mtx_lock(&builtins_lock
);
4883 builtins
.initialize();
4884 mtx_unlock(&builtins_lock
);
4888 _mesa_glsl_release_builtin_functions()
4890 mtx_lock(&builtins_lock
);
4892 mtx_unlock(&builtins_lock
);
4895 ir_function_signature
*
4896 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4897 const char *name
, exec_list
*actual_parameters
)
4899 ir_function_signature
* s
;
4900 mtx_lock(&builtins_lock
);
4901 s
= builtins
.find(state
, name
, actual_parameters
);
4902 mtx_unlock(&builtins_lock
);
4907 _mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state
*state
,
4911 mtx_lock(&builtins_lock
);
4912 f
= builtins
.shader
->symbols
->get_function(name
);
4913 mtx_unlock(&builtins_lock
);
4918 _mesa_glsl_get_builtin_function_shader()
4920 return builtins
.shader
;