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 texture_rectangle(const _mesa_glsl_parse_state
*state
)
141 return state
->ARB_texture_rectangle_enable
;
145 texture_external(const _mesa_glsl_parse_state
*state
)
147 return state
->OES_EGL_image_external_enable
;
150 /** True if texturing functions with explicit LOD are allowed. */
152 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
154 /* Texturing functions with "Lod" in their name exist:
155 * - In the vertex shader stage (for all languages)
156 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
157 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
159 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
160 * don't need to explicitly check state->es_shader.
162 return state
->stage
== MESA_SHADER_VERTEX
||
163 state
->is_version(130, 300) ||
164 state
->ARB_shader_texture_lod_enable
;
168 v110_lod(const _mesa_glsl_parse_state
*state
)
170 return !state
->es_shader
&& lod_exists_in_stage(state
);
174 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
176 return state
->ARB_shader_texture_lod_enable
;
180 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
182 return state
->ARB_shader_texture_lod_enable
&&
183 state
->ARB_texture_rectangle_enable
;
187 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
189 return state
->is_version(330, 300) ||
190 state
->ARB_shader_bit_encoding_enable
||
191 state
->ARB_gpu_shader5_enable
;
195 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
197 return v130(state
) && state
->EXT_shader_integer_mix_enable
;
201 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
203 return state
->ARB_shading_language_packing_enable
||
204 state
->is_version(400, 300);
208 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
210 return state
->ARB_shading_language_packing_enable
||
211 state
->ARB_gpu_shader5_enable
||
212 state
->is_version(400, 300);
216 gpu_shader5(const _mesa_glsl_parse_state
*state
)
218 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
222 shader_packing_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
224 return state
->ARB_shading_language_packing_enable
||
229 texture_array_lod(const _mesa_glsl_parse_state
*state
)
231 return lod_exists_in_stage(state
) &&
232 state
->EXT_texture_array_enable
;
236 fs_texture_array(const _mesa_glsl_parse_state
*state
)
238 return state
->stage
== MESA_SHADER_FRAGMENT
&&
239 state
->EXT_texture_array_enable
;
243 texture_array(const _mesa_glsl_parse_state
*state
)
245 return state
->EXT_texture_array_enable
;
249 texture_multisample(const _mesa_glsl_parse_state
*state
)
251 return state
->is_version(150, 0) ||
252 state
->ARB_texture_multisample_enable
;
256 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
258 return state
->stage
== MESA_SHADER_FRAGMENT
&&
259 (state
->is_version(400, 0) ||
260 state
->ARB_texture_cube_map_array_enable
);
264 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
266 return state
->is_version(400, 0) ||
267 state
->ARB_texture_cube_map_array_enable
;
271 texture_query_levels(const _mesa_glsl_parse_state
*state
)
273 return state
->is_version(430, 0) ||
274 state
->ARB_texture_query_levels_enable
;
278 texture_query_lod(const _mesa_glsl_parse_state
*state
)
280 return state
->stage
== MESA_SHADER_FRAGMENT
&&
281 state
->ARB_texture_query_lod_enable
;
285 texture_gather(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(400, 0) ||
288 state
->ARB_texture_gather_enable
||
289 state
->ARB_gpu_shader5_enable
;
292 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
293 * used for relaxation of const offset requirements.
296 texture_gather_only(const _mesa_glsl_parse_state
*state
)
298 return !state
->is_version(400, 0) &&
299 !state
->ARB_gpu_shader5_enable
&&
300 state
->ARB_texture_gather_enable
;
303 /* Desktop GL or OES_standard_derivatives + fragment shader only */
305 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
307 return state
->stage
== MESA_SHADER_FRAGMENT
&&
308 (state
->is_version(110, 300) ||
309 state
->OES_standard_derivatives_enable
);
313 tex1d_lod(const _mesa_glsl_parse_state
*state
)
315 return !state
->es_shader
&& lod_exists_in_stage(state
);
318 /** True if sampler3D exists */
320 tex3d(const _mesa_glsl_parse_state
*state
)
322 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
323 * OES_texture_3D extension, and in GLSL ES 3.00.
325 return !state
->es_shader
||
326 state
->OES_texture_3D_enable
||
327 state
->language_version
>= 300;
331 fs_tex3d(const _mesa_glsl_parse_state
*state
)
333 return state
->stage
== MESA_SHADER_FRAGMENT
&&
334 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
338 tex3d_lod(const _mesa_glsl_parse_state
*state
)
340 return tex3d(state
) && lod_exists_in_stage(state
);
344 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
346 return state
->ARB_shader_atomic_counters_enable
;
350 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
352 return state
->AMD_shader_trinary_minmax_enable
;
356 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
358 return (state
->is_version(420, 0) ||
359 state
->ARB_shader_image_load_store_enable
);
363 gs_streams(const _mesa_glsl_parse_state
*state
)
365 return gpu_shader5(state
) && gs_only(state
);
370 /******************************************************************************/
375 * builtin_builder: A singleton object representing the core of the built-in
378 * It generates IR for every built-in function signature, and organizes them
381 class builtin_builder
{
388 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
389 const char *name
, exec_list
*actual_parameters
);
392 * A shader to hold all the built-in signatures; created by this module.
394 * This includes signatures for every built-in, regardless of version or
395 * enabled extensions. The availability predicate associated with each
396 * signature allows matching_signature() to filter out the irrelevant ones.
403 /** Global variables used by built-in functions. */
404 ir_variable
*gl_ModelViewProjectionMatrix
;
405 ir_variable
*gl_Vertex
;
407 void create_shader();
408 void create_intrinsics();
409 void create_builtins();
412 * IR builder helpers:
414 * These convenience functions assist in emitting IR, but don't necessarily
415 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
418 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
419 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
420 ir_constant
*imm(float f
, unsigned vector_elements
=1);
421 ir_constant
*imm(int i
, unsigned vector_elements
=1);
422 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
423 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
424 ir_dereference_variable
*var_ref(ir_variable
*var
);
425 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
426 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
428 ir_expression
*asin_expr(ir_variable
*x
);
431 * Call function \param f with parameters specified as the linked
432 * list \param params of \c ir_variable objects. \param ret should
433 * point to the ir_variable that will hold the function return
434 * value, or be \c NULL if the function has void return type.
436 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
438 /** Create a new function and add the given signatures. */
439 void add_function(const char *name
, ...);
441 enum image_function_flags
{
442 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
443 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
444 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
445 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
446 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
447 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5)
451 * Create a new image built-in function for all known image types.
452 * \p flags is a bitfield of \c image_function_flags flags.
454 void add_image_function(const char *name
,
455 const char *intrinsic_name
,
456 unsigned num_arguments
,
460 * Create new functions for all known image built-ins and types.
461 * If \p glsl is \c true, use the GLSL built-in names and emit code
462 * to call into the actual compiler intrinsic. If \p glsl is
463 * false, emit a function prototype with no body for each image
466 void add_image_functions(bool glsl
);
468 ir_function_signature
*new_sig(const glsl_type
*return_type
,
469 builtin_available_predicate avail
,
470 int num_params
, ...);
473 * Function signature generators:
476 ir_function_signature
*unop(builtin_available_predicate avail
,
477 ir_expression_operation opcode
,
478 const glsl_type
*return_type
,
479 const glsl_type
*param_type
);
480 ir_function_signature
*binop(ir_expression_operation opcode
,
481 builtin_available_predicate avail
,
482 const glsl_type
*return_type
,
483 const glsl_type
*param0_type
,
484 const glsl_type
*param1_type
);
486 #define B0(X) ir_function_signature *_##X();
487 #define B1(X) ir_function_signature *_##X(const glsl_type *);
488 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
489 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
490 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
491 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
528 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
529 const glsl_type
*val_type
,
530 const glsl_type
*blend_type
);
539 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
540 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
541 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
542 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
543 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
544 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
545 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
546 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
547 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
548 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
560 B0(determinant_mat2
);
561 B0(determinant_mat3
);
562 B0(determinant_mat4
);
570 BA1(greaterThanEqual
);
577 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
578 const glsl_type
*return_type
,
579 const glsl_type
*sampler_type
);
581 /** Flags to _texture() */
582 #define TEX_PROJECT 1
584 #define TEX_COMPONENT 4
585 #define TEX_OFFSET_NONCONST 8
586 #define TEX_OFFSET_ARRAY 16
588 ir_function_signature
*_texture(ir_texture_opcode opcode
,
589 builtin_available_predicate avail
,
590 const glsl_type
*return_type
,
591 const glsl_type
*sampler_type
,
592 const glsl_type
*coord_type
,
594 B0(textureCubeArrayShadow
);
595 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
596 const glsl_type
*return_type
,
597 const glsl_type
*sampler_type
,
598 const glsl_type
*coord_type
,
599 const glsl_type
*offset_type
= NULL
);
603 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
604 const glsl_type
*stream_type
);
605 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
606 const glsl_type
*stream_type
);
609 B1(textureQueryLevels
);
631 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
632 ir_function_signature
*_atomic_op(const char *intrinsic
,
633 builtin_available_predicate avail
);
639 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
640 const char *intrinsic_name
,
641 unsigned num_arguments
,
643 ir_function_signature
*_image(const glsl_type
*image_type
,
644 const char *intrinsic_name
,
645 unsigned num_arguments
,
648 ir_function_signature
*_memory_barrier_intrinsic(
649 builtin_available_predicate avail
);
650 ir_function_signature
*_memory_barrier(
651 builtin_available_predicate avail
);
662 } /* anonymous namespace */
665 * Core builtin_builder functionality:
668 builtin_builder::builtin_builder()
670 gl_ModelViewProjectionMatrix(NULL
),
676 builtin_builder::~builtin_builder()
678 ralloc_free(mem_ctx
);
681 ir_function_signature
*
682 builtin_builder::find(_mesa_glsl_parse_state
*state
,
683 const char *name
, exec_list
*actual_parameters
)
685 /* The shader currently being compiled requested a built-in function;
686 * it needs to link against builtin_builder::shader in order to get them.
688 * Even if we don't find a matching signature, we still need to do this so
689 * that the "no matching signature" error will list potential candidates
690 * from the available built-ins.
692 state
->uses_builtin_functions
= true;
694 ir_function
*f
= shader
->symbols
->get_function(name
);
698 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
706 builtin_builder::initialize()
708 /* If already initialized, don't do it again. */
712 mem_ctx
= ralloc_context(NULL
);
719 builtin_builder::release()
721 ralloc_free(mem_ctx
);
729 builtin_builder::create_shader()
731 /* The target doesn't actually matter. There's no target for generic
732 * GLSL utility code that could be linked against any stage, so just
733 * arbitrarily pick GL_VERTEX_SHADER.
735 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
736 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
738 gl_ModelViewProjectionMatrix
=
739 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
740 "gl_ModelViewProjectionMatrix",
743 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
745 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
746 shader
->symbols
->add_variable(gl_Vertex
);
752 * Create ir_function and ir_function_signature objects for each
756 builtin_builder::create_intrinsics()
758 add_function("__intrinsic_atomic_read",
759 _atomic_intrinsic(shader_atomic_counters
),
761 add_function("__intrinsic_atomic_increment",
762 _atomic_intrinsic(shader_atomic_counters
),
764 add_function("__intrinsic_atomic_predecrement",
765 _atomic_intrinsic(shader_atomic_counters
),
768 add_image_functions(false);
770 add_function("__intrinsic_memory_barrier",
771 _memory_barrier_intrinsic(shader_image_load_store
),
776 * Create ir_function and ir_function_signature objects for each built-in.
778 * Contains a list of every available built-in.
781 builtin_builder::create_builtins()
784 add_function(#NAME, \
785 _##NAME(glsl_type::float_type), \
786 _##NAME(glsl_type::vec2_type), \
787 _##NAME(glsl_type::vec3_type), \
788 _##NAME(glsl_type::vec4_type), \
792 add_function(#NAME, \
793 _##NAME(glsl_type::float_type), \
794 _##NAME(glsl_type::vec2_type), \
795 _##NAME(glsl_type::vec3_type), \
796 _##NAME(glsl_type::vec4_type), \
797 _##NAME(glsl_type::int_type), \
798 _##NAME(glsl_type::ivec2_type), \
799 _##NAME(glsl_type::ivec3_type), \
800 _##NAME(glsl_type::ivec4_type), \
804 add_function(#NAME, \
805 _##NAME(always_available, glsl_type::float_type), \
806 _##NAME(always_available, glsl_type::vec2_type), \
807 _##NAME(always_available, glsl_type::vec3_type), \
808 _##NAME(always_available, glsl_type::vec4_type), \
810 _##NAME(always_available, glsl_type::int_type), \
811 _##NAME(always_available, glsl_type::ivec2_type), \
812 _##NAME(always_available, glsl_type::ivec3_type), \
813 _##NAME(always_available, glsl_type::ivec4_type), \
815 _##NAME(v130, glsl_type::uint_type), \
816 _##NAME(v130, glsl_type::uvec2_type), \
817 _##NAME(v130, glsl_type::uvec3_type), \
818 _##NAME(v130, glsl_type::uvec4_type), \
822 add_function(#NAME, \
823 _##NAME(glsl_type::int_type), \
824 _##NAME(glsl_type::ivec2_type), \
825 _##NAME(glsl_type::ivec3_type), \
826 _##NAME(glsl_type::ivec4_type), \
828 _##NAME(glsl_type::uint_type), \
829 _##NAME(glsl_type::uvec2_type), \
830 _##NAME(glsl_type::uvec3_type), \
831 _##NAME(glsl_type::uvec4_type), \
835 add_function(#NAME, \
836 _##NAME(always_available, glsl_type::float_type), \
837 _##NAME(always_available, glsl_type::vec2_type), \
838 _##NAME(always_available, glsl_type::vec3_type), \
839 _##NAME(always_available, glsl_type::vec4_type), \
841 _##NAME(always_available, glsl_type::int_type), \
842 _##NAME(always_available, glsl_type::ivec2_type), \
843 _##NAME(always_available, glsl_type::ivec3_type), \
844 _##NAME(always_available, glsl_type::ivec4_type), \
846 _##NAME(v130, glsl_type::uint_type), \
847 _##NAME(v130, glsl_type::uvec2_type), \
848 _##NAME(v130, glsl_type::uvec3_type), \
849 _##NAME(v130, glsl_type::uvec4_type), \
851 _##NAME(always_available, glsl_type::bool_type), \
852 _##NAME(always_available, glsl_type::bvec2_type), \
853 _##NAME(always_available, glsl_type::bvec3_type), \
854 _##NAME(always_available, glsl_type::bvec4_type), \
857 #define FIU2_MIXED(NAME) \
858 add_function(#NAME, \
859 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
860 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
861 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
862 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
864 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
865 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
866 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
868 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
869 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
870 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
871 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
873 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
874 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
875 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
877 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
878 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
879 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
880 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
882 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
883 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
884 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
896 _atan(glsl_type::float_type
),
897 _atan(glsl_type::vec2_type
),
898 _atan(glsl_type::vec3_type
),
899 _atan(glsl_type::vec4_type
),
900 _atan2(glsl_type::float_type
),
901 _atan2(glsl_type::vec2_type
),
902 _atan2(glsl_type::vec3_type
),
903 _atan2(glsl_type::vec4_type
),
929 _mod(glsl_type::float_type
, glsl_type::float_type
),
930 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
931 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
932 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
934 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
935 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
936 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
946 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
947 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
948 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
949 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
951 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
952 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
953 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
955 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
956 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
957 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
958 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
960 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
961 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
962 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
963 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
965 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
966 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
967 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
968 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
970 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
971 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
972 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
973 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
977 _step(glsl_type::float_type
, glsl_type::float_type
),
978 _step(glsl_type::float_type
, glsl_type::vec2_type
),
979 _step(glsl_type::float_type
, glsl_type::vec3_type
),
980 _step(glsl_type::float_type
, glsl_type::vec4_type
),
982 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
983 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
984 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
987 add_function("smoothstep",
988 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
989 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
990 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
991 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
993 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
994 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
995 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
1003 add_function("intBitsToFloat",
1004 _intBitsToFloat(glsl_type::int_type
),
1005 _intBitsToFloat(glsl_type::ivec2_type
),
1006 _intBitsToFloat(glsl_type::ivec3_type
),
1007 _intBitsToFloat(glsl_type::ivec4_type
),
1009 add_function("uintBitsToFloat",
1010 _uintBitsToFloat(glsl_type::uint_type
),
1011 _uintBitsToFloat(glsl_type::uvec2_type
),
1012 _uintBitsToFloat(glsl_type::uvec3_type
),
1013 _uintBitsToFloat(glsl_type::uvec4_type
),
1016 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1017 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1018 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1019 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1020 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1021 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1022 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1023 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1024 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1025 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1031 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
1034 add_function("ftransform", _ftransform(), NULL
);
1039 add_function("matrixCompMult",
1040 _matrixCompMult(glsl_type::mat2_type
),
1041 _matrixCompMult(glsl_type::mat3_type
),
1042 _matrixCompMult(glsl_type::mat4_type
),
1043 _matrixCompMult(glsl_type::mat2x3_type
),
1044 _matrixCompMult(glsl_type::mat2x4_type
),
1045 _matrixCompMult(glsl_type::mat3x2_type
),
1046 _matrixCompMult(glsl_type::mat3x4_type
),
1047 _matrixCompMult(glsl_type::mat4x2_type
),
1048 _matrixCompMult(glsl_type::mat4x3_type
),
1050 add_function("outerProduct",
1051 _outerProduct(glsl_type::mat2_type
),
1052 _outerProduct(glsl_type::mat3_type
),
1053 _outerProduct(glsl_type::mat4_type
),
1054 _outerProduct(glsl_type::mat2x3_type
),
1055 _outerProduct(glsl_type::mat2x4_type
),
1056 _outerProduct(glsl_type::mat3x2_type
),
1057 _outerProduct(glsl_type::mat3x4_type
),
1058 _outerProduct(glsl_type::mat4x2_type
),
1059 _outerProduct(glsl_type::mat4x3_type
),
1061 add_function("determinant",
1062 _determinant_mat2(),
1063 _determinant_mat3(),
1064 _determinant_mat4(),
1066 add_function("inverse",
1071 add_function("transpose",
1072 _transpose(glsl_type::mat2_type
),
1073 _transpose(glsl_type::mat3_type
),
1074 _transpose(glsl_type::mat4_type
),
1075 _transpose(glsl_type::mat2x3_type
),
1076 _transpose(glsl_type::mat2x4_type
),
1077 _transpose(glsl_type::mat3x2_type
),
1078 _transpose(glsl_type::mat3x4_type
),
1079 _transpose(glsl_type::mat4x2_type
),
1080 _transpose(glsl_type::mat4x3_type
),
1085 FIU(greaterThanEqual
)
1090 _any(glsl_type::bvec2_type
),
1091 _any(glsl_type::bvec3_type
),
1092 _any(glsl_type::bvec4_type
),
1096 _all(glsl_type::bvec2_type
),
1097 _all(glsl_type::bvec3_type
),
1098 _all(glsl_type::bvec4_type
),
1102 _not(glsl_type::bvec2_type
),
1103 _not(glsl_type::bvec3_type
),
1104 _not(glsl_type::bvec4_type
),
1107 add_function("textureSize",
1108 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1109 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1110 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1112 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1113 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1114 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1116 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1117 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1118 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1120 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1121 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1122 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1124 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1125 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1126 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1128 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1129 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1130 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1131 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1132 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1133 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1135 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1136 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1138 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1139 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1140 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1141 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1143 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1144 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1145 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1146 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1148 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1149 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1150 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1151 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1152 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1153 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1155 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1156 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1157 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1160 add_function("texture",
1161 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1162 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1163 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1165 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1166 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1167 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1169 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1170 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1171 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1173 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1174 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1175 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1177 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1178 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1179 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1181 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1182 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1183 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1185 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1186 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1187 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1189 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1190 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1191 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1193 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1194 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1195 /* samplerCubeArrayShadow is special; it has an extra parameter
1196 * for the shadow comparitor since there is no vec5 type.
1198 _textureCubeArrayShadow(),
1200 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1201 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1202 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1204 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1206 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1207 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1208 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1210 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1211 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1212 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1214 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1215 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1216 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1218 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1219 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1220 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1222 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1223 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1224 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1226 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1227 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1228 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1230 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1231 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1232 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1234 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1235 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1236 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1238 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1241 add_function("textureLod",
1242 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1243 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1244 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1246 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1247 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1248 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1250 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1251 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1252 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1254 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1255 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1256 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1258 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1259 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1261 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1262 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1263 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1265 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1266 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1267 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1269 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1270 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1271 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1273 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1276 add_function("textureOffset",
1277 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1278 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1279 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1281 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1282 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1283 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1285 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1286 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1287 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1289 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1290 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1291 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1293 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1295 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1296 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1298 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1299 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1300 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1302 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1303 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1304 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1306 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1308 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1309 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1310 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1312 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1313 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1314 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1316 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1317 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1318 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1320 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1321 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1323 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1324 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1325 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1327 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1328 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1329 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1331 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1334 add_function("textureProj",
1335 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1336 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1337 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1338 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1339 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1340 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1342 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1343 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1344 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1345 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1346 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1347 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1349 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1350 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1351 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1353 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1354 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1356 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1357 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1358 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1359 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1360 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1361 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1363 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1365 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1366 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1367 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1368 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1369 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1370 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1372 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1373 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1374 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1375 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1376 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1377 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1379 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1380 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1381 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1383 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1384 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1387 add_function("texelFetch",
1388 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1389 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1390 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1392 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1393 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1394 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1396 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1397 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1398 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1400 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1401 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1402 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1404 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1405 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1406 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1408 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1409 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1410 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1412 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1413 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1414 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1416 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1417 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1418 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1420 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1421 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1422 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1425 add_function("texelFetchOffset",
1426 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1427 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1428 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1430 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1431 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1432 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1434 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1435 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1436 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1438 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1439 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1440 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1442 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1443 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1444 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1446 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1447 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1448 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1452 add_function("textureProjOffset",
1453 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1454 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1455 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1456 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1457 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1458 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1460 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1461 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1462 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1463 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1464 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1465 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1467 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1468 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1469 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1471 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1472 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1474 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1475 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1476 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1477 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1478 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1479 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1481 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1483 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1484 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1485 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1486 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1487 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1488 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1490 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1491 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1492 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1493 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1494 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1495 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1497 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1498 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1499 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1501 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1502 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1505 add_function("textureLodOffset",
1506 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1507 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1508 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1510 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1511 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1512 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1514 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1515 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1516 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1518 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1519 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1521 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1522 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1523 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1525 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1526 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1527 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1529 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1532 add_function("textureProjLod",
1533 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1534 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1535 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1536 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1537 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1538 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1540 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1541 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1542 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1543 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1544 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1545 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1547 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1548 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1549 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1551 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1552 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1555 add_function("textureProjLodOffset",
1556 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1557 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1558 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1559 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1560 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1561 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1563 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1564 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1565 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1566 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1567 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1568 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1570 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1571 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1572 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1574 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1575 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1578 add_function("textureGrad",
1579 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1580 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1581 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1583 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1584 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1585 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1587 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1588 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1589 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1591 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1592 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1593 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1595 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1596 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1597 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1599 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1601 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1602 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1603 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1605 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1606 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1607 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1609 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1610 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1611 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1613 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1614 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1615 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1617 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1618 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1621 add_function("textureGradOffset",
1622 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1623 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1624 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1626 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1627 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1628 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1630 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1631 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1632 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1634 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1635 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1636 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1638 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1640 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1641 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1643 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1644 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1645 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1647 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1648 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1649 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1651 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1652 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1655 add_function("textureProjGrad",
1656 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1657 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1658 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1659 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1660 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1661 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1663 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1664 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1665 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1666 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1667 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1668 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1670 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1671 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1672 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1674 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1675 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1676 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1677 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1678 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1679 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1681 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1683 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1684 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1687 add_function("textureProjGradOffset",
1688 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1689 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1690 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1691 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1692 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1693 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1695 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1696 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1697 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1698 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1699 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1700 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1702 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1703 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1704 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1706 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1707 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1708 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1709 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1710 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1711 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1713 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1715 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1716 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1719 add_function("EmitVertex", _EmitVertex(), NULL
);
1720 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1721 add_function("EmitStreamVertex",
1722 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1723 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1725 add_function("EndStreamPrimitive",
1726 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1727 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
1730 add_function("textureQueryLOD",
1731 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1732 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1733 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1735 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1736 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1737 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1739 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1740 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1741 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1743 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1744 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1745 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1747 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1748 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1749 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1751 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1752 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1753 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1755 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1756 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1757 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1759 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1760 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1761 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1762 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1763 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1764 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1767 add_function("textureQueryLevels",
1768 _textureQueryLevels(glsl_type::sampler1D_type
),
1769 _textureQueryLevels(glsl_type::sampler2D_type
),
1770 _textureQueryLevels(glsl_type::sampler3D_type
),
1771 _textureQueryLevels(glsl_type::samplerCube_type
),
1772 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1773 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1774 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1775 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1776 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1777 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1778 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1779 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1780 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1782 _textureQueryLevels(glsl_type::isampler1D_type
),
1783 _textureQueryLevels(glsl_type::isampler2D_type
),
1784 _textureQueryLevels(glsl_type::isampler3D_type
),
1785 _textureQueryLevels(glsl_type::isamplerCube_type
),
1786 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1787 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1788 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1790 _textureQueryLevels(glsl_type::usampler1D_type
),
1791 _textureQueryLevels(glsl_type::usampler2D_type
),
1792 _textureQueryLevels(glsl_type::usampler3D_type
),
1793 _textureQueryLevels(glsl_type::usamplerCube_type
),
1794 _textureQueryLevels(glsl_type::usampler1DArray_type
),
1795 _textureQueryLevels(glsl_type::usampler2DArray_type
),
1796 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
1800 add_function("texture1D",
1801 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1802 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1805 add_function("texture1DArray",
1806 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1807 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1810 add_function("texture1DProj",
1811 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1812 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1813 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1814 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1817 add_function("texture1DLod",
1818 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1821 add_function("texture1DArrayLod",
1822 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1825 add_function("texture1DProjLod",
1826 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1827 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1830 add_function("texture2D",
1831 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1832 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1833 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1836 add_function("texture2DArray",
1837 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1838 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1841 add_function("texture2DProj",
1842 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1843 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1844 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1845 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1846 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1847 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1850 add_function("texture2DLod",
1851 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1854 add_function("texture2DArrayLod",
1855 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1858 add_function("texture2DProjLod",
1859 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1860 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1863 add_function("texture3D",
1864 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1865 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1868 add_function("texture3DProj",
1869 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1870 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1873 add_function("texture3DLod",
1874 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1877 add_function("texture3DProjLod",
1878 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1881 add_function("textureCube",
1882 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1883 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1886 add_function("textureCubeLod",
1887 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1890 add_function("texture2DRect",
1891 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1894 add_function("texture2DRectProj",
1895 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1896 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1899 add_function("shadow1D",
1900 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1901 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1904 add_function("shadow1DArray",
1905 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1906 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1909 add_function("shadow2D",
1910 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1911 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1914 add_function("shadow2DArray",
1915 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1916 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1919 add_function("shadow1DProj",
1920 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1921 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1924 add_function("shadow2DProj",
1925 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1926 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1929 add_function("shadow1DLod",
1930 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1933 add_function("shadow2DLod",
1934 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1937 add_function("shadow1DArrayLod",
1938 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1941 add_function("shadow1DProjLod",
1942 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1945 add_function("shadow2DProjLod",
1946 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1949 add_function("shadow2DRect",
1950 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1953 add_function("shadow2DRectProj",
1954 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1957 add_function("texture1DGradARB",
1958 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1961 add_function("texture1DProjGradARB",
1962 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1963 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1966 add_function("texture2DGradARB",
1967 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1970 add_function("texture2DProjGradARB",
1971 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1972 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1975 add_function("texture3DGradARB",
1976 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1979 add_function("texture3DProjGradARB",
1980 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1983 add_function("textureCubeGradARB",
1984 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1987 add_function("shadow1DGradARB",
1988 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1991 add_function("shadow1DProjGradARB",
1992 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1995 add_function("shadow2DGradARB",
1996 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1999 add_function("shadow2DProjGradARB",
2000 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2003 add_function("texture2DRectGradARB",
2004 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2007 add_function("texture2DRectProjGradARB",
2008 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2009 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2012 add_function("shadow2DRectGradARB",
2013 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2016 add_function("shadow2DRectProjGradARB",
2017 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2020 add_function("textureGather",
2021 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2022 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2023 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2025 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2026 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2027 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2029 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2030 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2031 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2033 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2034 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2035 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2037 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2038 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2039 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2041 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2042 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2043 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2045 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2046 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2047 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2049 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2050 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2051 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2053 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2054 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2055 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2057 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2058 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2059 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2061 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2062 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2063 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2064 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2065 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2068 add_function("textureGatherOffset",
2069 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2070 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2071 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2073 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2074 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2075 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2077 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2078 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2079 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2081 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2082 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2083 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2085 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2086 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2087 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2089 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2090 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2091 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2093 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2094 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2095 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2097 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2098 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2099 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2101 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2102 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2103 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2106 add_function("textureGatherOffsets",
2107 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2108 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2109 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2111 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2112 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2113 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2115 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2116 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2117 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2119 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2120 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2121 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2123 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2124 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2125 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2127 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2128 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2129 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2131 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2132 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2133 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2152 add_function("ldexp",
2153 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2154 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2155 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2156 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2159 add_function("frexp",
2160 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2161 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2162 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2163 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2165 add_function("uaddCarry",
2166 _uaddCarry(glsl_type::uint_type
),
2167 _uaddCarry(glsl_type::uvec2_type
),
2168 _uaddCarry(glsl_type::uvec3_type
),
2169 _uaddCarry(glsl_type::uvec4_type
),
2171 add_function("usubBorrow",
2172 _usubBorrow(glsl_type::uint_type
),
2173 _usubBorrow(glsl_type::uvec2_type
),
2174 _usubBorrow(glsl_type::uvec3_type
),
2175 _usubBorrow(glsl_type::uvec4_type
),
2177 add_function("imulExtended",
2178 _mulExtended(glsl_type::int_type
),
2179 _mulExtended(glsl_type::ivec2_type
),
2180 _mulExtended(glsl_type::ivec3_type
),
2181 _mulExtended(glsl_type::ivec4_type
),
2183 add_function("umulExtended",
2184 _mulExtended(glsl_type::uint_type
),
2185 _mulExtended(glsl_type::uvec2_type
),
2186 _mulExtended(glsl_type::uvec3_type
),
2187 _mulExtended(glsl_type::uvec4_type
),
2190 add_function("atomicCounter",
2191 _atomic_op("__intrinsic_atomic_read",
2192 shader_atomic_counters
),
2194 add_function("atomicCounterIncrement",
2195 _atomic_op("__intrinsic_atomic_increment",
2196 shader_atomic_counters
),
2198 add_function("atomicCounterDecrement",
2199 _atomic_op("__intrinsic_atomic_predecrement",
2200 shader_atomic_counters
),
2203 add_function("min3",
2204 _min3(glsl_type::float_type
),
2205 _min3(glsl_type::vec2_type
),
2206 _min3(glsl_type::vec3_type
),
2207 _min3(glsl_type::vec4_type
),
2209 _min3(glsl_type::int_type
),
2210 _min3(glsl_type::ivec2_type
),
2211 _min3(glsl_type::ivec3_type
),
2212 _min3(glsl_type::ivec4_type
),
2214 _min3(glsl_type::uint_type
),
2215 _min3(glsl_type::uvec2_type
),
2216 _min3(glsl_type::uvec3_type
),
2217 _min3(glsl_type::uvec4_type
),
2220 add_function("max3",
2221 _max3(glsl_type::float_type
),
2222 _max3(glsl_type::vec2_type
),
2223 _max3(glsl_type::vec3_type
),
2224 _max3(glsl_type::vec4_type
),
2226 _max3(glsl_type::int_type
),
2227 _max3(glsl_type::ivec2_type
),
2228 _max3(glsl_type::ivec3_type
),
2229 _max3(glsl_type::ivec4_type
),
2231 _max3(glsl_type::uint_type
),
2232 _max3(glsl_type::uvec2_type
),
2233 _max3(glsl_type::uvec3_type
),
2234 _max3(glsl_type::uvec4_type
),
2237 add_function("mid3",
2238 _mid3(glsl_type::float_type
),
2239 _mid3(glsl_type::vec2_type
),
2240 _mid3(glsl_type::vec3_type
),
2241 _mid3(glsl_type::vec4_type
),
2243 _mid3(glsl_type::int_type
),
2244 _mid3(glsl_type::ivec2_type
),
2245 _mid3(glsl_type::ivec3_type
),
2246 _mid3(glsl_type::ivec4_type
),
2248 _mid3(glsl_type::uint_type
),
2249 _mid3(glsl_type::uvec2_type
),
2250 _mid3(glsl_type::uvec3_type
),
2251 _mid3(glsl_type::uvec4_type
),
2254 add_image_functions(true);
2256 add_function("memoryBarrier",
2257 _memory_barrier(shader_image_load_store
),
2268 builtin_builder::add_function(const char *name
, ...)
2272 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2276 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2282 stuff
.push_tail(sig
);
2283 validate_ir_tree(&stuff
);
2286 f
->add_signature(sig
);
2290 shader
->symbols
->add_function(f
);
2294 builtin_builder::add_image_function(const char *name
,
2295 const char *intrinsic_name
,
2296 unsigned num_arguments
,
2299 static const glsl_type
*const types
[] = {
2300 glsl_type::image1D_type
,
2301 glsl_type::image2D_type
,
2302 glsl_type::image3D_type
,
2303 glsl_type::image2DRect_type
,
2304 glsl_type::imageCube_type
,
2305 glsl_type::imageBuffer_type
,
2306 glsl_type::image1DArray_type
,
2307 glsl_type::image2DArray_type
,
2308 glsl_type::imageCubeArray_type
,
2309 glsl_type::image2DMS_type
,
2310 glsl_type::image2DMSArray_type
,
2311 glsl_type::iimage1D_type
,
2312 glsl_type::iimage2D_type
,
2313 glsl_type::iimage3D_type
,
2314 glsl_type::iimage2DRect_type
,
2315 glsl_type::iimageCube_type
,
2316 glsl_type::iimageBuffer_type
,
2317 glsl_type::iimage1DArray_type
,
2318 glsl_type::iimage2DArray_type
,
2319 glsl_type::iimageCubeArray_type
,
2320 glsl_type::iimage2DMS_type
,
2321 glsl_type::iimage2DMSArray_type
,
2322 glsl_type::uimage1D_type
,
2323 glsl_type::uimage2D_type
,
2324 glsl_type::uimage3D_type
,
2325 glsl_type::uimage2DRect_type
,
2326 glsl_type::uimageCube_type
,
2327 glsl_type::uimageBuffer_type
,
2328 glsl_type::uimage1DArray_type
,
2329 glsl_type::uimage2DArray_type
,
2330 glsl_type::uimageCubeArray_type
,
2331 glsl_type::uimage2DMS_type
,
2332 glsl_type::uimage2DMSArray_type
2334 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2336 for (unsigned i
= 0; i
< Elements(types
); ++i
) {
2337 if (types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2338 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
))
2339 f
->add_signature(_image(types
[i
], intrinsic_name
,
2340 num_arguments
, flags
));
2343 shader
->symbols
->add_function(f
);
2347 builtin_builder::add_image_functions(bool glsl
)
2349 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2351 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2352 "__intrinsic_image_load", 0,
2353 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2354 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2355 IMAGE_FUNCTION_READ_ONLY
));
2357 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2358 "__intrinsic_image_store", 1,
2359 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2360 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2361 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2362 IMAGE_FUNCTION_WRITE_ONLY
));
2364 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2365 "__intrinsic_image_atomic_add", 1, flags
);
2367 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2368 "__intrinsic_image_atomic_min", 1, flags
);
2370 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2371 "__intrinsic_image_atomic_max", 1, flags
);
2373 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2374 "__intrinsic_image_atomic_and", 1, flags
);
2376 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2377 "__intrinsic_image_atomic_or", 1, flags
);
2379 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2380 "__intrinsic_image_atomic_xor", 1, flags
);
2382 add_image_function((glsl
? "imageAtomicExchange" :
2383 "__intrinsic_image_atomic_exchange"),
2384 "__intrinsic_image_atomic_exchange", 1, flags
);
2386 add_image_function((glsl
? "imageAtomicCompSwap" :
2387 "__intrinsic_image_atomic_comp_swap"),
2388 "__intrinsic_image_atomic_comp_swap", 2, flags
);
2392 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2394 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2398 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2400 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2404 builtin_builder::imm(float f
, unsigned vector_elements
)
2406 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2410 builtin_builder::imm(int i
, unsigned vector_elements
)
2412 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2416 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2418 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2422 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2424 return new(mem_ctx
) ir_constant(type
, &data
);
2427 ir_dereference_variable
*
2428 builtin_builder::var_ref(ir_variable
*var
)
2430 return new(mem_ctx
) ir_dereference_variable(var
);
2433 ir_dereference_array
*
2434 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2436 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2439 /** Return an element of a matrix */
2441 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2443 return swizzle(array_ref(var
, column
), row
, 1);
2447 * Implementations of built-in functions:
2450 ir_function_signature
*
2451 builtin_builder::new_sig(const glsl_type
*return_type
,
2452 builtin_available_predicate avail
,
2458 ir_function_signature
*sig
=
2459 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2462 va_start(ap
, num_params
);
2463 for (int i
= 0; i
< num_params
; i
++) {
2464 plist
.push_tail(va_arg(ap
, ir_variable
*));
2468 sig
->replace_parameters(&plist
);
2472 #define MAKE_SIG(return_type, avail, ...) \
2473 ir_function_signature *sig = \
2474 new_sig(return_type, avail, __VA_ARGS__); \
2475 ir_factory body(&sig->body, mem_ctx); \
2476 sig->is_defined = true;
2478 #define MAKE_INTRINSIC(return_type, avail, ...) \
2479 ir_function_signature *sig = \
2480 new_sig(return_type, avail, __VA_ARGS__); \
2481 sig->is_intrinsic = true;
2483 ir_function_signature
*
2484 builtin_builder::unop(builtin_available_predicate avail
,
2485 ir_expression_operation opcode
,
2486 const glsl_type
*return_type
,
2487 const glsl_type
*param_type
)
2489 ir_variable
*x
= in_var(param_type
, "x");
2490 MAKE_SIG(return_type
, avail
, 1, x
);
2491 body
.emit(ret(expr(opcode
, x
)));
2495 #define UNOP(NAME, OPCODE, AVAIL) \
2496 ir_function_signature * \
2497 builtin_builder::_##NAME(const glsl_type *type) \
2499 return unop(&AVAIL, OPCODE, type, type); \
2502 ir_function_signature
*
2503 builtin_builder::binop(ir_expression_operation opcode
,
2504 builtin_available_predicate avail
,
2505 const glsl_type
*return_type
,
2506 const glsl_type
*param0_type
,
2507 const glsl_type
*param1_type
)
2509 ir_variable
*x
= in_var(param0_type
, "x");
2510 ir_variable
*y
= in_var(param1_type
, "y");
2511 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2512 body
.emit(ret(expr(opcode
, x
, y
)));
2516 #define BINOP(NAME, OPCODE, AVAIL) \
2517 ir_function_signature * \
2518 builtin_builder::_##NAME(const glsl_type *return_type, \
2519 const glsl_type *param0_type, \
2520 const glsl_type *param1_type) \
2522 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2526 * Angle and Trigonometry Functions @{
2529 ir_function_signature
*
2530 builtin_builder::_radians(const glsl_type
*type
)
2532 ir_variable
*degrees
= in_var(type
, "degrees");
2533 MAKE_SIG(type
, always_available
, 1, degrees
);
2534 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2538 ir_function_signature
*
2539 builtin_builder::_degrees(const glsl_type
*type
)
2541 ir_variable
*radians
= in_var(type
, "radians");
2542 MAKE_SIG(type
, always_available
, 1, radians
);
2543 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2547 UNOP(sin
, ir_unop_sin
, always_available
)
2548 UNOP(cos
, ir_unop_cos
, always_available
)
2550 ir_function_signature
*
2551 builtin_builder::_tan(const glsl_type
*type
)
2553 ir_variable
*theta
= in_var(type
, "theta");
2554 MAKE_SIG(type
, always_available
, 1, theta
);
2555 body
.emit(ret(div(sin(theta
), cos(theta
))));
2560 builtin_builder::asin_expr(ir_variable
*x
)
2564 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2567 add(imm(M_PI_4f
- 1.0f
),
2569 add(imm(0.086566724f
),
2570 mul(abs(x
), imm(-0.03102955f
))))))))));
2574 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2576 exec_list actual_params
;
2578 foreach_in_list(ir_variable
, var
, ¶ms
) {
2579 actual_params
.push_tail(var_ref(var
));
2582 ir_function_signature
*sig
=
2583 f
->exact_matching_signature(NULL
, &actual_params
);
2587 ir_dereference_variable
*deref
=
2588 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2590 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2593 ir_function_signature
*
2594 builtin_builder::_asin(const glsl_type
*type
)
2596 ir_variable
*x
= in_var(type
, "x");
2597 MAKE_SIG(type
, always_available
, 1, x
);
2599 body
.emit(ret(asin_expr(x
)));
2604 ir_function_signature
*
2605 builtin_builder::_acos(const glsl_type
*type
)
2607 ir_variable
*x
= in_var(type
, "x");
2608 MAKE_SIG(type
, always_available
, 1, x
);
2610 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
2615 ir_function_signature
*
2616 builtin_builder::_atan2(const glsl_type
*type
)
2618 ir_variable
*vec_y
= in_var(type
, "vec_y");
2619 ir_variable
*vec_x
= in_var(type
, "vec_x");
2620 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2622 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2623 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2624 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2625 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2626 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2627 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2628 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2630 /* If |x| >= 1.0e-8 * |y|: */
2632 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2634 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2636 /* Then...call atan(y/x) */
2637 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2638 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2639 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2641 outer_then
.emit(assign(r
, asin_expr(r
)));
2643 /* ...and fix it up: */
2644 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2645 inner_if
->then_instructions
.push_tail(
2646 if_tree(gequal(y
, imm(0.0f
)),
2647 assign(r
, add(r
, imm(M_PIf
))),
2648 assign(r
, sub(r
, imm(M_PIf
)))));
2649 outer_then
.emit(inner_if
);
2652 outer_if
->else_instructions
.push_tail(
2653 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
2655 body
.emit(outer_if
);
2657 body
.emit(assign(vec_result
, r
, 1 << i
));
2659 body
.emit(ret(vec_result
));
2664 ir_function_signature
*
2665 builtin_builder::_atan(const glsl_type
*type
)
2667 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2668 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2670 ir_variable
*t
= body
.make_temp(type
, "t");
2671 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2674 body
.emit(ret(asin_expr(t
)));
2679 ir_function_signature
*
2680 builtin_builder::_sinh(const glsl_type
*type
)
2682 ir_variable
*x
= in_var(type
, "x");
2683 MAKE_SIG(type
, v130
, 1, x
);
2685 /* 0.5 * (e^x - e^(-x)) */
2686 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2691 ir_function_signature
*
2692 builtin_builder::_cosh(const glsl_type
*type
)
2694 ir_variable
*x
= in_var(type
, "x");
2695 MAKE_SIG(type
, v130
, 1, x
);
2697 /* 0.5 * (e^x + e^(-x)) */
2698 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2703 ir_function_signature
*
2704 builtin_builder::_tanh(const glsl_type
*type
)
2706 ir_variable
*x
= in_var(type
, "x");
2707 MAKE_SIG(type
, v130
, 1, x
);
2709 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2710 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2711 add(exp(x
), exp(neg(x
))))));
2716 ir_function_signature
*
2717 builtin_builder::_asinh(const glsl_type
*type
)
2719 ir_variable
*x
= in_var(type
, "x");
2720 MAKE_SIG(type
, v130
, 1, x
);
2722 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2727 ir_function_signature
*
2728 builtin_builder::_acosh(const glsl_type
*type
)
2730 ir_variable
*x
= in_var(type
, "x");
2731 MAKE_SIG(type
, v130
, 1, x
);
2733 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2737 ir_function_signature
*
2738 builtin_builder::_atanh(const glsl_type
*type
)
2740 ir_variable
*x
= in_var(type
, "x");
2741 MAKE_SIG(type
, v130
, 1, x
);
2743 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2744 sub(imm(1.0f
), x
))))));
2750 * Exponential Functions @{
2753 ir_function_signature
*
2754 builtin_builder::_pow(const glsl_type
*type
)
2756 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2759 UNOP(exp
, ir_unop_exp
, always_available
)
2760 UNOP(log
, ir_unop_log
, always_available
)
2761 UNOP(exp2
, ir_unop_exp2
, always_available
)
2762 UNOP(log2
, ir_unop_log2
, always_available
)
2763 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2764 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2768 UNOP(abs
, ir_unop_abs
, always_available
)
2769 UNOP(sign
, ir_unop_sign
, always_available
)
2770 UNOP(floor
, ir_unop_floor
, always_available
)
2771 UNOP(trunc
, ir_unop_trunc
, v130
)
2772 UNOP(round
, ir_unop_round_even
, always_available
)
2773 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2774 UNOP(ceil
, ir_unop_ceil
, always_available
)
2775 UNOP(fract
, ir_unop_fract
, always_available
)
2777 ir_function_signature
*
2778 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2780 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2783 ir_function_signature
*
2784 builtin_builder::_modf(const glsl_type
*type
)
2786 ir_variable
*x
= in_var(type
, "x");
2787 ir_variable
*i
= out_var(type
, "i");
2788 MAKE_SIG(type
, v130
, 2, x
, i
);
2790 ir_variable
*t
= body
.make_temp(type
, "t");
2791 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2792 body
.emit(assign(i
, t
));
2793 body
.emit(ret(sub(x
, t
)));
2798 ir_function_signature
*
2799 builtin_builder::_min(builtin_available_predicate avail
,
2800 const glsl_type
*x_type
, const glsl_type
*y_type
)
2802 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2805 ir_function_signature
*
2806 builtin_builder::_max(builtin_available_predicate avail
,
2807 const glsl_type
*x_type
, const glsl_type
*y_type
)
2809 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2812 ir_function_signature
*
2813 builtin_builder::_clamp(builtin_available_predicate avail
,
2814 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2816 ir_variable
*x
= in_var(val_type
, "x");
2817 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2818 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2819 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2821 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2826 ir_function_signature
*
2827 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2829 ir_variable
*x
= in_var(val_type
, "x");
2830 ir_variable
*y
= in_var(val_type
, "y");
2831 ir_variable
*a
= in_var(blend_type
, "a");
2832 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2834 body
.emit(ret(lrp(x
, y
, a
)));
2839 ir_function_signature
*
2840 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2841 const glsl_type
*val_type
,
2842 const glsl_type
*blend_type
)
2844 ir_variable
*x
= in_var(val_type
, "x");
2845 ir_variable
*y
= in_var(val_type
, "y");
2846 ir_variable
*a
= in_var(blend_type
, "a");
2847 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2849 /* csel matches the ternary operator in that a selector of true choses the
2850 * first argument. This differs from mix(x, y, false) which choses the
2851 * second argument (to remain consistent with the interpolating version of
2852 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2854 * To handle the behavior mismatch, reverse the x and y arguments.
2856 body
.emit(ret(csel(a
, y
, x
)));
2861 ir_function_signature
*
2862 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2864 ir_variable
*edge
= in_var(edge_type
, "edge");
2865 ir_variable
*x
= in_var(x_type
, "x");
2866 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2868 ir_variable
*t
= body
.make_temp(x_type
, "t");
2869 if (x_type
->vector_elements
== 1) {
2870 /* Both are floats */
2871 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2872 } else if (edge_type
->vector_elements
== 1) {
2873 /* x is a vector but edge is a float */
2874 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2875 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2878 /* Both are vectors */
2879 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2880 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2889 ir_function_signature
*
2890 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2892 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2893 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2894 ir_variable
*x
= in_var(x_type
, "x");
2895 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2897 /* From the GLSL 1.10 specification:
2900 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2901 * return t * t * (3 - 2 * t);
2904 ir_variable
*t
= body
.make_temp(x_type
, "t");
2905 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2906 imm(0.0f
), imm(1.0f
))));
2908 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2913 ir_function_signature
*
2914 builtin_builder::_isnan(const glsl_type
*type
)
2916 ir_variable
*x
= in_var(type
, "x");
2917 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2919 body
.emit(ret(nequal(x
, x
)));
2924 ir_function_signature
*
2925 builtin_builder::_isinf(const glsl_type
*type
)
2927 ir_variable
*x
= in_var(type
, "x");
2928 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2930 ir_constant_data infinities
;
2931 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2932 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2935 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2940 ir_function_signature
*
2941 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2943 ir_variable
*x
= in_var(type
, "x");
2944 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2945 body
.emit(ret(bitcast_f2i(x
)));
2949 ir_function_signature
*
2950 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2952 ir_variable
*x
= in_var(type
, "x");
2953 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2954 body
.emit(ret(bitcast_f2u(x
)));
2958 ir_function_signature
*
2959 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2961 ir_variable
*x
= in_var(type
, "x");
2962 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2963 body
.emit(ret(bitcast_i2f(x
)));
2967 ir_function_signature
*
2968 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2970 ir_variable
*x
= in_var(type
, "x");
2971 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2972 body
.emit(ret(bitcast_u2f(x
)));
2976 ir_function_signature
*
2977 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2979 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2980 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2981 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2985 ir_function_signature
*
2986 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2988 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2989 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2990 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2994 ir_function_signature
*
2995 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2997 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2998 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2999 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3003 ir_function_signature
*
3004 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3006 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3007 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3008 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3012 ir_function_signature
*
3013 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3015 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3016 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3017 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3021 ir_function_signature
*
3022 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3024 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3025 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3026 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3031 ir_function_signature
*
3032 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3034 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3035 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3036 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3040 ir_function_signature
*
3041 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3043 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3044 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3045 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3049 ir_function_signature
*
3050 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3052 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3053 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3054 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3058 ir_function_signature
*
3059 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3061 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3062 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3063 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3067 ir_function_signature
*
3068 builtin_builder::_length(const glsl_type
*type
)
3070 ir_variable
*x
= in_var(type
, "x");
3071 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
3073 body
.emit(ret(sqrt(dot(x
, x
))));
3078 ir_function_signature
*
3079 builtin_builder::_distance(const glsl_type
*type
)
3081 ir_variable
*p0
= in_var(type
, "p0");
3082 ir_variable
*p1
= in_var(type
, "p1");
3083 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
3085 if (type
->vector_elements
== 1) {
3086 body
.emit(ret(abs(sub(p0
, p1
))));
3088 ir_variable
*p
= body
.make_temp(type
, "p");
3089 body
.emit(assign(p
, sub(p0
, p1
)));
3090 body
.emit(ret(sqrt(dot(p
, p
))));
3096 ir_function_signature
*
3097 builtin_builder::_dot(const glsl_type
*type
)
3099 if (type
->vector_elements
== 1)
3100 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
3102 return binop(ir_binop_dot
, always_available
,
3103 glsl_type::float_type
, type
, type
);
3106 ir_function_signature
*
3107 builtin_builder::_cross(const glsl_type
*type
)
3109 ir_variable
*a
= in_var(type
, "a");
3110 ir_variable
*b
= in_var(type
, "b");
3111 MAKE_SIG(type
, always_available
, 2, a
, b
);
3113 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3114 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3116 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3117 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3122 ir_function_signature
*
3123 builtin_builder::_normalize(const glsl_type
*type
)
3125 ir_variable
*x
= in_var(type
, "x");
3126 MAKE_SIG(type
, always_available
, 1, x
);
3128 if (type
->vector_elements
== 1) {
3129 body
.emit(ret(sign(x
)));
3131 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3137 ir_function_signature
*
3138 builtin_builder::_ftransform()
3140 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3142 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3143 glsl_type::vec4_type
,
3144 var_ref(gl_ModelViewProjectionMatrix
),
3145 var_ref(gl_Vertex
))));
3147 /* FINISHME: Once the ir_expression() constructor handles type inference
3148 * for matrix operations, we can simplify this to:
3150 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3155 ir_function_signature
*
3156 builtin_builder::_faceforward(const glsl_type
*type
)
3158 ir_variable
*N
= in_var(type
, "N");
3159 ir_variable
*I
= in_var(type
, "I");
3160 ir_variable
*Nref
= in_var(type
, "Nref");
3161 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
3163 body
.emit(if_tree(less(dot(Nref
, I
), imm(0.0f
)),
3164 ret(N
), ret(neg(N
))));
3169 ir_function_signature
*
3170 builtin_builder::_reflect(const glsl_type
*type
)
3172 ir_variable
*I
= in_var(type
, "I");
3173 ir_variable
*N
= in_var(type
, "N");
3174 MAKE_SIG(type
, always_available
, 2, I
, N
);
3176 /* I - 2 * dot(N, I) * N */
3177 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dot(N
, I
), N
)))));
3182 ir_function_signature
*
3183 builtin_builder::_refract(const glsl_type
*type
)
3185 ir_variable
*I
= in_var(type
, "I");
3186 ir_variable
*N
= in_var(type
, "N");
3187 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
3188 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
3190 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
3191 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3193 /* From the GLSL 1.10 specification:
3194 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3196 * return genType(0.0)
3198 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3200 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
3201 body
.emit(assign(k
, sub(imm(1.0f
),
3202 mul(eta
, mul(eta
, sub(imm(1.0f
),
3203 mul(n_dot_i
, n_dot_i
)))))));
3204 body
.emit(if_tree(less(k
, imm(0.0f
)),
3205 ret(ir_constant::zero(mem_ctx
, type
)),
3206 ret(sub(mul(eta
, I
),
3207 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3212 ir_function_signature
*
3213 builtin_builder::_matrixCompMult(const glsl_type
*type
)
3215 ir_variable
*x
= in_var(type
, "x");
3216 ir_variable
*y
= in_var(type
, "y");
3217 MAKE_SIG(type
, always_available
, 2, x
, y
);
3219 ir_variable
*z
= body
.make_temp(type
, "z");
3220 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3221 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3228 ir_function_signature
*
3229 builtin_builder::_outerProduct(const glsl_type
*type
)
3231 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3232 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3233 MAKE_SIG(type
, v120
, 2, c
, r
);
3235 ir_variable
*m
= body
.make_temp(type
, "m");
3236 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3237 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3244 ir_function_signature
*
3245 builtin_builder::_transpose(const glsl_type
*orig_type
)
3247 const glsl_type
*transpose_type
=
3248 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
3249 orig_type
->matrix_columns
,
3250 orig_type
->vector_elements
);
3252 ir_variable
*m
= in_var(orig_type
, "m");
3253 MAKE_SIG(transpose_type
, v120
, 1, m
);
3255 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3256 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3257 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3258 body
.emit(assign(array_ref(t
, j
),
3259 matrix_elt(m
, i
, j
),
3268 ir_function_signature
*
3269 builtin_builder::_determinant_mat2()
3271 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3272 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3274 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3275 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3280 ir_function_signature
*
3281 builtin_builder::_determinant_mat3()
3283 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3284 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3287 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3288 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3291 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3292 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3295 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3296 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3298 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3299 mul(matrix_elt(m
, 0, 1), f2
)),
3300 mul(matrix_elt(m
, 0, 2), f3
))));
3305 ir_function_signature
*
3306 builtin_builder::_determinant_mat4()
3308 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3309 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3311 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3312 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3313 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3314 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3315 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3316 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3317 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3318 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3319 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3320 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3321 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3322 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3323 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3324 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3325 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3326 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3327 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3328 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3329 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3331 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)))));
3332 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)))));
3333 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)))));
3334 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)))));
3335 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)))));
3336 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)))));
3337 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)))));
3338 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)))));
3339 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)))));
3340 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)))));
3341 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)))));
3342 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)))));
3343 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)))));
3344 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)))));
3345 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)))));
3346 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)))));
3347 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)))));
3348 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)))));
3349 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)))));
3351 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
3353 body
.emit(assign(adj_0
,
3354 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3355 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3356 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3358 body
.emit(assign(adj_0
, neg(
3359 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3360 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3361 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3363 body
.emit(assign(adj_0
,
3364 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3365 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3366 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3368 body
.emit(assign(adj_0
, neg(
3369 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3370 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3371 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3374 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3379 ir_function_signature
*
3380 builtin_builder::_inverse_mat2()
3382 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3383 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
3385 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
3386 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3387 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3388 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3389 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3391 ir_expression
*det
=
3392 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3393 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3395 body
.emit(ret(div(adj
, det
)));
3399 ir_function_signature
*
3400 builtin_builder::_inverse_mat3()
3402 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3403 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
3405 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
3406 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
3407 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
3409 body
.emit(assign(f11_22_21_12
,
3410 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3411 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3412 body
.emit(assign(f10_22_20_12
,
3413 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3414 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3415 body
.emit(assign(f10_21_20_11
,
3416 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3417 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3419 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
3420 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3421 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3422 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3424 body
.emit(assign(array_ref(adj
, 0), neg(
3425 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3426 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3428 body
.emit(assign(array_ref(adj
, 1),
3429 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3430 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3432 body
.emit(assign(array_ref(adj
, 2), neg(
3433 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3434 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3437 body
.emit(assign(array_ref(adj
, 0),
3438 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3439 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3441 body
.emit(assign(array_ref(adj
, 1), neg(
3442 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3443 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3445 body
.emit(assign(array_ref(adj
, 2),
3446 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3447 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3450 ir_expression
*det
=
3451 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3452 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3453 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3455 body
.emit(ret(div(adj
, det
)));
3460 ir_function_signature
*
3461 builtin_builder::_inverse_mat4()
3463 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3464 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
3466 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3467 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3468 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3469 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3470 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3471 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3472 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3473 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3474 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3475 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3476 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3477 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3478 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3479 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3480 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3481 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3482 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3483 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3484 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3486 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)))));
3487 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)))));
3488 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)))));
3489 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)))));
3490 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)))));
3491 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)))));
3492 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)))));
3493 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)))));
3494 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)))));
3495 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)))));
3496 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)))));
3497 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)))));
3498 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)))));
3499 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)))));
3500 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)))));
3501 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)))));
3502 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)))));
3503 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)))));
3504 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)))));
3506 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
3507 body
.emit(assign(array_ref(adj
, 0),
3508 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3509 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3510 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3512 body
.emit(assign(array_ref(adj
, 1), neg(
3513 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3514 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3515 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3517 body
.emit(assign(array_ref(adj
, 2),
3518 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3519 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3520 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3522 body
.emit(assign(array_ref(adj
, 3), neg(
3523 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3524 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3525 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3528 body
.emit(assign(array_ref(adj
, 0), neg(
3529 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3530 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3531 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3533 body
.emit(assign(array_ref(adj
, 1),
3534 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3535 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3536 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3538 body
.emit(assign(array_ref(adj
, 2), neg(
3539 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3540 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3541 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3543 body
.emit(assign(array_ref(adj
, 3),
3544 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3545 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3546 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3549 body
.emit(assign(array_ref(adj
, 0),
3550 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3551 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3552 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3554 body
.emit(assign(array_ref(adj
, 1), neg(
3555 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3556 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3557 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3559 body
.emit(assign(array_ref(adj
, 2),
3560 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3561 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3562 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3564 body
.emit(assign(array_ref(adj
, 3), neg(
3565 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3566 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3567 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3570 body
.emit(assign(array_ref(adj
, 0), neg(
3571 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3572 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3573 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3575 body
.emit(assign(array_ref(adj
, 1),
3576 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3577 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3578 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3580 body
.emit(assign(array_ref(adj
, 2), neg(
3581 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3582 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3583 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3585 body
.emit(assign(array_ref(adj
, 3),
3586 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3587 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3588 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3591 ir_expression
*det
=
3592 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3593 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3594 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3595 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3597 body
.emit(ret(div(adj
, det
)));
3603 ir_function_signature
*
3604 builtin_builder::_lessThan(builtin_available_predicate avail
,
3605 const glsl_type
*type
)
3607 return binop(ir_binop_less
, avail
,
3608 glsl_type::bvec(type
->vector_elements
), type
, type
);
3611 ir_function_signature
*
3612 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3613 const glsl_type
*type
)
3615 return binop(ir_binop_lequal
, avail
,
3616 glsl_type::bvec(type
->vector_elements
), type
, type
);
3619 ir_function_signature
*
3620 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3621 const glsl_type
*type
)
3623 return binop(ir_binop_greater
, avail
,
3624 glsl_type::bvec(type
->vector_elements
), type
, type
);
3627 ir_function_signature
*
3628 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3629 const glsl_type
*type
)
3631 return binop(ir_binop_gequal
, avail
,
3632 glsl_type::bvec(type
->vector_elements
), type
, type
);
3635 ir_function_signature
*
3636 builtin_builder::_equal(builtin_available_predicate avail
,
3637 const glsl_type
*type
)
3639 return binop(ir_binop_equal
, avail
,
3640 glsl_type::bvec(type
->vector_elements
), type
, type
);
3643 ir_function_signature
*
3644 builtin_builder::_notEqual(builtin_available_predicate avail
,
3645 const glsl_type
*type
)
3647 return binop(ir_binop_nequal
, avail
,
3648 glsl_type::bvec(type
->vector_elements
), type
, type
);
3651 ir_function_signature
*
3652 builtin_builder::_any(const glsl_type
*type
)
3654 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3657 ir_function_signature
*
3658 builtin_builder::_all(const glsl_type
*type
)
3660 ir_variable
*v
= in_var(type
, "v");
3661 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3663 switch (type
->vector_elements
) {
3665 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3668 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3672 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3681 UNOP(not, ir_unop_logic_not
, always_available
)
3684 has_lod(const glsl_type
*sampler_type
)
3686 assert(sampler_type
->is_sampler());
3688 switch (sampler_type
->sampler_dimensionality
) {
3689 case GLSL_SAMPLER_DIM_RECT
:
3690 case GLSL_SAMPLER_DIM_BUF
:
3691 case GLSL_SAMPLER_DIM_MS
:
3698 ir_function_signature
*
3699 builtin_builder::_textureSize(builtin_available_predicate avail
,
3700 const glsl_type
*return_type
,
3701 const glsl_type
*sampler_type
)
3703 ir_variable
*s
= in_var(sampler_type
, "sampler");
3704 /* The sampler always exists; add optional lod later. */
3705 MAKE_SIG(return_type
, avail
, 1, s
);
3707 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3708 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3710 if (has_lod(sampler_type
)) {
3711 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3712 sig
->parameters
.push_tail(lod
);
3713 tex
->lod_info
.lod
= var_ref(lod
);
3715 tex
->lod_info
.lod
= imm(0u);
3718 body
.emit(ret(tex
));
3723 ir_function_signature
*
3724 builtin_builder::_texture(ir_texture_opcode opcode
,
3725 builtin_available_predicate avail
,
3726 const glsl_type
*return_type
,
3727 const glsl_type
*sampler_type
,
3728 const glsl_type
*coord_type
,
3731 ir_variable
*s
= in_var(sampler_type
, "sampler");
3732 ir_variable
*P
= in_var(coord_type
, "P");
3733 /* The sampler and coordinate always exist; add optional parameters later. */
3734 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3736 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3737 tex
->set_sampler(var_ref(s
), return_type
);
3739 const int coord_size
= sampler_type
->coordinate_components();
3741 if (coord_size
== coord_type
->vector_elements
) {
3742 tex
->coordinate
= var_ref(P
);
3744 /* The incoming coordinate also has the projector or shadow comparitor,
3745 * so we need to swizzle those away.
3747 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3750 /* The projector is always in the last component. */
3751 if (flags
& TEX_PROJECT
)
3752 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3754 if (sampler_type
->sampler_shadow
) {
3755 if (opcode
== ir_tg4
) {
3756 /* gather has refz as a separate parameter, immediately after the
3759 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
3760 sig
->parameters
.push_tail(refz
);
3761 tex
->shadow_comparitor
= var_ref(refz
);
3763 /* The shadow comparitor is normally in the Z component, but a few types
3764 * have sufficiently large coordinates that it's in W.
3766 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3770 if (opcode
== ir_txl
) {
3771 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3772 sig
->parameters
.push_tail(lod
);
3773 tex
->lod_info
.lod
= var_ref(lod
);
3774 } else if (opcode
== ir_txd
) {
3775 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3776 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3777 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3778 sig
->parameters
.push_tail(dPdx
);
3779 sig
->parameters
.push_tail(dPdy
);
3780 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3781 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3784 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
3785 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3786 ir_variable
*offset
=
3787 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
3788 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
3789 sig
->parameters
.push_tail(offset
);
3790 tex
->offset
= var_ref(offset
);
3793 if (flags
& TEX_OFFSET_ARRAY
) {
3794 ir_variable
*offsets
=
3795 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
3796 "offsets", ir_var_const_in
);
3797 sig
->parameters
.push_tail(offsets
);
3798 tex
->offset
= var_ref(offsets
);
3801 if (opcode
== ir_tg4
) {
3802 if (flags
& TEX_COMPONENT
) {
3803 ir_variable
*component
=
3804 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
3805 sig
->parameters
.push_tail(component
);
3806 tex
->lod_info
.component
= var_ref(component
);
3809 tex
->lod_info
.component
= imm(0);
3813 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3814 * inconsistent with both textureLodOffset and textureGradOffset.
3816 if (opcode
== ir_txb
) {
3817 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3818 sig
->parameters
.push_tail(bias
);
3819 tex
->lod_info
.bias
= var_ref(bias
);
3822 body
.emit(ret(tex
));
3827 ir_function_signature
*
3828 builtin_builder::_textureCubeArrayShadow()
3830 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3831 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3832 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3833 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3835 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3836 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3838 tex
->coordinate
= var_ref(P
);
3839 tex
->shadow_comparitor
= var_ref(compare
);
3841 body
.emit(ret(tex
));
3846 ir_function_signature
*
3847 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3848 const glsl_type
*return_type
,
3849 const glsl_type
*sampler_type
,
3850 const glsl_type
*coord_type
,
3851 const glsl_type
*offset_type
)
3853 ir_variable
*s
= in_var(sampler_type
, "sampler");
3854 ir_variable
*P
= in_var(coord_type
, "P");
3855 /* The sampler and coordinate always exist; add optional parameters later. */
3856 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3858 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3859 tex
->coordinate
= var_ref(P
);
3860 tex
->set_sampler(var_ref(s
), return_type
);
3862 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3863 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3864 sig
->parameters
.push_tail(sample
);
3865 tex
->lod_info
.sample_index
= var_ref(sample
);
3866 tex
->op
= ir_txf_ms
;
3867 } else if (has_lod(sampler_type
)) {
3868 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3869 sig
->parameters
.push_tail(lod
);
3870 tex
->lod_info
.lod
= var_ref(lod
);
3872 tex
->lod_info
.lod
= imm(0u);
3875 if (offset_type
!= NULL
) {
3876 ir_variable
*offset
=
3877 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3878 sig
->parameters
.push_tail(offset
);
3879 tex
->offset
= var_ref(offset
);
3882 body
.emit(ret(tex
));
3887 ir_function_signature
*
3888 builtin_builder::_EmitVertex()
3890 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3892 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
3893 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
3898 ir_function_signature
*
3899 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
3900 const glsl_type
*stream_type
)
3902 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
3904 * "Emit the current values of output variables to the current output
3905 * primitive on stream stream. The argument to stream must be a constant
3906 * integral expression."
3908 ir_variable
*stream
=
3909 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
3911 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
3913 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
3918 ir_function_signature
*
3919 builtin_builder::_EndPrimitive()
3921 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3923 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
3924 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
3929 ir_function_signature
*
3930 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
3931 const glsl_type
*stream_type
)
3933 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
3935 * "Completes the current output primitive on stream stream and starts
3936 * a new one. The argument to stream must be a constant integral
3939 ir_variable
*stream
=
3940 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
3942 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
3944 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
3949 ir_function_signature
*
3950 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3951 const glsl_type
*coord_type
)
3953 ir_variable
*s
= in_var(sampler_type
, "sampler");
3954 ir_variable
*coord
= in_var(coord_type
, "coord");
3955 /* The sampler and coordinate always exist; add optional parameters later. */
3956 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3958 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3959 tex
->coordinate
= var_ref(coord
);
3960 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3962 body
.emit(ret(tex
));
3967 ir_function_signature
*
3968 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
3970 ir_variable
*s
= in_var(sampler_type
, "sampler");
3971 const glsl_type
*return_type
= glsl_type::int_type
;
3972 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
3974 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
3975 tex
->set_sampler(var_ref(s
), return_type
);
3977 body
.emit(ret(tex
));
3982 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3983 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3985 ir_function_signature
*
3986 builtin_builder::_fwidth(const glsl_type
*type
)
3988 ir_variable
*p
= in_var(type
, "p");
3989 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3991 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3996 ir_function_signature
*
3997 builtin_builder::_noise1(const glsl_type
*type
)
3999 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4002 ir_function_signature
*
4003 builtin_builder::_noise2(const glsl_type
*type
)
4005 ir_variable
*p
= in_var(type
, "p");
4006 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4008 ir_constant_data b_offset
;
4009 b_offset
.f
[0] = 601.0f
;
4010 b_offset
.f
[1] = 313.0f
;
4011 b_offset
.f
[2] = 29.0f
;
4012 b_offset
.f
[3] = 277.0f
;
4014 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4015 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4016 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4017 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4018 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4019 body
.emit(assign(t
, a
, WRITEMASK_X
));
4020 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4026 ir_function_signature
*
4027 builtin_builder::_noise3(const glsl_type
*type
)
4029 ir_variable
*p
= in_var(type
, "p");
4030 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4032 ir_constant_data b_offset
;
4033 b_offset
.f
[0] = 601.0f
;
4034 b_offset
.f
[1] = 313.0f
;
4035 b_offset
.f
[2] = 29.0f
;
4036 b_offset
.f
[3] = 277.0f
;
4038 ir_constant_data c_offset
;
4039 c_offset
.f
[0] = 1559.0f
;
4040 c_offset
.f
[1] = 113.0f
;
4041 c_offset
.f
[2] = 1861.0f
;
4042 c_offset
.f
[3] = 797.0f
;
4044 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4045 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4046 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4047 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4048 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4049 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4050 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4051 body
.emit(assign(t
, a
, WRITEMASK_X
));
4052 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4053 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4059 ir_function_signature
*
4060 builtin_builder::_noise4(const glsl_type
*type
)
4062 ir_variable
*p
= in_var(type
, "p");
4063 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4065 ir_variable
*_p
= body
.make_temp(type
, "_p");
4067 ir_constant_data p_offset
;
4068 p_offset
.f
[0] = 1559.0f
;
4069 p_offset
.f
[1] = 113.0f
;
4070 p_offset
.f
[2] = 1861.0f
;
4071 p_offset
.f
[3] = 797.0f
;
4073 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4075 ir_constant_data offset
;
4076 offset
.f
[0] = 601.0f
;
4077 offset
.f
[1] = 313.0f
;
4078 offset
.f
[2] = 29.0f
;
4079 offset
.f
[3] = 277.0f
;
4081 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4082 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4083 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4084 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4085 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4086 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4087 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4088 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4089 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4090 body
.emit(assign(t
, a
, WRITEMASK_X
));
4091 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4092 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4093 body
.emit(assign(t
, d
, WRITEMASK_W
));
4099 ir_function_signature
*
4100 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4102 ir_variable
*value
= in_var(type
, "value");
4103 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4104 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4105 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
4107 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4112 ir_function_signature
*
4113 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4115 ir_variable
*base
= in_var(type
, "base");
4116 ir_variable
*insert
= in_var(type
, "insert");
4117 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4118 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4119 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
4121 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4126 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
4128 ir_function_signature
*
4129 builtin_builder::_bitCount(const glsl_type
*type
)
4131 return unop(gpu_shader5
, ir_unop_bit_count
,
4132 glsl_type::ivec(type
->vector_elements
), type
);
4135 ir_function_signature
*
4136 builtin_builder::_findLSB(const glsl_type
*type
)
4138 return unop(gpu_shader5
, ir_unop_find_lsb
,
4139 glsl_type::ivec(type
->vector_elements
), type
);
4142 ir_function_signature
*
4143 builtin_builder::_findMSB(const glsl_type
*type
)
4145 return unop(gpu_shader5
, ir_unop_find_msb
,
4146 glsl_type::ivec(type
->vector_elements
), type
);
4149 ir_function_signature
*
4150 builtin_builder::_fma(const glsl_type
*type
)
4152 ir_variable
*a
= in_var(type
, "a");
4153 ir_variable
*b
= in_var(type
, "b");
4154 ir_variable
*c
= in_var(type
, "c");
4155 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
4157 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4162 ir_function_signature
*
4163 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4165 return binop(ir_binop_ldexp
, gpu_shader5
, x_type
, x_type
, exp_type
);
4168 ir_function_signature
*
4169 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4171 ir_variable
*x
= in_var(x_type
, "x");
4172 ir_variable
*exponent
= out_var(exp_type
, "exp");
4173 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
4175 const unsigned vec_elem
= x_type
->vector_elements
;
4176 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4177 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4179 /* Single-precision floating-point values are stored as
4184 * An exponent shift of 23 will shift the mantissa out, leaving only the
4185 * exponent and sign bit (which itself may be zero, if the absolute value
4186 * was taken before the bitcast and shift.
4188 ir_constant
*exponent_shift
= imm(23);
4189 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4191 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4193 /* Exponent of floating-point values in the range [0.5, 1.0). */
4194 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4196 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4197 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4199 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4200 * to unsigned integers to ensure that 1 bits aren't shifted in.
4202 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4203 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4204 imm(0, vec_elem
)))));
4206 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4207 body
.emit(assign(bits
, bitcast_f2u(x
)));
4208 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4209 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4210 imm(0u, vec_elem
)))));
4211 body
.emit(ret(bitcast_u2f(bits
)));
4216 ir_function_signature
*
4217 builtin_builder::_uaddCarry(const glsl_type
*type
)
4219 ir_variable
*x
= in_var(type
, "x");
4220 ir_variable
*y
= in_var(type
, "y");
4221 ir_variable
*carry
= out_var(type
, "carry");
4222 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
4224 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4225 body
.emit(ret(add(x
, y
)));
4230 ir_function_signature
*
4231 builtin_builder::_usubBorrow(const glsl_type
*type
)
4233 ir_variable
*x
= in_var(type
, "x");
4234 ir_variable
*y
= in_var(type
, "y");
4235 ir_variable
*borrow
= out_var(type
, "borrow");
4236 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
4238 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4239 body
.emit(ret(sub(x
, y
)));
4245 * For both imulExtended() and umulExtended() built-ins.
4247 ir_function_signature
*
4248 builtin_builder::_mulExtended(const glsl_type
*type
)
4250 ir_variable
*x
= in_var(type
, "x");
4251 ir_variable
*y
= in_var(type
, "y");
4252 ir_variable
*msb
= out_var(type
, "msb");
4253 ir_variable
*lsb
= out_var(type
, "lsb");
4254 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
4256 body
.emit(assign(msb
, imul_high(x
, y
)));
4257 body
.emit(assign(lsb
, mul(x
, y
)));
4262 ir_function_signature
*
4263 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4265 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4266 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4270 ir_function_signature
*
4271 builtin_builder::_atomic_op(const char *intrinsic
,
4272 builtin_available_predicate avail
)
4274 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4275 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4277 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4278 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4280 body
.emit(ret(retval
));
4284 ir_function_signature
*
4285 builtin_builder::_min3(const glsl_type
*type
)
4287 ir_variable
*x
= in_var(type
, "x");
4288 ir_variable
*y
= in_var(type
, "y");
4289 ir_variable
*z
= in_var(type
, "z");
4290 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4292 ir_expression
*min3
= min2(x
, min2(y
,z
));
4293 body
.emit(ret(min3
));
4298 ir_function_signature
*
4299 builtin_builder::_max3(const glsl_type
*type
)
4301 ir_variable
*x
= in_var(type
, "x");
4302 ir_variable
*y
= in_var(type
, "y");
4303 ir_variable
*z
= in_var(type
, "z");
4304 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4306 ir_expression
*max3
= max2(x
, max2(y
,z
));
4307 body
.emit(ret(max3
));
4312 ir_function_signature
*
4313 builtin_builder::_mid3(const glsl_type
*type
)
4315 ir_variable
*x
= in_var(type
, "x");
4316 ir_variable
*y
= in_var(type
, "y");
4317 ir_variable
*z
= in_var(type
, "z");
4318 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4320 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4321 body
.emit(ret(mid3
));
4326 ir_function_signature
*
4327 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4328 const char *intrinsic_name
,
4329 unsigned num_arguments
,
4332 const glsl_type
*data_type
= glsl_type::get_instance(
4333 image_type
->sampler_type
,
4334 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4336 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4337 glsl_type::void_type
: data_type
);
4339 /* Addressing arguments that are always present. */
4340 ir_variable
*image
= in_var(image_type
, "image");
4341 ir_variable
*coord
= in_var(
4342 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4344 ir_function_signature
*sig
= new_sig(
4345 ret_type
, shader_image_load_store
, 2, image
, coord
);
4347 /* Sample index for multisample images. */
4348 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4349 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4351 /* Data arguments. */
4352 for (unsigned i
= 0; i
< num_arguments
; ++i
)
4353 sig
->parameters
.push_tail(in_var(data_type
,
4354 ralloc_asprintf(NULL
, "arg%d", i
)));
4356 /* Set the maximal set of qualifiers allowed for this image
4357 * built-in. Function calls with arguments having fewer
4358 * qualifiers than present in the prototype are allowed by the
4359 * spec, but not with more, i.e. this will make the compiler
4360 * accept everything that needs to be accepted, and reject cases
4361 * like loads from write-only or stores to read-only images.
4363 image
->data
.image
.read_only
= flags
& IMAGE_FUNCTION_READ_ONLY
;
4364 image
->data
.image
.write_only
= flags
& IMAGE_FUNCTION_WRITE_ONLY
;
4365 image
->data
.image
.coherent
= true;
4366 image
->data
.image
._volatile
= true;
4367 image
->data
.image
.restrict_flag
= true;
4372 ir_function_signature
*
4373 builtin_builder::_image(const glsl_type
*image_type
,
4374 const char *intrinsic_name
,
4375 unsigned num_arguments
,
4378 ir_function_signature
*sig
= _image_prototype(image_type
, intrinsic_name
,
4379 num_arguments
, flags
);
4381 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
4382 ir_factory
body(&sig
->body
, mem_ctx
);
4383 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
4385 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
4386 body
.emit(call(f
, NULL
, sig
->parameters
));
4388 ir_variable
*ret_val
=
4389 body
.make_temp(sig
->return_type
, "_ret_val");
4390 body
.emit(call(f
, ret_val
, sig
->parameters
));
4391 body
.emit(ret(ret_val
));
4394 sig
->is_defined
= true;
4397 sig
->is_intrinsic
= true;
4403 ir_function_signature
*
4404 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
4406 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
4410 ir_function_signature
*
4411 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
4413 MAKE_SIG(glsl_type::void_type
, avail
, 0);
4414 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
4415 NULL
, sig
->parameters
));
4421 /******************************************************************************/
4423 /* The singleton instance of builtin_builder. */
4424 static builtin_builder builtins
;
4425 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
4428 * External API (exposing the built-in module to the rest of the compiler):
4432 _mesa_glsl_initialize_builtin_functions()
4434 mtx_lock(&builtins_lock
);
4435 builtins
.initialize();
4436 mtx_unlock(&builtins_lock
);
4440 _mesa_glsl_release_builtin_functions()
4442 mtx_lock(&builtins_lock
);
4444 mtx_unlock(&builtins_lock
);
4447 ir_function_signature
*
4448 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4449 const char *name
, exec_list
*actual_parameters
)
4451 ir_function_signature
* s
;
4452 mtx_lock(&builtins_lock
);
4453 s
= builtins
.find(state
, name
, actual_parameters
);
4454 mtx_unlock(&builtins_lock
);
4459 _mesa_glsl_get_builtin_function_shader()
4461 return builtins
.shader
;