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 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
231 return state
->stage
== MESA_SHADER_FRAGMENT
&&
232 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
237 texture_array_lod(const _mesa_glsl_parse_state
*state
)
239 return lod_exists_in_stage(state
) &&
240 state
->EXT_texture_array_enable
;
244 fs_texture_array(const _mesa_glsl_parse_state
*state
)
246 return state
->stage
== MESA_SHADER_FRAGMENT
&&
247 state
->EXT_texture_array_enable
;
251 texture_array(const _mesa_glsl_parse_state
*state
)
253 return state
->EXT_texture_array_enable
;
257 texture_multisample(const _mesa_glsl_parse_state
*state
)
259 return state
->is_version(150, 0) ||
260 state
->ARB_texture_multisample_enable
;
264 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
266 return state
->stage
== MESA_SHADER_FRAGMENT
&&
267 (state
->is_version(400, 0) ||
268 state
->ARB_texture_cube_map_array_enable
);
272 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
274 return state
->is_version(400, 0) ||
275 state
->ARB_texture_cube_map_array_enable
;
279 texture_query_levels(const _mesa_glsl_parse_state
*state
)
281 return state
->is_version(430, 0) ||
282 state
->ARB_texture_query_levels_enable
;
286 texture_query_lod(const _mesa_glsl_parse_state
*state
)
288 return state
->stage
== MESA_SHADER_FRAGMENT
&&
289 state
->ARB_texture_query_lod_enable
;
293 texture_gather(const _mesa_glsl_parse_state
*state
)
295 return state
->is_version(400, 0) ||
296 state
->ARB_texture_gather_enable
||
297 state
->ARB_gpu_shader5_enable
;
300 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
301 * used for relaxation of const offset requirements.
304 texture_gather_only(const _mesa_glsl_parse_state
*state
)
306 return !state
->is_version(400, 0) &&
307 !state
->ARB_gpu_shader5_enable
&&
308 state
->ARB_texture_gather_enable
;
311 /* Desktop GL or OES_standard_derivatives + fragment shader only */
313 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
315 return state
->stage
== MESA_SHADER_FRAGMENT
&&
316 (state
->is_version(110, 300) ||
317 state
->OES_standard_derivatives_enable
);
321 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
323 return state
->stage
== MESA_SHADER_FRAGMENT
&&
324 (state
->is_version(450, 0) ||
325 state
->ARB_derivative_control_enable
);
329 tex1d_lod(const _mesa_glsl_parse_state
*state
)
331 return !state
->es_shader
&& lod_exists_in_stage(state
);
334 /** True if sampler3D exists */
336 tex3d(const _mesa_glsl_parse_state
*state
)
338 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
339 * OES_texture_3D extension, and in GLSL ES 3.00.
341 return !state
->es_shader
||
342 state
->OES_texture_3D_enable
||
343 state
->language_version
>= 300;
347 fs_tex3d(const _mesa_glsl_parse_state
*state
)
349 return state
->stage
== MESA_SHADER_FRAGMENT
&&
350 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
354 tex3d_lod(const _mesa_glsl_parse_state
*state
)
356 return tex3d(state
) && lod_exists_in_stage(state
);
360 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
362 return state
->ARB_shader_atomic_counters_enable
;
366 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
368 return state
->AMD_shader_trinary_minmax_enable
;
372 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
374 return (state
->is_version(420, 0) ||
375 state
->ARB_shader_image_load_store_enable
);
379 gs_streams(const _mesa_glsl_parse_state
*state
)
381 return gpu_shader5(state
) && gs_only(state
);
386 /******************************************************************************/
391 * builtin_builder: A singleton object representing the core of the built-in
394 * It generates IR for every built-in function signature, and organizes them
397 class builtin_builder
{
404 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
405 const char *name
, exec_list
*actual_parameters
);
408 * A shader to hold all the built-in signatures; created by this module.
410 * This includes signatures for every built-in, regardless of version or
411 * enabled extensions. The availability predicate associated with each
412 * signature allows matching_signature() to filter out the irrelevant ones.
419 /** Global variables used by built-in functions. */
420 ir_variable
*gl_ModelViewProjectionMatrix
;
421 ir_variable
*gl_Vertex
;
423 void create_shader();
424 void create_intrinsics();
425 void create_builtins();
428 * IR builder helpers:
430 * These convenience functions assist in emitting IR, but don't necessarily
431 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
434 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
435 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
436 ir_constant
*imm(float f
, unsigned vector_elements
=1);
437 ir_constant
*imm(int i
, unsigned vector_elements
=1);
438 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
439 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
440 ir_dereference_variable
*var_ref(ir_variable
*var
);
441 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
442 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
444 ir_expression
*asin_expr(ir_variable
*x
);
445 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
448 * Call function \param f with parameters specified as the linked
449 * list \param params of \c ir_variable objects. \param ret should
450 * point to the ir_variable that will hold the function return
451 * value, or be \c NULL if the function has void return type.
453 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
455 /** Create a new function and add the given signatures. */
456 void add_function(const char *name
, ...);
458 enum image_function_flags
{
459 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
460 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
461 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
462 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
463 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
464 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5)
468 * Create a new image built-in function for all known image types.
469 * \p flags is a bitfield of \c image_function_flags flags.
471 void add_image_function(const char *name
,
472 const char *intrinsic_name
,
473 unsigned num_arguments
,
477 * Create new functions for all known image built-ins and types.
478 * If \p glsl is \c true, use the GLSL built-in names and emit code
479 * to call into the actual compiler intrinsic. If \p glsl is
480 * false, emit a function prototype with no body for each image
483 void add_image_functions(bool glsl
);
485 ir_function_signature
*new_sig(const glsl_type
*return_type
,
486 builtin_available_predicate avail
,
487 int num_params
, ...);
490 * Function signature generators:
493 ir_function_signature
*unop(builtin_available_predicate avail
,
494 ir_expression_operation opcode
,
495 const glsl_type
*return_type
,
496 const glsl_type
*param_type
);
497 ir_function_signature
*binop(ir_expression_operation opcode
,
498 builtin_available_predicate avail
,
499 const glsl_type
*return_type
,
500 const glsl_type
*param0_type
,
501 const glsl_type
*param1_type
);
503 #define B0(X) ir_function_signature *_##X();
504 #define B1(X) ir_function_signature *_##X(const glsl_type *);
505 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
506 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
507 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
508 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
545 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
546 const glsl_type
*val_type
,
547 const glsl_type
*blend_type
);
556 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
557 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
558 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
559 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
560 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
561 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
562 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
563 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
564 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
565 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
577 B0(determinant_mat2
);
578 B0(determinant_mat3
);
579 B0(determinant_mat4
);
587 BA1(greaterThanEqual
);
594 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
595 const glsl_type
*return_type
,
596 const glsl_type
*sampler_type
);
598 /** Flags to _texture() */
599 #define TEX_PROJECT 1
601 #define TEX_COMPONENT 4
602 #define TEX_OFFSET_NONCONST 8
603 #define TEX_OFFSET_ARRAY 16
605 ir_function_signature
*_texture(ir_texture_opcode opcode
,
606 builtin_available_predicate avail
,
607 const glsl_type
*return_type
,
608 const glsl_type
*sampler_type
,
609 const glsl_type
*coord_type
,
611 B0(textureCubeArrayShadow
);
612 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
613 const glsl_type
*return_type
,
614 const glsl_type
*sampler_type
,
615 const glsl_type
*coord_type
,
616 const glsl_type
*offset_type
= NULL
);
620 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
621 const glsl_type
*stream_type
);
622 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
623 const glsl_type
*stream_type
);
626 B1(textureQueryLevels
);
653 B1(interpolateAtCentroid
)
654 B1(interpolateAtOffset
)
655 B1(interpolateAtSample
)
657 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
658 ir_function_signature
*_atomic_op(const char *intrinsic
,
659 builtin_available_predicate avail
);
665 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
666 const char *intrinsic_name
,
667 unsigned num_arguments
,
669 ir_function_signature
*_image(const glsl_type
*image_type
,
670 const char *intrinsic_name
,
671 unsigned num_arguments
,
674 ir_function_signature
*_memory_barrier_intrinsic(
675 builtin_available_predicate avail
);
676 ir_function_signature
*_memory_barrier(
677 builtin_available_predicate avail
);
688 } /* anonymous namespace */
691 * Core builtin_builder functionality:
694 builtin_builder::builtin_builder()
696 gl_ModelViewProjectionMatrix(NULL
),
702 builtin_builder::~builtin_builder()
704 ralloc_free(mem_ctx
);
707 ir_function_signature
*
708 builtin_builder::find(_mesa_glsl_parse_state
*state
,
709 const char *name
, exec_list
*actual_parameters
)
711 /* The shader currently being compiled requested a built-in function;
712 * it needs to link against builtin_builder::shader in order to get them.
714 * Even if we don't find a matching signature, we still need to do this so
715 * that the "no matching signature" error will list potential candidates
716 * from the available built-ins.
718 state
->uses_builtin_functions
= true;
720 ir_function
*f
= shader
->symbols
->get_function(name
);
724 ir_function_signature
*sig
=
725 f
->matching_signature(state
, actual_parameters
, true);
733 builtin_builder::initialize()
735 /* If already initialized, don't do it again. */
739 mem_ctx
= ralloc_context(NULL
);
746 builtin_builder::release()
748 ralloc_free(mem_ctx
);
756 builtin_builder::create_shader()
758 /* The target doesn't actually matter. There's no target for generic
759 * GLSL utility code that could be linked against any stage, so just
760 * arbitrarily pick GL_VERTEX_SHADER.
762 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
763 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
765 gl_ModelViewProjectionMatrix
=
766 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
767 "gl_ModelViewProjectionMatrix",
770 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
772 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
773 shader
->symbols
->add_variable(gl_Vertex
);
779 * Create ir_function and ir_function_signature objects for each
783 builtin_builder::create_intrinsics()
785 add_function("__intrinsic_atomic_read",
786 _atomic_intrinsic(shader_atomic_counters
),
788 add_function("__intrinsic_atomic_increment",
789 _atomic_intrinsic(shader_atomic_counters
),
791 add_function("__intrinsic_atomic_predecrement",
792 _atomic_intrinsic(shader_atomic_counters
),
795 add_image_functions(false);
797 add_function("__intrinsic_memory_barrier",
798 _memory_barrier_intrinsic(shader_image_load_store
),
803 * Create ir_function and ir_function_signature objects for each built-in.
805 * Contains a list of every available built-in.
808 builtin_builder::create_builtins()
811 add_function(#NAME, \
812 _##NAME(glsl_type::float_type), \
813 _##NAME(glsl_type::vec2_type), \
814 _##NAME(glsl_type::vec3_type), \
815 _##NAME(glsl_type::vec4_type), \
819 add_function(#NAME, \
820 _##NAME(glsl_type::float_type), \
821 _##NAME(glsl_type::vec2_type), \
822 _##NAME(glsl_type::vec3_type), \
823 _##NAME(glsl_type::vec4_type), \
824 _##NAME(glsl_type::int_type), \
825 _##NAME(glsl_type::ivec2_type), \
826 _##NAME(glsl_type::ivec3_type), \
827 _##NAME(glsl_type::ivec4_type), \
831 add_function(#NAME, \
832 _##NAME(always_available, glsl_type::float_type), \
833 _##NAME(always_available, glsl_type::vec2_type), \
834 _##NAME(always_available, glsl_type::vec3_type), \
835 _##NAME(always_available, glsl_type::vec4_type), \
837 _##NAME(always_available, glsl_type::int_type), \
838 _##NAME(always_available, glsl_type::ivec2_type), \
839 _##NAME(always_available, glsl_type::ivec3_type), \
840 _##NAME(always_available, glsl_type::ivec4_type), \
842 _##NAME(v130, glsl_type::uint_type), \
843 _##NAME(v130, glsl_type::uvec2_type), \
844 _##NAME(v130, glsl_type::uvec3_type), \
845 _##NAME(v130, glsl_type::uvec4_type), \
849 add_function(#NAME, \
850 _##NAME(glsl_type::int_type), \
851 _##NAME(glsl_type::ivec2_type), \
852 _##NAME(glsl_type::ivec3_type), \
853 _##NAME(glsl_type::ivec4_type), \
855 _##NAME(glsl_type::uint_type), \
856 _##NAME(glsl_type::uvec2_type), \
857 _##NAME(glsl_type::uvec3_type), \
858 _##NAME(glsl_type::uvec4_type), \
862 add_function(#NAME, \
863 _##NAME(always_available, glsl_type::float_type), \
864 _##NAME(always_available, glsl_type::vec2_type), \
865 _##NAME(always_available, glsl_type::vec3_type), \
866 _##NAME(always_available, glsl_type::vec4_type), \
868 _##NAME(always_available, glsl_type::int_type), \
869 _##NAME(always_available, glsl_type::ivec2_type), \
870 _##NAME(always_available, glsl_type::ivec3_type), \
871 _##NAME(always_available, glsl_type::ivec4_type), \
873 _##NAME(v130, glsl_type::uint_type), \
874 _##NAME(v130, glsl_type::uvec2_type), \
875 _##NAME(v130, glsl_type::uvec3_type), \
876 _##NAME(v130, glsl_type::uvec4_type), \
878 _##NAME(always_available, glsl_type::bool_type), \
879 _##NAME(always_available, glsl_type::bvec2_type), \
880 _##NAME(always_available, glsl_type::bvec3_type), \
881 _##NAME(always_available, glsl_type::bvec4_type), \
884 #define FIU2_MIXED(NAME) \
885 add_function(#NAME, \
886 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
887 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
888 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
889 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
891 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
892 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
893 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
895 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
896 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
897 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
898 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
900 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
901 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
902 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
904 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
905 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
906 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
907 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
909 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
910 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
911 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
923 _atan(glsl_type::float_type
),
924 _atan(glsl_type::vec2_type
),
925 _atan(glsl_type::vec3_type
),
926 _atan(glsl_type::vec4_type
),
927 _atan2(glsl_type::float_type
),
928 _atan2(glsl_type::vec2_type
),
929 _atan2(glsl_type::vec3_type
),
930 _atan2(glsl_type::vec4_type
),
956 _mod(glsl_type::float_type
, glsl_type::float_type
),
957 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
958 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
959 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
961 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
962 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
963 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
973 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
974 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
975 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
976 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
978 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
979 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
980 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
982 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
983 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
984 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
985 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
987 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
988 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
989 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
990 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
992 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
993 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
994 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
995 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
997 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
998 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
999 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1000 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1003 add_function("step",
1004 _step(glsl_type::float_type
, glsl_type::float_type
),
1005 _step(glsl_type::float_type
, glsl_type::vec2_type
),
1006 _step(glsl_type::float_type
, glsl_type::vec3_type
),
1007 _step(glsl_type::float_type
, glsl_type::vec4_type
),
1009 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
1010 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
1011 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
1014 add_function("smoothstep",
1015 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
1016 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
1017 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
1018 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
1020 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
1021 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
1022 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
1030 add_function("intBitsToFloat",
1031 _intBitsToFloat(glsl_type::int_type
),
1032 _intBitsToFloat(glsl_type::ivec2_type
),
1033 _intBitsToFloat(glsl_type::ivec3_type
),
1034 _intBitsToFloat(glsl_type::ivec4_type
),
1036 add_function("uintBitsToFloat",
1037 _uintBitsToFloat(glsl_type::uint_type
),
1038 _uintBitsToFloat(glsl_type::uvec2_type
),
1039 _uintBitsToFloat(glsl_type::uvec3_type
),
1040 _uintBitsToFloat(glsl_type::uvec4_type
),
1043 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1044 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1045 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1046 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1047 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1048 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1049 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1050 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_gpu_shader5
), NULL
);
1051 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1052 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1058 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
1061 add_function("ftransform", _ftransform(), NULL
);
1066 add_function("matrixCompMult",
1067 _matrixCompMult(glsl_type::mat2_type
),
1068 _matrixCompMult(glsl_type::mat3_type
),
1069 _matrixCompMult(glsl_type::mat4_type
),
1070 _matrixCompMult(glsl_type::mat2x3_type
),
1071 _matrixCompMult(glsl_type::mat2x4_type
),
1072 _matrixCompMult(glsl_type::mat3x2_type
),
1073 _matrixCompMult(glsl_type::mat3x4_type
),
1074 _matrixCompMult(glsl_type::mat4x2_type
),
1075 _matrixCompMult(glsl_type::mat4x3_type
),
1077 add_function("outerProduct",
1078 _outerProduct(glsl_type::mat2_type
),
1079 _outerProduct(glsl_type::mat3_type
),
1080 _outerProduct(glsl_type::mat4_type
),
1081 _outerProduct(glsl_type::mat2x3_type
),
1082 _outerProduct(glsl_type::mat2x4_type
),
1083 _outerProduct(glsl_type::mat3x2_type
),
1084 _outerProduct(glsl_type::mat3x4_type
),
1085 _outerProduct(glsl_type::mat4x2_type
),
1086 _outerProduct(glsl_type::mat4x3_type
),
1088 add_function("determinant",
1089 _determinant_mat2(),
1090 _determinant_mat3(),
1091 _determinant_mat4(),
1093 add_function("inverse",
1098 add_function("transpose",
1099 _transpose(glsl_type::mat2_type
),
1100 _transpose(glsl_type::mat3_type
),
1101 _transpose(glsl_type::mat4_type
),
1102 _transpose(glsl_type::mat2x3_type
),
1103 _transpose(glsl_type::mat2x4_type
),
1104 _transpose(glsl_type::mat3x2_type
),
1105 _transpose(glsl_type::mat3x4_type
),
1106 _transpose(glsl_type::mat4x2_type
),
1107 _transpose(glsl_type::mat4x3_type
),
1112 FIU(greaterThanEqual
)
1117 _any(glsl_type::bvec2_type
),
1118 _any(glsl_type::bvec3_type
),
1119 _any(glsl_type::bvec4_type
),
1123 _all(glsl_type::bvec2_type
),
1124 _all(glsl_type::bvec3_type
),
1125 _all(glsl_type::bvec4_type
),
1129 _not(glsl_type::bvec2_type
),
1130 _not(glsl_type::bvec3_type
),
1131 _not(glsl_type::bvec4_type
),
1134 add_function("textureSize",
1135 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1136 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1137 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1139 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1140 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1141 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1143 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1144 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1145 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1147 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1148 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1149 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1151 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1152 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1153 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1155 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1156 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1157 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1158 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1159 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1160 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1162 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1163 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1165 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1166 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1167 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1168 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1170 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1171 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1172 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1173 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1175 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1176 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1177 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1178 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1179 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1180 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1182 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1183 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1184 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1187 add_function("texture",
1188 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1189 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1190 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1192 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1193 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1194 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1196 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1197 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1198 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1200 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1201 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1202 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1204 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1205 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1206 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1208 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1209 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1210 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1212 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1213 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1214 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1216 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1217 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1218 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1220 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1221 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1222 /* samplerCubeArrayShadow is special; it has an extra parameter
1223 * for the shadow comparitor since there is no vec5 type.
1225 _textureCubeArrayShadow(),
1227 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1228 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1229 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1231 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1233 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1234 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1235 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1237 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1238 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1239 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1241 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1242 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1243 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1245 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1246 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1247 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1249 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1250 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1251 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1253 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1254 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1255 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1257 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1258 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1259 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1261 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1262 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1263 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1265 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1268 add_function("textureLod",
1269 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1270 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1271 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1273 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1274 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1275 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1277 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1278 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1279 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1281 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1282 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1283 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1285 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1286 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1288 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1289 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1290 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1292 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1293 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1294 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1296 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1297 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1298 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1300 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1303 add_function("textureOffset",
1304 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1305 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1306 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1308 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1309 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1310 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1312 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1313 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1314 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1316 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1317 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1318 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1320 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1322 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1323 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1325 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1326 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1327 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1329 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1330 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1331 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1333 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1335 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1336 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1337 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1339 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1340 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1341 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1343 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1344 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1345 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1347 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1348 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1350 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1351 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1352 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1354 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1355 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1356 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1358 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1361 add_function("textureProj",
1362 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1363 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1364 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1365 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1366 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1367 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1369 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1370 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1371 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1372 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1373 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1374 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1376 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1377 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1378 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1380 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1381 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1383 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1384 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1385 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1386 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1387 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1388 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1390 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1392 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1393 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1394 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1395 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1396 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1397 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1399 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1400 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1401 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1402 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1403 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1404 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1406 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1407 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1408 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1410 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1411 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1414 add_function("texelFetch",
1415 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1416 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1417 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1419 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1420 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1421 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1423 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1424 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1425 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1427 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1428 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1429 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1431 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1432 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1433 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1435 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1436 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1437 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1439 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1440 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1441 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1443 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1444 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1445 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1447 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1448 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1449 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1452 add_function("texelFetchOffset",
1453 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1454 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1455 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1457 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1458 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1459 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1461 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1462 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1463 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1465 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1466 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1467 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1469 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1470 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1471 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1473 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1474 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1475 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1479 add_function("textureProjOffset",
1480 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1481 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1482 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1483 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1484 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1485 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1487 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1488 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1489 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1490 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1491 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1492 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1494 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1495 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1496 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1498 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1499 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1501 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1502 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1503 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1504 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1505 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1506 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1508 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1510 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1511 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1512 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1513 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1514 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1515 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1517 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1518 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1519 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1520 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1521 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1522 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1524 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1525 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1526 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1528 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1529 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1532 add_function("textureLodOffset",
1533 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1534 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1535 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1537 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1538 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1539 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1541 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1542 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1543 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1545 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1546 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1548 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1549 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1550 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1552 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1553 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1554 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1556 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1559 add_function("textureProjLod",
1560 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1561 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1562 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1563 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1564 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1565 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1567 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1568 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1569 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1570 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1571 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1572 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1574 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1575 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1576 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1578 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1579 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1582 add_function("textureProjLodOffset",
1583 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1584 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1585 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1586 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1587 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1588 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1590 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1591 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1592 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1593 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1594 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1595 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1597 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1598 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1599 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1601 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1602 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1605 add_function("textureGrad",
1606 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1607 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1608 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1610 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1611 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1612 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1614 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1615 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1616 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1618 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1619 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1620 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1622 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1623 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1624 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1626 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1628 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1629 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1630 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1632 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1633 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1634 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1636 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1637 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1638 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1640 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1641 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1642 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1644 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1645 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1648 add_function("textureGradOffset",
1649 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1650 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1651 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1653 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1654 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1655 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1657 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1658 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1659 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1661 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1662 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1663 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1665 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1667 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1668 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1670 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1671 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1672 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1674 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1675 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1676 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1678 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1679 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1682 add_function("textureProjGrad",
1683 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1684 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1685 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1686 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1687 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1688 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1690 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1691 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1692 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1693 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1694 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1695 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1697 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1698 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1699 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1701 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1702 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1703 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1704 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1705 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1706 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1708 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1710 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1711 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1714 add_function("textureProjGradOffset",
1715 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1716 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1717 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1718 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1719 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1720 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1722 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1723 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1724 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1725 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1726 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1727 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1729 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1730 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1731 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1733 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1734 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1735 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1736 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1737 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1738 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1740 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1742 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1743 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1746 add_function("EmitVertex", _EmitVertex(), NULL
);
1747 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1748 add_function("EmitStreamVertex",
1749 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1750 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1752 add_function("EndStreamPrimitive",
1753 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1754 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
1757 add_function("textureQueryLOD",
1758 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1759 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1760 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1762 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1763 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1764 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1766 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1767 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1768 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1770 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1771 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1772 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1774 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1775 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1776 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1778 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1779 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1780 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1782 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1783 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1784 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1786 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1787 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1788 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1789 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1790 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1791 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1794 add_function("textureQueryLevels",
1795 _textureQueryLevels(glsl_type::sampler1D_type
),
1796 _textureQueryLevels(glsl_type::sampler2D_type
),
1797 _textureQueryLevels(glsl_type::sampler3D_type
),
1798 _textureQueryLevels(glsl_type::samplerCube_type
),
1799 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1800 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1801 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1802 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1803 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1804 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1805 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1806 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1807 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1809 _textureQueryLevels(glsl_type::isampler1D_type
),
1810 _textureQueryLevels(glsl_type::isampler2D_type
),
1811 _textureQueryLevels(glsl_type::isampler3D_type
),
1812 _textureQueryLevels(glsl_type::isamplerCube_type
),
1813 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1814 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1815 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1817 _textureQueryLevels(glsl_type::usampler1D_type
),
1818 _textureQueryLevels(glsl_type::usampler2D_type
),
1819 _textureQueryLevels(glsl_type::usampler3D_type
),
1820 _textureQueryLevels(glsl_type::usamplerCube_type
),
1821 _textureQueryLevels(glsl_type::usampler1DArray_type
),
1822 _textureQueryLevels(glsl_type::usampler2DArray_type
),
1823 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
1827 add_function("texture1D",
1828 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1829 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1832 add_function("texture1DArray",
1833 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1834 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1837 add_function("texture1DProj",
1838 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1839 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1840 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1841 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1844 add_function("texture1DLod",
1845 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1848 add_function("texture1DArrayLod",
1849 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1852 add_function("texture1DProjLod",
1853 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1854 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1857 add_function("texture2D",
1858 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1859 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1860 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1863 add_function("texture2DArray",
1864 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1865 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1868 add_function("texture2DProj",
1869 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1870 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1871 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1872 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1873 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1874 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1877 add_function("texture2DLod",
1878 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1881 add_function("texture2DArrayLod",
1882 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1885 add_function("texture2DProjLod",
1886 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1887 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1890 add_function("texture3D",
1891 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1892 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1895 add_function("texture3DProj",
1896 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1897 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1900 add_function("texture3DLod",
1901 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1904 add_function("texture3DProjLod",
1905 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1908 add_function("textureCube",
1909 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1910 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1913 add_function("textureCubeLod",
1914 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1917 add_function("texture2DRect",
1918 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1921 add_function("texture2DRectProj",
1922 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1923 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1926 add_function("shadow1D",
1927 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1928 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1931 add_function("shadow1DArray",
1932 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1933 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1936 add_function("shadow2D",
1937 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1938 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1941 add_function("shadow2DArray",
1942 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1943 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1946 add_function("shadow1DProj",
1947 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1948 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1951 add_function("shadow2DProj",
1952 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1953 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1956 add_function("shadow1DLod",
1957 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1960 add_function("shadow2DLod",
1961 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1964 add_function("shadow1DArrayLod",
1965 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1968 add_function("shadow1DProjLod",
1969 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1972 add_function("shadow2DProjLod",
1973 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1976 add_function("shadow2DRect",
1977 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1980 add_function("shadow2DRectProj",
1981 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1984 add_function("texture1DGradARB",
1985 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1988 add_function("texture1DProjGradARB",
1989 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1990 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1993 add_function("texture2DGradARB",
1994 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1997 add_function("texture2DProjGradARB",
1998 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1999 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2002 add_function("texture3DGradARB",
2003 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2006 add_function("texture3DProjGradARB",
2007 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2010 add_function("textureCubeGradARB",
2011 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2014 add_function("shadow1DGradARB",
2015 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2018 add_function("shadow1DProjGradARB",
2019 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2022 add_function("shadow2DGradARB",
2023 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2026 add_function("shadow2DProjGradARB",
2027 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2030 add_function("texture2DRectGradARB",
2031 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2034 add_function("texture2DRectProjGradARB",
2035 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2036 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2039 add_function("shadow2DRectGradARB",
2040 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2043 add_function("shadow2DRectProjGradARB",
2044 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2047 add_function("textureGather",
2048 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2049 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2050 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2052 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2053 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2054 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2056 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2057 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2058 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2060 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2061 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2062 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2064 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2065 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2066 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2068 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2069 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2070 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2072 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2073 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2074 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2076 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2077 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2078 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2080 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2081 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2082 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2084 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2085 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2086 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2088 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2089 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2090 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2091 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2092 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2095 add_function("textureGatherOffset",
2096 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2097 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2098 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2100 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2101 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2102 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2104 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2105 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2106 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2108 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2109 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2110 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2112 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2113 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2114 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2116 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2117 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2118 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2120 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2121 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2122 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2124 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2125 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2126 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2128 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2129 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2130 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2133 add_function("textureGatherOffsets",
2134 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2135 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2136 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2138 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2139 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2140 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2142 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2143 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2144 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2146 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2147 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2148 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2150 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2151 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2152 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2154 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2155 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2156 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2158 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2159 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2160 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2185 add_function("ldexp",
2186 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2187 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2188 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2189 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2192 add_function("frexp",
2193 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2194 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2195 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2196 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2198 add_function("uaddCarry",
2199 _uaddCarry(glsl_type::uint_type
),
2200 _uaddCarry(glsl_type::uvec2_type
),
2201 _uaddCarry(glsl_type::uvec3_type
),
2202 _uaddCarry(glsl_type::uvec4_type
),
2204 add_function("usubBorrow",
2205 _usubBorrow(glsl_type::uint_type
),
2206 _usubBorrow(glsl_type::uvec2_type
),
2207 _usubBorrow(glsl_type::uvec3_type
),
2208 _usubBorrow(glsl_type::uvec4_type
),
2210 add_function("imulExtended",
2211 _mulExtended(glsl_type::int_type
),
2212 _mulExtended(glsl_type::ivec2_type
),
2213 _mulExtended(glsl_type::ivec3_type
),
2214 _mulExtended(glsl_type::ivec4_type
),
2216 add_function("umulExtended",
2217 _mulExtended(glsl_type::uint_type
),
2218 _mulExtended(glsl_type::uvec2_type
),
2219 _mulExtended(glsl_type::uvec3_type
),
2220 _mulExtended(glsl_type::uvec4_type
),
2222 add_function("interpolateAtCentroid",
2223 _interpolateAtCentroid(glsl_type::float_type
),
2224 _interpolateAtCentroid(glsl_type::vec2_type
),
2225 _interpolateAtCentroid(glsl_type::vec3_type
),
2226 _interpolateAtCentroid(glsl_type::vec4_type
),
2228 add_function("interpolateAtOffset",
2229 _interpolateAtOffset(glsl_type::float_type
),
2230 _interpolateAtOffset(glsl_type::vec2_type
),
2231 _interpolateAtOffset(glsl_type::vec3_type
),
2232 _interpolateAtOffset(glsl_type::vec4_type
),
2234 add_function("interpolateAtSample",
2235 _interpolateAtSample(glsl_type::float_type
),
2236 _interpolateAtSample(glsl_type::vec2_type
),
2237 _interpolateAtSample(glsl_type::vec3_type
),
2238 _interpolateAtSample(glsl_type::vec4_type
),
2241 add_function("atomicCounter",
2242 _atomic_op("__intrinsic_atomic_read",
2243 shader_atomic_counters
),
2245 add_function("atomicCounterIncrement",
2246 _atomic_op("__intrinsic_atomic_increment",
2247 shader_atomic_counters
),
2249 add_function("atomicCounterDecrement",
2250 _atomic_op("__intrinsic_atomic_predecrement",
2251 shader_atomic_counters
),
2254 add_function("min3",
2255 _min3(glsl_type::float_type
),
2256 _min3(glsl_type::vec2_type
),
2257 _min3(glsl_type::vec3_type
),
2258 _min3(glsl_type::vec4_type
),
2260 _min3(glsl_type::int_type
),
2261 _min3(glsl_type::ivec2_type
),
2262 _min3(glsl_type::ivec3_type
),
2263 _min3(glsl_type::ivec4_type
),
2265 _min3(glsl_type::uint_type
),
2266 _min3(glsl_type::uvec2_type
),
2267 _min3(glsl_type::uvec3_type
),
2268 _min3(glsl_type::uvec4_type
),
2271 add_function("max3",
2272 _max3(glsl_type::float_type
),
2273 _max3(glsl_type::vec2_type
),
2274 _max3(glsl_type::vec3_type
),
2275 _max3(glsl_type::vec4_type
),
2277 _max3(glsl_type::int_type
),
2278 _max3(glsl_type::ivec2_type
),
2279 _max3(glsl_type::ivec3_type
),
2280 _max3(glsl_type::ivec4_type
),
2282 _max3(glsl_type::uint_type
),
2283 _max3(glsl_type::uvec2_type
),
2284 _max3(glsl_type::uvec3_type
),
2285 _max3(glsl_type::uvec4_type
),
2288 add_function("mid3",
2289 _mid3(glsl_type::float_type
),
2290 _mid3(glsl_type::vec2_type
),
2291 _mid3(glsl_type::vec3_type
),
2292 _mid3(glsl_type::vec4_type
),
2294 _mid3(glsl_type::int_type
),
2295 _mid3(glsl_type::ivec2_type
),
2296 _mid3(glsl_type::ivec3_type
),
2297 _mid3(glsl_type::ivec4_type
),
2299 _mid3(glsl_type::uint_type
),
2300 _mid3(glsl_type::uvec2_type
),
2301 _mid3(glsl_type::uvec3_type
),
2302 _mid3(glsl_type::uvec4_type
),
2305 add_image_functions(true);
2307 add_function("memoryBarrier",
2308 _memory_barrier(shader_image_load_store
),
2319 builtin_builder::add_function(const char *name
, ...)
2323 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2327 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2333 stuff
.push_tail(sig
);
2334 validate_ir_tree(&stuff
);
2337 f
->add_signature(sig
);
2341 shader
->symbols
->add_function(f
);
2345 builtin_builder::add_image_function(const char *name
,
2346 const char *intrinsic_name
,
2347 unsigned num_arguments
,
2350 static const glsl_type
*const types
[] = {
2351 glsl_type::image1D_type
,
2352 glsl_type::image2D_type
,
2353 glsl_type::image3D_type
,
2354 glsl_type::image2DRect_type
,
2355 glsl_type::imageCube_type
,
2356 glsl_type::imageBuffer_type
,
2357 glsl_type::image1DArray_type
,
2358 glsl_type::image2DArray_type
,
2359 glsl_type::imageCubeArray_type
,
2360 glsl_type::image2DMS_type
,
2361 glsl_type::image2DMSArray_type
,
2362 glsl_type::iimage1D_type
,
2363 glsl_type::iimage2D_type
,
2364 glsl_type::iimage3D_type
,
2365 glsl_type::iimage2DRect_type
,
2366 glsl_type::iimageCube_type
,
2367 glsl_type::iimageBuffer_type
,
2368 glsl_type::iimage1DArray_type
,
2369 glsl_type::iimage2DArray_type
,
2370 glsl_type::iimageCubeArray_type
,
2371 glsl_type::iimage2DMS_type
,
2372 glsl_type::iimage2DMSArray_type
,
2373 glsl_type::uimage1D_type
,
2374 glsl_type::uimage2D_type
,
2375 glsl_type::uimage3D_type
,
2376 glsl_type::uimage2DRect_type
,
2377 glsl_type::uimageCube_type
,
2378 glsl_type::uimageBuffer_type
,
2379 glsl_type::uimage1DArray_type
,
2380 glsl_type::uimage2DArray_type
,
2381 glsl_type::uimageCubeArray_type
,
2382 glsl_type::uimage2DMS_type
,
2383 glsl_type::uimage2DMSArray_type
2385 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2387 for (unsigned i
= 0; i
< Elements(types
); ++i
) {
2388 if (types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2389 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
))
2390 f
->add_signature(_image(types
[i
], intrinsic_name
,
2391 num_arguments
, flags
));
2394 shader
->symbols
->add_function(f
);
2398 builtin_builder::add_image_functions(bool glsl
)
2400 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2402 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2403 "__intrinsic_image_load", 0,
2404 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2405 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2406 IMAGE_FUNCTION_READ_ONLY
));
2408 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2409 "__intrinsic_image_store", 1,
2410 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2411 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2412 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2413 IMAGE_FUNCTION_WRITE_ONLY
));
2415 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2416 "__intrinsic_image_atomic_add", 1, flags
);
2418 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2419 "__intrinsic_image_atomic_min", 1, flags
);
2421 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2422 "__intrinsic_image_atomic_max", 1, flags
);
2424 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2425 "__intrinsic_image_atomic_and", 1, flags
);
2427 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2428 "__intrinsic_image_atomic_or", 1, flags
);
2430 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2431 "__intrinsic_image_atomic_xor", 1, flags
);
2433 add_image_function((glsl
? "imageAtomicExchange" :
2434 "__intrinsic_image_atomic_exchange"),
2435 "__intrinsic_image_atomic_exchange", 1, flags
);
2437 add_image_function((glsl
? "imageAtomicCompSwap" :
2438 "__intrinsic_image_atomic_comp_swap"),
2439 "__intrinsic_image_atomic_comp_swap", 2, flags
);
2443 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2445 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2449 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2451 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2455 builtin_builder::imm(float f
, unsigned vector_elements
)
2457 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2461 builtin_builder::imm(int i
, unsigned vector_elements
)
2463 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2467 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2469 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2473 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2475 return new(mem_ctx
) ir_constant(type
, &data
);
2478 ir_dereference_variable
*
2479 builtin_builder::var_ref(ir_variable
*var
)
2481 return new(mem_ctx
) ir_dereference_variable(var
);
2484 ir_dereference_array
*
2485 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2487 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2490 /** Return an element of a matrix */
2492 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2494 return swizzle(array_ref(var
, column
), row
, 1);
2498 * Implementations of built-in functions:
2501 ir_function_signature
*
2502 builtin_builder::new_sig(const glsl_type
*return_type
,
2503 builtin_available_predicate avail
,
2509 ir_function_signature
*sig
=
2510 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2513 va_start(ap
, num_params
);
2514 for (int i
= 0; i
< num_params
; i
++) {
2515 plist
.push_tail(va_arg(ap
, ir_variable
*));
2519 sig
->replace_parameters(&plist
);
2523 #define MAKE_SIG(return_type, avail, ...) \
2524 ir_function_signature *sig = \
2525 new_sig(return_type, avail, __VA_ARGS__); \
2526 ir_factory body(&sig->body, mem_ctx); \
2527 sig->is_defined = true;
2529 #define MAKE_INTRINSIC(return_type, avail, ...) \
2530 ir_function_signature *sig = \
2531 new_sig(return_type, avail, __VA_ARGS__); \
2532 sig->is_intrinsic = true;
2534 ir_function_signature
*
2535 builtin_builder::unop(builtin_available_predicate avail
,
2536 ir_expression_operation opcode
,
2537 const glsl_type
*return_type
,
2538 const glsl_type
*param_type
)
2540 ir_variable
*x
= in_var(param_type
, "x");
2541 MAKE_SIG(return_type
, avail
, 1, x
);
2542 body
.emit(ret(expr(opcode
, x
)));
2546 #define UNOP(NAME, OPCODE, AVAIL) \
2547 ir_function_signature * \
2548 builtin_builder::_##NAME(const glsl_type *type) \
2550 return unop(&AVAIL, OPCODE, type, type); \
2553 ir_function_signature
*
2554 builtin_builder::binop(ir_expression_operation opcode
,
2555 builtin_available_predicate avail
,
2556 const glsl_type
*return_type
,
2557 const glsl_type
*param0_type
,
2558 const glsl_type
*param1_type
)
2560 ir_variable
*x
= in_var(param0_type
, "x");
2561 ir_variable
*y
= in_var(param1_type
, "y");
2562 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2563 body
.emit(ret(expr(opcode
, x
, y
)));
2567 #define BINOP(NAME, OPCODE, AVAIL) \
2568 ir_function_signature * \
2569 builtin_builder::_##NAME(const glsl_type *return_type, \
2570 const glsl_type *param0_type, \
2571 const glsl_type *param1_type) \
2573 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2577 * Angle and Trigonometry Functions @{
2580 ir_function_signature
*
2581 builtin_builder::_radians(const glsl_type
*type
)
2583 ir_variable
*degrees
= in_var(type
, "degrees");
2584 MAKE_SIG(type
, always_available
, 1, degrees
);
2585 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2589 ir_function_signature
*
2590 builtin_builder::_degrees(const glsl_type
*type
)
2592 ir_variable
*radians
= in_var(type
, "radians");
2593 MAKE_SIG(type
, always_available
, 1, radians
);
2594 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2598 UNOP(sin
, ir_unop_sin
, always_available
)
2599 UNOP(cos
, ir_unop_cos
, always_available
)
2601 ir_function_signature
*
2602 builtin_builder::_tan(const glsl_type
*type
)
2604 ir_variable
*theta
= in_var(type
, "theta");
2605 MAKE_SIG(type
, always_available
, 1, theta
);
2606 body
.emit(ret(div(sin(theta
), cos(theta
))));
2611 builtin_builder::asin_expr(ir_variable
*x
)
2615 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2618 add(imm(M_PI_4f
- 1.0f
),
2620 add(imm(0.086566724f
),
2621 mul(abs(x
), imm(-0.03102955f
))))))))));
2625 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2627 exec_list actual_params
;
2629 foreach_in_list(ir_variable
, var
, ¶ms
) {
2630 actual_params
.push_tail(var_ref(var
));
2633 ir_function_signature
*sig
=
2634 f
->exact_matching_signature(NULL
, &actual_params
);
2638 ir_dereference_variable
*deref
=
2639 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2641 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2644 ir_function_signature
*
2645 builtin_builder::_asin(const glsl_type
*type
)
2647 ir_variable
*x
= in_var(type
, "x");
2648 MAKE_SIG(type
, always_available
, 1, x
);
2650 body
.emit(ret(asin_expr(x
)));
2655 ir_function_signature
*
2656 builtin_builder::_acos(const glsl_type
*type
)
2658 ir_variable
*x
= in_var(type
, "x");
2659 MAKE_SIG(type
, always_available
, 1, x
);
2661 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
2666 ir_function_signature
*
2667 builtin_builder::_atan2(const glsl_type
*type
)
2669 ir_variable
*vec_y
= in_var(type
, "vec_y");
2670 ir_variable
*vec_x
= in_var(type
, "vec_x");
2671 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2673 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2674 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2675 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2676 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2677 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2678 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2679 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2681 /* If |x| >= 1.0e-8 * |y|: */
2683 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2685 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2687 /* Then...call atan(y/x) */
2688 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
2690 /* ...and fix it up: */
2691 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2692 inner_if
->then_instructions
.push_tail(
2693 if_tree(gequal(y
, imm(0.0f
)),
2694 assign(r
, add(r
, imm(M_PIf
))),
2695 assign(r
, sub(r
, imm(M_PIf
)))));
2696 outer_then
.emit(inner_if
);
2699 outer_if
->else_instructions
.push_tail(
2700 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
2702 body
.emit(outer_if
);
2704 body
.emit(assign(vec_result
, r
, 1 << i
));
2706 body
.emit(ret(vec_result
));
2712 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
2715 * range-reduction, first step:
2717 * / y_over_x if |y_over_x| <= 1.0;
2719 * \ 1.0 / y_over_x otherwise
2721 ir_variable
*x
= body
.make_temp(type
, "atan_x");
2722 body
.emit(assign(x
, div(min2(abs(y_over_x
),
2728 * approximate atan by evaluating polynomial:
2730 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
2731 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
2732 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
2734 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
2735 body
.emit(assign(tmp
, mul(x
, x
)));
2736 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
2738 imm(0.0536813784310406f
)),
2740 imm(0.1173503194786851f
)),
2742 imm(0.1938924977115610f
)),
2744 imm(0.3326756418091246f
)),
2746 imm(0.9999793128310355f
)),
2749 /* range-reduction fixup */
2750 body
.emit(assign(tmp
, add(tmp
,
2751 mul(b2f(greater(abs(y_over_x
),
2752 imm(1.0f
, type
->components()))),
2758 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
2761 ir_function_signature
*
2762 builtin_builder::_atan(const glsl_type
*type
)
2764 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2765 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2767 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
2768 do_atan(body
, type
, tmp
, y_over_x
);
2769 body
.emit(ret(tmp
));
2774 ir_function_signature
*
2775 builtin_builder::_sinh(const glsl_type
*type
)
2777 ir_variable
*x
= in_var(type
, "x");
2778 MAKE_SIG(type
, v130
, 1, x
);
2780 /* 0.5 * (e^x - e^(-x)) */
2781 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2786 ir_function_signature
*
2787 builtin_builder::_cosh(const glsl_type
*type
)
2789 ir_variable
*x
= in_var(type
, "x");
2790 MAKE_SIG(type
, v130
, 1, x
);
2792 /* 0.5 * (e^x + e^(-x)) */
2793 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2798 ir_function_signature
*
2799 builtin_builder::_tanh(const glsl_type
*type
)
2801 ir_variable
*x
= in_var(type
, "x");
2802 MAKE_SIG(type
, v130
, 1, x
);
2804 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2805 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2806 add(exp(x
), exp(neg(x
))))));
2811 ir_function_signature
*
2812 builtin_builder::_asinh(const glsl_type
*type
)
2814 ir_variable
*x
= in_var(type
, "x");
2815 MAKE_SIG(type
, v130
, 1, x
);
2817 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2822 ir_function_signature
*
2823 builtin_builder::_acosh(const glsl_type
*type
)
2825 ir_variable
*x
= in_var(type
, "x");
2826 MAKE_SIG(type
, v130
, 1, x
);
2828 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2832 ir_function_signature
*
2833 builtin_builder::_atanh(const glsl_type
*type
)
2835 ir_variable
*x
= in_var(type
, "x");
2836 MAKE_SIG(type
, v130
, 1, x
);
2838 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2839 sub(imm(1.0f
), x
))))));
2845 * Exponential Functions @{
2848 ir_function_signature
*
2849 builtin_builder::_pow(const glsl_type
*type
)
2851 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2854 UNOP(exp
, ir_unop_exp
, always_available
)
2855 UNOP(log
, ir_unop_log
, always_available
)
2856 UNOP(exp2
, ir_unop_exp2
, always_available
)
2857 UNOP(log2
, ir_unop_log2
, always_available
)
2858 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2859 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2863 UNOP(abs
, ir_unop_abs
, always_available
)
2864 UNOP(sign
, ir_unop_sign
, always_available
)
2865 UNOP(floor
, ir_unop_floor
, always_available
)
2866 UNOP(trunc
, ir_unop_trunc
, v130
)
2867 UNOP(round
, ir_unop_round_even
, always_available
)
2868 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2869 UNOP(ceil
, ir_unop_ceil
, always_available
)
2870 UNOP(fract
, ir_unop_fract
, always_available
)
2872 ir_function_signature
*
2873 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2875 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2878 ir_function_signature
*
2879 builtin_builder::_modf(const glsl_type
*type
)
2881 ir_variable
*x
= in_var(type
, "x");
2882 ir_variable
*i
= out_var(type
, "i");
2883 MAKE_SIG(type
, v130
, 2, x
, i
);
2885 ir_variable
*t
= body
.make_temp(type
, "t");
2886 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2887 body
.emit(assign(i
, t
));
2888 body
.emit(ret(sub(x
, t
)));
2893 ir_function_signature
*
2894 builtin_builder::_min(builtin_available_predicate avail
,
2895 const glsl_type
*x_type
, const glsl_type
*y_type
)
2897 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2900 ir_function_signature
*
2901 builtin_builder::_max(builtin_available_predicate avail
,
2902 const glsl_type
*x_type
, const glsl_type
*y_type
)
2904 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2907 ir_function_signature
*
2908 builtin_builder::_clamp(builtin_available_predicate avail
,
2909 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2911 ir_variable
*x
= in_var(val_type
, "x");
2912 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2913 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2914 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2916 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2921 ir_function_signature
*
2922 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2924 ir_variable
*x
= in_var(val_type
, "x");
2925 ir_variable
*y
= in_var(val_type
, "y");
2926 ir_variable
*a
= in_var(blend_type
, "a");
2927 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2929 body
.emit(ret(lrp(x
, y
, a
)));
2934 ir_function_signature
*
2935 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2936 const glsl_type
*val_type
,
2937 const glsl_type
*blend_type
)
2939 ir_variable
*x
= in_var(val_type
, "x");
2940 ir_variable
*y
= in_var(val_type
, "y");
2941 ir_variable
*a
= in_var(blend_type
, "a");
2942 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2944 /* csel matches the ternary operator in that a selector of true choses the
2945 * first argument. This differs from mix(x, y, false) which choses the
2946 * second argument (to remain consistent with the interpolating version of
2947 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2949 * To handle the behavior mismatch, reverse the x and y arguments.
2951 body
.emit(ret(csel(a
, y
, x
)));
2956 ir_function_signature
*
2957 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2959 ir_variable
*edge
= in_var(edge_type
, "edge");
2960 ir_variable
*x
= in_var(x_type
, "x");
2961 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2963 ir_variable
*t
= body
.make_temp(x_type
, "t");
2964 if (x_type
->vector_elements
== 1) {
2965 /* Both are floats */
2966 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2967 } else if (edge_type
->vector_elements
== 1) {
2968 /* x is a vector but edge is a float */
2969 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2970 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2973 /* Both are vectors */
2974 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2975 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2984 ir_function_signature
*
2985 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2987 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2988 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2989 ir_variable
*x
= in_var(x_type
, "x");
2990 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2992 /* From the GLSL 1.10 specification:
2995 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2996 * return t * t * (3 - 2 * t);
2999 ir_variable
*t
= body
.make_temp(x_type
, "t");
3000 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3001 imm(0.0f
), imm(1.0f
))));
3003 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
3008 ir_function_signature
*
3009 builtin_builder::_isnan(const glsl_type
*type
)
3011 ir_variable
*x
= in_var(type
, "x");
3012 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
3014 body
.emit(ret(nequal(x
, x
)));
3019 ir_function_signature
*
3020 builtin_builder::_isinf(const glsl_type
*type
)
3022 ir_variable
*x
= in_var(type
, "x");
3023 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
3025 ir_constant_data infinities
;
3026 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3027 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
3030 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3035 ir_function_signature
*
3036 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3038 ir_variable
*x
= in_var(type
, "x");
3039 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3040 body
.emit(ret(bitcast_f2i(x
)));
3044 ir_function_signature
*
3045 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3047 ir_variable
*x
= in_var(type
, "x");
3048 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3049 body
.emit(ret(bitcast_f2u(x
)));
3053 ir_function_signature
*
3054 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3056 ir_variable
*x
= in_var(type
, "x");
3057 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3058 body
.emit(ret(bitcast_i2f(x
)));
3062 ir_function_signature
*
3063 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3065 ir_variable
*x
= in_var(type
, "x");
3066 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3067 body
.emit(ret(bitcast_u2f(x
)));
3071 ir_function_signature
*
3072 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3074 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3075 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3076 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3080 ir_function_signature
*
3081 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3083 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3084 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3085 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3089 ir_function_signature
*
3090 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3092 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3093 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3094 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3098 ir_function_signature
*
3099 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3101 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3102 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3103 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3107 ir_function_signature
*
3108 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3110 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3111 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3112 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3116 ir_function_signature
*
3117 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3119 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3120 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3121 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3126 ir_function_signature
*
3127 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3129 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3130 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3131 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3135 ir_function_signature
*
3136 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3138 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3139 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3140 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3144 ir_function_signature
*
3145 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3147 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3148 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3149 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3153 ir_function_signature
*
3154 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3156 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3157 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3158 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3162 ir_function_signature
*
3163 builtin_builder::_length(const glsl_type
*type
)
3165 ir_variable
*x
= in_var(type
, "x");
3166 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
3168 body
.emit(ret(sqrt(dot(x
, x
))));
3173 ir_function_signature
*
3174 builtin_builder::_distance(const glsl_type
*type
)
3176 ir_variable
*p0
= in_var(type
, "p0");
3177 ir_variable
*p1
= in_var(type
, "p1");
3178 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
3180 if (type
->vector_elements
== 1) {
3181 body
.emit(ret(abs(sub(p0
, p1
))));
3183 ir_variable
*p
= body
.make_temp(type
, "p");
3184 body
.emit(assign(p
, sub(p0
, p1
)));
3185 body
.emit(ret(sqrt(dot(p
, p
))));
3191 ir_function_signature
*
3192 builtin_builder::_dot(const glsl_type
*type
)
3194 if (type
->vector_elements
== 1)
3195 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
3197 return binop(ir_binop_dot
, always_available
,
3198 glsl_type::float_type
, type
, type
);
3201 ir_function_signature
*
3202 builtin_builder::_cross(const glsl_type
*type
)
3204 ir_variable
*a
= in_var(type
, "a");
3205 ir_variable
*b
= in_var(type
, "b");
3206 MAKE_SIG(type
, always_available
, 2, a
, b
);
3208 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3209 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3211 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3212 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3217 ir_function_signature
*
3218 builtin_builder::_normalize(const glsl_type
*type
)
3220 ir_variable
*x
= in_var(type
, "x");
3221 MAKE_SIG(type
, always_available
, 1, x
);
3223 if (type
->vector_elements
== 1) {
3224 body
.emit(ret(sign(x
)));
3226 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3232 ir_function_signature
*
3233 builtin_builder::_ftransform()
3235 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3237 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3238 glsl_type::vec4_type
,
3239 var_ref(gl_ModelViewProjectionMatrix
),
3240 var_ref(gl_Vertex
))));
3242 /* FINISHME: Once the ir_expression() constructor handles type inference
3243 * for matrix operations, we can simplify this to:
3245 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3250 ir_function_signature
*
3251 builtin_builder::_faceforward(const glsl_type
*type
)
3253 ir_variable
*N
= in_var(type
, "N");
3254 ir_variable
*I
= in_var(type
, "I");
3255 ir_variable
*Nref
= in_var(type
, "Nref");
3256 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
3258 body
.emit(if_tree(less(dot(Nref
, I
), imm(0.0f
)),
3259 ret(N
), ret(neg(N
))));
3264 ir_function_signature
*
3265 builtin_builder::_reflect(const glsl_type
*type
)
3267 ir_variable
*I
= in_var(type
, "I");
3268 ir_variable
*N
= in_var(type
, "N");
3269 MAKE_SIG(type
, always_available
, 2, I
, N
);
3271 /* I - 2 * dot(N, I) * N */
3272 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dot(N
, I
), N
)))));
3277 ir_function_signature
*
3278 builtin_builder::_refract(const glsl_type
*type
)
3280 ir_variable
*I
= in_var(type
, "I");
3281 ir_variable
*N
= in_var(type
, "N");
3282 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
3283 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
3285 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
3286 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3288 /* From the GLSL 1.10 specification:
3289 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3291 * return genType(0.0)
3293 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3295 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
3296 body
.emit(assign(k
, sub(imm(1.0f
),
3297 mul(eta
, mul(eta
, sub(imm(1.0f
),
3298 mul(n_dot_i
, n_dot_i
)))))));
3299 body
.emit(if_tree(less(k
, imm(0.0f
)),
3300 ret(ir_constant::zero(mem_ctx
, type
)),
3301 ret(sub(mul(eta
, I
),
3302 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3307 ir_function_signature
*
3308 builtin_builder::_matrixCompMult(const glsl_type
*type
)
3310 ir_variable
*x
= in_var(type
, "x");
3311 ir_variable
*y
= in_var(type
, "y");
3312 MAKE_SIG(type
, always_available
, 2, x
, y
);
3314 ir_variable
*z
= body
.make_temp(type
, "z");
3315 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3316 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3323 ir_function_signature
*
3324 builtin_builder::_outerProduct(const glsl_type
*type
)
3326 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3327 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3328 MAKE_SIG(type
, v120
, 2, c
, r
);
3330 ir_variable
*m
= body
.make_temp(type
, "m");
3331 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3332 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3339 ir_function_signature
*
3340 builtin_builder::_transpose(const glsl_type
*orig_type
)
3342 const glsl_type
*transpose_type
=
3343 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
3344 orig_type
->matrix_columns
,
3345 orig_type
->vector_elements
);
3347 ir_variable
*m
= in_var(orig_type
, "m");
3348 MAKE_SIG(transpose_type
, v120
, 1, m
);
3350 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3351 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3352 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3353 body
.emit(assign(array_ref(t
, j
),
3354 matrix_elt(m
, i
, j
),
3363 ir_function_signature
*
3364 builtin_builder::_determinant_mat2()
3366 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3367 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3369 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3370 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3375 ir_function_signature
*
3376 builtin_builder::_determinant_mat3()
3378 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3379 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3382 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3383 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3386 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3387 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3390 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3391 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3393 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3394 mul(matrix_elt(m
, 0, 1), f2
)),
3395 mul(matrix_elt(m
, 0, 2), f3
))));
3400 ir_function_signature
*
3401 builtin_builder::_determinant_mat4()
3403 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3404 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3406 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3407 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3408 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3409 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3410 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3411 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3412 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3413 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3414 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3415 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3416 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3417 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3418 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3419 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3420 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3421 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3422 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3423 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3424 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3426 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)))));
3427 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)))));
3428 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)))));
3429 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)))));
3430 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)))));
3431 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)))));
3432 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)))));
3433 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)))));
3434 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)))));
3435 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)))));
3436 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)))));
3437 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)))));
3438 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)))));
3439 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)))));
3440 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)))));
3441 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)))));
3442 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)))));
3443 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)))));
3444 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)))));
3446 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
3448 body
.emit(assign(adj_0
,
3449 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3450 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3451 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3453 body
.emit(assign(adj_0
, neg(
3454 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3455 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3456 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3458 body
.emit(assign(adj_0
,
3459 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3460 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3461 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3463 body
.emit(assign(adj_0
, neg(
3464 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3465 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3466 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3469 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3474 ir_function_signature
*
3475 builtin_builder::_inverse_mat2()
3477 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3478 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
3480 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
3481 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3482 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3483 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3484 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3486 ir_expression
*det
=
3487 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3488 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3490 body
.emit(ret(div(adj
, det
)));
3494 ir_function_signature
*
3495 builtin_builder::_inverse_mat3()
3497 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3498 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
3500 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
3501 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
3502 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
3504 body
.emit(assign(f11_22_21_12
,
3505 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3506 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3507 body
.emit(assign(f10_22_20_12
,
3508 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3509 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3510 body
.emit(assign(f10_21_20_11
,
3511 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3512 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3514 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
3515 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3516 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3517 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3519 body
.emit(assign(array_ref(adj
, 0), neg(
3520 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3521 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3523 body
.emit(assign(array_ref(adj
, 1),
3524 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3525 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3527 body
.emit(assign(array_ref(adj
, 2), neg(
3528 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3529 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3532 body
.emit(assign(array_ref(adj
, 0),
3533 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3534 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3536 body
.emit(assign(array_ref(adj
, 1), neg(
3537 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3538 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3540 body
.emit(assign(array_ref(adj
, 2),
3541 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3542 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3545 ir_expression
*det
=
3546 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3547 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3548 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3550 body
.emit(ret(div(adj
, det
)));
3555 ir_function_signature
*
3556 builtin_builder::_inverse_mat4()
3558 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3559 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
3561 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3562 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3563 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3564 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3565 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3566 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3567 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3568 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3569 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3570 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3571 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3572 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3573 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3574 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3575 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3576 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3577 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3578 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3579 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3581 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)))));
3582 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)))));
3583 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)))));
3584 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)))));
3585 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)))));
3586 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)))));
3587 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)))));
3588 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)))));
3589 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)))));
3590 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)))));
3591 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)))));
3592 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)))));
3593 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)))));
3594 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)))));
3595 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)))));
3596 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)))));
3597 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)))));
3598 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)))));
3599 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)))));
3601 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
3602 body
.emit(assign(array_ref(adj
, 0),
3603 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3604 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3605 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3607 body
.emit(assign(array_ref(adj
, 1), neg(
3608 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3609 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3610 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3612 body
.emit(assign(array_ref(adj
, 2),
3613 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3614 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3615 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3617 body
.emit(assign(array_ref(adj
, 3), neg(
3618 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3619 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3620 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3623 body
.emit(assign(array_ref(adj
, 0), neg(
3624 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3625 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3626 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3628 body
.emit(assign(array_ref(adj
, 1),
3629 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3630 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3631 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3633 body
.emit(assign(array_ref(adj
, 2), neg(
3634 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3635 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3636 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3638 body
.emit(assign(array_ref(adj
, 3),
3639 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3640 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3641 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3644 body
.emit(assign(array_ref(adj
, 0),
3645 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3646 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3647 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3649 body
.emit(assign(array_ref(adj
, 1), neg(
3650 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3651 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3652 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3654 body
.emit(assign(array_ref(adj
, 2),
3655 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3656 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3657 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3659 body
.emit(assign(array_ref(adj
, 3), neg(
3660 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3661 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3662 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3665 body
.emit(assign(array_ref(adj
, 0), neg(
3666 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3667 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3668 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3670 body
.emit(assign(array_ref(adj
, 1),
3671 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3672 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3673 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3675 body
.emit(assign(array_ref(adj
, 2), neg(
3676 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3677 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3678 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3680 body
.emit(assign(array_ref(adj
, 3),
3681 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3682 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3683 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3686 ir_expression
*det
=
3687 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3688 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3689 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3690 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3692 body
.emit(ret(div(adj
, det
)));
3698 ir_function_signature
*
3699 builtin_builder::_lessThan(builtin_available_predicate avail
,
3700 const glsl_type
*type
)
3702 return binop(ir_binop_less
, avail
,
3703 glsl_type::bvec(type
->vector_elements
), type
, type
);
3706 ir_function_signature
*
3707 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3708 const glsl_type
*type
)
3710 return binop(ir_binop_lequal
, avail
,
3711 glsl_type::bvec(type
->vector_elements
), type
, type
);
3714 ir_function_signature
*
3715 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3716 const glsl_type
*type
)
3718 return binop(ir_binop_greater
, avail
,
3719 glsl_type::bvec(type
->vector_elements
), type
, type
);
3722 ir_function_signature
*
3723 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3724 const glsl_type
*type
)
3726 return binop(ir_binop_gequal
, avail
,
3727 glsl_type::bvec(type
->vector_elements
), type
, type
);
3730 ir_function_signature
*
3731 builtin_builder::_equal(builtin_available_predicate avail
,
3732 const glsl_type
*type
)
3734 return binop(ir_binop_equal
, avail
,
3735 glsl_type::bvec(type
->vector_elements
), type
, type
);
3738 ir_function_signature
*
3739 builtin_builder::_notEqual(builtin_available_predicate avail
,
3740 const glsl_type
*type
)
3742 return binop(ir_binop_nequal
, avail
,
3743 glsl_type::bvec(type
->vector_elements
), type
, type
);
3746 ir_function_signature
*
3747 builtin_builder::_any(const glsl_type
*type
)
3749 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3752 ir_function_signature
*
3753 builtin_builder::_all(const glsl_type
*type
)
3755 ir_variable
*v
= in_var(type
, "v");
3756 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3758 switch (type
->vector_elements
) {
3760 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3763 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3767 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3776 UNOP(not, ir_unop_logic_not
, always_available
)
3779 has_lod(const glsl_type
*sampler_type
)
3781 assert(sampler_type
->is_sampler());
3783 switch (sampler_type
->sampler_dimensionality
) {
3784 case GLSL_SAMPLER_DIM_RECT
:
3785 case GLSL_SAMPLER_DIM_BUF
:
3786 case GLSL_SAMPLER_DIM_MS
:
3793 ir_function_signature
*
3794 builtin_builder::_textureSize(builtin_available_predicate avail
,
3795 const glsl_type
*return_type
,
3796 const glsl_type
*sampler_type
)
3798 ir_variable
*s
= in_var(sampler_type
, "sampler");
3799 /* The sampler always exists; add optional lod later. */
3800 MAKE_SIG(return_type
, avail
, 1, s
);
3802 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3803 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3805 if (has_lod(sampler_type
)) {
3806 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3807 sig
->parameters
.push_tail(lod
);
3808 tex
->lod_info
.lod
= var_ref(lod
);
3810 tex
->lod_info
.lod
= imm(0u);
3813 body
.emit(ret(tex
));
3818 ir_function_signature
*
3819 builtin_builder::_texture(ir_texture_opcode opcode
,
3820 builtin_available_predicate avail
,
3821 const glsl_type
*return_type
,
3822 const glsl_type
*sampler_type
,
3823 const glsl_type
*coord_type
,
3826 ir_variable
*s
= in_var(sampler_type
, "sampler");
3827 ir_variable
*P
= in_var(coord_type
, "P");
3828 /* The sampler and coordinate always exist; add optional parameters later. */
3829 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3831 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3832 tex
->set_sampler(var_ref(s
), return_type
);
3834 const int coord_size
= sampler_type
->coordinate_components();
3836 if (coord_size
== coord_type
->vector_elements
) {
3837 tex
->coordinate
= var_ref(P
);
3839 /* The incoming coordinate also has the projector or shadow comparitor,
3840 * so we need to swizzle those away.
3842 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3845 /* The projector is always in the last component. */
3846 if (flags
& TEX_PROJECT
)
3847 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3849 if (sampler_type
->sampler_shadow
) {
3850 if (opcode
== ir_tg4
) {
3851 /* gather has refz as a separate parameter, immediately after the
3854 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
3855 sig
->parameters
.push_tail(refz
);
3856 tex
->shadow_comparitor
= var_ref(refz
);
3858 /* The shadow comparitor is normally in the Z component, but a few types
3859 * have sufficiently large coordinates that it's in W.
3861 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3865 if (opcode
== ir_txl
) {
3866 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3867 sig
->parameters
.push_tail(lod
);
3868 tex
->lod_info
.lod
= var_ref(lod
);
3869 } else if (opcode
== ir_txd
) {
3870 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3871 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3872 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3873 sig
->parameters
.push_tail(dPdx
);
3874 sig
->parameters
.push_tail(dPdy
);
3875 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3876 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3879 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
3880 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3881 ir_variable
*offset
=
3882 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
3883 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
3884 sig
->parameters
.push_tail(offset
);
3885 tex
->offset
= var_ref(offset
);
3888 if (flags
& TEX_OFFSET_ARRAY
) {
3889 ir_variable
*offsets
=
3890 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
3891 "offsets", ir_var_const_in
);
3892 sig
->parameters
.push_tail(offsets
);
3893 tex
->offset
= var_ref(offsets
);
3896 if (opcode
== ir_tg4
) {
3897 if (flags
& TEX_COMPONENT
) {
3898 ir_variable
*component
=
3899 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
3900 sig
->parameters
.push_tail(component
);
3901 tex
->lod_info
.component
= var_ref(component
);
3904 tex
->lod_info
.component
= imm(0);
3908 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3909 * inconsistent with both textureLodOffset and textureGradOffset.
3911 if (opcode
== ir_txb
) {
3912 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3913 sig
->parameters
.push_tail(bias
);
3914 tex
->lod_info
.bias
= var_ref(bias
);
3917 body
.emit(ret(tex
));
3922 ir_function_signature
*
3923 builtin_builder::_textureCubeArrayShadow()
3925 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3926 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3927 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3928 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3930 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3931 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3933 tex
->coordinate
= var_ref(P
);
3934 tex
->shadow_comparitor
= var_ref(compare
);
3936 body
.emit(ret(tex
));
3941 ir_function_signature
*
3942 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3943 const glsl_type
*return_type
,
3944 const glsl_type
*sampler_type
,
3945 const glsl_type
*coord_type
,
3946 const glsl_type
*offset_type
)
3948 ir_variable
*s
= in_var(sampler_type
, "sampler");
3949 ir_variable
*P
= in_var(coord_type
, "P");
3950 /* The sampler and coordinate always exist; add optional parameters later. */
3951 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3953 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3954 tex
->coordinate
= var_ref(P
);
3955 tex
->set_sampler(var_ref(s
), return_type
);
3957 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3958 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3959 sig
->parameters
.push_tail(sample
);
3960 tex
->lod_info
.sample_index
= var_ref(sample
);
3961 tex
->op
= ir_txf_ms
;
3962 } else if (has_lod(sampler_type
)) {
3963 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3964 sig
->parameters
.push_tail(lod
);
3965 tex
->lod_info
.lod
= var_ref(lod
);
3967 tex
->lod_info
.lod
= imm(0u);
3970 if (offset_type
!= NULL
) {
3971 ir_variable
*offset
=
3972 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3973 sig
->parameters
.push_tail(offset
);
3974 tex
->offset
= var_ref(offset
);
3977 body
.emit(ret(tex
));
3982 ir_function_signature
*
3983 builtin_builder::_EmitVertex()
3985 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3987 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
3988 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
3993 ir_function_signature
*
3994 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
3995 const glsl_type
*stream_type
)
3997 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
3999 * "Emit the current values of output variables to the current output
4000 * primitive on stream stream. The argument to stream must be a constant
4001 * integral expression."
4003 ir_variable
*stream
=
4004 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4006 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4008 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4013 ir_function_signature
*
4014 builtin_builder::_EndPrimitive()
4016 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4018 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4019 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4024 ir_function_signature
*
4025 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4026 const glsl_type
*stream_type
)
4028 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4030 * "Completes the current output primitive on stream stream and starts
4031 * a new one. The argument to stream must be a constant integral
4034 ir_variable
*stream
=
4035 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4037 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4039 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4044 ir_function_signature
*
4045 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
4046 const glsl_type
*coord_type
)
4048 ir_variable
*s
= in_var(sampler_type
, "sampler");
4049 ir_variable
*coord
= in_var(coord_type
, "coord");
4050 /* The sampler and coordinate always exist; add optional parameters later. */
4051 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
4053 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4054 tex
->coordinate
= var_ref(coord
);
4055 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4057 body
.emit(ret(tex
));
4062 ir_function_signature
*
4063 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4065 ir_variable
*s
= in_var(sampler_type
, "sampler");
4066 const glsl_type
*return_type
= glsl_type::int_type
;
4067 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4069 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4070 tex
->set_sampler(var_ref(s
), return_type
);
4072 body
.emit(ret(tex
));
4077 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4078 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4079 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4080 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4081 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4082 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4084 ir_function_signature
*
4085 builtin_builder::_fwidth(const glsl_type
*type
)
4087 ir_variable
*p
= in_var(type
, "p");
4088 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4090 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4095 ir_function_signature
*
4096 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4098 ir_variable
*p
= in_var(type
, "p");
4099 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4101 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4102 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4107 ir_function_signature
*
4108 builtin_builder::_fwidthFine(const glsl_type
*type
)
4110 ir_variable
*p
= in_var(type
, "p");
4111 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4113 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4114 abs(expr(ir_unop_dFdy_fine
, p
)))));
4119 ir_function_signature
*
4120 builtin_builder::_noise1(const glsl_type
*type
)
4122 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4125 ir_function_signature
*
4126 builtin_builder::_noise2(const glsl_type
*type
)
4128 ir_variable
*p
= in_var(type
, "p");
4129 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4131 ir_constant_data b_offset
;
4132 b_offset
.f
[0] = 601.0f
;
4133 b_offset
.f
[1] = 313.0f
;
4134 b_offset
.f
[2] = 29.0f
;
4135 b_offset
.f
[3] = 277.0f
;
4137 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4138 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4139 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4140 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4141 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4142 body
.emit(assign(t
, a
, WRITEMASK_X
));
4143 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4149 ir_function_signature
*
4150 builtin_builder::_noise3(const glsl_type
*type
)
4152 ir_variable
*p
= in_var(type
, "p");
4153 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4155 ir_constant_data b_offset
;
4156 b_offset
.f
[0] = 601.0f
;
4157 b_offset
.f
[1] = 313.0f
;
4158 b_offset
.f
[2] = 29.0f
;
4159 b_offset
.f
[3] = 277.0f
;
4161 ir_constant_data c_offset
;
4162 c_offset
.f
[0] = 1559.0f
;
4163 c_offset
.f
[1] = 113.0f
;
4164 c_offset
.f
[2] = 1861.0f
;
4165 c_offset
.f
[3] = 797.0f
;
4167 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4168 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4169 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4170 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4171 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4172 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4173 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4174 body
.emit(assign(t
, a
, WRITEMASK_X
));
4175 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4176 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4182 ir_function_signature
*
4183 builtin_builder::_noise4(const glsl_type
*type
)
4185 ir_variable
*p
= in_var(type
, "p");
4186 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4188 ir_variable
*_p
= body
.make_temp(type
, "_p");
4190 ir_constant_data p_offset
;
4191 p_offset
.f
[0] = 1559.0f
;
4192 p_offset
.f
[1] = 113.0f
;
4193 p_offset
.f
[2] = 1861.0f
;
4194 p_offset
.f
[3] = 797.0f
;
4196 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4198 ir_constant_data offset
;
4199 offset
.f
[0] = 601.0f
;
4200 offset
.f
[1] = 313.0f
;
4201 offset
.f
[2] = 29.0f
;
4202 offset
.f
[3] = 277.0f
;
4204 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4205 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4206 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4207 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4208 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4209 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4210 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4211 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4212 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4213 body
.emit(assign(t
, a
, WRITEMASK_X
));
4214 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4215 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4216 body
.emit(assign(t
, d
, WRITEMASK_W
));
4222 ir_function_signature
*
4223 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4225 ir_variable
*value
= in_var(type
, "value");
4226 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4227 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4228 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
4230 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4235 ir_function_signature
*
4236 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4238 ir_variable
*base
= in_var(type
, "base");
4239 ir_variable
*insert
= in_var(type
, "insert");
4240 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4241 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4242 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
4244 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4249 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
4251 ir_function_signature
*
4252 builtin_builder::_bitCount(const glsl_type
*type
)
4254 return unop(gpu_shader5
, ir_unop_bit_count
,
4255 glsl_type::ivec(type
->vector_elements
), type
);
4258 ir_function_signature
*
4259 builtin_builder::_findLSB(const glsl_type
*type
)
4261 return unop(gpu_shader5
, ir_unop_find_lsb
,
4262 glsl_type::ivec(type
->vector_elements
), type
);
4265 ir_function_signature
*
4266 builtin_builder::_findMSB(const glsl_type
*type
)
4268 return unop(gpu_shader5
, ir_unop_find_msb
,
4269 glsl_type::ivec(type
->vector_elements
), type
);
4272 ir_function_signature
*
4273 builtin_builder::_fma(const glsl_type
*type
)
4275 ir_variable
*a
= in_var(type
, "a");
4276 ir_variable
*b
= in_var(type
, "b");
4277 ir_variable
*c
= in_var(type
, "c");
4278 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
4280 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4285 ir_function_signature
*
4286 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4288 return binop(ir_binop_ldexp
, gpu_shader5
, x_type
, x_type
, exp_type
);
4291 ir_function_signature
*
4292 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4294 ir_variable
*x
= in_var(x_type
, "x");
4295 ir_variable
*exponent
= out_var(exp_type
, "exp");
4296 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
4298 const unsigned vec_elem
= x_type
->vector_elements
;
4299 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4300 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4302 /* Single-precision floating-point values are stored as
4307 * An exponent shift of 23 will shift the mantissa out, leaving only the
4308 * exponent and sign bit (which itself may be zero, if the absolute value
4309 * was taken before the bitcast and shift.
4311 ir_constant
*exponent_shift
= imm(23);
4312 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4314 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4316 /* Exponent of floating-point values in the range [0.5, 1.0). */
4317 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4319 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4320 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4322 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4323 * to unsigned integers to ensure that 1 bits aren't shifted in.
4325 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4326 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4327 imm(0, vec_elem
)))));
4329 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4330 body
.emit(assign(bits
, bitcast_f2u(x
)));
4331 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4332 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4333 imm(0u, vec_elem
)))));
4334 body
.emit(ret(bitcast_u2f(bits
)));
4339 ir_function_signature
*
4340 builtin_builder::_uaddCarry(const glsl_type
*type
)
4342 ir_variable
*x
= in_var(type
, "x");
4343 ir_variable
*y
= in_var(type
, "y");
4344 ir_variable
*carry
= out_var(type
, "carry");
4345 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
4347 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4348 body
.emit(ret(add(x
, y
)));
4353 ir_function_signature
*
4354 builtin_builder::_usubBorrow(const glsl_type
*type
)
4356 ir_variable
*x
= in_var(type
, "x");
4357 ir_variable
*y
= in_var(type
, "y");
4358 ir_variable
*borrow
= out_var(type
, "borrow");
4359 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
4361 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4362 body
.emit(ret(sub(x
, y
)));
4368 * For both imulExtended() and umulExtended() built-ins.
4370 ir_function_signature
*
4371 builtin_builder::_mulExtended(const glsl_type
*type
)
4373 ir_variable
*x
= in_var(type
, "x");
4374 ir_variable
*y
= in_var(type
, "y");
4375 ir_variable
*msb
= out_var(type
, "msb");
4376 ir_variable
*lsb
= out_var(type
, "lsb");
4377 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
4379 body
.emit(assign(msb
, imul_high(x
, y
)));
4380 body
.emit(assign(lsb
, mul(x
, y
)));
4385 ir_function_signature
*
4386 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4388 ir_variable
*interpolant
= in_var(type
, "interpolant");
4389 interpolant
->data
.must_be_shader_input
= 1;
4390 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4392 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4397 ir_function_signature
*
4398 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4400 ir_variable
*interpolant
= in_var(type
, "interpolant");
4401 interpolant
->data
.must_be_shader_input
= 1;
4402 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4403 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4405 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4410 ir_function_signature
*
4411 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4413 ir_variable
*interpolant
= in_var(type
, "interpolant");
4414 interpolant
->data
.must_be_shader_input
= 1;
4415 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4416 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4418 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4423 ir_function_signature
*
4424 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4426 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4427 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4431 ir_function_signature
*
4432 builtin_builder::_atomic_op(const char *intrinsic
,
4433 builtin_available_predicate avail
)
4435 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4436 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4438 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4439 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4441 body
.emit(ret(retval
));
4445 ir_function_signature
*
4446 builtin_builder::_min3(const glsl_type
*type
)
4448 ir_variable
*x
= in_var(type
, "x");
4449 ir_variable
*y
= in_var(type
, "y");
4450 ir_variable
*z
= in_var(type
, "z");
4451 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4453 ir_expression
*min3
= min2(x
, min2(y
,z
));
4454 body
.emit(ret(min3
));
4459 ir_function_signature
*
4460 builtin_builder::_max3(const glsl_type
*type
)
4462 ir_variable
*x
= in_var(type
, "x");
4463 ir_variable
*y
= in_var(type
, "y");
4464 ir_variable
*z
= in_var(type
, "z");
4465 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4467 ir_expression
*max3
= max2(x
, max2(y
,z
));
4468 body
.emit(ret(max3
));
4473 ir_function_signature
*
4474 builtin_builder::_mid3(const glsl_type
*type
)
4476 ir_variable
*x
= in_var(type
, "x");
4477 ir_variable
*y
= in_var(type
, "y");
4478 ir_variable
*z
= in_var(type
, "z");
4479 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4481 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4482 body
.emit(ret(mid3
));
4487 ir_function_signature
*
4488 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4489 const char *intrinsic_name
,
4490 unsigned num_arguments
,
4493 const glsl_type
*data_type
= glsl_type::get_instance(
4494 image_type
->sampler_type
,
4495 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4497 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4498 glsl_type::void_type
: data_type
);
4500 /* Addressing arguments that are always present. */
4501 ir_variable
*image
= in_var(image_type
, "image");
4502 ir_variable
*coord
= in_var(
4503 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4505 ir_function_signature
*sig
= new_sig(
4506 ret_type
, shader_image_load_store
, 2, image
, coord
);
4508 /* Sample index for multisample images. */
4509 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4510 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4512 /* Data arguments. */
4513 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
4514 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
4515 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
4516 ralloc_free(arg_name
);
4519 /* Set the maximal set of qualifiers allowed for this image
4520 * built-in. Function calls with arguments having fewer
4521 * qualifiers than present in the prototype are allowed by the
4522 * spec, but not with more, i.e. this will make the compiler
4523 * accept everything that needs to be accepted, and reject cases
4524 * like loads from write-only or stores to read-only images.
4526 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
4527 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
4528 image
->data
.image_coherent
= true;
4529 image
->data
.image_volatile
= true;
4530 image
->data
.image_restrict
= true;
4535 ir_function_signature
*
4536 builtin_builder::_image(const glsl_type
*image_type
,
4537 const char *intrinsic_name
,
4538 unsigned num_arguments
,
4541 ir_function_signature
*sig
= _image_prototype(image_type
, intrinsic_name
,
4542 num_arguments
, flags
);
4544 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
4545 ir_factory
body(&sig
->body
, mem_ctx
);
4546 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
4548 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
4549 body
.emit(call(f
, NULL
, sig
->parameters
));
4551 ir_variable
*ret_val
=
4552 body
.make_temp(sig
->return_type
, "_ret_val");
4553 body
.emit(call(f
, ret_val
, sig
->parameters
));
4554 body
.emit(ret(ret_val
));
4557 sig
->is_defined
= true;
4560 sig
->is_intrinsic
= true;
4566 ir_function_signature
*
4567 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
4569 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
4573 ir_function_signature
*
4574 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
4576 MAKE_SIG(glsl_type::void_type
, avail
, 0);
4577 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
4578 NULL
, sig
->parameters
));
4584 /******************************************************************************/
4586 /* The singleton instance of builtin_builder. */
4587 static builtin_builder builtins
;
4588 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
4591 * External API (exposing the built-in module to the rest of the compiler):
4595 _mesa_glsl_initialize_builtin_functions()
4597 mtx_lock(&builtins_lock
);
4598 builtins
.initialize();
4599 mtx_unlock(&builtins_lock
);
4603 _mesa_glsl_release_builtin_functions()
4605 mtx_lock(&builtins_lock
);
4607 mtx_unlock(&builtins_lock
);
4610 ir_function_signature
*
4611 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4612 const char *name
, exec_list
*actual_parameters
)
4614 ir_function_signature
* s
;
4615 mtx_lock(&builtins_lock
);
4616 s
= builtins
.find(state
, name
, actual_parameters
);
4617 mtx_unlock(&builtins_lock
);
4622 _mesa_glsl_get_builtin_function_shader()
4624 return builtins
.shader
;