2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 #define M_PIf ((float) M_PI)
66 #define M_PI_2f ((float) M_PI_2)
67 #define M_PI_4f ((float) M_PI_4)
69 using namespace ir_builder
;
72 * Availability predicates:
76 always_available(const _mesa_glsl_parse_state
*)
82 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
84 return state
->stage
== MESA_SHADER_VERTEX
&&
85 state
->language_version
<= 130 &&
90 fs_only(const _mesa_glsl_parse_state
*state
)
92 return state
->stage
== MESA_SHADER_FRAGMENT
;
96 gs_only(const _mesa_glsl_parse_state
*state
)
98 return state
->stage
== MESA_SHADER_GEOMETRY
;
102 v110(const _mesa_glsl_parse_state
*state
)
104 return !state
->es_shader
;
108 v110_fs_only(const _mesa_glsl_parse_state
*state
)
110 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
114 v120(const _mesa_glsl_parse_state
*state
)
116 return state
->is_version(120, 300);
120 v130(const _mesa_glsl_parse_state
*state
)
122 return state
->is_version(130, 300);
126 v130_fs_only(const _mesa_glsl_parse_state
*state
)
128 return state
->is_version(130, 300) &&
129 state
->stage
== MESA_SHADER_FRAGMENT
;
133 v140(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 0);
139 v400_fs_only(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(400, 0) &&
142 state
->stage
== MESA_SHADER_FRAGMENT
;
146 es31(const _mesa_glsl_parse_state
*state
)
148 return state
->is_version(0, 310);
152 texture_rectangle(const _mesa_glsl_parse_state
*state
)
154 return state
->ARB_texture_rectangle_enable
;
158 texture_external(const _mesa_glsl_parse_state
*state
)
160 return state
->OES_EGL_image_external_enable
;
163 /** True if texturing functions with explicit LOD are allowed. */
165 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
167 /* Texturing functions with "Lod" in their name exist:
168 * - In the vertex shader stage (for all languages)
169 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
170 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
172 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
173 * don't need to explicitly check state->es_shader.
175 return state
->stage
== MESA_SHADER_VERTEX
||
176 state
->is_version(130, 300) ||
177 state
->ARB_shader_texture_lod_enable
;
181 v110_lod(const _mesa_glsl_parse_state
*state
)
183 return !state
->es_shader
&& lod_exists_in_stage(state
);
187 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
189 return state
->ARB_shader_texture_lod_enable
;
193 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
195 return state
->ARB_shader_texture_lod_enable
&&
196 state
->ARB_texture_rectangle_enable
;
200 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
202 return state
->is_version(330, 300) ||
203 state
->ARB_shader_bit_encoding_enable
||
204 state
->ARB_gpu_shader5_enable
;
208 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
210 return state
->is_version(450, 310) ||
211 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
215 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->is_version(420, 300);
222 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
224 return state
->ARB_shading_language_packing_enable
||
225 state
->ARB_gpu_shader5_enable
||
226 state
->is_version(400, 300);
230 gpu_shader5(const _mesa_glsl_parse_state
*state
)
232 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
236 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
242 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
244 return state
->ARB_shading_language_packing_enable
||
245 state
->ARB_gpu_shader5_enable
||
246 state
->is_version(400, 310);
250 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
252 return state
->stage
== MESA_SHADER_FRAGMENT
&&
253 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
258 texture_array_lod(const _mesa_glsl_parse_state
*state
)
260 return lod_exists_in_stage(state
) &&
261 state
->EXT_texture_array_enable
;
265 fs_texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->stage
== MESA_SHADER_FRAGMENT
&&
268 state
->EXT_texture_array_enable
;
272 texture_array(const _mesa_glsl_parse_state
*state
)
274 return state
->EXT_texture_array_enable
;
278 texture_multisample(const _mesa_glsl_parse_state
*state
)
280 return state
->is_version(150, 310) ||
281 state
->ARB_texture_multisample_enable
;
285 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(150, 320) ||
288 state
->ARB_texture_multisample_enable
||
289 state
->OES_texture_storage_multisample_2d_array_enable
;
293 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
295 return state
->stage
== MESA_SHADER_FRAGMENT
&&
296 (state
->is_version(400, 0) ||
297 state
->ARB_texture_cube_map_array_enable
);
301 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
303 return state
->is_version(400, 0) ||
304 state
->ARB_texture_cube_map_array_enable
;
308 texture_query_levels(const _mesa_glsl_parse_state
*state
)
310 return state
->is_version(430, 0) ||
311 state
->ARB_texture_query_levels_enable
;
315 texture_query_lod(const _mesa_glsl_parse_state
*state
)
317 return state
->stage
== MESA_SHADER_FRAGMENT
&&
318 state
->ARB_texture_query_lod_enable
;
322 texture_gather(const _mesa_glsl_parse_state
*state
)
324 return state
->is_version(400, 0) ||
325 state
->ARB_texture_gather_enable
||
326 state
->ARB_gpu_shader5_enable
;
330 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
332 return state
->is_version(400, 310) ||
333 state
->ARB_texture_gather_enable
||
334 state
->ARB_gpu_shader5_enable
;
337 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
338 * used for relaxation of const offset requirements.
341 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
343 return !state
->is_version(400, 0) &&
344 !state
->ARB_gpu_shader5_enable
&&
345 (state
->ARB_texture_gather_enable
||
346 state
->is_version(0, 310));
349 /* Desktop GL or OES_standard_derivatives + fragment shader only */
351 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
353 return state
->stage
== MESA_SHADER_FRAGMENT
&&
354 (state
->is_version(110, 300) ||
355 state
->OES_standard_derivatives_enable
);
359 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
361 return state
->stage
== MESA_SHADER_FRAGMENT
&&
362 (state
->is_version(450, 0) ||
363 state
->ARB_derivative_control_enable
);
367 tex1d_lod(const _mesa_glsl_parse_state
*state
)
369 return !state
->es_shader
&& lod_exists_in_stage(state
);
372 /** True if sampler3D exists */
374 tex3d(const _mesa_glsl_parse_state
*state
)
376 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
377 * OES_texture_3D extension, and in GLSL ES 3.00.
379 return !state
->es_shader
||
380 state
->OES_texture_3D_enable
||
381 state
->language_version
>= 300;
385 fs_tex3d(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
392 tex3d_lod(const _mesa_glsl_parse_state
*state
)
394 return tex3d(state
) && lod_exists_in_stage(state
);
398 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
400 return state
->has_atomic_counters();
404 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
406 return state
->ARB_shader_storage_buffer_object_enable
;
410 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
412 return state
->AMD_shader_trinary_minmax_enable
;
416 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
418 return (state
->is_version(420, 310) ||
419 state
->ARB_shader_image_load_store_enable
);
423 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
425 return (state
->is_version(420, 0) ||
426 state
->ARB_shader_image_load_store_enable
);
430 shader_image_size(const _mesa_glsl_parse_state
*state
)
432 return state
->is_version(430, 310) ||
433 state
->ARB_shader_image_size_enable
;
437 shader_samples(const _mesa_glsl_parse_state
*state
)
439 return state
->is_version(450, 0) ||
440 state
->ARB_shader_texture_image_samples_enable
;
444 gs_streams(const _mesa_glsl_parse_state
*state
)
446 return gpu_shader5(state
) && gs_only(state
);
450 fp64(const _mesa_glsl_parse_state
*state
)
452 return state
->has_double();
456 barrier_supported(const _mesa_glsl_parse_state
*state
)
458 return state
->stage
== MESA_SHADER_COMPUTE
||
459 state
->stage
== MESA_SHADER_TESS_CTRL
;
464 /******************************************************************************/
469 * builtin_builder: A singleton object representing the core of the built-in
472 * It generates IR for every built-in function signature, and organizes them
475 class builtin_builder
{
482 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
483 const char *name
, exec_list
*actual_parameters
);
486 * A shader to hold all the built-in signatures; created by this module.
488 * This includes signatures for every built-in, regardless of version or
489 * enabled extensions. The availability predicate associated with each
490 * signature allows matching_signature() to filter out the irrelevant ones.
497 /** Global variables used by built-in functions. */
498 ir_variable
*gl_ModelViewProjectionMatrix
;
499 ir_variable
*gl_Vertex
;
501 void create_shader();
502 void create_intrinsics();
503 void create_builtins();
506 * IR builder helpers:
508 * These convenience functions assist in emitting IR, but don't necessarily
509 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
512 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
513 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
514 ir_constant
*imm(float f
, unsigned vector_elements
=1);
515 ir_constant
*imm(int i
, unsigned vector_elements
=1);
516 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
517 ir_constant
*imm(double d
, unsigned vector_elements
=1);
518 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
519 ir_dereference_variable
*var_ref(ir_variable
*var
);
520 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
521 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
523 ir_expression
*asin_expr(ir_variable
*x
);
524 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
527 * Call function \param f with parameters specified as the linked
528 * list \param params of \c ir_variable objects. \param ret should
529 * point to the ir_variable that will hold the function return
530 * value, or be \c NULL if the function has void return type.
532 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
534 /** Create a new function and add the given signatures. */
535 void add_function(const char *name
, ...);
537 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
538 unsigned num_arguments
,
541 enum image_function_flags
{
542 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
543 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
544 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
545 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
546 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
547 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
548 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
549 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
553 * Create a new image built-in function for all known image types.
554 * \p flags is a bitfield of \c image_function_flags flags.
556 void add_image_function(const char *name
,
557 const char *intrinsic_name
,
558 image_prototype_ctr prototype
,
559 unsigned num_arguments
,
563 * Create new functions for all known image built-ins and types.
564 * If \p glsl is \c true, use the GLSL built-in names and emit code
565 * to call into the actual compiler intrinsic. If \p glsl is
566 * false, emit a function prototype with no body for each image
569 void add_image_functions(bool glsl
);
571 ir_function_signature
*new_sig(const glsl_type
*return_type
,
572 builtin_available_predicate avail
,
573 int num_params
, ...);
576 * Function signature generators:
579 ir_function_signature
*unop(builtin_available_predicate avail
,
580 ir_expression_operation opcode
,
581 const glsl_type
*return_type
,
582 const glsl_type
*param_type
);
583 ir_function_signature
*binop(ir_expression_operation opcode
,
584 builtin_available_predicate avail
,
585 const glsl_type
*return_type
,
586 const glsl_type
*param0_type
,
587 const glsl_type
*param1_type
);
589 #define B0(X) ir_function_signature *_##X();
590 #define B1(X) ir_function_signature *_##X(const glsl_type *);
591 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
592 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
593 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
594 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
631 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
632 const glsl_type
*val_type
,
633 const glsl_type
*blend_type
);
642 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
643 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
644 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
645 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
646 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
647 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
648 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
649 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
650 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
651 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
652 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
653 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
666 BA1(determinant_mat2
);
667 BA1(determinant_mat3
);
668 BA1(determinant_mat4
);
676 BA1(greaterThanEqual
);
685 /** Flags to _texture() */
686 #define TEX_PROJECT 1
688 #define TEX_COMPONENT 4
689 #define TEX_OFFSET_NONCONST 8
690 #define TEX_OFFSET_ARRAY 16
692 ir_function_signature
*_texture(ir_texture_opcode opcode
,
693 builtin_available_predicate avail
,
694 const glsl_type
*return_type
,
695 const glsl_type
*sampler_type
,
696 const glsl_type
*coord_type
,
698 B0(textureCubeArrayShadow
);
699 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
700 const glsl_type
*return_type
,
701 const glsl_type
*sampler_type
,
702 const glsl_type
*coord_type
,
703 const glsl_type
*offset_type
= NULL
);
707 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
708 const glsl_type
*stream_type
);
709 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
710 const glsl_type
*stream_type
);
713 BA2(textureQueryLod
);
714 B1(textureQueryLevels
);
742 B1(interpolateAtCentroid
)
743 B1(interpolateAtOffset
)
744 B1(interpolateAtSample
)
746 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
747 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
748 builtin_available_predicate avail
);
750 ir_function_signature
*_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
751 const glsl_type
*type
);
752 ir_function_signature
*_atomic_ssbo_op2(const char *intrinsic
,
753 builtin_available_predicate avail
,
754 const glsl_type
*type
);
755 ir_function_signature
*_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
756 const glsl_type
*type
);
757 ir_function_signature
*_atomic_ssbo_op3(const char *intrinsic
,
758 builtin_available_predicate avail
,
759 const glsl_type
*type
);
765 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
766 unsigned num_arguments
,
768 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
769 unsigned num_arguments
,
771 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
772 unsigned num_arguments
,
774 ir_function_signature
*_image(image_prototype_ctr prototype
,
775 const glsl_type
*image_type
,
776 const char *intrinsic_name
,
777 unsigned num_arguments
,
780 ir_function_signature
*_memory_barrier_intrinsic(
781 builtin_available_predicate avail
);
782 ir_function_signature
*_memory_barrier(
783 builtin_available_predicate avail
);
794 } /* anonymous namespace */
797 * Core builtin_builder functionality:
800 builtin_builder::builtin_builder()
802 gl_ModelViewProjectionMatrix(NULL
),
808 builtin_builder::~builtin_builder()
810 ralloc_free(mem_ctx
);
813 ir_function_signature
*
814 builtin_builder::find(_mesa_glsl_parse_state
*state
,
815 const char *name
, exec_list
*actual_parameters
)
817 /* The shader currently being compiled requested a built-in function;
818 * it needs to link against builtin_builder::shader in order to get them.
820 * Even if we don't find a matching signature, we still need to do this so
821 * that the "no matching signature" error will list potential candidates
822 * from the available built-ins.
824 state
->uses_builtin_functions
= true;
826 ir_function
*f
= shader
->symbols
->get_function(name
);
830 ir_function_signature
*sig
=
831 f
->matching_signature(state
, actual_parameters
, true);
839 builtin_builder::initialize()
841 /* If already initialized, don't do it again. */
845 mem_ctx
= ralloc_context(NULL
);
852 builtin_builder::release()
854 ralloc_free(mem_ctx
);
862 builtin_builder::create_shader()
864 /* The target doesn't actually matter. There's no target for generic
865 * GLSL utility code that could be linked against any stage, so just
866 * arbitrarily pick GL_VERTEX_SHADER.
868 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
869 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
871 gl_ModelViewProjectionMatrix
=
872 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
873 "gl_ModelViewProjectionMatrix",
876 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
878 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
879 shader
->symbols
->add_variable(gl_Vertex
);
885 * Create ir_function and ir_function_signature objects for each
889 builtin_builder::create_intrinsics()
891 add_function("__intrinsic_atomic_read",
892 _atomic_counter_intrinsic(shader_atomic_counters
),
894 add_function("__intrinsic_atomic_increment",
895 _atomic_counter_intrinsic(shader_atomic_counters
),
897 add_function("__intrinsic_atomic_predecrement",
898 _atomic_counter_intrinsic(shader_atomic_counters
),
901 add_function("__intrinsic_ssbo_atomic_add",
902 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
903 glsl_type::uint_type
),
904 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
905 glsl_type::int_type
),
907 add_function("__intrinsic_ssbo_atomic_min",
908 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
909 glsl_type::uint_type
),
910 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
911 glsl_type::int_type
),
913 add_function("__intrinsic_ssbo_atomic_max",
914 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
915 glsl_type::uint_type
),
916 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
917 glsl_type::int_type
),
919 add_function("__intrinsic_ssbo_atomic_and",
920 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
921 glsl_type::uint_type
),
922 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
923 glsl_type::int_type
),
925 add_function("__intrinsic_ssbo_atomic_or",
926 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
927 glsl_type::uint_type
),
928 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
929 glsl_type::int_type
),
931 add_function("__intrinsic_ssbo_atomic_xor",
932 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
933 glsl_type::uint_type
),
934 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
935 glsl_type::int_type
),
937 add_function("__intrinsic_ssbo_atomic_exchange",
938 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
939 glsl_type::uint_type
),
940 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
941 glsl_type::int_type
),
943 add_function("__intrinsic_ssbo_atomic_comp_swap",
944 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
945 glsl_type::uint_type
),
946 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
947 glsl_type::int_type
),
950 add_image_functions(false);
952 add_function("__intrinsic_memory_barrier",
953 _memory_barrier_intrinsic(shader_image_load_store
),
958 * Create ir_function and ir_function_signature objects for each built-in.
960 * Contains a list of every available built-in.
963 builtin_builder::create_builtins()
966 add_function(#NAME, \
967 _##NAME(glsl_type::float_type), \
968 _##NAME(glsl_type::vec2_type), \
969 _##NAME(glsl_type::vec3_type), \
970 _##NAME(glsl_type::vec4_type), \
974 add_function(#NAME, \
975 _##NAME(always_available, glsl_type::float_type), \
976 _##NAME(always_available, glsl_type::vec2_type), \
977 _##NAME(always_available, glsl_type::vec3_type), \
978 _##NAME(always_available, glsl_type::vec4_type), \
979 _##NAME(fp64, glsl_type::double_type), \
980 _##NAME(fp64, glsl_type::dvec2_type), \
981 _##NAME(fp64, glsl_type::dvec3_type), \
982 _##NAME(fp64, glsl_type::dvec4_type), \
985 #define FD130(NAME) \
986 add_function(#NAME, \
987 _##NAME(v130, glsl_type::float_type), \
988 _##NAME(v130, glsl_type::vec2_type), \
989 _##NAME(v130, glsl_type::vec3_type), \
990 _##NAME(v130, glsl_type::vec4_type), \
991 _##NAME(fp64, glsl_type::double_type), \
992 _##NAME(fp64, glsl_type::dvec2_type), \
993 _##NAME(fp64, glsl_type::dvec3_type), \
994 _##NAME(fp64, glsl_type::dvec4_type), \
997 #define FDGS5(NAME) \
998 add_function(#NAME, \
999 _##NAME(gpu_shader5, glsl_type::float_type), \
1000 _##NAME(gpu_shader5, glsl_type::vec2_type), \
1001 _##NAME(gpu_shader5, glsl_type::vec3_type), \
1002 _##NAME(gpu_shader5, glsl_type::vec4_type), \
1003 _##NAME(fp64, glsl_type::double_type), \
1004 _##NAME(fp64, glsl_type::dvec2_type), \
1005 _##NAME(fp64, glsl_type::dvec3_type), \
1006 _##NAME(fp64, glsl_type::dvec4_type), \
1010 add_function(#NAME, \
1011 _##NAME(glsl_type::float_type), \
1012 _##NAME(glsl_type::vec2_type), \
1013 _##NAME(glsl_type::vec3_type), \
1014 _##NAME(glsl_type::vec4_type), \
1015 _##NAME(glsl_type::int_type), \
1016 _##NAME(glsl_type::ivec2_type), \
1017 _##NAME(glsl_type::ivec3_type), \
1018 _##NAME(glsl_type::ivec4_type), \
1022 add_function(#NAME, \
1023 _##NAME(always_available, glsl_type::float_type), \
1024 _##NAME(always_available, glsl_type::vec2_type), \
1025 _##NAME(always_available, glsl_type::vec3_type), \
1026 _##NAME(always_available, glsl_type::vec4_type), \
1027 _##NAME(always_available, glsl_type::int_type), \
1028 _##NAME(always_available, glsl_type::ivec2_type), \
1029 _##NAME(always_available, glsl_type::ivec3_type), \
1030 _##NAME(always_available, glsl_type::ivec4_type), \
1031 _##NAME(fp64, glsl_type::double_type), \
1032 _##NAME(fp64, glsl_type::dvec2_type), \
1033 _##NAME(fp64, glsl_type::dvec3_type), \
1034 _##NAME(fp64, glsl_type::dvec4_type), \
1037 #define FIUD(NAME) \
1038 add_function(#NAME, \
1039 _##NAME(always_available, glsl_type::float_type), \
1040 _##NAME(always_available, glsl_type::vec2_type), \
1041 _##NAME(always_available, glsl_type::vec3_type), \
1042 _##NAME(always_available, glsl_type::vec4_type), \
1044 _##NAME(always_available, glsl_type::int_type), \
1045 _##NAME(always_available, glsl_type::ivec2_type), \
1046 _##NAME(always_available, glsl_type::ivec3_type), \
1047 _##NAME(always_available, glsl_type::ivec4_type), \
1049 _##NAME(v130, glsl_type::uint_type), \
1050 _##NAME(v130, glsl_type::uvec2_type), \
1051 _##NAME(v130, glsl_type::uvec3_type), \
1052 _##NAME(v130, glsl_type::uvec4_type), \
1053 _##NAME(fp64, glsl_type::double_type), \
1054 _##NAME(fp64, glsl_type::dvec2_type), \
1055 _##NAME(fp64, glsl_type::dvec3_type), \
1056 _##NAME(fp64, glsl_type::dvec4_type), \
1060 add_function(#NAME, \
1061 _##NAME(glsl_type::int_type), \
1062 _##NAME(glsl_type::ivec2_type), \
1063 _##NAME(glsl_type::ivec3_type), \
1064 _##NAME(glsl_type::ivec4_type), \
1066 _##NAME(glsl_type::uint_type), \
1067 _##NAME(glsl_type::uvec2_type), \
1068 _##NAME(glsl_type::uvec3_type), \
1069 _##NAME(glsl_type::uvec4_type), \
1072 #define FIUBD(NAME) \
1073 add_function(#NAME, \
1074 _##NAME(always_available, glsl_type::float_type), \
1075 _##NAME(always_available, glsl_type::vec2_type), \
1076 _##NAME(always_available, glsl_type::vec3_type), \
1077 _##NAME(always_available, glsl_type::vec4_type), \
1079 _##NAME(always_available, glsl_type::int_type), \
1080 _##NAME(always_available, glsl_type::ivec2_type), \
1081 _##NAME(always_available, glsl_type::ivec3_type), \
1082 _##NAME(always_available, glsl_type::ivec4_type), \
1084 _##NAME(v130, glsl_type::uint_type), \
1085 _##NAME(v130, glsl_type::uvec2_type), \
1086 _##NAME(v130, glsl_type::uvec3_type), \
1087 _##NAME(v130, glsl_type::uvec4_type), \
1089 _##NAME(always_available, glsl_type::bool_type), \
1090 _##NAME(always_available, glsl_type::bvec2_type), \
1091 _##NAME(always_available, glsl_type::bvec3_type), \
1092 _##NAME(always_available, glsl_type::bvec4_type), \
1094 _##NAME(fp64, glsl_type::double_type), \
1095 _##NAME(fp64, glsl_type::dvec2_type), \
1096 _##NAME(fp64, glsl_type::dvec3_type), \
1097 _##NAME(fp64, glsl_type::dvec4_type), \
1100 #define FIUD2_MIXED(NAME) \
1101 add_function(#NAME, \
1102 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1103 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1104 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1105 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1107 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1108 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1109 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1111 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1112 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1113 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1114 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1116 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1117 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1118 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1120 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1121 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1122 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1123 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1125 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1126 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1127 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1129 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1130 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1131 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1132 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1133 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1134 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1135 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1146 add_function("atan",
1147 _atan(glsl_type::float_type
),
1148 _atan(glsl_type::vec2_type
),
1149 _atan(glsl_type::vec3_type
),
1150 _atan(glsl_type::vec4_type
),
1151 _atan2(glsl_type::float_type
),
1152 _atan2(glsl_type::vec2_type
),
1153 _atan2(glsl_type::vec3_type
),
1154 _atan2(glsl_type::vec4_type
),
1180 _mod(glsl_type::float_type
, glsl_type::float_type
),
1181 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1182 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1183 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1185 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1186 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1187 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1189 _mod(glsl_type::double_type
, glsl_type::double_type
),
1190 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1191 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1192 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1194 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1195 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1196 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1206 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1207 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1208 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1209 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1211 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1212 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1213 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1215 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1216 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1217 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1218 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1220 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1221 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1222 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1224 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1225 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1226 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1227 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1229 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1230 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1231 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1232 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1234 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1235 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1236 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1237 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1239 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1240 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1241 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1242 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1244 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1245 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1246 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1247 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1250 add_function("step",
1251 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1252 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1253 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1254 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1256 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1257 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1258 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1259 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1260 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1261 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1262 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1264 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1265 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1266 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1269 add_function("smoothstep",
1270 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1271 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1272 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1273 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1275 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1276 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1277 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1278 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1279 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1280 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1281 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1283 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1284 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1285 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1293 add_function("intBitsToFloat",
1294 _intBitsToFloat(glsl_type::int_type
),
1295 _intBitsToFloat(glsl_type::ivec2_type
),
1296 _intBitsToFloat(glsl_type::ivec3_type
),
1297 _intBitsToFloat(glsl_type::ivec4_type
),
1299 add_function("uintBitsToFloat",
1300 _uintBitsToFloat(glsl_type::uint_type
),
1301 _uintBitsToFloat(glsl_type::uvec2_type
),
1302 _uintBitsToFloat(glsl_type::uvec3_type
),
1303 _uintBitsToFloat(glsl_type::uvec4_type
),
1306 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1307 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1308 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1309 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1310 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1311 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1312 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1313 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1314 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1315 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1316 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1317 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1324 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1325 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1328 add_function("ftransform", _ftransform(), NULL
);
1333 add_function("matrixCompMult",
1334 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1335 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1336 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1337 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1338 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1339 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1340 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1341 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1342 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1343 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1344 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1345 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1346 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1347 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1348 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1349 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1350 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1351 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1353 add_function("outerProduct",
1354 _outerProduct(v120
, glsl_type::mat2_type
),
1355 _outerProduct(v120
, glsl_type::mat3_type
),
1356 _outerProduct(v120
, glsl_type::mat4_type
),
1357 _outerProduct(v120
, glsl_type::mat2x3_type
),
1358 _outerProduct(v120
, glsl_type::mat2x4_type
),
1359 _outerProduct(v120
, glsl_type::mat3x2_type
),
1360 _outerProduct(v120
, glsl_type::mat3x4_type
),
1361 _outerProduct(v120
, glsl_type::mat4x2_type
),
1362 _outerProduct(v120
, glsl_type::mat4x3_type
),
1363 _outerProduct(fp64
, glsl_type::dmat2_type
),
1364 _outerProduct(fp64
, glsl_type::dmat3_type
),
1365 _outerProduct(fp64
, glsl_type::dmat4_type
),
1366 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1367 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1368 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1369 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1370 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1371 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1373 add_function("determinant",
1374 _determinant_mat2(v120
, glsl_type::mat2_type
),
1375 _determinant_mat3(v120
, glsl_type::mat3_type
),
1376 _determinant_mat4(v120
, glsl_type::mat4_type
),
1377 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1378 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1379 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1382 add_function("inverse",
1383 _inverse_mat2(v120
, glsl_type::mat2_type
),
1384 _inverse_mat3(v120
, glsl_type::mat3_type
),
1385 _inverse_mat4(v120
, glsl_type::mat4_type
),
1386 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1387 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1388 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1390 add_function("transpose",
1391 _transpose(v120
, glsl_type::mat2_type
),
1392 _transpose(v120
, glsl_type::mat3_type
),
1393 _transpose(v120
, glsl_type::mat4_type
),
1394 _transpose(v120
, glsl_type::mat2x3_type
),
1395 _transpose(v120
, glsl_type::mat2x4_type
),
1396 _transpose(v120
, glsl_type::mat3x2_type
),
1397 _transpose(v120
, glsl_type::mat3x4_type
),
1398 _transpose(v120
, glsl_type::mat4x2_type
),
1399 _transpose(v120
, glsl_type::mat4x3_type
),
1400 _transpose(fp64
, glsl_type::dmat2_type
),
1401 _transpose(fp64
, glsl_type::dmat3_type
),
1402 _transpose(fp64
, glsl_type::dmat4_type
),
1403 _transpose(fp64
, glsl_type::dmat2x3_type
),
1404 _transpose(fp64
, glsl_type::dmat2x4_type
),
1405 _transpose(fp64
, glsl_type::dmat3x2_type
),
1406 _transpose(fp64
, glsl_type::dmat3x4_type
),
1407 _transpose(fp64
, glsl_type::dmat4x2_type
),
1408 _transpose(fp64
, glsl_type::dmat4x3_type
),
1413 FIUD(greaterThanEqual
)
1418 _any(glsl_type::bvec2_type
),
1419 _any(glsl_type::bvec3_type
),
1420 _any(glsl_type::bvec4_type
),
1424 _all(glsl_type::bvec2_type
),
1425 _all(glsl_type::bvec3_type
),
1426 _all(glsl_type::bvec4_type
),
1430 _not(glsl_type::bvec2_type
),
1431 _not(glsl_type::bvec3_type
),
1432 _not(glsl_type::bvec4_type
),
1435 add_function("textureSize",
1436 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1437 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1438 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1440 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1441 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1442 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1444 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1445 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1446 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1448 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1449 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1450 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1452 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1453 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1454 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1456 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1457 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1458 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1459 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1460 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1461 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1463 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1464 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1466 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1467 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1468 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1469 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1471 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1472 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1473 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1474 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1476 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1477 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1478 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1479 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1480 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1481 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1483 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1484 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1485 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1488 add_function("textureSamples",
1489 _textureSamples(glsl_type::sampler2DMS_type
),
1490 _textureSamples(glsl_type::isampler2DMS_type
),
1491 _textureSamples(glsl_type::usampler2DMS_type
),
1493 _textureSamples(glsl_type::sampler2DMSArray_type
),
1494 _textureSamples(glsl_type::isampler2DMSArray_type
),
1495 _textureSamples(glsl_type::usampler2DMSArray_type
),
1498 add_function("texture",
1499 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1500 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1501 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1503 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1504 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1505 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1507 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1508 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1509 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1511 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1512 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1513 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1515 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1516 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1517 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1519 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1520 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1521 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1523 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1524 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1525 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1527 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1528 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1529 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1531 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1532 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1533 /* samplerCubeArrayShadow is special; it has an extra parameter
1534 * for the shadow comparitor since there is no vec5 type.
1536 _textureCubeArrayShadow(),
1538 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1539 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1540 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1542 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1544 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1545 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1546 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1548 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1549 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1550 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1552 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1553 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1554 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1556 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1557 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1558 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1560 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1561 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1562 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1564 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1565 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1566 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1568 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1569 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1570 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1572 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1573 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1574 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1576 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1579 add_function("textureLod",
1580 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1581 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1582 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1584 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1585 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1586 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1588 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1589 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1590 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1592 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1593 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1594 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1596 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1597 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1599 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1600 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1601 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1603 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1604 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1605 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1607 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1608 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1609 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1611 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1614 add_function("textureOffset",
1615 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1616 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1617 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1619 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1620 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1621 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1623 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1624 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1625 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1627 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1628 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1629 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1631 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1633 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1634 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1636 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1637 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1638 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1640 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1641 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1642 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1644 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1646 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1647 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1648 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1650 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1651 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1652 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1654 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1655 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1656 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1658 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1659 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1661 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1662 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1663 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1665 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1666 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1667 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1669 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1672 add_function("textureProj",
1673 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1674 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1675 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1676 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1677 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1678 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1680 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1681 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1682 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1683 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1684 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1685 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1687 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1688 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1689 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1691 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1692 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1694 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1695 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1696 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1697 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1698 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1699 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1701 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1703 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1704 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1705 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1706 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1707 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1708 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1710 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1711 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1712 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1713 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1714 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1715 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1717 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1718 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1719 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1721 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1722 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1725 add_function("texelFetch",
1726 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1727 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1728 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1730 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1731 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1732 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1734 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1735 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1736 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1738 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1739 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1740 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1742 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1743 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1744 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1746 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1747 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1748 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1750 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1751 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1752 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1754 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1755 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1756 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1758 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1759 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1760 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1763 add_function("texelFetchOffset",
1764 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1765 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1766 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1768 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1769 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1770 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1772 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1773 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1774 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1776 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1777 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1778 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1780 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1781 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1782 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1784 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1785 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1786 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1790 add_function("textureProjOffset",
1791 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1792 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1793 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1794 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1795 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1796 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1798 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1799 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1800 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1801 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1802 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1803 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1805 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1806 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1807 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1809 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1810 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1812 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1813 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1814 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1815 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1816 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1817 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1819 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1821 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1822 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1823 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1824 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1825 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1826 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1828 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1829 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1830 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1831 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1832 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1833 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1835 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1836 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1837 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1839 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1840 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1843 add_function("textureLodOffset",
1844 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1845 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1846 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1848 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1849 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1850 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1852 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1853 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1854 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1856 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1857 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1859 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1860 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1861 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1863 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1864 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1865 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1867 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1870 add_function("textureProjLod",
1871 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1872 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1873 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1874 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1875 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1876 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1878 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1879 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1880 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1881 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1882 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1883 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1885 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1886 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1887 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1889 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1890 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1893 add_function("textureProjLodOffset",
1894 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1895 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1896 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1897 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1898 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1899 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1901 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1902 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1903 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1904 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1905 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1906 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1908 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1909 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1910 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1912 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1916 add_function("textureGrad",
1917 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1918 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1919 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1921 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1922 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1923 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1925 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1926 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1927 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1929 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1930 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1931 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1933 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1934 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1935 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1937 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1939 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1940 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1941 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1943 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1944 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1945 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1947 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1948 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1949 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1951 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1952 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1953 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1955 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1956 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1959 add_function("textureGradOffset",
1960 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1961 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1962 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1964 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1965 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1966 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1968 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1969 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1970 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1972 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1973 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1974 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1976 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1978 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1979 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1981 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1982 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1983 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1985 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1986 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1987 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1989 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1990 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1993 add_function("textureProjGrad",
1994 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1995 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1996 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1997 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1998 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1999 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2001 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2002 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2003 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2004 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2005 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2006 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2008 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2009 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2010 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2012 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2013 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2014 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2015 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2016 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2017 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2019 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2021 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2022 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2025 add_function("textureProjGradOffset",
2026 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2027 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2028 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2029 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2030 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2031 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2033 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2034 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2035 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2036 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2037 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2038 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2040 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2041 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2042 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2044 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2045 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2046 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2047 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2048 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2049 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2051 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2053 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2054 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2057 add_function("EmitVertex", _EmitVertex(), NULL
);
2058 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2059 add_function("EmitStreamVertex",
2060 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2061 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2063 add_function("EndStreamPrimitive",
2064 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2065 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2067 add_function("barrier", _barrier(), NULL
);
2069 add_function("textureQueryLOD",
2070 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2071 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2072 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2074 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2075 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2076 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2078 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2079 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2080 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2082 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2083 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2084 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2086 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2087 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2088 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2090 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2091 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2092 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2094 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2095 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2096 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2098 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2099 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2100 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2101 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2102 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2103 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2106 add_function("textureQueryLod",
2107 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2108 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2109 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2111 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2112 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2113 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2115 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2116 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2117 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2119 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2120 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2121 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2123 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2124 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2125 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2127 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2128 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2129 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2131 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2132 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2133 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2135 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2136 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2137 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2138 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2139 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2140 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2143 add_function("textureQueryLevels",
2144 _textureQueryLevels(glsl_type::sampler1D_type
),
2145 _textureQueryLevels(glsl_type::sampler2D_type
),
2146 _textureQueryLevels(glsl_type::sampler3D_type
),
2147 _textureQueryLevels(glsl_type::samplerCube_type
),
2148 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2149 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2150 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2151 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2152 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2153 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2154 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2155 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2156 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2158 _textureQueryLevels(glsl_type::isampler1D_type
),
2159 _textureQueryLevels(glsl_type::isampler2D_type
),
2160 _textureQueryLevels(glsl_type::isampler3D_type
),
2161 _textureQueryLevels(glsl_type::isamplerCube_type
),
2162 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2163 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2164 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2166 _textureQueryLevels(glsl_type::usampler1D_type
),
2167 _textureQueryLevels(glsl_type::usampler2D_type
),
2168 _textureQueryLevels(glsl_type::usampler3D_type
),
2169 _textureQueryLevels(glsl_type::usamplerCube_type
),
2170 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2171 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2172 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2176 add_function("texture1D",
2177 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2178 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2181 add_function("texture1DArray",
2182 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2183 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2186 add_function("texture1DProj",
2187 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2188 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2189 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2190 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2193 add_function("texture1DLod",
2194 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2197 add_function("texture1DArrayLod",
2198 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2201 add_function("texture1DProjLod",
2202 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2203 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2206 add_function("texture2D",
2207 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2208 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2209 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2212 add_function("texture2DArray",
2213 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2214 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2217 add_function("texture2DProj",
2218 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2219 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2220 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2221 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2222 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2223 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2226 add_function("texture2DLod",
2227 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2230 add_function("texture2DArrayLod",
2231 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2234 add_function("texture2DProjLod",
2235 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2236 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2239 add_function("texture3D",
2240 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2241 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2244 add_function("texture3DProj",
2245 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2246 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2249 add_function("texture3DLod",
2250 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2253 add_function("texture3DProjLod",
2254 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2257 add_function("textureCube",
2258 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2259 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2262 add_function("textureCubeLod",
2263 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2266 add_function("texture2DRect",
2267 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2270 add_function("texture2DRectProj",
2271 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2272 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2275 add_function("shadow1D",
2276 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2277 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2280 add_function("shadow1DArray",
2281 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2282 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2285 add_function("shadow2D",
2286 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2287 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2290 add_function("shadow2DArray",
2291 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2292 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2295 add_function("shadow1DProj",
2296 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2297 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2300 add_function("shadow2DProj",
2301 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2302 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2305 add_function("shadow1DLod",
2306 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2309 add_function("shadow2DLod",
2310 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2313 add_function("shadow1DArrayLod",
2314 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2317 add_function("shadow1DProjLod",
2318 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2321 add_function("shadow2DProjLod",
2322 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2325 add_function("shadow2DRect",
2326 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2329 add_function("shadow2DRectProj",
2330 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2333 add_function("texture1DGradARB",
2334 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2337 add_function("texture1DProjGradARB",
2338 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2339 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2342 add_function("texture2DGradARB",
2343 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2346 add_function("texture2DProjGradARB",
2347 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2348 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2351 add_function("texture3DGradARB",
2352 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2355 add_function("texture3DProjGradARB",
2356 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2359 add_function("textureCubeGradARB",
2360 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2363 add_function("shadow1DGradARB",
2364 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2367 add_function("shadow1DProjGradARB",
2368 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2371 add_function("shadow2DGradARB",
2372 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2375 add_function("shadow2DProjGradARB",
2376 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2379 add_function("texture2DRectGradARB",
2380 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2383 add_function("texture2DRectProjGradARB",
2384 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2385 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2388 add_function("shadow2DRectGradARB",
2389 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2392 add_function("shadow2DRectProjGradARB",
2393 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2396 add_function("textureGather",
2397 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2398 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2399 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2401 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2402 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2403 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2405 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2406 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2407 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2409 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2410 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2411 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2413 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2414 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2415 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2417 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2418 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2419 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2421 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2422 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2423 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2425 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2426 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2427 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2429 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2430 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2431 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2433 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2434 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2435 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2437 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2438 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2439 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2440 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2441 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2444 add_function("textureGatherOffset",
2445 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2446 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2447 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2449 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2450 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2451 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2453 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2454 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2455 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2457 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2458 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2459 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2461 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2462 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2463 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2465 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2466 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2467 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2469 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2470 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2471 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2473 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2474 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2475 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2477 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2478 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2479 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2481 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2482 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2483 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2485 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2486 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2487 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2489 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2490 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2493 add_function("textureGatherOffsets",
2494 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2495 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2496 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2498 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2499 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2500 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2502 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2503 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2504 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2506 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2507 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2508 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2510 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2511 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2512 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2514 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2515 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2516 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2518 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2519 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2520 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2545 add_function("ldexp",
2546 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2547 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2548 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2549 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2550 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2551 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2552 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2553 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2556 add_function("frexp",
2557 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2558 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2559 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2560 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2561 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2562 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2563 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2564 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2566 add_function("uaddCarry",
2567 _uaddCarry(glsl_type::uint_type
),
2568 _uaddCarry(glsl_type::uvec2_type
),
2569 _uaddCarry(glsl_type::uvec3_type
),
2570 _uaddCarry(glsl_type::uvec4_type
),
2572 add_function("usubBorrow",
2573 _usubBorrow(glsl_type::uint_type
),
2574 _usubBorrow(glsl_type::uvec2_type
),
2575 _usubBorrow(glsl_type::uvec3_type
),
2576 _usubBorrow(glsl_type::uvec4_type
),
2578 add_function("imulExtended",
2579 _mulExtended(glsl_type::int_type
),
2580 _mulExtended(glsl_type::ivec2_type
),
2581 _mulExtended(glsl_type::ivec3_type
),
2582 _mulExtended(glsl_type::ivec4_type
),
2584 add_function("umulExtended",
2585 _mulExtended(glsl_type::uint_type
),
2586 _mulExtended(glsl_type::uvec2_type
),
2587 _mulExtended(glsl_type::uvec3_type
),
2588 _mulExtended(glsl_type::uvec4_type
),
2590 add_function("interpolateAtCentroid",
2591 _interpolateAtCentroid(glsl_type::float_type
),
2592 _interpolateAtCentroid(glsl_type::vec2_type
),
2593 _interpolateAtCentroid(glsl_type::vec3_type
),
2594 _interpolateAtCentroid(glsl_type::vec4_type
),
2596 add_function("interpolateAtOffset",
2597 _interpolateAtOffset(glsl_type::float_type
),
2598 _interpolateAtOffset(glsl_type::vec2_type
),
2599 _interpolateAtOffset(glsl_type::vec3_type
),
2600 _interpolateAtOffset(glsl_type::vec4_type
),
2602 add_function("interpolateAtSample",
2603 _interpolateAtSample(glsl_type::float_type
),
2604 _interpolateAtSample(glsl_type::vec2_type
),
2605 _interpolateAtSample(glsl_type::vec3_type
),
2606 _interpolateAtSample(glsl_type::vec4_type
),
2609 add_function("atomicCounter",
2610 _atomic_counter_op("__intrinsic_atomic_read",
2611 shader_atomic_counters
),
2613 add_function("atomicCounterIncrement",
2614 _atomic_counter_op("__intrinsic_atomic_increment",
2615 shader_atomic_counters
),
2617 add_function("atomicCounterDecrement",
2618 _atomic_counter_op("__intrinsic_atomic_predecrement",
2619 shader_atomic_counters
),
2622 add_function("atomicAdd",
2623 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2624 shader_storage_buffer_object
,
2625 glsl_type::uint_type
),
2626 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2627 shader_storage_buffer_object
,
2628 glsl_type::int_type
),
2630 add_function("atomicMin",
2631 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2632 shader_storage_buffer_object
,
2633 glsl_type::uint_type
),
2634 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2635 shader_storage_buffer_object
,
2636 glsl_type::int_type
),
2638 add_function("atomicMax",
2639 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2640 shader_storage_buffer_object
,
2641 glsl_type::uint_type
),
2642 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2643 shader_storage_buffer_object
,
2644 glsl_type::int_type
),
2646 add_function("atomicAnd",
2647 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2648 shader_storage_buffer_object
,
2649 glsl_type::uint_type
),
2650 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2651 shader_storage_buffer_object
,
2652 glsl_type::int_type
),
2654 add_function("atomicOr",
2655 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2656 shader_storage_buffer_object
,
2657 glsl_type::uint_type
),
2658 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2659 shader_storage_buffer_object
,
2660 glsl_type::int_type
),
2662 add_function("atomicXor",
2663 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2664 shader_storage_buffer_object
,
2665 glsl_type::uint_type
),
2666 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2667 shader_storage_buffer_object
,
2668 glsl_type::int_type
),
2670 add_function("atomicExchange",
2671 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2672 shader_storage_buffer_object
,
2673 glsl_type::uint_type
),
2674 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2675 shader_storage_buffer_object
,
2676 glsl_type::int_type
),
2678 add_function("atomicCompSwap",
2679 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2680 shader_storage_buffer_object
,
2681 glsl_type::uint_type
),
2682 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2683 shader_storage_buffer_object
,
2684 glsl_type::int_type
),
2687 add_function("min3",
2688 _min3(glsl_type::float_type
),
2689 _min3(glsl_type::vec2_type
),
2690 _min3(glsl_type::vec3_type
),
2691 _min3(glsl_type::vec4_type
),
2693 _min3(glsl_type::int_type
),
2694 _min3(glsl_type::ivec2_type
),
2695 _min3(glsl_type::ivec3_type
),
2696 _min3(glsl_type::ivec4_type
),
2698 _min3(glsl_type::uint_type
),
2699 _min3(glsl_type::uvec2_type
),
2700 _min3(glsl_type::uvec3_type
),
2701 _min3(glsl_type::uvec4_type
),
2704 add_function("max3",
2705 _max3(glsl_type::float_type
),
2706 _max3(glsl_type::vec2_type
),
2707 _max3(glsl_type::vec3_type
),
2708 _max3(glsl_type::vec4_type
),
2710 _max3(glsl_type::int_type
),
2711 _max3(glsl_type::ivec2_type
),
2712 _max3(glsl_type::ivec3_type
),
2713 _max3(glsl_type::ivec4_type
),
2715 _max3(glsl_type::uint_type
),
2716 _max3(glsl_type::uvec2_type
),
2717 _max3(glsl_type::uvec3_type
),
2718 _max3(glsl_type::uvec4_type
),
2721 add_function("mid3",
2722 _mid3(glsl_type::float_type
),
2723 _mid3(glsl_type::vec2_type
),
2724 _mid3(glsl_type::vec3_type
),
2725 _mid3(glsl_type::vec4_type
),
2727 _mid3(glsl_type::int_type
),
2728 _mid3(glsl_type::ivec2_type
),
2729 _mid3(glsl_type::ivec3_type
),
2730 _mid3(glsl_type::ivec4_type
),
2732 _mid3(glsl_type::uint_type
),
2733 _mid3(glsl_type::uvec2_type
),
2734 _mid3(glsl_type::uvec3_type
),
2735 _mid3(glsl_type::uvec4_type
),
2738 add_image_functions(true);
2740 add_function("memoryBarrier",
2741 _memory_barrier(shader_image_load_store
),
2752 builtin_builder::add_function(const char *name
, ...)
2756 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2760 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2766 stuff
.push_tail(sig
);
2767 validate_ir_tree(&stuff
);
2770 f
->add_signature(sig
);
2774 shader
->symbols
->add_function(f
);
2778 builtin_builder::add_image_function(const char *name
,
2779 const char *intrinsic_name
,
2780 image_prototype_ctr prototype
,
2781 unsigned num_arguments
,
2784 static const glsl_type
*const types
[] = {
2785 glsl_type::image1D_type
,
2786 glsl_type::image2D_type
,
2787 glsl_type::image3D_type
,
2788 glsl_type::image2DRect_type
,
2789 glsl_type::imageCube_type
,
2790 glsl_type::imageBuffer_type
,
2791 glsl_type::image1DArray_type
,
2792 glsl_type::image2DArray_type
,
2793 glsl_type::imageCubeArray_type
,
2794 glsl_type::image2DMS_type
,
2795 glsl_type::image2DMSArray_type
,
2796 glsl_type::iimage1D_type
,
2797 glsl_type::iimage2D_type
,
2798 glsl_type::iimage3D_type
,
2799 glsl_type::iimage2DRect_type
,
2800 glsl_type::iimageCube_type
,
2801 glsl_type::iimageBuffer_type
,
2802 glsl_type::iimage1DArray_type
,
2803 glsl_type::iimage2DArray_type
,
2804 glsl_type::iimageCubeArray_type
,
2805 glsl_type::iimage2DMS_type
,
2806 glsl_type::iimage2DMSArray_type
,
2807 glsl_type::uimage1D_type
,
2808 glsl_type::uimage2D_type
,
2809 glsl_type::uimage3D_type
,
2810 glsl_type::uimage2DRect_type
,
2811 glsl_type::uimageCube_type
,
2812 glsl_type::uimageBuffer_type
,
2813 glsl_type::uimage1DArray_type
,
2814 glsl_type::uimage2DArray_type
,
2815 glsl_type::uimageCubeArray_type
,
2816 glsl_type::uimage2DMS_type
,
2817 glsl_type::uimage2DMSArray_type
2820 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2822 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2823 if ((types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2824 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2825 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2826 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2827 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2828 num_arguments
, flags
));
2831 shader
->symbols
->add_function(f
);
2835 builtin_builder::add_image_functions(bool glsl
)
2837 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2839 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2840 "__intrinsic_image_load",
2841 &builtin_builder::_image_prototype
, 0,
2842 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2843 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2844 IMAGE_FUNCTION_READ_ONLY
));
2846 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2847 "__intrinsic_image_store",
2848 &builtin_builder::_image_prototype
, 1,
2849 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2850 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2851 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2852 IMAGE_FUNCTION_WRITE_ONLY
));
2854 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2856 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2857 "__intrinsic_image_atomic_add",
2858 &builtin_builder::_image_prototype
, 1, atom_flags
);
2860 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2861 "__intrinsic_image_atomic_min",
2862 &builtin_builder::_image_prototype
, 1, atom_flags
);
2864 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2865 "__intrinsic_image_atomic_max",
2866 &builtin_builder::_image_prototype
, 1, atom_flags
);
2868 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2869 "__intrinsic_image_atomic_and",
2870 &builtin_builder::_image_prototype
, 1, atom_flags
);
2872 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2873 "__intrinsic_image_atomic_or",
2874 &builtin_builder::_image_prototype
, 1, atom_flags
);
2876 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2877 "__intrinsic_image_atomic_xor",
2878 &builtin_builder::_image_prototype
, 1, atom_flags
);
2880 add_image_function((glsl
? "imageAtomicExchange" :
2881 "__intrinsic_image_atomic_exchange"),
2882 "__intrinsic_image_atomic_exchange",
2883 &builtin_builder::_image_prototype
, 1, atom_flags
);
2885 add_image_function((glsl
? "imageAtomicCompSwap" :
2886 "__intrinsic_image_atomic_comp_swap"),
2887 "__intrinsic_image_atomic_comp_swap",
2888 &builtin_builder::_image_prototype
, 2, atom_flags
);
2890 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2891 "__intrinsic_image_size",
2892 &builtin_builder::_image_size_prototype
, 1,
2893 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2895 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
2896 "__intrinsic_image_samples",
2897 &builtin_builder::_image_samples_prototype
, 1,
2898 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2899 IMAGE_FUNCTION_MS_ONLY
);
2903 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2905 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2909 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2911 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2915 builtin_builder::imm(float f
, unsigned vector_elements
)
2917 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2921 builtin_builder::imm(int i
, unsigned vector_elements
)
2923 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2927 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2929 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2933 builtin_builder::imm(double d
, unsigned vector_elements
)
2935 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2939 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2941 return new(mem_ctx
) ir_constant(type
, &data
);
2944 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2946 ir_dereference_variable
*
2947 builtin_builder::var_ref(ir_variable
*var
)
2949 return new(mem_ctx
) ir_dereference_variable(var
);
2952 ir_dereference_array
*
2953 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2955 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2958 /** Return an element of a matrix */
2960 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2962 return swizzle(array_ref(var
, column
), row
, 1);
2966 * Implementations of built-in functions:
2969 ir_function_signature
*
2970 builtin_builder::new_sig(const glsl_type
*return_type
,
2971 builtin_available_predicate avail
,
2977 ir_function_signature
*sig
=
2978 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2981 va_start(ap
, num_params
);
2982 for (int i
= 0; i
< num_params
; i
++) {
2983 plist
.push_tail(va_arg(ap
, ir_variable
*));
2987 sig
->replace_parameters(&plist
);
2991 #define MAKE_SIG(return_type, avail, ...) \
2992 ir_function_signature *sig = \
2993 new_sig(return_type, avail, __VA_ARGS__); \
2994 ir_factory body(&sig->body, mem_ctx); \
2995 sig->is_defined = true;
2997 #define MAKE_INTRINSIC(return_type, avail, ...) \
2998 ir_function_signature *sig = \
2999 new_sig(return_type, avail, __VA_ARGS__); \
3000 sig->is_intrinsic = true;
3002 ir_function_signature
*
3003 builtin_builder::unop(builtin_available_predicate avail
,
3004 ir_expression_operation opcode
,
3005 const glsl_type
*return_type
,
3006 const glsl_type
*param_type
)
3008 ir_variable
*x
= in_var(param_type
, "x");
3009 MAKE_SIG(return_type
, avail
, 1, x
);
3010 body
.emit(ret(expr(opcode
, x
)));
3014 #define UNOP(NAME, OPCODE, AVAIL) \
3015 ir_function_signature * \
3016 builtin_builder::_##NAME(const glsl_type *type) \
3018 return unop(&AVAIL, OPCODE, type, type); \
3021 #define UNOPA(NAME, OPCODE) \
3022 ir_function_signature * \
3023 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3025 return unop(avail, OPCODE, type, type); \
3028 ir_function_signature
*
3029 builtin_builder::binop(ir_expression_operation opcode
,
3030 builtin_available_predicate avail
,
3031 const glsl_type
*return_type
,
3032 const glsl_type
*param0_type
,
3033 const glsl_type
*param1_type
)
3035 ir_variable
*x
= in_var(param0_type
, "x");
3036 ir_variable
*y
= in_var(param1_type
, "y");
3037 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3038 body
.emit(ret(expr(opcode
, x
, y
)));
3042 #define BINOP(NAME, OPCODE, AVAIL) \
3043 ir_function_signature * \
3044 builtin_builder::_##NAME(const glsl_type *return_type, \
3045 const glsl_type *param0_type, \
3046 const glsl_type *param1_type) \
3048 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3052 * Angle and Trigonometry Functions @{
3055 ir_function_signature
*
3056 builtin_builder::_radians(const glsl_type
*type
)
3058 ir_variable
*degrees
= in_var(type
, "degrees");
3059 MAKE_SIG(type
, always_available
, 1, degrees
);
3060 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3064 ir_function_signature
*
3065 builtin_builder::_degrees(const glsl_type
*type
)
3067 ir_variable
*radians
= in_var(type
, "radians");
3068 MAKE_SIG(type
, always_available
, 1, radians
);
3069 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3073 UNOP(sin
, ir_unop_sin
, always_available
)
3074 UNOP(cos
, ir_unop_cos
, always_available
)
3076 ir_function_signature
*
3077 builtin_builder::_tan(const glsl_type
*type
)
3079 ir_variable
*theta
= in_var(type
, "theta");
3080 MAKE_SIG(type
, always_available
, 1, theta
);
3081 body
.emit(ret(div(sin(theta
), cos(theta
))));
3086 builtin_builder::asin_expr(ir_variable
*x
)
3090 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3093 add(imm(M_PI_4f
- 1.0f
),
3095 add(imm(0.086566724f
),
3096 mul(abs(x
), imm(-0.03102955f
))))))))));
3100 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3102 exec_list actual_params
;
3104 foreach_in_list(ir_variable
, var
, ¶ms
) {
3105 actual_params
.push_tail(var_ref(var
));
3108 ir_function_signature
*sig
=
3109 f
->exact_matching_signature(NULL
, &actual_params
);
3113 ir_dereference_variable
*deref
=
3114 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3116 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3119 ir_function_signature
*
3120 builtin_builder::_asin(const glsl_type
*type
)
3122 ir_variable
*x
= in_var(type
, "x");
3123 MAKE_SIG(type
, always_available
, 1, x
);
3125 body
.emit(ret(asin_expr(x
)));
3130 ir_function_signature
*
3131 builtin_builder::_acos(const glsl_type
*type
)
3133 ir_variable
*x
= in_var(type
, "x");
3134 MAKE_SIG(type
, always_available
, 1, x
);
3136 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3141 ir_function_signature
*
3142 builtin_builder::_atan2(const glsl_type
*type
)
3144 ir_variable
*vec_y
= in_var(type
, "vec_y");
3145 ir_variable
*vec_x
= in_var(type
, "vec_x");
3146 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3148 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3149 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3150 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3151 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3152 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3153 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3154 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3156 /* If |x| >= 1.0e-8 * |y|: */
3158 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3160 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3162 /* Then...call atan(y/x) */
3163 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3165 /* ...and fix it up: */
3166 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3167 inner_if
->then_instructions
.push_tail(
3168 if_tree(gequal(y
, imm(0.0f
)),
3169 assign(r
, add(r
, imm(M_PIf
))),
3170 assign(r
, sub(r
, imm(M_PIf
)))));
3171 outer_then
.emit(inner_if
);
3174 outer_if
->else_instructions
.push_tail(
3175 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3177 body
.emit(outer_if
);
3179 body
.emit(assign(vec_result
, r
, 1 << i
));
3181 body
.emit(ret(vec_result
));
3187 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3190 * range-reduction, first step:
3192 * / y_over_x if |y_over_x| <= 1.0;
3194 * \ 1.0 / y_over_x otherwise
3196 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3197 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3203 * approximate atan by evaluating polynomial:
3205 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3206 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3207 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3209 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3210 body
.emit(assign(tmp
, mul(x
, x
)));
3211 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3213 imm(0.0536813784310406f
)),
3215 imm(0.1173503194786851f
)),
3217 imm(0.1938924977115610f
)),
3219 imm(0.3326756418091246f
)),
3221 imm(0.9999793128310355f
)),
3224 /* range-reduction fixup */
3225 body
.emit(assign(tmp
, add(tmp
,
3226 mul(b2f(greater(abs(y_over_x
),
3227 imm(1.0f
, type
->components()))),
3233 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3236 ir_function_signature
*
3237 builtin_builder::_atan(const glsl_type
*type
)
3239 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3240 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3242 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3243 do_atan(body
, type
, tmp
, y_over_x
);
3244 body
.emit(ret(tmp
));
3249 ir_function_signature
*
3250 builtin_builder::_sinh(const glsl_type
*type
)
3252 ir_variable
*x
= in_var(type
, "x");
3253 MAKE_SIG(type
, v130
, 1, x
);
3255 /* 0.5 * (e^x - e^(-x)) */
3256 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3261 ir_function_signature
*
3262 builtin_builder::_cosh(const glsl_type
*type
)
3264 ir_variable
*x
= in_var(type
, "x");
3265 MAKE_SIG(type
, v130
, 1, x
);
3267 /* 0.5 * (e^x + e^(-x)) */
3268 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3273 ir_function_signature
*
3274 builtin_builder::_tanh(const glsl_type
*type
)
3276 ir_variable
*x
= in_var(type
, "x");
3277 MAKE_SIG(type
, v130
, 1, x
);
3279 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3280 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3281 add(exp(x
), exp(neg(x
))))));
3286 ir_function_signature
*
3287 builtin_builder::_asinh(const glsl_type
*type
)
3289 ir_variable
*x
= in_var(type
, "x");
3290 MAKE_SIG(type
, v130
, 1, x
);
3292 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3297 ir_function_signature
*
3298 builtin_builder::_acosh(const glsl_type
*type
)
3300 ir_variable
*x
= in_var(type
, "x");
3301 MAKE_SIG(type
, v130
, 1, x
);
3303 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3307 ir_function_signature
*
3308 builtin_builder::_atanh(const glsl_type
*type
)
3310 ir_variable
*x
= in_var(type
, "x");
3311 MAKE_SIG(type
, v130
, 1, x
);
3313 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3314 sub(imm(1.0f
), x
))))));
3320 * Exponential Functions @{
3323 ir_function_signature
*
3324 builtin_builder::_pow(const glsl_type
*type
)
3326 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3329 UNOP(exp
, ir_unop_exp
, always_available
)
3330 UNOP(log
, ir_unop_log
, always_available
)
3331 UNOP(exp2
, ir_unop_exp2
, always_available
)
3332 UNOP(log2
, ir_unop_log2
, always_available
)
3333 UNOPA(sqrt
, ir_unop_sqrt
)
3334 UNOPA(inversesqrt
, ir_unop_rsq
)
3338 UNOPA(abs
, ir_unop_abs
)
3339 UNOPA(sign
, ir_unop_sign
)
3340 UNOPA(floor
, ir_unop_floor
)
3341 UNOPA(trunc
, ir_unop_trunc
)
3342 UNOPA(round
, ir_unop_round_even
)
3343 UNOPA(roundEven
, ir_unop_round_even
)
3344 UNOPA(ceil
, ir_unop_ceil
)
3345 UNOPA(fract
, ir_unop_fract
)
3347 ir_function_signature
*
3348 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3350 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3353 ir_function_signature
*
3354 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3356 ir_variable
*x
= in_var(type
, "x");
3357 ir_variable
*i
= out_var(type
, "i");
3358 MAKE_SIG(type
, avail
, 2, x
, i
);
3360 ir_variable
*t
= body
.make_temp(type
, "t");
3361 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3362 body
.emit(assign(i
, t
));
3363 body
.emit(ret(sub(x
, t
)));
3368 ir_function_signature
*
3369 builtin_builder::_min(builtin_available_predicate avail
,
3370 const glsl_type
*x_type
, const glsl_type
*y_type
)
3372 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3375 ir_function_signature
*
3376 builtin_builder::_max(builtin_available_predicate avail
,
3377 const glsl_type
*x_type
, const glsl_type
*y_type
)
3379 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3382 ir_function_signature
*
3383 builtin_builder::_clamp(builtin_available_predicate avail
,
3384 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3386 ir_variable
*x
= in_var(val_type
, "x");
3387 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3388 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3389 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3391 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3396 ir_function_signature
*
3397 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3399 ir_variable
*x
= in_var(val_type
, "x");
3400 ir_variable
*y
= in_var(val_type
, "y");
3401 ir_variable
*a
= in_var(blend_type
, "a");
3402 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3404 body
.emit(ret(lrp(x
, y
, a
)));
3409 ir_function_signature
*
3410 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3411 const glsl_type
*val_type
,
3412 const glsl_type
*blend_type
)
3414 ir_variable
*x
= in_var(val_type
, "x");
3415 ir_variable
*y
= in_var(val_type
, "y");
3416 ir_variable
*a
= in_var(blend_type
, "a");
3417 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3419 /* csel matches the ternary operator in that a selector of true choses the
3420 * first argument. This differs from mix(x, y, false) which choses the
3421 * second argument (to remain consistent with the interpolating version of
3422 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3424 * To handle the behavior mismatch, reverse the x and y arguments.
3426 body
.emit(ret(csel(a
, y
, x
)));
3431 ir_function_signature
*
3432 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3434 ir_variable
*edge
= in_var(edge_type
, "edge");
3435 ir_variable
*x
= in_var(x_type
, "x");
3436 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3438 ir_variable
*t
= body
.make_temp(x_type
, "t");
3439 if (x_type
->vector_elements
== 1) {
3440 /* Both are floats */
3441 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3442 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3444 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3445 } else if (edge_type
->vector_elements
== 1) {
3446 /* x is a vector but edge is a float */
3447 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3448 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3449 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3451 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3454 /* Both are vectors */
3455 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3456 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3457 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3460 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3470 ir_function_signature
*
3471 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3473 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3474 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3475 ir_variable
*x
= in_var(x_type
, "x");
3476 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3478 /* From the GLSL 1.10 specification:
3481 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3482 * return t * t * (3 - 2 * t);
3485 ir_variable
*t
= body
.make_temp(x_type
, "t");
3486 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3487 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3489 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3494 ir_function_signature
*
3495 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3497 ir_variable
*x
= in_var(type
, "x");
3498 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3500 body
.emit(ret(nequal(x
, x
)));
3505 ir_function_signature
*
3506 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3508 ir_variable
*x
= in_var(type
, "x");
3509 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3511 ir_constant_data infinities
;
3512 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3513 infinities
.f
[i
] = INFINITY
;
3516 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3521 ir_function_signature
*
3522 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3524 ir_variable
*x
= in_var(type
, "x");
3525 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3526 body
.emit(ret(bitcast_f2i(x
)));
3530 ir_function_signature
*
3531 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3533 ir_variable
*x
= in_var(type
, "x");
3534 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3535 body
.emit(ret(bitcast_f2u(x
)));
3539 ir_function_signature
*
3540 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3542 ir_variable
*x
= in_var(type
, "x");
3543 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3544 body
.emit(ret(bitcast_i2f(x
)));
3548 ir_function_signature
*
3549 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3551 ir_variable
*x
= in_var(type
, "x");
3552 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3553 body
.emit(ret(bitcast_u2f(x
)));
3557 ir_function_signature
*
3558 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3560 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3561 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3562 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3566 ir_function_signature
*
3567 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3569 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3570 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3571 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3575 ir_function_signature
*
3576 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3578 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3579 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3580 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3584 ir_function_signature
*
3585 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3587 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3588 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3589 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3593 ir_function_signature
*
3594 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3596 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3597 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3598 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3602 ir_function_signature
*
3603 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3605 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3606 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3607 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3612 ir_function_signature
*
3613 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3615 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3616 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3617 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3621 ir_function_signature
*
3622 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3624 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3625 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3626 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3630 ir_function_signature
*
3631 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3633 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3634 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3635 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3639 ir_function_signature
*
3640 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3642 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3643 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3644 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3648 ir_function_signature
*
3649 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3651 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3652 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3653 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3657 ir_function_signature
*
3658 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3660 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3661 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3662 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3666 ir_function_signature
*
3667 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3669 ir_variable
*x
= in_var(type
, "x");
3670 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3672 body
.emit(ret(sqrt(dot(x
, x
))));
3677 ir_function_signature
*
3678 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3680 ir_variable
*p0
= in_var(type
, "p0");
3681 ir_variable
*p1
= in_var(type
, "p1");
3682 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3684 if (type
->vector_elements
== 1) {
3685 body
.emit(ret(abs(sub(p0
, p1
))));
3687 ir_variable
*p
= body
.make_temp(type
, "p");
3688 body
.emit(assign(p
, sub(p0
, p1
)));
3689 body
.emit(ret(sqrt(dot(p
, p
))));
3695 ir_function_signature
*
3696 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3698 if (type
->vector_elements
== 1)
3699 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3701 return binop(ir_binop_dot
, avail
,
3702 type
->get_base_type(), type
, type
);
3705 ir_function_signature
*
3706 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3708 ir_variable
*a
= in_var(type
, "a");
3709 ir_variable
*b
= in_var(type
, "b");
3710 MAKE_SIG(type
, avail
, 2, a
, b
);
3712 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3713 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3715 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3716 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3721 ir_function_signature
*
3722 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3724 ir_variable
*x
= in_var(type
, "x");
3725 MAKE_SIG(type
, avail
, 1, x
);
3727 if (type
->vector_elements
== 1) {
3728 body
.emit(ret(sign(x
)));
3730 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3736 ir_function_signature
*
3737 builtin_builder::_ftransform()
3739 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3741 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3742 glsl_type::vec4_type
,
3743 var_ref(gl_ModelViewProjectionMatrix
),
3744 var_ref(gl_Vertex
))));
3746 /* FINISHME: Once the ir_expression() constructor handles type inference
3747 * for matrix operations, we can simplify this to:
3749 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3754 ir_function_signature
*
3755 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3757 ir_variable
*N
= in_var(type
, "N");
3758 ir_variable
*I
= in_var(type
, "I");
3759 ir_variable
*Nref
= in_var(type
, "Nref");
3760 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3762 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3763 ret(N
), ret(neg(N
))));
3768 ir_function_signature
*
3769 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3771 ir_variable
*I
= in_var(type
, "I");
3772 ir_variable
*N
= in_var(type
, "N");
3773 MAKE_SIG(type
, avail
, 2, I
, N
);
3775 /* I - 2 * dot(N, I) * N */
3776 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3781 ir_function_signature
*
3782 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3784 ir_variable
*I
= in_var(type
, "I");
3785 ir_variable
*N
= in_var(type
, "N");
3786 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3787 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3789 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3790 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3792 /* From the GLSL 1.10 specification:
3793 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3795 * return genType(0.0)
3797 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3799 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3800 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3801 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3802 mul(n_dot_i
, n_dot_i
)))))));
3803 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3804 ret(ir_constant::zero(mem_ctx
, type
)),
3805 ret(sub(mul(eta
, I
),
3806 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3811 ir_function_signature
*
3812 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3814 ir_variable
*x
= in_var(type
, "x");
3815 ir_variable
*y
= in_var(type
, "y");
3816 MAKE_SIG(type
, avail
, 2, x
, y
);
3818 ir_variable
*z
= body
.make_temp(type
, "z");
3819 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3820 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3827 ir_function_signature
*
3828 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3833 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3834 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3835 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3837 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3838 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3840 MAKE_SIG(type
, avail
, 2, c
, r
);
3842 ir_variable
*m
= body
.make_temp(type
, "m");
3843 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3844 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3851 ir_function_signature
*
3852 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3854 const glsl_type
*transpose_type
=
3855 glsl_type::get_instance(orig_type
->base_type
,
3856 orig_type
->matrix_columns
,
3857 orig_type
->vector_elements
);
3859 ir_variable
*m
= in_var(orig_type
, "m");
3860 MAKE_SIG(transpose_type
, avail
, 1, m
);
3862 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3863 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3864 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3865 body
.emit(assign(array_ref(t
, j
),
3866 matrix_elt(m
, i
, j
),
3875 ir_function_signature
*
3876 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3878 ir_variable
*m
= in_var(type
, "m");
3879 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3881 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3882 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3887 ir_function_signature
*
3888 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3890 ir_variable
*m
= in_var(type
, "m");
3891 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3894 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3895 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3898 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3899 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3902 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3903 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3905 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3906 mul(matrix_elt(m
, 0, 1), f2
)),
3907 mul(matrix_elt(m
, 0, 2), f3
))));
3912 ir_function_signature
*
3913 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3915 ir_variable
*m
= in_var(type
, "m");
3916 const glsl_type
*btype
= type
->get_base_type();
3917 MAKE_SIG(btype
, avail
, 1, m
);
3919 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3920 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3921 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3922 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3923 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3924 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3925 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3926 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3927 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3928 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3929 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3930 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3931 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3932 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3933 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3934 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3935 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3936 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3937 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3939 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)))));
3940 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)))));
3941 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)))));
3942 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)))));
3943 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)))));
3944 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)))));
3945 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)))));
3946 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)))));
3947 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)))));
3948 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)))));
3949 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)))));
3950 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)))));
3951 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)))));
3952 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)))));
3953 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)))));
3954 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)))));
3955 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)))));
3956 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)))));
3957 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)))));
3959 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3961 body
.emit(assign(adj_0
,
3962 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3963 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3964 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3966 body
.emit(assign(adj_0
, neg(
3967 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3968 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3969 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3971 body
.emit(assign(adj_0
,
3972 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3973 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3974 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3976 body
.emit(assign(adj_0
, neg(
3977 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3978 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3979 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3982 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3987 ir_function_signature
*
3988 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3990 ir_variable
*m
= in_var(type
, "m");
3991 MAKE_SIG(type
, avail
, 1, m
);
3993 ir_variable
*adj
= body
.make_temp(type
, "adj");
3994 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3995 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3996 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3997 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3999 ir_expression
*det
=
4000 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4001 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4003 body
.emit(ret(div(adj
, det
)));
4007 ir_function_signature
*
4008 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4010 ir_variable
*m
= in_var(type
, "m");
4011 const glsl_type
*btype
= type
->get_base_type();
4012 MAKE_SIG(type
, avail
, 1, m
);
4014 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4015 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4016 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4018 body
.emit(assign(f11_22_21_12
,
4019 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4020 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4021 body
.emit(assign(f10_22_20_12
,
4022 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4023 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4024 body
.emit(assign(f10_21_20_11
,
4025 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4026 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4028 ir_variable
*adj
= body
.make_temp(type
, "adj");
4029 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4030 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4031 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4033 body
.emit(assign(array_ref(adj
, 0), neg(
4034 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4035 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4037 body
.emit(assign(array_ref(adj
, 1),
4038 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4039 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4041 body
.emit(assign(array_ref(adj
, 2), neg(
4042 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4043 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4046 body
.emit(assign(array_ref(adj
, 0),
4047 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4048 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4050 body
.emit(assign(array_ref(adj
, 1), neg(
4051 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4052 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4054 body
.emit(assign(array_ref(adj
, 2),
4055 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4056 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4059 ir_expression
*det
=
4060 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4061 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4062 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4064 body
.emit(ret(div(adj
, det
)));
4069 ir_function_signature
*
4070 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4072 ir_variable
*m
= in_var(type
, "m");
4073 const glsl_type
*btype
= type
->get_base_type();
4074 MAKE_SIG(type
, avail
, 1, m
);
4076 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4077 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4078 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4079 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4080 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4081 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4082 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4083 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4084 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4085 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4086 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4087 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4088 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4089 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4090 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4091 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4092 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4093 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4094 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4096 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)))));
4097 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)))));
4098 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)))));
4099 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)))));
4100 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)))));
4101 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)))));
4102 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)))));
4103 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)))));
4104 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)))));
4105 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)))));
4106 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)))));
4107 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)))));
4108 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)))));
4109 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)))));
4110 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)))));
4111 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)))));
4112 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)))));
4113 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)))));
4114 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)))));
4116 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4117 body
.emit(assign(array_ref(adj
, 0),
4118 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4119 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4120 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4122 body
.emit(assign(array_ref(adj
, 1), neg(
4123 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4124 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4125 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4127 body
.emit(assign(array_ref(adj
, 2),
4128 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4129 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4130 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4132 body
.emit(assign(array_ref(adj
, 3), neg(
4133 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4134 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4135 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4138 body
.emit(assign(array_ref(adj
, 0), neg(
4139 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4140 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4141 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4143 body
.emit(assign(array_ref(adj
, 1),
4144 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4145 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4146 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4148 body
.emit(assign(array_ref(adj
, 2), neg(
4149 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4150 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4151 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4153 body
.emit(assign(array_ref(adj
, 3),
4154 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4155 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4156 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4159 body
.emit(assign(array_ref(adj
, 0),
4160 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4161 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4162 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4164 body
.emit(assign(array_ref(adj
, 1), neg(
4165 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4166 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4167 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4169 body
.emit(assign(array_ref(adj
, 2),
4170 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4171 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4172 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4174 body
.emit(assign(array_ref(adj
, 3), neg(
4175 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4176 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4177 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4180 body
.emit(assign(array_ref(adj
, 0), neg(
4181 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4182 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4183 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4185 body
.emit(assign(array_ref(adj
, 1),
4186 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4187 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4188 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4190 body
.emit(assign(array_ref(adj
, 2), neg(
4191 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4192 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4193 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4195 body
.emit(assign(array_ref(adj
, 3),
4196 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4197 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4198 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4201 ir_expression
*det
=
4202 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4203 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4204 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4205 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4207 body
.emit(ret(div(adj
, det
)));
4213 ir_function_signature
*
4214 builtin_builder::_lessThan(builtin_available_predicate avail
,
4215 const glsl_type
*type
)
4217 return binop(ir_binop_less
, avail
,
4218 glsl_type::bvec(type
->vector_elements
), type
, type
);
4221 ir_function_signature
*
4222 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4223 const glsl_type
*type
)
4225 return binop(ir_binop_lequal
, avail
,
4226 glsl_type::bvec(type
->vector_elements
), type
, type
);
4229 ir_function_signature
*
4230 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4231 const glsl_type
*type
)
4233 return binop(ir_binop_greater
, avail
,
4234 glsl_type::bvec(type
->vector_elements
), type
, type
);
4237 ir_function_signature
*
4238 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4239 const glsl_type
*type
)
4241 return binop(ir_binop_gequal
, avail
,
4242 glsl_type::bvec(type
->vector_elements
), type
, type
);
4245 ir_function_signature
*
4246 builtin_builder::_equal(builtin_available_predicate avail
,
4247 const glsl_type
*type
)
4249 return binop(ir_binop_equal
, avail
,
4250 glsl_type::bvec(type
->vector_elements
), type
, type
);
4253 ir_function_signature
*
4254 builtin_builder::_notEqual(builtin_available_predicate avail
,
4255 const glsl_type
*type
)
4257 return binop(ir_binop_nequal
, avail
,
4258 glsl_type::bvec(type
->vector_elements
), type
, type
);
4261 ir_function_signature
*
4262 builtin_builder::_any(const glsl_type
*type
)
4264 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4267 ir_function_signature
*
4268 builtin_builder::_all(const glsl_type
*type
)
4270 ir_variable
*v
= in_var(type
, "v");
4271 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4273 switch (type
->vector_elements
) {
4275 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4278 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4282 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4291 UNOP(not, ir_unop_logic_not
, always_available
)
4294 has_lod(const glsl_type
*sampler_type
)
4296 assert(sampler_type
->is_sampler());
4298 switch (sampler_type
->sampler_dimensionality
) {
4299 case GLSL_SAMPLER_DIM_RECT
:
4300 case GLSL_SAMPLER_DIM_BUF
:
4301 case GLSL_SAMPLER_DIM_MS
:
4308 ir_function_signature
*
4309 builtin_builder::_textureSize(builtin_available_predicate avail
,
4310 const glsl_type
*return_type
,
4311 const glsl_type
*sampler_type
)
4313 ir_variable
*s
= in_var(sampler_type
, "sampler");
4314 /* The sampler always exists; add optional lod later. */
4315 MAKE_SIG(return_type
, avail
, 1, s
);
4317 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4318 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4320 if (has_lod(sampler_type
)) {
4321 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4322 sig
->parameters
.push_tail(lod
);
4323 tex
->lod_info
.lod
= var_ref(lod
);
4325 tex
->lod_info
.lod
= imm(0u);
4328 body
.emit(ret(tex
));
4333 ir_function_signature
*
4334 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4336 ir_variable
*s
= in_var(sampler_type
, "sampler");
4337 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4339 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4340 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4341 body
.emit(ret(tex
));
4346 ir_function_signature
*
4347 builtin_builder::_texture(ir_texture_opcode opcode
,
4348 builtin_available_predicate avail
,
4349 const glsl_type
*return_type
,
4350 const glsl_type
*sampler_type
,
4351 const glsl_type
*coord_type
,
4354 ir_variable
*s
= in_var(sampler_type
, "sampler");
4355 ir_variable
*P
= in_var(coord_type
, "P");
4356 /* The sampler and coordinate always exist; add optional parameters later. */
4357 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4359 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4360 tex
->set_sampler(var_ref(s
), return_type
);
4362 const int coord_size
= sampler_type
->coordinate_components();
4364 if (coord_size
== coord_type
->vector_elements
) {
4365 tex
->coordinate
= var_ref(P
);
4367 /* The incoming coordinate also has the projector or shadow comparitor,
4368 * so we need to swizzle those away.
4370 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4373 /* The projector is always in the last component. */
4374 if (flags
& TEX_PROJECT
)
4375 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4377 if (sampler_type
->sampler_shadow
) {
4378 if (opcode
== ir_tg4
) {
4379 /* gather has refz as a separate parameter, immediately after the
4382 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4383 sig
->parameters
.push_tail(refz
);
4384 tex
->shadow_comparitor
= var_ref(refz
);
4386 /* The shadow comparitor is normally in the Z component, but a few types
4387 * have sufficiently large coordinates that it's in W.
4389 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4393 if (opcode
== ir_txl
) {
4394 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4395 sig
->parameters
.push_tail(lod
);
4396 tex
->lod_info
.lod
= var_ref(lod
);
4397 } else if (opcode
== ir_txd
) {
4398 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4399 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4400 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4401 sig
->parameters
.push_tail(dPdx
);
4402 sig
->parameters
.push_tail(dPdy
);
4403 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4404 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4407 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4408 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4409 ir_variable
*offset
=
4410 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4411 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4412 sig
->parameters
.push_tail(offset
);
4413 tex
->offset
= var_ref(offset
);
4416 if (flags
& TEX_OFFSET_ARRAY
) {
4417 ir_variable
*offsets
=
4418 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4419 "offsets", ir_var_const_in
);
4420 sig
->parameters
.push_tail(offsets
);
4421 tex
->offset
= var_ref(offsets
);
4424 if (opcode
== ir_tg4
) {
4425 if (flags
& TEX_COMPONENT
) {
4426 ir_variable
*component
=
4427 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4428 sig
->parameters
.push_tail(component
);
4429 tex
->lod_info
.component
= var_ref(component
);
4432 tex
->lod_info
.component
= imm(0);
4436 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4437 * inconsistent with both textureLodOffset and textureGradOffset.
4439 if (opcode
== ir_txb
) {
4440 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4441 sig
->parameters
.push_tail(bias
);
4442 tex
->lod_info
.bias
= var_ref(bias
);
4445 body
.emit(ret(tex
));
4450 ir_function_signature
*
4451 builtin_builder::_textureCubeArrayShadow()
4453 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4454 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4455 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4456 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4458 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4459 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4461 tex
->coordinate
= var_ref(P
);
4462 tex
->shadow_comparitor
= var_ref(compare
);
4464 body
.emit(ret(tex
));
4469 ir_function_signature
*
4470 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4471 const glsl_type
*return_type
,
4472 const glsl_type
*sampler_type
,
4473 const glsl_type
*coord_type
,
4474 const glsl_type
*offset_type
)
4476 ir_variable
*s
= in_var(sampler_type
, "sampler");
4477 ir_variable
*P
= in_var(coord_type
, "P");
4478 /* The sampler and coordinate always exist; add optional parameters later. */
4479 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4481 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4482 tex
->coordinate
= var_ref(P
);
4483 tex
->set_sampler(var_ref(s
), return_type
);
4485 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4486 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4487 sig
->parameters
.push_tail(sample
);
4488 tex
->lod_info
.sample_index
= var_ref(sample
);
4489 tex
->op
= ir_txf_ms
;
4490 } else if (has_lod(sampler_type
)) {
4491 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4492 sig
->parameters
.push_tail(lod
);
4493 tex
->lod_info
.lod
= var_ref(lod
);
4495 tex
->lod_info
.lod
= imm(0u);
4498 if (offset_type
!= NULL
) {
4499 ir_variable
*offset
=
4500 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4501 sig
->parameters
.push_tail(offset
);
4502 tex
->offset
= var_ref(offset
);
4505 body
.emit(ret(tex
));
4510 ir_function_signature
*
4511 builtin_builder::_EmitVertex()
4513 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4515 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4516 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4521 ir_function_signature
*
4522 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4523 const glsl_type
*stream_type
)
4525 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4527 * "Emit the current values of output variables to the current output
4528 * primitive on stream stream. The argument to stream must be a constant
4529 * integral expression."
4531 ir_variable
*stream
=
4532 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4534 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4536 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4541 ir_function_signature
*
4542 builtin_builder::_EndPrimitive()
4544 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4546 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4547 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4552 ir_function_signature
*
4553 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4554 const glsl_type
*stream_type
)
4556 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4558 * "Completes the current output primitive on stream stream and starts
4559 * a new one. The argument to stream must be a constant integral
4562 ir_variable
*stream
=
4563 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4565 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4567 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4572 ir_function_signature
*
4573 builtin_builder::_barrier()
4575 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4577 body
.emit(new(mem_ctx
) ir_barrier());
4581 ir_function_signature
*
4582 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4583 const glsl_type
*sampler_type
,
4584 const glsl_type
*coord_type
)
4586 ir_variable
*s
= in_var(sampler_type
, "sampler");
4587 ir_variable
*coord
= in_var(coord_type
, "coord");
4588 /* The sampler and coordinate always exist; add optional parameters later. */
4589 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4591 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4592 tex
->coordinate
= var_ref(coord
);
4593 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4595 body
.emit(ret(tex
));
4600 ir_function_signature
*
4601 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4603 ir_variable
*s
= in_var(sampler_type
, "sampler");
4604 const glsl_type
*return_type
= glsl_type::int_type
;
4605 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4607 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4608 tex
->set_sampler(var_ref(s
), return_type
);
4610 body
.emit(ret(tex
));
4615 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4616 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4617 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4618 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4619 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4620 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4622 ir_function_signature
*
4623 builtin_builder::_fwidth(const glsl_type
*type
)
4625 ir_variable
*p
= in_var(type
, "p");
4626 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4628 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4633 ir_function_signature
*
4634 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4636 ir_variable
*p
= in_var(type
, "p");
4637 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4639 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4640 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4645 ir_function_signature
*
4646 builtin_builder::_fwidthFine(const glsl_type
*type
)
4648 ir_variable
*p
= in_var(type
, "p");
4649 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4651 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4652 abs(expr(ir_unop_dFdy_fine
, p
)))));
4657 ir_function_signature
*
4658 builtin_builder::_noise1(const glsl_type
*type
)
4660 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4663 ir_function_signature
*
4664 builtin_builder::_noise2(const glsl_type
*type
)
4666 ir_variable
*p
= in_var(type
, "p");
4667 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4669 ir_constant_data b_offset
;
4670 b_offset
.f
[0] = 601.0f
;
4671 b_offset
.f
[1] = 313.0f
;
4672 b_offset
.f
[2] = 29.0f
;
4673 b_offset
.f
[3] = 277.0f
;
4675 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4676 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4677 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4678 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4679 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4680 body
.emit(assign(t
, a
, WRITEMASK_X
));
4681 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4687 ir_function_signature
*
4688 builtin_builder::_noise3(const glsl_type
*type
)
4690 ir_variable
*p
= in_var(type
, "p");
4691 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4693 ir_constant_data b_offset
;
4694 b_offset
.f
[0] = 601.0f
;
4695 b_offset
.f
[1] = 313.0f
;
4696 b_offset
.f
[2] = 29.0f
;
4697 b_offset
.f
[3] = 277.0f
;
4699 ir_constant_data c_offset
;
4700 c_offset
.f
[0] = 1559.0f
;
4701 c_offset
.f
[1] = 113.0f
;
4702 c_offset
.f
[2] = 1861.0f
;
4703 c_offset
.f
[3] = 797.0f
;
4705 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4706 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4707 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4708 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4709 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4710 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4711 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4712 body
.emit(assign(t
, a
, WRITEMASK_X
));
4713 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4714 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4720 ir_function_signature
*
4721 builtin_builder::_noise4(const glsl_type
*type
)
4723 ir_variable
*p
= in_var(type
, "p");
4724 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4726 ir_variable
*_p
= body
.make_temp(type
, "_p");
4728 ir_constant_data p_offset
;
4729 p_offset
.f
[0] = 1559.0f
;
4730 p_offset
.f
[1] = 113.0f
;
4731 p_offset
.f
[2] = 1861.0f
;
4732 p_offset
.f
[3] = 797.0f
;
4734 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4736 ir_constant_data offset
;
4737 offset
.f
[0] = 601.0f
;
4738 offset
.f
[1] = 313.0f
;
4739 offset
.f
[2] = 29.0f
;
4740 offset
.f
[3] = 277.0f
;
4742 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4743 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4744 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4745 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4746 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4747 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4748 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4749 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4750 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4751 body
.emit(assign(t
, a
, WRITEMASK_X
));
4752 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4753 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4754 body
.emit(assign(t
, d
, WRITEMASK_W
));
4760 ir_function_signature
*
4761 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4763 ir_variable
*value
= in_var(type
, "value");
4764 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4765 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4766 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4768 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4773 ir_function_signature
*
4774 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4776 ir_variable
*base
= in_var(type
, "base");
4777 ir_variable
*insert
= in_var(type
, "insert");
4778 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4779 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4780 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4782 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4787 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4789 ir_function_signature
*
4790 builtin_builder::_bitCount(const glsl_type
*type
)
4792 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4793 glsl_type::ivec(type
->vector_elements
), type
);
4796 ir_function_signature
*
4797 builtin_builder::_findLSB(const glsl_type
*type
)
4799 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4800 glsl_type::ivec(type
->vector_elements
), type
);
4803 ir_function_signature
*
4804 builtin_builder::_findMSB(const glsl_type
*type
)
4806 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4807 glsl_type::ivec(type
->vector_elements
), type
);
4810 ir_function_signature
*
4811 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4813 ir_variable
*a
= in_var(type
, "a");
4814 ir_variable
*b
= in_var(type
, "b");
4815 ir_variable
*c
= in_var(type
, "c");
4816 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4818 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4823 ir_function_signature
*
4824 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4826 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4829 ir_function_signature
*
4830 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4832 ir_variable
*x
= in_var(x_type
, "x");
4833 ir_variable
*exponent
= out_var(exp_type
, "exp");
4834 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4836 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4838 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4842 ir_function_signature
*
4843 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4845 ir_variable
*x
= in_var(x_type
, "x");
4846 ir_variable
*exponent
= out_var(exp_type
, "exp");
4847 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4849 const unsigned vec_elem
= x_type
->vector_elements
;
4850 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4851 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4853 /* Single-precision floating-point values are stored as
4858 * An exponent shift of 23 will shift the mantissa out, leaving only the
4859 * exponent and sign bit (which itself may be zero, if the absolute value
4860 * was taken before the bitcast and shift.
4862 ir_constant
*exponent_shift
= imm(23);
4863 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4865 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4867 /* Exponent of floating-point values in the range [0.5, 1.0). */
4868 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4870 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4871 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4873 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4874 * to unsigned integers to ensure that 1 bits aren't shifted in.
4876 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4877 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4878 imm(0, vec_elem
)))));
4880 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4881 body
.emit(assign(bits
, bitcast_f2u(x
)));
4882 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4883 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4884 imm(0u, vec_elem
)))));
4885 body
.emit(ret(bitcast_u2f(bits
)));
4890 ir_function_signature
*
4891 builtin_builder::_uaddCarry(const glsl_type
*type
)
4893 ir_variable
*x
= in_var(type
, "x");
4894 ir_variable
*y
= in_var(type
, "y");
4895 ir_variable
*carry
= out_var(type
, "carry");
4896 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4898 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4899 body
.emit(ret(add(x
, y
)));
4904 ir_function_signature
*
4905 builtin_builder::_usubBorrow(const glsl_type
*type
)
4907 ir_variable
*x
= in_var(type
, "x");
4908 ir_variable
*y
= in_var(type
, "y");
4909 ir_variable
*borrow
= out_var(type
, "borrow");
4910 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4912 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4913 body
.emit(ret(sub(x
, y
)));
4919 * For both imulExtended() and umulExtended() built-ins.
4921 ir_function_signature
*
4922 builtin_builder::_mulExtended(const glsl_type
*type
)
4924 ir_variable
*x
= in_var(type
, "x");
4925 ir_variable
*y
= in_var(type
, "y");
4926 ir_variable
*msb
= out_var(type
, "msb");
4927 ir_variable
*lsb
= out_var(type
, "lsb");
4928 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
4930 body
.emit(assign(msb
, imul_high(x
, y
)));
4931 body
.emit(assign(lsb
, mul(x
, y
)));
4936 ir_function_signature
*
4937 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4939 ir_variable
*interpolant
= in_var(type
, "interpolant");
4940 interpolant
->data
.must_be_shader_input
= 1;
4941 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4943 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4948 ir_function_signature
*
4949 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4951 ir_variable
*interpolant
= in_var(type
, "interpolant");
4952 interpolant
->data
.must_be_shader_input
= 1;
4953 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4954 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4956 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4961 ir_function_signature
*
4962 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4964 ir_variable
*interpolant
= in_var(type
, "interpolant");
4965 interpolant
->data
.must_be_shader_input
= 1;
4966 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4967 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4969 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4974 ir_function_signature
*
4975 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
4977 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4978 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4982 ir_function_signature
*
4983 builtin_builder::_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
4984 const glsl_type
*type
)
4986 ir_variable
*atomic
= in_var(type
, "atomic");
4987 ir_variable
*data
= in_var(type
, "data");
4988 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
4992 ir_function_signature
*
4993 builtin_builder::_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
4994 const glsl_type
*type
)
4996 ir_variable
*atomic
= in_var(type
, "atomic");
4997 ir_variable
*data1
= in_var(type
, "data1");
4998 ir_variable
*data2
= in_var(type
, "data2");
4999 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5003 ir_function_signature
*
5004 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5005 builtin_available_predicate avail
)
5007 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5008 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5010 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5011 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5013 body
.emit(ret(retval
));
5017 ir_function_signature
*
5018 builtin_builder::_atomic_ssbo_op2(const char *intrinsic
,
5019 builtin_available_predicate avail
,
5020 const glsl_type
*type
)
5022 ir_variable
*atomic
= in_var(type
, "atomic_var");
5023 ir_variable
*data
= in_var(type
, "atomic_data");
5024 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5026 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5027 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5029 body
.emit(ret(retval
));
5033 ir_function_signature
*
5034 builtin_builder::_atomic_ssbo_op3(const char *intrinsic
,
5035 builtin_available_predicate avail
,
5036 const glsl_type
*type
)
5038 ir_variable
*atomic
= in_var(type
, "atomic_var");
5039 ir_variable
*data1
= in_var(type
, "atomic_data1");
5040 ir_variable
*data2
= in_var(type
, "atomic_data2");
5041 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5043 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5044 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5046 body
.emit(ret(retval
));
5050 ir_function_signature
*
5051 builtin_builder::_min3(const glsl_type
*type
)
5053 ir_variable
*x
= in_var(type
, "x");
5054 ir_variable
*y
= in_var(type
, "y");
5055 ir_variable
*z
= in_var(type
, "z");
5056 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5058 ir_expression
*min3
= min2(x
, min2(y
,z
));
5059 body
.emit(ret(min3
));
5064 ir_function_signature
*
5065 builtin_builder::_max3(const glsl_type
*type
)
5067 ir_variable
*x
= in_var(type
, "x");
5068 ir_variable
*y
= in_var(type
, "y");
5069 ir_variable
*z
= in_var(type
, "z");
5070 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5072 ir_expression
*max3
= max2(x
, max2(y
,z
));
5073 body
.emit(ret(max3
));
5078 ir_function_signature
*
5079 builtin_builder::_mid3(const glsl_type
*type
)
5081 ir_variable
*x
= in_var(type
, "x");
5082 ir_variable
*y
= in_var(type
, "y");
5083 ir_variable
*z
= in_var(type
, "z");
5084 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5086 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5087 body
.emit(ret(mid3
));
5092 ir_function_signature
*
5093 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5094 unsigned num_arguments
,
5097 const glsl_type
*data_type
= glsl_type::get_instance(
5098 image_type
->sampler_type
,
5099 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5101 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5102 glsl_type::void_type
: data_type
);
5104 /* Addressing arguments that are always present. */
5105 ir_variable
*image
= in_var(image_type
, "image");
5106 ir_variable
*coord
= in_var(
5107 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5109 const builtin_available_predicate avail
=
5110 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
5111 shader_image_load_store
);
5112 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
5114 /* Sample index for multisample images. */
5115 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5116 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5118 /* Data arguments. */
5119 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5120 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5121 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5122 ralloc_free(arg_name
);
5125 /* Set the maximal set of qualifiers allowed for this image
5126 * built-in. Function calls with arguments having fewer
5127 * qualifiers than present in the prototype are allowed by the
5128 * spec, but not with more, i.e. this will make the compiler
5129 * accept everything that needs to be accepted, and reject cases
5130 * like loads from write-only or stores to read-only images.
5132 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5133 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5134 image
->data
.image_coherent
= true;
5135 image
->data
.image_volatile
= true;
5136 image
->data
.image_restrict
= true;
5141 ir_function_signature
*
5142 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5143 unsigned /* num_arguments */,
5144 unsigned /* flags */)
5146 const glsl_type
*ret_type
;
5147 unsigned num_components
= image_type
->coordinate_components();
5149 /* From the ARB_shader_image_size extension:
5150 * "Cube images return the dimensions of one face."
5152 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5153 !image_type
->sampler_array
) {
5157 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5158 * supported by mesa.
5160 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5162 ir_variable
*image
= in_var(image_type
, "image");
5163 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5165 /* Set the maximal set of qualifiers allowed for this image
5166 * built-in. Function calls with arguments having fewer
5167 * qualifiers than present in the prototype are allowed by the
5168 * spec, but not with more, i.e. this will make the compiler
5169 * accept everything that needs to be accepted, and reject cases
5170 * like loads from write-only or stores to read-only images.
5172 image
->data
.image_read_only
= true;
5173 image
->data
.image_write_only
= true;
5174 image
->data
.image_coherent
= true;
5175 image
->data
.image_volatile
= true;
5176 image
->data
.image_restrict
= true;
5181 ir_function_signature
*
5182 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5183 unsigned num_arguments
,
5186 ir_variable
*image
= in_var(image_type
, "image");
5187 ir_function_signature
*sig
=
5188 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5190 /* Set the maximal set of qualifiers allowed for this image
5191 * built-in. Function calls with arguments having fewer
5192 * qualifiers than present in the prototype are allowed by the
5193 * spec, but not with more, i.e. this will make the compiler
5194 * accept everything that needs to be accepted, and reject cases
5195 * like loads from write-only or stores to read-only images.
5197 image
->data
.image_read_only
= true;
5198 image
->data
.image_write_only
= true;
5199 image
->data
.image_coherent
= true;
5200 image
->data
.image_volatile
= true;
5201 image
->data
.image_restrict
= true;
5206 ir_function_signature
*
5207 builtin_builder::_image(image_prototype_ctr prototype
,
5208 const glsl_type
*image_type
,
5209 const char *intrinsic_name
,
5210 unsigned num_arguments
,
5213 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5214 num_arguments
, flags
);
5216 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5217 ir_factory
body(&sig
->body
, mem_ctx
);
5218 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5220 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5221 body
.emit(call(f
, NULL
, sig
->parameters
));
5223 ir_variable
*ret_val
=
5224 body
.make_temp(sig
->return_type
, "_ret_val");
5225 body
.emit(call(f
, ret_val
, sig
->parameters
));
5226 body
.emit(ret(ret_val
));
5229 sig
->is_defined
= true;
5232 sig
->is_intrinsic
= true;
5238 ir_function_signature
*
5239 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5241 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5245 ir_function_signature
*
5246 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
5248 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5249 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
5250 NULL
, sig
->parameters
));
5256 /******************************************************************************/
5258 /* The singleton instance of builtin_builder. */
5259 static builtin_builder builtins
;
5260 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5263 * External API (exposing the built-in module to the rest of the compiler):
5267 _mesa_glsl_initialize_builtin_functions()
5269 mtx_lock(&builtins_lock
);
5270 builtins
.initialize();
5271 mtx_unlock(&builtins_lock
);
5275 _mesa_glsl_release_builtin_functions()
5277 mtx_lock(&builtins_lock
);
5279 mtx_unlock(&builtins_lock
);
5282 ir_function_signature
*
5283 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5284 const char *name
, exec_list
*actual_parameters
)
5286 ir_function_signature
* s
;
5287 mtx_lock(&builtins_lock
);
5288 s
= builtins
.find(state
, name
, actual_parameters
);
5289 mtx_unlock(&builtins_lock
);
5294 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5297 mtx_lock(&builtins_lock
);
5298 f
= builtins
.shader
->symbols
->get_function(name
);
5299 mtx_unlock(&builtins_lock
);
5304 _mesa_glsl_get_builtin_function_shader()
5306 return builtins
.shader
;
5311 * Get the function signature for main from a shader
5313 ir_function_signature
*
5314 _mesa_get_main_function_signature(gl_shader
*sh
)
5316 ir_function
*const f
= sh
->symbols
->get_function("main");
5318 exec_list void_parameters
;
5320 /* Look for the 'void main()' signature and ensure that it's defined.
5321 * This keeps the linker from accidentally pick a shader that just
5322 * contains a prototype for main.
5324 * We don't have to check for multiple definitions of main (in multiple
5325 * shaders) because that would have already been caught above.
5327 ir_function_signature
*sig
=
5328 f
->matching_signature(NULL
, &void_parameters
, false);
5329 if ((sig
!= NULL
) && sig
->is_defined
) {