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 v140_or_es3(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(140, 300);
145 v400_fs_only(const _mesa_glsl_parse_state
*state
)
147 return state
->is_version(400, 0) &&
148 state
->stage
== MESA_SHADER_FRAGMENT
;
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_es(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 320) ||
239 state
->ARB_gpu_shader5_enable
||
240 state
->EXT_gpu_shader5_enable
||
241 state
->OES_gpu_shader5_enable
;
245 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
247 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
251 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
253 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
257 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
259 return state
->ARB_shading_language_packing_enable
||
260 state
->ARB_gpu_shader5_enable
||
261 state
->is_version(400, 310);
265 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
267 return state
->stage
== MESA_SHADER_FRAGMENT
&&
268 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
273 texture_array_lod(const _mesa_glsl_parse_state
*state
)
275 return lod_exists_in_stage(state
) &&
276 state
->EXT_texture_array_enable
;
280 fs_texture_array(const _mesa_glsl_parse_state
*state
)
282 return state
->stage
== MESA_SHADER_FRAGMENT
&&
283 state
->EXT_texture_array_enable
;
287 texture_array(const _mesa_glsl_parse_state
*state
)
289 return state
->EXT_texture_array_enable
;
293 texture_multisample(const _mesa_glsl_parse_state
*state
)
295 return state
->is_version(150, 310) ||
296 state
->ARB_texture_multisample_enable
;
300 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
302 return state
->is_version(150, 320) ||
303 state
->ARB_texture_multisample_enable
||
304 state
->OES_texture_storage_multisample_2d_array_enable
;
308 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
310 return texture_multisample(state
) &&
311 state
->EXT_shader_samples_identical_enable
;
315 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
317 return texture_multisample_array(state
) &&
318 state
->EXT_shader_samples_identical_enable
;
322 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
324 return state
->stage
== MESA_SHADER_FRAGMENT
&&
325 (state
->is_version(400, 0) ||
326 state
->ARB_texture_cube_map_array_enable
);
330 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
332 return state
->is_version(400, 0) ||
333 state
->ARB_texture_cube_map_array_enable
;
337 texture_query_levels(const _mesa_glsl_parse_state
*state
)
339 return state
->is_version(430, 0) ||
340 state
->ARB_texture_query_levels_enable
;
344 texture_query_lod(const _mesa_glsl_parse_state
*state
)
346 return state
->stage
== MESA_SHADER_FRAGMENT
&&
347 state
->ARB_texture_query_lod_enable
;
351 texture_gather(const _mesa_glsl_parse_state
*state
)
353 return state
->is_version(400, 0) ||
354 state
->ARB_texture_gather_enable
||
355 state
->ARB_gpu_shader5_enable
;
359 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
361 return state
->is_version(400, 310) ||
362 state
->ARB_texture_gather_enable
||
363 state
->ARB_gpu_shader5_enable
;
366 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
367 * used for relaxation of const offset requirements.
370 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
372 return !state
->is_version(400, 320) &&
373 !state
->ARB_gpu_shader5_enable
&&
374 !state
->EXT_gpu_shader5_enable
&&
375 !state
->OES_gpu_shader5_enable
&&
376 (state
->ARB_texture_gather_enable
||
377 state
->is_version(0, 310));
380 /* Desktop GL or OES_standard_derivatives + fragment shader only */
382 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
384 return state
->stage
== MESA_SHADER_FRAGMENT
&&
385 (state
->is_version(110, 300) ||
386 state
->OES_standard_derivatives_enable
);
390 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
392 return state
->stage
== MESA_SHADER_FRAGMENT
&&
393 (state
->is_version(450, 0) ||
394 state
->ARB_derivative_control_enable
);
398 tex1d_lod(const _mesa_glsl_parse_state
*state
)
400 return !state
->es_shader
&& lod_exists_in_stage(state
);
403 /** True if sampler3D exists */
405 tex3d(const _mesa_glsl_parse_state
*state
)
407 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
408 * OES_texture_3D extension, and in GLSL ES 3.00.
410 return !state
->es_shader
||
411 state
->OES_texture_3D_enable
||
412 state
->language_version
>= 300;
416 fs_tex3d(const _mesa_glsl_parse_state
*state
)
418 return state
->stage
== MESA_SHADER_FRAGMENT
&&
419 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
423 tex3d_lod(const _mesa_glsl_parse_state
*state
)
425 return tex3d(state
) && lod_exists_in_stage(state
);
429 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
431 return state
->has_atomic_counters();
435 shader_clock(const _mesa_glsl_parse_state
*state
)
437 return state
->ARB_shader_clock_enable
;
441 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
443 return state
->has_shader_storage_buffer_objects();
447 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
449 return state
->AMD_shader_trinary_minmax_enable
;
453 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
455 return (state
->is_version(420, 310) ||
456 state
->ARB_shader_image_load_store_enable
);
460 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
462 return (state
->is_version(420, 320) ||
463 state
->ARB_shader_image_load_store_enable
||
464 state
->OES_shader_image_atomic_enable
);
468 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
470 return (state
->is_version(450, 320) ||
471 state
->OES_shader_image_atomic_enable
);
475 shader_image_size(const _mesa_glsl_parse_state
*state
)
477 return state
->is_version(430, 310) ||
478 state
->ARB_shader_image_size_enable
;
482 shader_samples(const _mesa_glsl_parse_state
*state
)
484 return state
->is_version(450, 0) ||
485 state
->ARB_shader_texture_image_samples_enable
;
489 gs_streams(const _mesa_glsl_parse_state
*state
)
491 return gpu_shader5(state
) && gs_only(state
);
495 fp64(const _mesa_glsl_parse_state
*state
)
497 return state
->has_double();
501 compute_shader(const _mesa_glsl_parse_state
*state
)
503 return state
->stage
== MESA_SHADER_COMPUTE
;
507 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
509 return compute_shader(state
) || shader_storage_buffer_object(state
);
513 barrier_supported(const _mesa_glsl_parse_state
*state
)
515 return compute_shader(state
) ||
516 state
->stage
== MESA_SHADER_TESS_CTRL
;
521 /******************************************************************************/
526 * builtin_builder: A singleton object representing the core of the built-in
529 * It generates IR for every built-in function signature, and organizes them
532 class builtin_builder
{
539 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
540 const char *name
, exec_list
*actual_parameters
);
543 * A shader to hold all the built-in signatures; created by this module.
545 * This includes signatures for every built-in, regardless of version or
546 * enabled extensions. The availability predicate associated with each
547 * signature allows matching_signature() to filter out the irrelevant ones.
554 /** Global variables used by built-in functions. */
555 ir_variable
*gl_ModelViewProjectionMatrix
;
556 ir_variable
*gl_Vertex
;
558 void create_shader();
559 void create_intrinsics();
560 void create_builtins();
563 * IR builder helpers:
565 * These convenience functions assist in emitting IR, but don't necessarily
566 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
569 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
570 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
571 ir_constant
*imm(float f
, unsigned vector_elements
=1);
572 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
573 ir_constant
*imm(int i
, unsigned vector_elements
=1);
574 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
575 ir_constant
*imm(double d
, unsigned vector_elements
=1);
576 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
577 ir_dereference_variable
*var_ref(ir_variable
*var
);
578 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
579 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
581 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
582 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
585 * Call function \param f with parameters specified as the linked
586 * list \param params of \c ir_variable objects. \param ret should
587 * point to the ir_variable that will hold the function return
588 * value, or be \c NULL if the function has void return type.
590 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
592 /** Create a new function and add the given signatures. */
593 void add_function(const char *name
, ...);
595 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
596 unsigned num_arguments
,
600 * Create a new image built-in function for all known image types.
601 * \p flags is a bitfield of \c image_function_flags flags.
603 void add_image_function(const char *name
,
604 const char *intrinsic_name
,
605 image_prototype_ctr prototype
,
606 unsigned num_arguments
,
610 * Create new functions for all known image built-ins and types.
611 * If \p glsl is \c true, use the GLSL built-in names and emit code
612 * to call into the actual compiler intrinsic. If \p glsl is
613 * false, emit a function prototype with no body for each image
616 void add_image_functions(bool glsl
);
618 ir_function_signature
*new_sig(const glsl_type
*return_type
,
619 builtin_available_predicate avail
,
620 int num_params
, ...);
623 * Function signature generators:
626 ir_function_signature
*unop(builtin_available_predicate avail
,
627 ir_expression_operation opcode
,
628 const glsl_type
*return_type
,
629 const glsl_type
*param_type
);
630 ir_function_signature
*binop(builtin_available_predicate avail
,
631 ir_expression_operation opcode
,
632 const glsl_type
*return_type
,
633 const glsl_type
*param0_type
,
634 const glsl_type
*param1_type
);
636 #define B0(X) ir_function_signature *_##X();
637 #define B1(X) ir_function_signature *_##X(const glsl_type *);
638 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
639 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
640 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
641 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
678 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
679 const glsl_type
*val_type
,
680 const glsl_type
*blend_type
);
689 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
690 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
691 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
692 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
693 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
694 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
695 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
696 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
697 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
698 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
699 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
700 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
713 BA1(determinant_mat2
);
714 BA1(determinant_mat3
);
715 BA1(determinant_mat4
);
723 BA1(greaterThanEqual
);
732 /** Flags to _texture() */
733 #define TEX_PROJECT 1
735 #define TEX_COMPONENT 4
736 #define TEX_OFFSET_NONCONST 8
737 #define TEX_OFFSET_ARRAY 16
739 ir_function_signature
*_texture(ir_texture_opcode opcode
,
740 builtin_available_predicate avail
,
741 const glsl_type
*return_type
,
742 const glsl_type
*sampler_type
,
743 const glsl_type
*coord_type
,
745 B0(textureCubeArrayShadow
);
746 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
747 const glsl_type
*return_type
,
748 const glsl_type
*sampler_type
,
749 const glsl_type
*coord_type
,
750 const glsl_type
*offset_type
= NULL
);
754 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
755 const glsl_type
*stream_type
);
756 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
757 const glsl_type
*stream_type
);
760 BA2(textureQueryLod
);
761 B1(textureQueryLevels
);
762 BA2(textureSamplesIdentical
);
790 B1(interpolateAtCentroid
)
791 B1(interpolateAtOffset
)
792 B1(interpolateAtSample
)
794 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
795 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
796 builtin_available_predicate avail
);
798 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
799 const glsl_type
*type
);
800 ir_function_signature
*_atomic_op2(const char *intrinsic
,
801 builtin_available_predicate avail
,
802 const glsl_type
*type
);
803 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
804 const glsl_type
*type
);
805 ir_function_signature
*_atomic_op3(const char *intrinsic
,
806 builtin_available_predicate avail
,
807 const glsl_type
*type
);
813 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
814 unsigned num_arguments
,
816 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
817 unsigned num_arguments
,
819 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
820 unsigned num_arguments
,
822 ir_function_signature
*_image(image_prototype_ctr prototype
,
823 const glsl_type
*image_type
,
824 const char *intrinsic_name
,
825 unsigned num_arguments
,
828 ir_function_signature
*_memory_barrier_intrinsic(
829 builtin_available_predicate avail
);
830 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
831 builtin_available_predicate avail
);
833 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
834 const glsl_type
*type
);
835 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
836 const glsl_type
*type
);
847 enum image_function_flags
{
848 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
849 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
850 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
851 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
852 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
853 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
854 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
855 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
856 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
859 } /* anonymous namespace */
862 * Core builtin_builder functionality:
865 builtin_builder::builtin_builder()
867 gl_ModelViewProjectionMatrix(NULL
),
873 builtin_builder::~builtin_builder()
875 ralloc_free(mem_ctx
);
878 ir_function_signature
*
879 builtin_builder::find(_mesa_glsl_parse_state
*state
,
880 const char *name
, exec_list
*actual_parameters
)
882 /* The shader currently being compiled requested a built-in function;
883 * it needs to link against builtin_builder::shader in order to get them.
885 * Even if we don't find a matching signature, we still need to do this so
886 * that the "no matching signature" error will list potential candidates
887 * from the available built-ins.
889 state
->uses_builtin_functions
= true;
891 ir_function
*f
= shader
->symbols
->get_function(name
);
895 ir_function_signature
*sig
=
896 f
->matching_signature(state
, actual_parameters
, true);
904 builtin_builder::initialize()
906 /* If already initialized, don't do it again. */
910 mem_ctx
= ralloc_context(NULL
);
917 builtin_builder::release()
919 ralloc_free(mem_ctx
);
927 builtin_builder::create_shader()
929 /* The target doesn't actually matter. There's no target for generic
930 * GLSL utility code that could be linked against any stage, so just
931 * arbitrarily pick GL_VERTEX_SHADER.
933 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
934 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
936 gl_ModelViewProjectionMatrix
=
937 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
938 "gl_ModelViewProjectionMatrix",
941 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
943 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
944 shader
->symbols
->add_variable(gl_Vertex
);
950 * Create ir_function and ir_function_signature objects for each
954 builtin_builder::create_intrinsics()
956 add_function("__intrinsic_atomic_read",
957 _atomic_counter_intrinsic(shader_atomic_counters
),
959 add_function("__intrinsic_atomic_increment",
960 _atomic_counter_intrinsic(shader_atomic_counters
),
962 add_function("__intrinsic_atomic_predecrement",
963 _atomic_counter_intrinsic(shader_atomic_counters
),
966 add_function("__intrinsic_atomic_add",
967 _atomic_intrinsic2(buffer_atomics_supported
,
968 glsl_type::uint_type
),
969 _atomic_intrinsic2(buffer_atomics_supported
,
970 glsl_type::int_type
),
972 add_function("__intrinsic_atomic_min",
973 _atomic_intrinsic2(buffer_atomics_supported
,
974 glsl_type::uint_type
),
975 _atomic_intrinsic2(buffer_atomics_supported
,
976 glsl_type::int_type
),
978 add_function("__intrinsic_atomic_max",
979 _atomic_intrinsic2(buffer_atomics_supported
,
980 glsl_type::uint_type
),
981 _atomic_intrinsic2(buffer_atomics_supported
,
982 glsl_type::int_type
),
984 add_function("__intrinsic_atomic_and",
985 _atomic_intrinsic2(buffer_atomics_supported
,
986 glsl_type::uint_type
),
987 _atomic_intrinsic2(buffer_atomics_supported
,
988 glsl_type::int_type
),
990 add_function("__intrinsic_atomic_or",
991 _atomic_intrinsic2(buffer_atomics_supported
,
992 glsl_type::uint_type
),
993 _atomic_intrinsic2(buffer_atomics_supported
,
994 glsl_type::int_type
),
996 add_function("__intrinsic_atomic_xor",
997 _atomic_intrinsic2(buffer_atomics_supported
,
998 glsl_type::uint_type
),
999 _atomic_intrinsic2(buffer_atomics_supported
,
1000 glsl_type::int_type
),
1002 add_function("__intrinsic_atomic_exchange",
1003 _atomic_intrinsic2(buffer_atomics_supported
,
1004 glsl_type::uint_type
),
1005 _atomic_intrinsic2(buffer_atomics_supported
,
1006 glsl_type::int_type
),
1008 add_function("__intrinsic_atomic_comp_swap",
1009 _atomic_intrinsic3(buffer_atomics_supported
,
1010 glsl_type::uint_type
),
1011 _atomic_intrinsic3(buffer_atomics_supported
,
1012 glsl_type::int_type
),
1015 add_image_functions(false);
1017 add_function("__intrinsic_memory_barrier",
1018 _memory_barrier_intrinsic(shader_image_load_store
),
1020 add_function("__intrinsic_group_memory_barrier",
1021 _memory_barrier_intrinsic(compute_shader
),
1023 add_function("__intrinsic_memory_barrier_atomic_counter",
1024 _memory_barrier_intrinsic(compute_shader
),
1026 add_function("__intrinsic_memory_barrier_buffer",
1027 _memory_barrier_intrinsic(compute_shader
),
1029 add_function("__intrinsic_memory_barrier_image",
1030 _memory_barrier_intrinsic(compute_shader
),
1032 add_function("__intrinsic_memory_barrier_shared",
1033 _memory_barrier_intrinsic(compute_shader
),
1036 add_function("__intrinsic_shader_clock",
1037 _shader_clock_intrinsic(shader_clock
,
1038 glsl_type::uvec2_type
),
1043 * Create ir_function and ir_function_signature objects for each built-in.
1045 * Contains a list of every available built-in.
1048 builtin_builder::create_builtins()
1051 add_function(#NAME, \
1052 _##NAME(glsl_type::float_type), \
1053 _##NAME(glsl_type::vec2_type), \
1054 _##NAME(glsl_type::vec3_type), \
1055 _##NAME(glsl_type::vec4_type), \
1059 add_function(#NAME, \
1060 _##NAME(always_available, glsl_type::float_type), \
1061 _##NAME(always_available, glsl_type::vec2_type), \
1062 _##NAME(always_available, glsl_type::vec3_type), \
1063 _##NAME(always_available, glsl_type::vec4_type), \
1064 _##NAME(fp64, glsl_type::double_type), \
1065 _##NAME(fp64, glsl_type::dvec2_type), \
1066 _##NAME(fp64, glsl_type::dvec3_type), \
1067 _##NAME(fp64, glsl_type::dvec4_type), \
1070 #define FD130(NAME) \
1071 add_function(#NAME, \
1072 _##NAME(v130, glsl_type::float_type), \
1073 _##NAME(v130, glsl_type::vec2_type), \
1074 _##NAME(v130, glsl_type::vec3_type), \
1075 _##NAME(v130, glsl_type::vec4_type), \
1076 _##NAME(fp64, glsl_type::double_type), \
1077 _##NAME(fp64, glsl_type::dvec2_type), \
1078 _##NAME(fp64, glsl_type::dvec3_type), \
1079 _##NAME(fp64, glsl_type::dvec4_type), \
1082 #define FDGS5(NAME) \
1083 add_function(#NAME, \
1084 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1085 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1086 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1087 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1088 _##NAME(fp64, glsl_type::double_type), \
1089 _##NAME(fp64, glsl_type::dvec2_type), \
1090 _##NAME(fp64, glsl_type::dvec3_type), \
1091 _##NAME(fp64, glsl_type::dvec4_type), \
1095 add_function(#NAME, \
1096 _##NAME(glsl_type::float_type), \
1097 _##NAME(glsl_type::vec2_type), \
1098 _##NAME(glsl_type::vec3_type), \
1099 _##NAME(glsl_type::vec4_type), \
1100 _##NAME(glsl_type::int_type), \
1101 _##NAME(glsl_type::ivec2_type), \
1102 _##NAME(glsl_type::ivec3_type), \
1103 _##NAME(glsl_type::ivec4_type), \
1107 add_function(#NAME, \
1108 _##NAME(always_available, glsl_type::float_type), \
1109 _##NAME(always_available, glsl_type::vec2_type), \
1110 _##NAME(always_available, glsl_type::vec3_type), \
1111 _##NAME(always_available, glsl_type::vec4_type), \
1112 _##NAME(always_available, glsl_type::int_type), \
1113 _##NAME(always_available, glsl_type::ivec2_type), \
1114 _##NAME(always_available, glsl_type::ivec3_type), \
1115 _##NAME(always_available, glsl_type::ivec4_type), \
1116 _##NAME(fp64, glsl_type::double_type), \
1117 _##NAME(fp64, glsl_type::dvec2_type), \
1118 _##NAME(fp64, glsl_type::dvec3_type), \
1119 _##NAME(fp64, glsl_type::dvec4_type), \
1122 #define FIUD(NAME) \
1123 add_function(#NAME, \
1124 _##NAME(always_available, glsl_type::float_type), \
1125 _##NAME(always_available, glsl_type::vec2_type), \
1126 _##NAME(always_available, glsl_type::vec3_type), \
1127 _##NAME(always_available, glsl_type::vec4_type), \
1129 _##NAME(always_available, glsl_type::int_type), \
1130 _##NAME(always_available, glsl_type::ivec2_type), \
1131 _##NAME(always_available, glsl_type::ivec3_type), \
1132 _##NAME(always_available, glsl_type::ivec4_type), \
1134 _##NAME(v130, glsl_type::uint_type), \
1135 _##NAME(v130, glsl_type::uvec2_type), \
1136 _##NAME(v130, glsl_type::uvec3_type), \
1137 _##NAME(v130, glsl_type::uvec4_type), \
1138 _##NAME(fp64, glsl_type::double_type), \
1139 _##NAME(fp64, glsl_type::dvec2_type), \
1140 _##NAME(fp64, glsl_type::dvec3_type), \
1141 _##NAME(fp64, glsl_type::dvec4_type), \
1145 add_function(#NAME, \
1146 _##NAME(glsl_type::int_type), \
1147 _##NAME(glsl_type::ivec2_type), \
1148 _##NAME(glsl_type::ivec3_type), \
1149 _##NAME(glsl_type::ivec4_type), \
1151 _##NAME(glsl_type::uint_type), \
1152 _##NAME(glsl_type::uvec2_type), \
1153 _##NAME(glsl_type::uvec3_type), \
1154 _##NAME(glsl_type::uvec4_type), \
1157 #define FIUBD(NAME) \
1158 add_function(#NAME, \
1159 _##NAME(always_available, glsl_type::float_type), \
1160 _##NAME(always_available, glsl_type::vec2_type), \
1161 _##NAME(always_available, glsl_type::vec3_type), \
1162 _##NAME(always_available, glsl_type::vec4_type), \
1164 _##NAME(always_available, glsl_type::int_type), \
1165 _##NAME(always_available, glsl_type::ivec2_type), \
1166 _##NAME(always_available, glsl_type::ivec3_type), \
1167 _##NAME(always_available, glsl_type::ivec4_type), \
1169 _##NAME(v130, glsl_type::uint_type), \
1170 _##NAME(v130, glsl_type::uvec2_type), \
1171 _##NAME(v130, glsl_type::uvec3_type), \
1172 _##NAME(v130, glsl_type::uvec4_type), \
1174 _##NAME(always_available, glsl_type::bool_type), \
1175 _##NAME(always_available, glsl_type::bvec2_type), \
1176 _##NAME(always_available, glsl_type::bvec3_type), \
1177 _##NAME(always_available, glsl_type::bvec4_type), \
1179 _##NAME(fp64, glsl_type::double_type), \
1180 _##NAME(fp64, glsl_type::dvec2_type), \
1181 _##NAME(fp64, glsl_type::dvec3_type), \
1182 _##NAME(fp64, glsl_type::dvec4_type), \
1185 #define FIUD2_MIXED(NAME) \
1186 add_function(#NAME, \
1187 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1188 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1189 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1190 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1192 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1193 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1194 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1196 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1197 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1198 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1199 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1201 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1202 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1203 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1205 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1206 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1207 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1208 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1210 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1211 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1212 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1214 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1215 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1216 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1217 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1218 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1219 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1220 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1231 add_function("atan",
1232 _atan(glsl_type::float_type
),
1233 _atan(glsl_type::vec2_type
),
1234 _atan(glsl_type::vec3_type
),
1235 _atan(glsl_type::vec4_type
),
1236 _atan2(glsl_type::float_type
),
1237 _atan2(glsl_type::vec2_type
),
1238 _atan2(glsl_type::vec3_type
),
1239 _atan2(glsl_type::vec4_type
),
1265 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1266 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1267 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1268 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1270 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1271 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1272 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1274 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1275 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1276 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1277 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1279 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1280 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1281 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1291 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1292 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1293 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1294 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1296 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1297 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1298 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1300 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1301 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1302 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1303 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1305 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1306 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1307 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1309 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1310 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1311 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1312 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1314 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1315 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1316 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1317 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1319 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1320 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1321 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1322 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1324 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1325 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1326 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1327 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1329 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1330 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1331 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1332 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1335 add_function("step",
1336 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1337 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1338 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1339 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1341 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1342 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1343 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1344 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1345 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1346 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1347 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1349 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1350 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1351 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1354 add_function("smoothstep",
1355 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1356 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1357 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1358 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1360 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1361 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1362 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1363 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1364 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1365 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1366 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1368 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1369 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1370 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1378 add_function("intBitsToFloat",
1379 _intBitsToFloat(glsl_type::int_type
),
1380 _intBitsToFloat(glsl_type::ivec2_type
),
1381 _intBitsToFloat(glsl_type::ivec3_type
),
1382 _intBitsToFloat(glsl_type::ivec4_type
),
1384 add_function("uintBitsToFloat",
1385 _uintBitsToFloat(glsl_type::uint_type
),
1386 _uintBitsToFloat(glsl_type::uvec2_type
),
1387 _uintBitsToFloat(glsl_type::uvec3_type
),
1388 _uintBitsToFloat(glsl_type::uvec4_type
),
1391 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1392 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1393 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1394 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1395 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1396 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1397 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1398 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1399 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1400 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1401 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1402 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1409 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1410 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1413 add_function("ftransform", _ftransform(), NULL
);
1418 add_function("matrixCompMult",
1419 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1420 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1421 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1422 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1423 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1424 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1425 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1426 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1427 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1428 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1429 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1430 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1431 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1432 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1433 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1434 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1435 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1436 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1438 add_function("outerProduct",
1439 _outerProduct(v120
, glsl_type::mat2_type
),
1440 _outerProduct(v120
, glsl_type::mat3_type
),
1441 _outerProduct(v120
, glsl_type::mat4_type
),
1442 _outerProduct(v120
, glsl_type::mat2x3_type
),
1443 _outerProduct(v120
, glsl_type::mat2x4_type
),
1444 _outerProduct(v120
, glsl_type::mat3x2_type
),
1445 _outerProduct(v120
, glsl_type::mat3x4_type
),
1446 _outerProduct(v120
, glsl_type::mat4x2_type
),
1447 _outerProduct(v120
, glsl_type::mat4x3_type
),
1448 _outerProduct(fp64
, glsl_type::dmat2_type
),
1449 _outerProduct(fp64
, glsl_type::dmat3_type
),
1450 _outerProduct(fp64
, glsl_type::dmat4_type
),
1451 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1452 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1453 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1454 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1455 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1456 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1458 add_function("determinant",
1459 _determinant_mat2(v120
, glsl_type::mat2_type
),
1460 _determinant_mat3(v120
, glsl_type::mat3_type
),
1461 _determinant_mat4(v120
, glsl_type::mat4_type
),
1462 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1463 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1464 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1467 add_function("inverse",
1468 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1469 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1470 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1471 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1472 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1473 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1475 add_function("transpose",
1476 _transpose(v120
, glsl_type::mat2_type
),
1477 _transpose(v120
, glsl_type::mat3_type
),
1478 _transpose(v120
, glsl_type::mat4_type
),
1479 _transpose(v120
, glsl_type::mat2x3_type
),
1480 _transpose(v120
, glsl_type::mat2x4_type
),
1481 _transpose(v120
, glsl_type::mat3x2_type
),
1482 _transpose(v120
, glsl_type::mat3x4_type
),
1483 _transpose(v120
, glsl_type::mat4x2_type
),
1484 _transpose(v120
, glsl_type::mat4x3_type
),
1485 _transpose(fp64
, glsl_type::dmat2_type
),
1486 _transpose(fp64
, glsl_type::dmat3_type
),
1487 _transpose(fp64
, glsl_type::dmat4_type
),
1488 _transpose(fp64
, glsl_type::dmat2x3_type
),
1489 _transpose(fp64
, glsl_type::dmat2x4_type
),
1490 _transpose(fp64
, glsl_type::dmat3x2_type
),
1491 _transpose(fp64
, glsl_type::dmat3x4_type
),
1492 _transpose(fp64
, glsl_type::dmat4x2_type
),
1493 _transpose(fp64
, glsl_type::dmat4x3_type
),
1498 FIUD(greaterThanEqual
)
1503 _any(glsl_type::bvec2_type
),
1504 _any(glsl_type::bvec3_type
),
1505 _any(glsl_type::bvec4_type
),
1509 _all(glsl_type::bvec2_type
),
1510 _all(glsl_type::bvec3_type
),
1511 _all(glsl_type::bvec4_type
),
1515 _not(glsl_type::bvec2_type
),
1516 _not(glsl_type::bvec3_type
),
1517 _not(glsl_type::bvec4_type
),
1520 add_function("textureSize",
1521 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1522 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1523 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1525 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1526 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1527 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1529 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1530 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1531 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1533 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1534 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1535 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1537 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1538 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1539 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1541 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1542 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1543 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1544 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1545 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1546 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1548 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1549 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1551 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1552 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1553 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1554 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1556 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1557 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1558 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1559 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1561 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1562 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1563 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1564 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1565 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1566 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1568 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1569 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1570 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1573 add_function("textureSamples",
1574 _textureSamples(glsl_type::sampler2DMS_type
),
1575 _textureSamples(glsl_type::isampler2DMS_type
),
1576 _textureSamples(glsl_type::usampler2DMS_type
),
1578 _textureSamples(glsl_type::sampler2DMSArray_type
),
1579 _textureSamples(glsl_type::isampler2DMSArray_type
),
1580 _textureSamples(glsl_type::usampler2DMSArray_type
),
1583 add_function("texture",
1584 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1585 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1586 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1588 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1589 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1590 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1592 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1593 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1594 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1596 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1597 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1598 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1600 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1601 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1602 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1604 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1605 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1606 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1608 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1609 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1610 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1612 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1613 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1614 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1616 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1617 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1618 /* samplerCubeArrayShadow is special; it has an extra parameter
1619 * for the shadow comparitor since there is no vec5 type.
1621 _textureCubeArrayShadow(),
1623 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1624 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1625 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1627 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1629 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1630 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1631 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1633 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1634 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1635 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1637 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1638 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1639 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1641 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1642 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1643 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1645 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1646 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1647 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1649 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1650 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1651 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1653 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1654 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1655 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1657 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1658 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1659 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1661 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1664 add_function("textureLod",
1665 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1666 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1667 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1669 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1670 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1671 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1673 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1674 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1675 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1677 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1678 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1679 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1681 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1682 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1684 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1685 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1686 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1688 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1689 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1690 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1692 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1693 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1694 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1696 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1699 add_function("textureOffset",
1700 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1701 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1702 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1704 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1705 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1706 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1708 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1709 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1710 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1712 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1713 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1714 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1716 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1718 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1719 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1721 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1722 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1723 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1725 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1726 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1727 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1729 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1731 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1732 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1733 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1735 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1736 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1737 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1739 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1740 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1741 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1743 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1744 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1746 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1747 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1748 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1750 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1751 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1752 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1754 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1757 add_function("textureProj",
1758 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1759 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1760 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1761 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1763 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1765 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1766 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1767 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1768 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1769 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1770 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1772 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1773 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1774 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1776 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1777 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1779 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1780 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1781 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1782 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1783 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1784 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1786 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1788 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1789 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1790 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1791 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1792 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1793 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1795 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1796 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1797 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1798 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1799 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1800 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1802 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1803 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1804 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1806 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1807 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1810 add_function("texelFetch",
1811 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1812 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1813 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1815 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1816 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1817 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1819 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1820 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1821 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1823 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1824 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1825 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1827 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1828 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1829 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1831 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1832 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1833 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1835 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1836 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1837 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1839 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1840 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1841 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1843 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1844 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1845 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1848 add_function("texelFetchOffset",
1849 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1850 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1851 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1853 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1854 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1855 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1857 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1858 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1859 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1861 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1862 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1863 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1865 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1866 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1867 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1869 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1870 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1871 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1875 add_function("textureProjOffset",
1876 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1877 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1878 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1879 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1880 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1881 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1883 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1884 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1885 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1886 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1887 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1888 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1890 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1891 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1892 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1894 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1895 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1897 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1898 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1899 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1900 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1901 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1902 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1904 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1906 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1907 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1908 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1909 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1910 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1911 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1914 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1915 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1916 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1918 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1920 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1921 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1922 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1924 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1925 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1928 add_function("textureLodOffset",
1929 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1930 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1931 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1933 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1934 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1935 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1937 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1938 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1939 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1941 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1942 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1944 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1945 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1946 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1948 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1949 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1950 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1952 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1955 add_function("textureProjLod",
1956 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1957 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1958 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1959 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1960 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1961 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1963 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1964 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1965 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1966 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1967 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1968 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1970 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1971 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1972 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1974 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1975 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1978 add_function("textureProjLodOffset",
1979 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1980 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1981 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1982 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1983 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1984 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1986 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1987 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1988 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1989 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1990 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1991 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1993 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1994 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1995 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1997 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1998 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2001 add_function("textureGrad",
2002 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2003 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2004 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2006 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2007 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2008 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2010 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2011 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2012 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2014 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2015 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2016 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2018 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2019 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2020 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2022 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2024 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2025 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2026 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2028 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2029 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2030 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2032 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2033 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2034 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2036 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2037 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2038 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2040 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2041 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2044 add_function("textureGradOffset",
2045 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2046 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2047 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2049 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2050 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2051 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2053 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2054 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2055 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2057 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2058 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2059 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2061 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2063 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2064 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2066 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2067 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2068 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2070 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2071 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2072 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2074 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2075 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2078 add_function("textureProjGrad",
2079 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2080 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2081 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2082 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2083 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2084 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2086 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2087 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2088 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2089 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2090 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2091 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2093 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2094 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2095 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2097 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2098 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2099 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2100 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2101 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2102 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2104 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2106 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2107 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2110 add_function("textureProjGradOffset",
2111 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2112 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2113 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2114 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2115 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2116 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2118 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2119 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2120 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2121 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2122 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2123 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2125 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2126 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2127 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2129 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2130 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2131 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2132 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2133 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2134 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2136 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2138 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2139 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2142 add_function("EmitVertex", _EmitVertex(), NULL
);
2143 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2144 add_function("EmitStreamVertex",
2145 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2146 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2148 add_function("EndStreamPrimitive",
2149 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2150 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2152 add_function("barrier", _barrier(), NULL
);
2154 add_function("textureQueryLOD",
2155 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2156 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2157 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2159 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2160 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2161 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2163 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2164 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2165 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2167 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2168 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2169 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2171 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2172 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2173 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2175 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2176 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2177 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2179 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2180 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2181 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2183 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2184 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2185 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2186 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2187 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2188 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2191 add_function("textureQueryLod",
2192 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2193 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2194 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2196 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2197 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2198 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2200 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2201 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2202 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2204 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2205 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2206 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2208 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2209 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2210 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2212 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2213 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2214 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2216 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2217 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2218 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2220 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2221 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2222 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2223 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2224 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2225 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2228 add_function("textureQueryLevels",
2229 _textureQueryLevels(glsl_type::sampler1D_type
),
2230 _textureQueryLevels(glsl_type::sampler2D_type
),
2231 _textureQueryLevels(glsl_type::sampler3D_type
),
2232 _textureQueryLevels(glsl_type::samplerCube_type
),
2233 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2234 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2235 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2236 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2237 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2238 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2239 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2240 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2241 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2243 _textureQueryLevels(glsl_type::isampler1D_type
),
2244 _textureQueryLevels(glsl_type::isampler2D_type
),
2245 _textureQueryLevels(glsl_type::isampler3D_type
),
2246 _textureQueryLevels(glsl_type::isamplerCube_type
),
2247 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2248 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2249 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2251 _textureQueryLevels(glsl_type::usampler1D_type
),
2252 _textureQueryLevels(glsl_type::usampler2D_type
),
2253 _textureQueryLevels(glsl_type::usampler3D_type
),
2254 _textureQueryLevels(glsl_type::usamplerCube_type
),
2255 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2256 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2257 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2261 add_function("textureSamplesIdenticalEXT",
2262 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2263 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2264 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2266 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2267 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2268 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2271 add_function("texture1D",
2272 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2273 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2276 add_function("texture1DArray",
2277 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2278 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2281 add_function("texture1DProj",
2282 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2283 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2284 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2285 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2288 add_function("texture1DLod",
2289 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2292 add_function("texture1DArrayLod",
2293 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2296 add_function("texture1DProjLod",
2297 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2298 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2301 add_function("texture2D",
2302 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2303 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2304 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2307 add_function("texture2DArray",
2308 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2309 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2312 add_function("texture2DProj",
2313 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2314 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2315 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2316 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2317 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2318 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2321 add_function("texture2DLod",
2322 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2325 add_function("texture2DArrayLod",
2326 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2329 add_function("texture2DProjLod",
2330 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2331 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2334 add_function("texture3D",
2335 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2336 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2339 add_function("texture3DProj",
2340 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2341 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2344 add_function("texture3DLod",
2345 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2348 add_function("texture3DProjLod",
2349 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2352 add_function("textureCube",
2353 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2354 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2357 add_function("textureCubeLod",
2358 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2361 add_function("texture2DRect",
2362 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2365 add_function("texture2DRectProj",
2366 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2367 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 add_function("shadow1D",
2371 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2372 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2375 add_function("shadow1DArray",
2376 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2377 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2380 add_function("shadow2D",
2381 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2382 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2385 add_function("shadow2DArray",
2386 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2387 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2390 add_function("shadow1DProj",
2391 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2392 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2395 add_function("shadow2DProj",
2396 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2397 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2400 add_function("shadow1DLod",
2401 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2404 add_function("shadow2DLod",
2405 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2408 add_function("shadow1DArrayLod",
2409 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2412 add_function("shadow1DProjLod",
2413 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2416 add_function("shadow2DProjLod",
2417 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2420 add_function("shadow2DRect",
2421 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2424 add_function("shadow2DRectProj",
2425 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2428 add_function("texture1DGradARB",
2429 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2432 add_function("texture1DProjGradARB",
2433 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2434 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2437 add_function("texture2DGradARB",
2438 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2441 add_function("texture2DProjGradARB",
2442 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2443 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2446 add_function("texture3DGradARB",
2447 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2450 add_function("texture3DProjGradARB",
2451 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2454 add_function("textureCubeGradARB",
2455 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2458 add_function("shadow1DGradARB",
2459 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2462 add_function("shadow1DProjGradARB",
2463 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2466 add_function("shadow2DGradARB",
2467 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2470 add_function("shadow2DProjGradARB",
2471 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2474 add_function("texture2DRectGradARB",
2475 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2478 add_function("texture2DRectProjGradARB",
2479 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2480 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2483 add_function("shadow2DRectGradARB",
2484 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2487 add_function("shadow2DRectProjGradARB",
2488 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2491 add_function("textureGather",
2492 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2493 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2494 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2496 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2497 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2498 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2500 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2501 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2502 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2504 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2505 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2506 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2508 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2509 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2510 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2512 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2513 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2514 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2516 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2517 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2518 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2520 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2521 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2522 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2524 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2525 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2526 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2528 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2529 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2530 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2532 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2533 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2534 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2535 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2536 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2539 add_function("textureGatherOffset",
2540 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2541 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2542 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2544 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2545 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2546 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2548 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2549 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2550 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2552 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2553 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2554 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2556 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2557 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2558 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2560 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2561 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2562 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2564 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2565 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2566 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2568 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2569 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2570 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2572 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2573 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2574 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2576 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2577 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2578 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2580 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2581 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2582 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2584 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2585 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2588 add_function("textureGatherOffsets",
2589 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2590 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2591 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2593 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2594 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2595 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2597 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2598 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2599 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2601 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2602 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2603 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2605 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2606 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2607 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2609 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2610 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2611 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2613 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2614 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2615 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2640 add_function("ldexp",
2641 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2642 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2643 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2644 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2645 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2646 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2647 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2648 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2651 add_function("frexp",
2652 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2653 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2654 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2655 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2656 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2657 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2658 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2659 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2661 add_function("uaddCarry",
2662 _uaddCarry(glsl_type::uint_type
),
2663 _uaddCarry(glsl_type::uvec2_type
),
2664 _uaddCarry(glsl_type::uvec3_type
),
2665 _uaddCarry(glsl_type::uvec4_type
),
2667 add_function("usubBorrow",
2668 _usubBorrow(glsl_type::uint_type
),
2669 _usubBorrow(glsl_type::uvec2_type
),
2670 _usubBorrow(glsl_type::uvec3_type
),
2671 _usubBorrow(glsl_type::uvec4_type
),
2673 add_function("imulExtended",
2674 _mulExtended(glsl_type::int_type
),
2675 _mulExtended(glsl_type::ivec2_type
),
2676 _mulExtended(glsl_type::ivec3_type
),
2677 _mulExtended(glsl_type::ivec4_type
),
2679 add_function("umulExtended",
2680 _mulExtended(glsl_type::uint_type
),
2681 _mulExtended(glsl_type::uvec2_type
),
2682 _mulExtended(glsl_type::uvec3_type
),
2683 _mulExtended(glsl_type::uvec4_type
),
2685 add_function("interpolateAtCentroid",
2686 _interpolateAtCentroid(glsl_type::float_type
),
2687 _interpolateAtCentroid(glsl_type::vec2_type
),
2688 _interpolateAtCentroid(glsl_type::vec3_type
),
2689 _interpolateAtCentroid(glsl_type::vec4_type
),
2691 add_function("interpolateAtOffset",
2692 _interpolateAtOffset(glsl_type::float_type
),
2693 _interpolateAtOffset(glsl_type::vec2_type
),
2694 _interpolateAtOffset(glsl_type::vec3_type
),
2695 _interpolateAtOffset(glsl_type::vec4_type
),
2697 add_function("interpolateAtSample",
2698 _interpolateAtSample(glsl_type::float_type
),
2699 _interpolateAtSample(glsl_type::vec2_type
),
2700 _interpolateAtSample(glsl_type::vec3_type
),
2701 _interpolateAtSample(glsl_type::vec4_type
),
2704 add_function("atomicCounter",
2705 _atomic_counter_op("__intrinsic_atomic_read",
2706 shader_atomic_counters
),
2708 add_function("atomicCounterIncrement",
2709 _atomic_counter_op("__intrinsic_atomic_increment",
2710 shader_atomic_counters
),
2712 add_function("atomicCounterDecrement",
2713 _atomic_counter_op("__intrinsic_atomic_predecrement",
2714 shader_atomic_counters
),
2717 add_function("atomicAdd",
2718 _atomic_op2("__intrinsic_atomic_add",
2719 buffer_atomics_supported
,
2720 glsl_type::uint_type
),
2721 _atomic_op2("__intrinsic_atomic_add",
2722 buffer_atomics_supported
,
2723 glsl_type::int_type
),
2725 add_function("atomicMin",
2726 _atomic_op2("__intrinsic_atomic_min",
2727 buffer_atomics_supported
,
2728 glsl_type::uint_type
),
2729 _atomic_op2("__intrinsic_atomic_min",
2730 buffer_atomics_supported
,
2731 glsl_type::int_type
),
2733 add_function("atomicMax",
2734 _atomic_op2("__intrinsic_atomic_max",
2735 buffer_atomics_supported
,
2736 glsl_type::uint_type
),
2737 _atomic_op2("__intrinsic_atomic_max",
2738 buffer_atomics_supported
,
2739 glsl_type::int_type
),
2741 add_function("atomicAnd",
2742 _atomic_op2("__intrinsic_atomic_and",
2743 buffer_atomics_supported
,
2744 glsl_type::uint_type
),
2745 _atomic_op2("__intrinsic_atomic_and",
2746 buffer_atomics_supported
,
2747 glsl_type::int_type
),
2749 add_function("atomicOr",
2750 _atomic_op2("__intrinsic_atomic_or",
2751 buffer_atomics_supported
,
2752 glsl_type::uint_type
),
2753 _atomic_op2("__intrinsic_atomic_or",
2754 buffer_atomics_supported
,
2755 glsl_type::int_type
),
2757 add_function("atomicXor",
2758 _atomic_op2("__intrinsic_atomic_xor",
2759 buffer_atomics_supported
,
2760 glsl_type::uint_type
),
2761 _atomic_op2("__intrinsic_atomic_xor",
2762 buffer_atomics_supported
,
2763 glsl_type::int_type
),
2765 add_function("atomicExchange",
2766 _atomic_op2("__intrinsic_atomic_exchange",
2767 buffer_atomics_supported
,
2768 glsl_type::uint_type
),
2769 _atomic_op2("__intrinsic_atomic_exchange",
2770 buffer_atomics_supported
,
2771 glsl_type::int_type
),
2773 add_function("atomicCompSwap",
2774 _atomic_op3("__intrinsic_atomic_comp_swap",
2775 buffer_atomics_supported
,
2776 glsl_type::uint_type
),
2777 _atomic_op3("__intrinsic_atomic_comp_swap",
2778 buffer_atomics_supported
,
2779 glsl_type::int_type
),
2782 add_function("min3",
2783 _min3(glsl_type::float_type
),
2784 _min3(glsl_type::vec2_type
),
2785 _min3(glsl_type::vec3_type
),
2786 _min3(glsl_type::vec4_type
),
2788 _min3(glsl_type::int_type
),
2789 _min3(glsl_type::ivec2_type
),
2790 _min3(glsl_type::ivec3_type
),
2791 _min3(glsl_type::ivec4_type
),
2793 _min3(glsl_type::uint_type
),
2794 _min3(glsl_type::uvec2_type
),
2795 _min3(glsl_type::uvec3_type
),
2796 _min3(glsl_type::uvec4_type
),
2799 add_function("max3",
2800 _max3(glsl_type::float_type
),
2801 _max3(glsl_type::vec2_type
),
2802 _max3(glsl_type::vec3_type
),
2803 _max3(glsl_type::vec4_type
),
2805 _max3(glsl_type::int_type
),
2806 _max3(glsl_type::ivec2_type
),
2807 _max3(glsl_type::ivec3_type
),
2808 _max3(glsl_type::ivec4_type
),
2810 _max3(glsl_type::uint_type
),
2811 _max3(glsl_type::uvec2_type
),
2812 _max3(glsl_type::uvec3_type
),
2813 _max3(glsl_type::uvec4_type
),
2816 add_function("mid3",
2817 _mid3(glsl_type::float_type
),
2818 _mid3(glsl_type::vec2_type
),
2819 _mid3(glsl_type::vec3_type
),
2820 _mid3(glsl_type::vec4_type
),
2822 _mid3(glsl_type::int_type
),
2823 _mid3(glsl_type::ivec2_type
),
2824 _mid3(glsl_type::ivec3_type
),
2825 _mid3(glsl_type::ivec4_type
),
2827 _mid3(glsl_type::uint_type
),
2828 _mid3(glsl_type::uvec2_type
),
2829 _mid3(glsl_type::uvec3_type
),
2830 _mid3(glsl_type::uvec4_type
),
2833 add_image_functions(true);
2835 add_function("memoryBarrier",
2836 _memory_barrier("__intrinsic_memory_barrier",
2837 shader_image_load_store
),
2839 add_function("groupMemoryBarrier",
2840 _memory_barrier("__intrinsic_group_memory_barrier",
2843 add_function("memoryBarrierAtomicCounter",
2844 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2847 add_function("memoryBarrierBuffer",
2848 _memory_barrier("__intrinsic_memory_barrier_buffer",
2851 add_function("memoryBarrierImage",
2852 _memory_barrier("__intrinsic_memory_barrier_image",
2855 add_function("memoryBarrierShared",
2856 _memory_barrier("__intrinsic_memory_barrier_shared",
2860 add_function("clock2x32ARB",
2861 _shader_clock(shader_clock
,
2862 glsl_type::uvec2_type
),
2873 builtin_builder::add_function(const char *name
, ...)
2877 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2881 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2887 stuff
.push_tail(sig
);
2888 validate_ir_tree(&stuff
);
2891 f
->add_signature(sig
);
2895 shader
->symbols
->add_function(f
);
2899 builtin_builder::add_image_function(const char *name
,
2900 const char *intrinsic_name
,
2901 image_prototype_ctr prototype
,
2902 unsigned num_arguments
,
2905 static const glsl_type
*const types
[] = {
2906 glsl_type::image1D_type
,
2907 glsl_type::image2D_type
,
2908 glsl_type::image3D_type
,
2909 glsl_type::image2DRect_type
,
2910 glsl_type::imageCube_type
,
2911 glsl_type::imageBuffer_type
,
2912 glsl_type::image1DArray_type
,
2913 glsl_type::image2DArray_type
,
2914 glsl_type::imageCubeArray_type
,
2915 glsl_type::image2DMS_type
,
2916 glsl_type::image2DMSArray_type
,
2917 glsl_type::iimage1D_type
,
2918 glsl_type::iimage2D_type
,
2919 glsl_type::iimage3D_type
,
2920 glsl_type::iimage2DRect_type
,
2921 glsl_type::iimageCube_type
,
2922 glsl_type::iimageBuffer_type
,
2923 glsl_type::iimage1DArray_type
,
2924 glsl_type::iimage2DArray_type
,
2925 glsl_type::iimageCubeArray_type
,
2926 glsl_type::iimage2DMS_type
,
2927 glsl_type::iimage2DMSArray_type
,
2928 glsl_type::uimage1D_type
,
2929 glsl_type::uimage2D_type
,
2930 glsl_type::uimage3D_type
,
2931 glsl_type::uimage2DRect_type
,
2932 glsl_type::uimageCube_type
,
2933 glsl_type::uimageBuffer_type
,
2934 glsl_type::uimage1DArray_type
,
2935 glsl_type::uimage2DArray_type
,
2936 glsl_type::uimageCubeArray_type
,
2937 glsl_type::uimage2DMS_type
,
2938 glsl_type::uimage2DMSArray_type
2941 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2943 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2944 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
2945 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2946 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2947 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2948 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2949 num_arguments
, flags
));
2952 shader
->symbols
->add_function(f
);
2956 builtin_builder::add_image_functions(bool glsl
)
2958 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2960 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2961 "__intrinsic_image_load",
2962 &builtin_builder::_image_prototype
, 0,
2963 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2964 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2965 IMAGE_FUNCTION_READ_ONLY
));
2967 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2968 "__intrinsic_image_store",
2969 &builtin_builder::_image_prototype
, 1,
2970 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2971 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2972 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2973 IMAGE_FUNCTION_WRITE_ONLY
));
2975 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2977 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2978 "__intrinsic_image_atomic_add",
2979 &builtin_builder::_image_prototype
, 1, atom_flags
);
2981 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2982 "__intrinsic_image_atomic_min",
2983 &builtin_builder::_image_prototype
, 1, atom_flags
);
2985 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2986 "__intrinsic_image_atomic_max",
2987 &builtin_builder::_image_prototype
, 1, atom_flags
);
2989 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2990 "__intrinsic_image_atomic_and",
2991 &builtin_builder::_image_prototype
, 1, atom_flags
);
2993 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2994 "__intrinsic_image_atomic_or",
2995 &builtin_builder::_image_prototype
, 1, atom_flags
);
2997 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2998 "__intrinsic_image_atomic_xor",
2999 &builtin_builder::_image_prototype
, 1, atom_flags
);
3001 add_image_function((glsl
? "imageAtomicExchange" :
3002 "__intrinsic_image_atomic_exchange"),
3003 "__intrinsic_image_atomic_exchange",
3004 &builtin_builder::_image_prototype
, 1,
3005 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3006 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
));
3008 add_image_function((glsl
? "imageAtomicCompSwap" :
3009 "__intrinsic_image_atomic_comp_swap"),
3010 "__intrinsic_image_atomic_comp_swap",
3011 &builtin_builder::_image_prototype
, 2, atom_flags
);
3013 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3014 "__intrinsic_image_size",
3015 &builtin_builder::_image_size_prototype
, 1,
3016 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
3018 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3019 "__intrinsic_image_samples",
3020 &builtin_builder::_image_samples_prototype
, 1,
3021 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3022 IMAGE_FUNCTION_MS_ONLY
);
3026 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3028 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3032 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3034 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3038 builtin_builder::imm(bool b
, unsigned vector_elements
)
3040 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3044 builtin_builder::imm(float f
, unsigned vector_elements
)
3046 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3050 builtin_builder::imm(int i
, unsigned vector_elements
)
3052 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3056 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3058 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3062 builtin_builder::imm(double d
, unsigned vector_elements
)
3064 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3068 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3070 return new(mem_ctx
) ir_constant(type
, &data
);
3073 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3075 ir_dereference_variable
*
3076 builtin_builder::var_ref(ir_variable
*var
)
3078 return new(mem_ctx
) ir_dereference_variable(var
);
3081 ir_dereference_array
*
3082 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3084 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3087 /** Return an element of a matrix */
3089 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3091 return swizzle(array_ref(var
, column
), row
, 1);
3095 * Implementations of built-in functions:
3098 ir_function_signature
*
3099 builtin_builder::new_sig(const glsl_type
*return_type
,
3100 builtin_available_predicate avail
,
3106 ir_function_signature
*sig
=
3107 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3110 va_start(ap
, num_params
);
3111 for (int i
= 0; i
< num_params
; i
++) {
3112 plist
.push_tail(va_arg(ap
, ir_variable
*));
3116 sig
->replace_parameters(&plist
);
3120 #define MAKE_SIG(return_type, avail, ...) \
3121 ir_function_signature *sig = \
3122 new_sig(return_type, avail, __VA_ARGS__); \
3123 ir_factory body(&sig->body, mem_ctx); \
3124 sig->is_defined = true;
3126 #define MAKE_INTRINSIC(return_type, avail, ...) \
3127 ir_function_signature *sig = \
3128 new_sig(return_type, avail, __VA_ARGS__); \
3129 sig->is_intrinsic = true;
3131 ir_function_signature
*
3132 builtin_builder::unop(builtin_available_predicate avail
,
3133 ir_expression_operation opcode
,
3134 const glsl_type
*return_type
,
3135 const glsl_type
*param_type
)
3137 ir_variable
*x
= in_var(param_type
, "x");
3138 MAKE_SIG(return_type
, avail
, 1, x
);
3139 body
.emit(ret(expr(opcode
, x
)));
3143 #define UNOP(NAME, OPCODE, AVAIL) \
3144 ir_function_signature * \
3145 builtin_builder::_##NAME(const glsl_type *type) \
3147 return unop(&AVAIL, OPCODE, type, type); \
3150 #define UNOPA(NAME, OPCODE) \
3151 ir_function_signature * \
3152 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3154 return unop(avail, OPCODE, type, type); \
3157 ir_function_signature
*
3158 builtin_builder::binop(builtin_available_predicate avail
,
3159 ir_expression_operation opcode
,
3160 const glsl_type
*return_type
,
3161 const glsl_type
*param0_type
,
3162 const glsl_type
*param1_type
)
3164 ir_variable
*x
= in_var(param0_type
, "x");
3165 ir_variable
*y
= in_var(param1_type
, "y");
3166 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3167 body
.emit(ret(expr(opcode
, x
, y
)));
3171 #define BINOP(NAME, OPCODE, AVAIL) \
3172 ir_function_signature * \
3173 builtin_builder::_##NAME(const glsl_type *return_type, \
3174 const glsl_type *param0_type, \
3175 const glsl_type *param1_type) \
3177 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3181 * Angle and Trigonometry Functions @{
3184 ir_function_signature
*
3185 builtin_builder::_radians(const glsl_type
*type
)
3187 ir_variable
*degrees
= in_var(type
, "degrees");
3188 MAKE_SIG(type
, always_available
, 1, degrees
);
3189 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3193 ir_function_signature
*
3194 builtin_builder::_degrees(const glsl_type
*type
)
3196 ir_variable
*radians
= in_var(type
, "radians");
3197 MAKE_SIG(type
, always_available
, 1, radians
);
3198 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3202 UNOP(sin
, ir_unop_sin
, always_available
)
3203 UNOP(cos
, ir_unop_cos
, always_available
)
3205 ir_function_signature
*
3206 builtin_builder::_tan(const glsl_type
*type
)
3208 ir_variable
*theta
= in_var(type
, "theta");
3209 MAKE_SIG(type
, always_available
, 1, theta
);
3210 body
.emit(ret(div(sin(theta
), cos(theta
))));
3215 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3219 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3222 add(imm(M_PI_4f
- 1.0f
),
3225 mul(abs(x
), imm(p1
))))))))));
3229 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3231 exec_list actual_params
;
3233 foreach_in_list(ir_variable
, var
, ¶ms
) {
3234 actual_params
.push_tail(var_ref(var
));
3237 ir_function_signature
*sig
=
3238 f
->exact_matching_signature(NULL
, &actual_params
);
3242 ir_dereference_variable
*deref
=
3243 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3245 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3248 ir_function_signature
*
3249 builtin_builder::_asin(const glsl_type
*type
)
3251 ir_variable
*x
= in_var(type
, "x");
3252 MAKE_SIG(type
, always_available
, 1, x
);
3254 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3259 ir_function_signature
*
3260 builtin_builder::_acos(const glsl_type
*type
)
3262 ir_variable
*x
= in_var(type
, "x");
3263 MAKE_SIG(type
, always_available
, 1, x
);
3265 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3270 ir_function_signature
*
3271 builtin_builder::_atan2(const glsl_type
*type
)
3273 ir_variable
*vec_y
= in_var(type
, "vec_y");
3274 ir_variable
*vec_x
= in_var(type
, "vec_x");
3275 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3277 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3278 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3279 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3280 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3281 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3282 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3283 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3285 /* If |x| >= 1.0e-8 * |y|: */
3287 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3289 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3291 /* Then...call atan(y/x) */
3292 do_atan(outer_then
, glsl_type::float_type
, r
, div(y
, x
));
3294 /* ...and fix it up: */
3295 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3296 inner_if
->then_instructions
.push_tail(
3297 if_tree(gequal(y
, imm(0.0f
)),
3298 assign(r
, add(r
, imm(M_PIf
))),
3299 assign(r
, sub(r
, imm(M_PIf
)))));
3300 outer_then
.emit(inner_if
);
3303 outer_if
->else_instructions
.push_tail(
3304 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3306 body
.emit(outer_if
);
3308 body
.emit(assign(vec_result
, r
, 1 << i
));
3310 body
.emit(ret(vec_result
));
3316 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3319 * range-reduction, first step:
3321 * / y_over_x if |y_over_x| <= 1.0;
3323 * \ 1.0 / y_over_x otherwise
3325 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3326 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3332 * approximate atan by evaluating polynomial:
3334 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3335 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3336 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3338 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3339 body
.emit(assign(tmp
, mul(x
, x
)));
3340 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3342 imm(0.0536813784310406f
)),
3344 imm(0.1173503194786851f
)),
3346 imm(0.1938924977115610f
)),
3348 imm(0.3326756418091246f
)),
3350 imm(0.9999793128310355f
)),
3353 /* range-reduction fixup */
3354 body
.emit(assign(tmp
, add(tmp
,
3355 mul(b2f(greater(abs(y_over_x
),
3356 imm(1.0f
, type
->components()))),
3362 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3365 ir_function_signature
*
3366 builtin_builder::_atan(const glsl_type
*type
)
3368 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3369 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3371 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3372 do_atan(body
, type
, tmp
, y_over_x
);
3373 body
.emit(ret(tmp
));
3378 ir_function_signature
*
3379 builtin_builder::_sinh(const glsl_type
*type
)
3381 ir_variable
*x
= in_var(type
, "x");
3382 MAKE_SIG(type
, v130
, 1, x
);
3384 /* 0.5 * (e^x - e^(-x)) */
3385 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3390 ir_function_signature
*
3391 builtin_builder::_cosh(const glsl_type
*type
)
3393 ir_variable
*x
= in_var(type
, "x");
3394 MAKE_SIG(type
, v130
, 1, x
);
3396 /* 0.5 * (e^x + e^(-x)) */
3397 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3402 ir_function_signature
*
3403 builtin_builder::_tanh(const glsl_type
*type
)
3405 ir_variable
*x
= in_var(type
, "x");
3406 MAKE_SIG(type
, v130
, 1, x
);
3408 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3409 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3410 add(exp(x
), exp(neg(x
))))));
3415 ir_function_signature
*
3416 builtin_builder::_asinh(const glsl_type
*type
)
3418 ir_variable
*x
= in_var(type
, "x");
3419 MAKE_SIG(type
, v130
, 1, x
);
3421 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3426 ir_function_signature
*
3427 builtin_builder::_acosh(const glsl_type
*type
)
3429 ir_variable
*x
= in_var(type
, "x");
3430 MAKE_SIG(type
, v130
, 1, x
);
3432 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3436 ir_function_signature
*
3437 builtin_builder::_atanh(const glsl_type
*type
)
3439 ir_variable
*x
= in_var(type
, "x");
3440 MAKE_SIG(type
, v130
, 1, x
);
3442 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3443 sub(imm(1.0f
), x
))))));
3449 * Exponential Functions @{
3452 ir_function_signature
*
3453 builtin_builder::_pow(const glsl_type
*type
)
3455 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3458 UNOP(exp
, ir_unop_exp
, always_available
)
3459 UNOP(log
, ir_unop_log
, always_available
)
3460 UNOP(exp2
, ir_unop_exp2
, always_available
)
3461 UNOP(log2
, ir_unop_log2
, always_available
)
3462 UNOPA(sqrt
, ir_unop_sqrt
)
3463 UNOPA(inversesqrt
, ir_unop_rsq
)
3467 UNOPA(abs
, ir_unop_abs
)
3468 UNOPA(sign
, ir_unop_sign
)
3469 UNOPA(floor
, ir_unop_floor
)
3470 UNOPA(trunc
, ir_unop_trunc
)
3471 UNOPA(round
, ir_unop_round_even
)
3472 UNOPA(roundEven
, ir_unop_round_even
)
3473 UNOPA(ceil
, ir_unop_ceil
)
3474 UNOPA(fract
, ir_unop_fract
)
3476 ir_function_signature
*
3477 builtin_builder::_mod(builtin_available_predicate avail
,
3478 const glsl_type
*x_type
, const glsl_type
*y_type
)
3480 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3483 ir_function_signature
*
3484 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3486 ir_variable
*x
= in_var(type
, "x");
3487 ir_variable
*i
= out_var(type
, "i");
3488 MAKE_SIG(type
, avail
, 2, x
, i
);
3490 ir_variable
*t
= body
.make_temp(type
, "t");
3491 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3492 body
.emit(assign(i
, t
));
3493 body
.emit(ret(sub(x
, t
)));
3498 ir_function_signature
*
3499 builtin_builder::_min(builtin_available_predicate avail
,
3500 const glsl_type
*x_type
, const glsl_type
*y_type
)
3502 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3505 ir_function_signature
*
3506 builtin_builder::_max(builtin_available_predicate avail
,
3507 const glsl_type
*x_type
, const glsl_type
*y_type
)
3509 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3512 ir_function_signature
*
3513 builtin_builder::_clamp(builtin_available_predicate avail
,
3514 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3516 ir_variable
*x
= in_var(val_type
, "x");
3517 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3518 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3519 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3521 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3526 ir_function_signature
*
3527 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3529 ir_variable
*x
= in_var(val_type
, "x");
3530 ir_variable
*y
= in_var(val_type
, "y");
3531 ir_variable
*a
= in_var(blend_type
, "a");
3532 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3534 body
.emit(ret(lrp(x
, y
, a
)));
3539 ir_function_signature
*
3540 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3541 const glsl_type
*val_type
,
3542 const glsl_type
*blend_type
)
3544 ir_variable
*x
= in_var(val_type
, "x");
3545 ir_variable
*y
= in_var(val_type
, "y");
3546 ir_variable
*a
= in_var(blend_type
, "a");
3547 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3549 /* csel matches the ternary operator in that a selector of true choses the
3550 * first argument. This differs from mix(x, y, false) which choses the
3551 * second argument (to remain consistent with the interpolating version of
3552 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3554 * To handle the behavior mismatch, reverse the x and y arguments.
3556 body
.emit(ret(csel(a
, y
, x
)));
3561 ir_function_signature
*
3562 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3564 ir_variable
*edge
= in_var(edge_type
, "edge");
3565 ir_variable
*x
= in_var(x_type
, "x");
3566 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3568 ir_variable
*t
= body
.make_temp(x_type
, "t");
3569 if (x_type
->vector_elements
== 1) {
3570 /* Both are floats */
3571 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3572 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3574 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3575 } else if (edge_type
->vector_elements
== 1) {
3576 /* x is a vector but edge is a float */
3577 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3578 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3579 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3581 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3584 /* Both are vectors */
3585 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3586 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3587 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3590 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3600 ir_function_signature
*
3601 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3603 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3604 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3605 ir_variable
*x
= in_var(x_type
, "x");
3606 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3608 /* From the GLSL 1.10 specification:
3611 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3612 * return t * t * (3 - 2 * t);
3615 ir_variable
*t
= body
.make_temp(x_type
, "t");
3616 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3617 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3619 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3624 ir_function_signature
*
3625 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3627 ir_variable
*x
= in_var(type
, "x");
3628 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3630 body
.emit(ret(nequal(x
, x
)));
3635 ir_function_signature
*
3636 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3638 ir_variable
*x
= in_var(type
, "x");
3639 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3641 ir_constant_data infinities
;
3642 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3643 switch (type
->base_type
) {
3644 case GLSL_TYPE_FLOAT
:
3645 infinities
.f
[i
] = INFINITY
;
3647 case GLSL_TYPE_DOUBLE
:
3648 infinities
.d
[i
] = INFINITY
;
3651 unreachable("unknown type");
3655 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3660 ir_function_signature
*
3661 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3663 ir_variable
*x
= in_var(type
, "x");
3664 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3665 body
.emit(ret(bitcast_f2i(x
)));
3669 ir_function_signature
*
3670 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3672 ir_variable
*x
= in_var(type
, "x");
3673 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3674 body
.emit(ret(bitcast_f2u(x
)));
3678 ir_function_signature
*
3679 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3681 ir_variable
*x
= in_var(type
, "x");
3682 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3683 body
.emit(ret(bitcast_i2f(x
)));
3687 ir_function_signature
*
3688 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3690 ir_variable
*x
= in_var(type
, "x");
3691 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3692 body
.emit(ret(bitcast_u2f(x
)));
3696 ir_function_signature
*
3697 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3699 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3700 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3701 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3705 ir_function_signature
*
3706 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3708 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3709 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3710 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3714 ir_function_signature
*
3715 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3717 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3718 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3719 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3723 ir_function_signature
*
3724 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3726 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3727 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3728 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3732 ir_function_signature
*
3733 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3735 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3736 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3737 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3741 ir_function_signature
*
3742 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3744 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3745 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3746 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3751 ir_function_signature
*
3752 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3754 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3755 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3756 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3760 ir_function_signature
*
3761 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3763 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3764 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3765 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3769 ir_function_signature
*
3770 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3772 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3773 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3774 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3778 ir_function_signature
*
3779 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3781 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3782 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3783 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3787 ir_function_signature
*
3788 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3790 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3791 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3792 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3796 ir_function_signature
*
3797 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3799 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3800 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3801 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3805 ir_function_signature
*
3806 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3808 ir_variable
*x
= in_var(type
, "x");
3809 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3811 body
.emit(ret(sqrt(dot(x
, x
))));
3816 ir_function_signature
*
3817 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3819 ir_variable
*p0
= in_var(type
, "p0");
3820 ir_variable
*p1
= in_var(type
, "p1");
3821 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3823 if (type
->vector_elements
== 1) {
3824 body
.emit(ret(abs(sub(p0
, p1
))));
3826 ir_variable
*p
= body
.make_temp(type
, "p");
3827 body
.emit(assign(p
, sub(p0
, p1
)));
3828 body
.emit(ret(sqrt(dot(p
, p
))));
3834 ir_function_signature
*
3835 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3837 if (type
->vector_elements
== 1)
3838 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3840 return binop(avail
, ir_binop_dot
,
3841 type
->get_base_type(), type
, type
);
3844 ir_function_signature
*
3845 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3847 ir_variable
*a
= in_var(type
, "a");
3848 ir_variable
*b
= in_var(type
, "b");
3849 MAKE_SIG(type
, avail
, 2, a
, b
);
3851 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3852 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3854 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3855 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3860 ir_function_signature
*
3861 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3863 ir_variable
*x
= in_var(type
, "x");
3864 MAKE_SIG(type
, avail
, 1, x
);
3866 if (type
->vector_elements
== 1) {
3867 body
.emit(ret(sign(x
)));
3869 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3875 ir_function_signature
*
3876 builtin_builder::_ftransform()
3878 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3880 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3881 glsl_type::vec4_type
,
3882 var_ref(gl_ModelViewProjectionMatrix
),
3883 var_ref(gl_Vertex
))));
3885 /* FINISHME: Once the ir_expression() constructor handles type inference
3886 * for matrix operations, we can simplify this to:
3888 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3893 ir_function_signature
*
3894 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3896 ir_variable
*N
= in_var(type
, "N");
3897 ir_variable
*I
= in_var(type
, "I");
3898 ir_variable
*Nref
= in_var(type
, "Nref");
3899 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3901 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3902 ret(N
), ret(neg(N
))));
3907 ir_function_signature
*
3908 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3910 ir_variable
*I
= in_var(type
, "I");
3911 ir_variable
*N
= in_var(type
, "N");
3912 MAKE_SIG(type
, avail
, 2, I
, N
);
3914 /* I - 2 * dot(N, I) * N */
3915 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3920 ir_function_signature
*
3921 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3923 ir_variable
*I
= in_var(type
, "I");
3924 ir_variable
*N
= in_var(type
, "N");
3925 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3926 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3928 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3929 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3931 /* From the GLSL 1.10 specification:
3932 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3934 * return genType(0.0)
3936 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3938 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3939 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3940 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3941 mul(n_dot_i
, n_dot_i
)))))));
3942 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3943 ret(ir_constant::zero(mem_ctx
, type
)),
3944 ret(sub(mul(eta
, I
),
3945 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3950 ir_function_signature
*
3951 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3953 ir_variable
*x
= in_var(type
, "x");
3954 ir_variable
*y
= in_var(type
, "y");
3955 MAKE_SIG(type
, avail
, 2, x
, y
);
3957 ir_variable
*z
= body
.make_temp(type
, "z");
3958 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3959 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3966 ir_function_signature
*
3967 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3972 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3973 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3974 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3976 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3977 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3979 MAKE_SIG(type
, avail
, 2, c
, r
);
3981 ir_variable
*m
= body
.make_temp(type
, "m");
3982 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3983 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3990 ir_function_signature
*
3991 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3993 const glsl_type
*transpose_type
=
3994 glsl_type::get_instance(orig_type
->base_type
,
3995 orig_type
->matrix_columns
,
3996 orig_type
->vector_elements
);
3998 ir_variable
*m
= in_var(orig_type
, "m");
3999 MAKE_SIG(transpose_type
, avail
, 1, m
);
4001 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4002 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4003 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4004 body
.emit(assign(array_ref(t
, j
),
4005 matrix_elt(m
, i
, j
),
4014 ir_function_signature
*
4015 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4017 ir_variable
*m
= in_var(type
, "m");
4018 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4020 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4021 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4026 ir_function_signature
*
4027 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4029 ir_variable
*m
= in_var(type
, "m");
4030 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4033 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4034 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4037 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4038 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4041 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4042 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4044 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4045 mul(matrix_elt(m
, 0, 1), f2
)),
4046 mul(matrix_elt(m
, 0, 2), f3
))));
4051 ir_function_signature
*
4052 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4054 ir_variable
*m
= in_var(type
, "m");
4055 const glsl_type
*btype
= type
->get_base_type();
4056 MAKE_SIG(btype
, avail
, 1, m
);
4058 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4059 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4060 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4061 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4062 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4063 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4064 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4065 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4066 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4067 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4068 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4069 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4070 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4071 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4072 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4073 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4074 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4075 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4076 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4078 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)))));
4079 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)))));
4080 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)))));
4081 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)))));
4082 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)))));
4083 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)))));
4084 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)))));
4085 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)))));
4086 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)))));
4087 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)))));
4088 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)))));
4089 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)))));
4090 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)))));
4091 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)))));
4092 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)))));
4093 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)))));
4094 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)))));
4095 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)))));
4096 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)))));
4098 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4100 body
.emit(assign(adj_0
,
4101 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4102 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4103 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4105 body
.emit(assign(adj_0
, neg(
4106 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4107 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4108 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4110 body
.emit(assign(adj_0
,
4111 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4112 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4113 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4115 body
.emit(assign(adj_0
, neg(
4116 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4117 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4118 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4121 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4126 ir_function_signature
*
4127 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4129 ir_variable
*m
= in_var(type
, "m");
4130 MAKE_SIG(type
, avail
, 1, m
);
4132 ir_variable
*adj
= body
.make_temp(type
, "adj");
4133 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4134 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4135 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4136 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4138 ir_expression
*det
=
4139 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4140 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4142 body
.emit(ret(div(adj
, det
)));
4146 ir_function_signature
*
4147 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4149 ir_variable
*m
= in_var(type
, "m");
4150 const glsl_type
*btype
= type
->get_base_type();
4151 MAKE_SIG(type
, avail
, 1, m
);
4153 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4154 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4155 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4157 body
.emit(assign(f11_22_21_12
,
4158 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4159 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4160 body
.emit(assign(f10_22_20_12
,
4161 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4162 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4163 body
.emit(assign(f10_21_20_11
,
4164 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4165 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4167 ir_variable
*adj
= body
.make_temp(type
, "adj");
4168 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4169 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4170 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4172 body
.emit(assign(array_ref(adj
, 0), neg(
4173 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4174 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4176 body
.emit(assign(array_ref(adj
, 1),
4177 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4178 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4180 body
.emit(assign(array_ref(adj
, 2), neg(
4181 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4182 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4185 body
.emit(assign(array_ref(adj
, 0),
4186 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4187 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4189 body
.emit(assign(array_ref(adj
, 1), neg(
4190 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4191 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4193 body
.emit(assign(array_ref(adj
, 2),
4194 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4195 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4198 ir_expression
*det
=
4199 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4200 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4201 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4203 body
.emit(ret(div(adj
, det
)));
4208 ir_function_signature
*
4209 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4211 ir_variable
*m
= in_var(type
, "m");
4212 const glsl_type
*btype
= type
->get_base_type();
4213 MAKE_SIG(type
, avail
, 1, m
);
4215 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4216 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4217 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4218 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4219 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4220 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4221 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4222 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4223 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4224 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4225 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4226 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4227 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4228 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4229 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4230 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4231 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4232 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4233 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4235 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)))));
4236 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)))));
4237 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)))));
4238 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)))));
4239 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)))));
4240 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)))));
4241 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)))));
4242 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)))));
4243 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)))));
4244 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)))));
4245 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)))));
4246 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)))));
4247 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)))));
4248 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)))));
4249 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)))));
4250 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)))));
4251 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)))));
4252 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)))));
4253 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)))));
4255 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4256 body
.emit(assign(array_ref(adj
, 0),
4257 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4258 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4259 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4261 body
.emit(assign(array_ref(adj
, 1), neg(
4262 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4263 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4264 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4266 body
.emit(assign(array_ref(adj
, 2),
4267 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4268 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4269 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4271 body
.emit(assign(array_ref(adj
, 3), neg(
4272 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4273 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4274 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4277 body
.emit(assign(array_ref(adj
, 0), neg(
4278 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4279 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4280 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4282 body
.emit(assign(array_ref(adj
, 1),
4283 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4284 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4285 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4287 body
.emit(assign(array_ref(adj
, 2), neg(
4288 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4289 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4290 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4292 body
.emit(assign(array_ref(adj
, 3),
4293 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4294 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4295 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4298 body
.emit(assign(array_ref(adj
, 0),
4299 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4300 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4301 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4303 body
.emit(assign(array_ref(adj
, 1), neg(
4304 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4305 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4306 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4308 body
.emit(assign(array_ref(adj
, 2),
4309 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4310 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4311 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4313 body
.emit(assign(array_ref(adj
, 3), neg(
4314 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4315 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4316 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4319 body
.emit(assign(array_ref(adj
, 0), neg(
4320 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4321 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4322 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4324 body
.emit(assign(array_ref(adj
, 1),
4325 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4326 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4327 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4329 body
.emit(assign(array_ref(adj
, 2), neg(
4330 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4331 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4332 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4334 body
.emit(assign(array_ref(adj
, 3),
4335 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4336 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4337 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4340 ir_expression
*det
=
4341 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4342 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4343 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4344 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4346 body
.emit(ret(div(adj
, det
)));
4352 ir_function_signature
*
4353 builtin_builder::_lessThan(builtin_available_predicate avail
,
4354 const glsl_type
*type
)
4356 return binop(avail
, ir_binop_less
,
4357 glsl_type::bvec(type
->vector_elements
), type
, type
);
4360 ir_function_signature
*
4361 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4362 const glsl_type
*type
)
4364 return binop(avail
, ir_binop_lequal
,
4365 glsl_type::bvec(type
->vector_elements
), type
, type
);
4368 ir_function_signature
*
4369 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4370 const glsl_type
*type
)
4372 return binop(avail
, ir_binop_greater
,
4373 glsl_type::bvec(type
->vector_elements
), type
, type
);
4376 ir_function_signature
*
4377 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4378 const glsl_type
*type
)
4380 return binop(avail
, ir_binop_gequal
,
4381 glsl_type::bvec(type
->vector_elements
), type
, type
);
4384 ir_function_signature
*
4385 builtin_builder::_equal(builtin_available_predicate avail
,
4386 const glsl_type
*type
)
4388 return binop(avail
, ir_binop_equal
,
4389 glsl_type::bvec(type
->vector_elements
), type
, type
);
4392 ir_function_signature
*
4393 builtin_builder::_notEqual(builtin_available_predicate avail
,
4394 const glsl_type
*type
)
4396 return binop(avail
, ir_binop_nequal
,
4397 glsl_type::bvec(type
->vector_elements
), type
, type
);
4400 ir_function_signature
*
4401 builtin_builder::_any(const glsl_type
*type
)
4403 ir_variable
*v
= in_var(type
, "v");
4404 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4406 const unsigned vec_elem
= v
->type
->vector_elements
;
4407 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4412 ir_function_signature
*
4413 builtin_builder::_all(const glsl_type
*type
)
4415 ir_variable
*v
= in_var(type
, "v");
4416 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4418 const unsigned vec_elem
= v
->type
->vector_elements
;
4419 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4424 UNOP(not, ir_unop_logic_not
, always_available
)
4427 has_lod(const glsl_type
*sampler_type
)
4429 assert(sampler_type
->is_sampler());
4431 switch (sampler_type
->sampler_dimensionality
) {
4432 case GLSL_SAMPLER_DIM_RECT
:
4433 case GLSL_SAMPLER_DIM_BUF
:
4434 case GLSL_SAMPLER_DIM_MS
:
4441 ir_function_signature
*
4442 builtin_builder::_textureSize(builtin_available_predicate avail
,
4443 const glsl_type
*return_type
,
4444 const glsl_type
*sampler_type
)
4446 ir_variable
*s
= in_var(sampler_type
, "sampler");
4447 /* The sampler always exists; add optional lod later. */
4448 MAKE_SIG(return_type
, avail
, 1, s
);
4450 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4451 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4453 if (has_lod(sampler_type
)) {
4454 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4455 sig
->parameters
.push_tail(lod
);
4456 tex
->lod_info
.lod
= var_ref(lod
);
4458 tex
->lod_info
.lod
= imm(0u);
4461 body
.emit(ret(tex
));
4466 ir_function_signature
*
4467 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4469 ir_variable
*s
= in_var(sampler_type
, "sampler");
4470 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4472 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4473 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4474 body
.emit(ret(tex
));
4479 ir_function_signature
*
4480 builtin_builder::_texture(ir_texture_opcode opcode
,
4481 builtin_available_predicate avail
,
4482 const glsl_type
*return_type
,
4483 const glsl_type
*sampler_type
,
4484 const glsl_type
*coord_type
,
4487 ir_variable
*s
= in_var(sampler_type
, "sampler");
4488 ir_variable
*P
= in_var(coord_type
, "P");
4489 /* The sampler and coordinate always exist; add optional parameters later. */
4490 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4492 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4493 tex
->set_sampler(var_ref(s
), return_type
);
4495 const int coord_size
= sampler_type
->coordinate_components();
4497 if (coord_size
== coord_type
->vector_elements
) {
4498 tex
->coordinate
= var_ref(P
);
4500 /* The incoming coordinate also has the projector or shadow comparitor,
4501 * so we need to swizzle those away.
4503 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4506 /* The projector is always in the last component. */
4507 if (flags
& TEX_PROJECT
)
4508 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4510 if (sampler_type
->sampler_shadow
) {
4511 if (opcode
== ir_tg4
) {
4512 /* gather has refz as a separate parameter, immediately after the
4515 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4516 sig
->parameters
.push_tail(refz
);
4517 tex
->shadow_comparitor
= var_ref(refz
);
4519 /* The shadow comparitor is normally in the Z component, but a few types
4520 * have sufficiently large coordinates that it's in W.
4522 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4526 if (opcode
== ir_txl
) {
4527 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4528 sig
->parameters
.push_tail(lod
);
4529 tex
->lod_info
.lod
= var_ref(lod
);
4530 } else if (opcode
== ir_txd
) {
4531 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4532 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4533 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4534 sig
->parameters
.push_tail(dPdx
);
4535 sig
->parameters
.push_tail(dPdy
);
4536 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4537 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4540 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4541 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4542 ir_variable
*offset
=
4543 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4544 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4545 sig
->parameters
.push_tail(offset
);
4546 tex
->offset
= var_ref(offset
);
4549 if (flags
& TEX_OFFSET_ARRAY
) {
4550 ir_variable
*offsets
=
4551 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4552 "offsets", ir_var_const_in
);
4553 sig
->parameters
.push_tail(offsets
);
4554 tex
->offset
= var_ref(offsets
);
4557 if (opcode
== ir_tg4
) {
4558 if (flags
& TEX_COMPONENT
) {
4559 ir_variable
*component
=
4560 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4561 sig
->parameters
.push_tail(component
);
4562 tex
->lod_info
.component
= var_ref(component
);
4565 tex
->lod_info
.component
= imm(0);
4569 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4570 * inconsistent with both textureLodOffset and textureGradOffset.
4572 if (opcode
== ir_txb
) {
4573 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4574 sig
->parameters
.push_tail(bias
);
4575 tex
->lod_info
.bias
= var_ref(bias
);
4578 body
.emit(ret(tex
));
4583 ir_function_signature
*
4584 builtin_builder::_textureCubeArrayShadow()
4586 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4587 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4588 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4589 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4591 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4592 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4594 tex
->coordinate
= var_ref(P
);
4595 tex
->shadow_comparitor
= var_ref(compare
);
4597 body
.emit(ret(tex
));
4602 ir_function_signature
*
4603 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4604 const glsl_type
*return_type
,
4605 const glsl_type
*sampler_type
,
4606 const glsl_type
*coord_type
,
4607 const glsl_type
*offset_type
)
4609 ir_variable
*s
= in_var(sampler_type
, "sampler");
4610 ir_variable
*P
= in_var(coord_type
, "P");
4611 /* The sampler and coordinate always exist; add optional parameters later. */
4612 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4614 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4615 tex
->coordinate
= var_ref(P
);
4616 tex
->set_sampler(var_ref(s
), return_type
);
4618 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4619 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4620 sig
->parameters
.push_tail(sample
);
4621 tex
->lod_info
.sample_index
= var_ref(sample
);
4622 tex
->op
= ir_txf_ms
;
4623 } else if (has_lod(sampler_type
)) {
4624 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4625 sig
->parameters
.push_tail(lod
);
4626 tex
->lod_info
.lod
= var_ref(lod
);
4628 tex
->lod_info
.lod
= imm(0u);
4631 if (offset_type
!= NULL
) {
4632 ir_variable
*offset
=
4633 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4634 sig
->parameters
.push_tail(offset
);
4635 tex
->offset
= var_ref(offset
);
4638 body
.emit(ret(tex
));
4643 ir_function_signature
*
4644 builtin_builder::_EmitVertex()
4646 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4648 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4649 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4654 ir_function_signature
*
4655 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4656 const glsl_type
*stream_type
)
4658 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4660 * "Emit the current values of output variables to the current output
4661 * primitive on stream stream. The argument to stream must be a constant
4662 * integral expression."
4664 ir_variable
*stream
=
4665 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4667 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4669 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4674 ir_function_signature
*
4675 builtin_builder::_EndPrimitive()
4677 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4679 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4680 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4685 ir_function_signature
*
4686 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4687 const glsl_type
*stream_type
)
4689 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4691 * "Completes the current output primitive on stream stream and starts
4692 * a new one. The argument to stream must be a constant integral
4695 ir_variable
*stream
=
4696 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4698 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4700 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4705 ir_function_signature
*
4706 builtin_builder::_barrier()
4708 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4710 body
.emit(new(mem_ctx
) ir_barrier());
4714 ir_function_signature
*
4715 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4716 const glsl_type
*sampler_type
,
4717 const glsl_type
*coord_type
)
4719 ir_variable
*s
= in_var(sampler_type
, "sampler");
4720 ir_variable
*coord
= in_var(coord_type
, "coord");
4721 /* The sampler and coordinate always exist; add optional parameters later. */
4722 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4724 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4725 tex
->coordinate
= var_ref(coord
);
4726 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4728 body
.emit(ret(tex
));
4733 ir_function_signature
*
4734 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4736 ir_variable
*s
= in_var(sampler_type
, "sampler");
4737 const glsl_type
*return_type
= glsl_type::int_type
;
4738 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4740 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4741 tex
->set_sampler(var_ref(s
), return_type
);
4743 body
.emit(ret(tex
));
4748 ir_function_signature
*
4749 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4750 const glsl_type
*sampler_type
,
4751 const glsl_type
*coord_type
)
4753 ir_variable
*s
= in_var(sampler_type
, "sampler");
4754 ir_variable
*P
= in_var(coord_type
, "P");
4755 const glsl_type
*return_type
= glsl_type::bool_type
;
4756 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4758 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4759 tex
->coordinate
= var_ref(P
);
4760 tex
->set_sampler(var_ref(s
), return_type
);
4762 body
.emit(ret(tex
));
4767 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4768 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4769 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4770 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4771 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4772 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4774 ir_function_signature
*
4775 builtin_builder::_fwidth(const glsl_type
*type
)
4777 ir_variable
*p
= in_var(type
, "p");
4778 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4780 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4785 ir_function_signature
*
4786 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4788 ir_variable
*p
= in_var(type
, "p");
4789 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4791 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4792 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4797 ir_function_signature
*
4798 builtin_builder::_fwidthFine(const glsl_type
*type
)
4800 ir_variable
*p
= in_var(type
, "p");
4801 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4803 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4804 abs(expr(ir_unop_dFdy_fine
, p
)))));
4809 ir_function_signature
*
4810 builtin_builder::_noise1(const glsl_type
*type
)
4812 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4815 ir_function_signature
*
4816 builtin_builder::_noise2(const glsl_type
*type
)
4818 ir_variable
*p
= in_var(type
, "p");
4819 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4821 ir_constant_data b_offset
;
4822 b_offset
.f
[0] = 601.0f
;
4823 b_offset
.f
[1] = 313.0f
;
4824 b_offset
.f
[2] = 29.0f
;
4825 b_offset
.f
[3] = 277.0f
;
4827 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4828 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4829 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4830 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4831 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4832 body
.emit(assign(t
, a
, WRITEMASK_X
));
4833 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4839 ir_function_signature
*
4840 builtin_builder::_noise3(const glsl_type
*type
)
4842 ir_variable
*p
= in_var(type
, "p");
4843 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4845 ir_constant_data b_offset
;
4846 b_offset
.f
[0] = 601.0f
;
4847 b_offset
.f
[1] = 313.0f
;
4848 b_offset
.f
[2] = 29.0f
;
4849 b_offset
.f
[3] = 277.0f
;
4851 ir_constant_data c_offset
;
4852 c_offset
.f
[0] = 1559.0f
;
4853 c_offset
.f
[1] = 113.0f
;
4854 c_offset
.f
[2] = 1861.0f
;
4855 c_offset
.f
[3] = 797.0f
;
4857 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4858 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4859 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4860 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4861 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4862 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4863 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4864 body
.emit(assign(t
, a
, WRITEMASK_X
));
4865 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4866 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4872 ir_function_signature
*
4873 builtin_builder::_noise4(const glsl_type
*type
)
4875 ir_variable
*p
= in_var(type
, "p");
4876 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4878 ir_variable
*_p
= body
.make_temp(type
, "_p");
4880 ir_constant_data p_offset
;
4881 p_offset
.f
[0] = 1559.0f
;
4882 p_offset
.f
[1] = 113.0f
;
4883 p_offset
.f
[2] = 1861.0f
;
4884 p_offset
.f
[3] = 797.0f
;
4886 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4888 ir_constant_data offset
;
4889 offset
.f
[0] = 601.0f
;
4890 offset
.f
[1] = 313.0f
;
4891 offset
.f
[2] = 29.0f
;
4892 offset
.f
[3] = 277.0f
;
4894 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4895 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4896 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4897 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4898 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4899 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4900 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4901 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4902 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4903 body
.emit(assign(t
, a
, WRITEMASK_X
));
4904 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4905 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4906 body
.emit(assign(t
, d
, WRITEMASK_W
));
4912 ir_function_signature
*
4913 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4915 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4916 ir_variable
*value
= in_var(type
, "value");
4917 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4918 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4919 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4921 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
4922 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
4924 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
4925 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
4926 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
4931 ir_function_signature
*
4932 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4934 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4935 ir_variable
*base
= in_var(type
, "base");
4936 ir_variable
*insert
= in_var(type
, "insert");
4937 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4938 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4939 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4941 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
4942 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
4944 body
.emit(ret(bitfield_insert(base
, insert
,
4945 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
4946 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
4951 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4953 ir_function_signature
*
4954 builtin_builder::_bitCount(const glsl_type
*type
)
4956 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4957 glsl_type::ivec(type
->vector_elements
), type
);
4960 ir_function_signature
*
4961 builtin_builder::_findLSB(const glsl_type
*type
)
4963 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4964 glsl_type::ivec(type
->vector_elements
), type
);
4967 ir_function_signature
*
4968 builtin_builder::_findMSB(const glsl_type
*type
)
4970 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4971 glsl_type::ivec(type
->vector_elements
), type
);
4974 ir_function_signature
*
4975 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4977 ir_variable
*a
= in_var(type
, "a");
4978 ir_variable
*b
= in_var(type
, "b");
4979 ir_variable
*c
= in_var(type
, "c");
4980 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4982 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4987 ir_function_signature
*
4988 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4990 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
,
4991 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
4994 ir_function_signature
*
4995 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4997 ir_variable
*x
= in_var(x_type
, "x");
4998 ir_variable
*exponent
= out_var(exp_type
, "exp");
4999 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5001 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5003 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5007 ir_function_signature
*
5008 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5010 ir_variable
*x
= in_var(x_type
, "x");
5011 ir_variable
*exponent
= out_var(exp_type
, "exp");
5012 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
5014 const unsigned vec_elem
= x_type
->vector_elements
;
5015 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5016 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5018 /* Single-precision floating-point values are stored as
5023 * An exponent shift of 23 will shift the mantissa out, leaving only the
5024 * exponent and sign bit (which itself may be zero, if the absolute value
5025 * was taken before the bitcast and shift.
5027 ir_constant
*exponent_shift
= imm(23);
5028 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5030 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5032 /* Exponent of floating-point values in the range [0.5, 1.0). */
5033 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5035 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5036 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5038 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5039 * to unsigned integers to ensure that 1 bits aren't shifted in.
5041 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5042 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5043 imm(0, vec_elem
)))));
5045 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5046 body
.emit(assign(bits
, bitcast_f2u(x
)));
5047 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5048 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5049 imm(0u, vec_elem
)))));
5050 body
.emit(ret(bitcast_u2f(bits
)));
5055 ir_function_signature
*
5056 builtin_builder::_uaddCarry(const glsl_type
*type
)
5058 ir_variable
*x
= in_var(type
, "x");
5059 ir_variable
*y
= in_var(type
, "y");
5060 ir_variable
*carry
= out_var(type
, "carry");
5061 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
5063 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5064 body
.emit(ret(add(x
, y
)));
5069 ir_function_signature
*
5070 builtin_builder::_usubBorrow(const glsl_type
*type
)
5072 ir_variable
*x
= in_var(type
, "x");
5073 ir_variable
*y
= in_var(type
, "y");
5074 ir_variable
*borrow
= out_var(type
, "borrow");
5075 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
5077 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5078 body
.emit(ret(sub(x
, y
)));
5084 * For both imulExtended() and umulExtended() built-ins.
5086 ir_function_signature
*
5087 builtin_builder::_mulExtended(const glsl_type
*type
)
5089 ir_variable
*x
= in_var(type
, "x");
5090 ir_variable
*y
= in_var(type
, "y");
5091 ir_variable
*msb
= out_var(type
, "msb");
5092 ir_variable
*lsb
= out_var(type
, "lsb");
5093 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5095 body
.emit(assign(msb
, imul_high(x
, y
)));
5096 body
.emit(assign(lsb
, mul(x
, y
)));
5101 ir_function_signature
*
5102 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5104 ir_variable
*interpolant
= in_var(type
, "interpolant");
5105 interpolant
->data
.must_be_shader_input
= 1;
5106 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
5108 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5113 ir_function_signature
*
5114 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5116 ir_variable
*interpolant
= in_var(type
, "interpolant");
5117 interpolant
->data
.must_be_shader_input
= 1;
5118 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5119 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
5121 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5126 ir_function_signature
*
5127 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5129 ir_variable
*interpolant
= in_var(type
, "interpolant");
5130 interpolant
->data
.must_be_shader_input
= 1;
5131 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5132 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
5134 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5139 ir_function_signature
*
5140 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5142 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5143 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5147 ir_function_signature
*
5148 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5149 const glsl_type
*type
)
5151 ir_variable
*atomic
= in_var(type
, "atomic");
5152 ir_variable
*data
= in_var(type
, "data");
5153 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5157 ir_function_signature
*
5158 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5159 const glsl_type
*type
)
5161 ir_variable
*atomic
= in_var(type
, "atomic");
5162 ir_variable
*data1
= in_var(type
, "data1");
5163 ir_variable
*data2
= in_var(type
, "data2");
5164 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5168 ir_function_signature
*
5169 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5170 builtin_available_predicate avail
)
5172 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5173 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5175 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5176 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5178 body
.emit(ret(retval
));
5182 ir_function_signature
*
5183 builtin_builder::_atomic_op2(const char *intrinsic
,
5184 builtin_available_predicate avail
,
5185 const glsl_type
*type
)
5187 ir_variable
*atomic
= in_var(type
, "atomic_var");
5188 ir_variable
*data
= in_var(type
, "atomic_data");
5189 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5191 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5192 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5194 body
.emit(ret(retval
));
5198 ir_function_signature
*
5199 builtin_builder::_atomic_op3(const char *intrinsic
,
5200 builtin_available_predicate avail
,
5201 const glsl_type
*type
)
5203 ir_variable
*atomic
= in_var(type
, "atomic_var");
5204 ir_variable
*data1
= in_var(type
, "atomic_data1");
5205 ir_variable
*data2
= in_var(type
, "atomic_data2");
5206 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5208 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5209 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5211 body
.emit(ret(retval
));
5215 ir_function_signature
*
5216 builtin_builder::_min3(const glsl_type
*type
)
5218 ir_variable
*x
= in_var(type
, "x");
5219 ir_variable
*y
= in_var(type
, "y");
5220 ir_variable
*z
= in_var(type
, "z");
5221 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5223 ir_expression
*min3
= min2(x
, min2(y
,z
));
5224 body
.emit(ret(min3
));
5229 ir_function_signature
*
5230 builtin_builder::_max3(const glsl_type
*type
)
5232 ir_variable
*x
= in_var(type
, "x");
5233 ir_variable
*y
= in_var(type
, "y");
5234 ir_variable
*z
= in_var(type
, "z");
5235 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5237 ir_expression
*max3
= max2(x
, max2(y
,z
));
5238 body
.emit(ret(max3
));
5243 ir_function_signature
*
5244 builtin_builder::_mid3(const glsl_type
*type
)
5246 ir_variable
*x
= in_var(type
, "x");
5247 ir_variable
*y
= in_var(type
, "y");
5248 ir_variable
*z
= in_var(type
, "z");
5249 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5251 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5252 body
.emit(ret(mid3
));
5257 static builtin_available_predicate
5258 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5260 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5261 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5262 return shader_image_atomic_exchange_float
;
5264 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5265 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5266 return shader_image_atomic
;
5269 return shader_image_load_store
;
5272 ir_function_signature
*
5273 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5274 unsigned num_arguments
,
5277 const glsl_type
*data_type
= glsl_type::get_instance(
5278 image_type
->sampled_type
,
5279 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5281 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5282 glsl_type::void_type
: data_type
);
5284 /* Addressing arguments that are always present. */
5285 ir_variable
*image
= in_var(image_type
, "image");
5286 ir_variable
*coord
= in_var(
5287 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5289 ir_function_signature
*sig
= new_sig(
5290 ret_type
, get_image_available_predicate(image_type
, flags
),
5293 /* Sample index for multisample images. */
5294 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5295 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5297 /* Data arguments. */
5298 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5299 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5300 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5301 ralloc_free(arg_name
);
5304 /* Set the maximal set of qualifiers allowed for this image
5305 * built-in. Function calls with arguments having fewer
5306 * qualifiers than present in the prototype are allowed by the
5307 * spec, but not with more, i.e. this will make the compiler
5308 * accept everything that needs to be accepted, and reject cases
5309 * like loads from write-only or stores to read-only images.
5311 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5312 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5313 image
->data
.image_coherent
= true;
5314 image
->data
.image_volatile
= true;
5315 image
->data
.image_restrict
= true;
5320 ir_function_signature
*
5321 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5322 unsigned /* num_arguments */,
5323 unsigned /* flags */)
5325 const glsl_type
*ret_type
;
5326 unsigned num_components
= image_type
->coordinate_components();
5328 /* From the ARB_shader_image_size extension:
5329 * "Cube images return the dimensions of one face."
5331 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5332 !image_type
->sampler_array
) {
5336 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5337 * supported by mesa.
5339 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5341 ir_variable
*image
= in_var(image_type
, "image");
5342 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5344 /* Set the maximal set of qualifiers allowed for this image
5345 * built-in. Function calls with arguments having fewer
5346 * qualifiers than present in the prototype are allowed by the
5347 * spec, but not with more, i.e. this will make the compiler
5348 * accept everything that needs to be accepted, and reject cases
5349 * like loads from write-only or stores to read-only images.
5351 image
->data
.image_read_only
= true;
5352 image
->data
.image_write_only
= true;
5353 image
->data
.image_coherent
= true;
5354 image
->data
.image_volatile
= true;
5355 image
->data
.image_restrict
= true;
5360 ir_function_signature
*
5361 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5362 unsigned /* num_arguments */,
5363 unsigned /* flags */)
5365 ir_variable
*image
= in_var(image_type
, "image");
5366 ir_function_signature
*sig
=
5367 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5369 /* Set the maximal set of qualifiers allowed for this image
5370 * built-in. Function calls with arguments having fewer
5371 * qualifiers than present in the prototype are allowed by the
5372 * spec, but not with more, i.e. this will make the compiler
5373 * accept everything that needs to be accepted, and reject cases
5374 * like loads from write-only or stores to read-only images.
5376 image
->data
.image_read_only
= true;
5377 image
->data
.image_write_only
= true;
5378 image
->data
.image_coherent
= true;
5379 image
->data
.image_volatile
= true;
5380 image
->data
.image_restrict
= true;
5385 ir_function_signature
*
5386 builtin_builder::_image(image_prototype_ctr prototype
,
5387 const glsl_type
*image_type
,
5388 const char *intrinsic_name
,
5389 unsigned num_arguments
,
5392 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5393 num_arguments
, flags
);
5395 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5396 ir_factory
body(&sig
->body
, mem_ctx
);
5397 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5399 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5400 body
.emit(call(f
, NULL
, sig
->parameters
));
5402 ir_variable
*ret_val
=
5403 body
.make_temp(sig
->return_type
, "_ret_val");
5404 body
.emit(call(f
, ret_val
, sig
->parameters
));
5405 body
.emit(ret(ret_val
));
5408 sig
->is_defined
= true;
5411 sig
->is_intrinsic
= true;
5417 ir_function_signature
*
5418 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5420 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5424 ir_function_signature
*
5425 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5426 builtin_available_predicate avail
)
5428 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5429 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5430 NULL
, sig
->parameters
));
5434 ir_function_signature
*
5435 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5436 const glsl_type
*type
)
5438 MAKE_INTRINSIC(type
, avail
, 0);
5442 ir_function_signature
*
5443 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5444 const glsl_type
*type
)
5446 MAKE_SIG(type
, avail
, 0);
5448 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5450 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5451 retval
, sig
->parameters
));
5452 body
.emit(ret(retval
));
5458 /******************************************************************************/
5460 /* The singleton instance of builtin_builder. */
5461 static builtin_builder builtins
;
5462 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5465 * External API (exposing the built-in module to the rest of the compiler):
5469 _mesa_glsl_initialize_builtin_functions()
5471 mtx_lock(&builtins_lock
);
5472 builtins
.initialize();
5473 mtx_unlock(&builtins_lock
);
5477 _mesa_glsl_release_builtin_functions()
5479 mtx_lock(&builtins_lock
);
5481 mtx_unlock(&builtins_lock
);
5484 ir_function_signature
*
5485 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5486 const char *name
, exec_list
*actual_parameters
)
5488 ir_function_signature
* s
;
5489 mtx_lock(&builtins_lock
);
5490 s
= builtins
.find(state
, name
, actual_parameters
);
5491 mtx_unlock(&builtins_lock
);
5496 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5499 mtx_lock(&builtins_lock
);
5500 f
= builtins
.shader
->symbols
->get_function(name
);
5501 mtx_unlock(&builtins_lock
);
5506 _mesa_glsl_get_builtin_function_shader()
5508 return builtins
.shader
;
5513 * Get the function signature for main from a shader
5515 ir_function_signature
*
5516 _mesa_get_main_function_signature(gl_shader
*sh
)
5518 ir_function
*const f
= sh
->symbols
->get_function("main");
5520 exec_list void_parameters
;
5522 /* Look for the 'void main()' signature and ensure that it's defined.
5523 * This keeps the linker from accidentally pick a shader that just
5524 * contains a prototype for main.
5526 * We don't have to check for multiple definitions of main (in multiple
5527 * shaders) because that would have already been caught above.
5529 ir_function_signature
*sig
=
5530 f
->matching_signature(NULL
, &void_parameters
, false);
5531 if ((sig
!= NULL
) && sig
->is_defined
) {