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 using namespace ir_builder
;
68 * Availability predicates:
72 always_available(const _mesa_glsl_parse_state
*state
)
78 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
80 return state
->stage
== MESA_SHADER_VERTEX
&&
81 state
->language_version
<= 130 &&
86 fs_only(const _mesa_glsl_parse_state
*state
)
88 return state
->stage
== MESA_SHADER_FRAGMENT
;
92 gs_only(const _mesa_glsl_parse_state
*state
)
94 return state
->stage
== MESA_SHADER_GEOMETRY
;
98 v110(const _mesa_glsl_parse_state
*state
)
100 return !state
->es_shader
;
104 v110_fs_only(const _mesa_glsl_parse_state
*state
)
106 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
110 v120(const _mesa_glsl_parse_state
*state
)
112 return state
->is_version(120, 300);
116 v130(const _mesa_glsl_parse_state
*state
)
118 return state
->is_version(130, 300);
122 v130_fs_only(const _mesa_glsl_parse_state
*state
)
124 return state
->is_version(130, 300) &&
125 state
->stage
== MESA_SHADER_FRAGMENT
;
129 v140(const _mesa_glsl_parse_state
*state
)
131 return state
->is_version(140, 0);
135 texture_rectangle(const _mesa_glsl_parse_state
*state
)
137 return state
->ARB_texture_rectangle_enable
;
141 texture_external(const _mesa_glsl_parse_state
*state
)
143 return state
->OES_EGL_image_external_enable
;
146 /** True if texturing functions with explicit LOD are allowed. */
148 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
150 /* Texturing functions with "Lod" in their name exist:
151 * - In the vertex shader stage (for all languages)
152 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
153 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
155 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
156 * don't need to explicitly check state->es_shader.
158 return state
->stage
== MESA_SHADER_VERTEX
||
159 state
->is_version(130, 300) ||
160 state
->ARB_shader_texture_lod_enable
;
164 v110_lod(const _mesa_glsl_parse_state
*state
)
166 return !state
->es_shader
&& lod_exists_in_stage(state
);
170 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
172 return state
->ARB_shader_texture_lod_enable
;
176 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
178 return state
->ARB_shader_texture_lod_enable
&&
179 state
->ARB_texture_rectangle_enable
;
183 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
185 return state
->is_version(330, 300) ||
186 state
->ARB_shader_bit_encoding_enable
||
187 state
->ARB_gpu_shader5_enable
;
191 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
193 return v130(state
) && state
->EXT_shader_integer_mix_enable
;
197 shader_packing(const _mesa_glsl_parse_state
*state
)
199 return state
->ARB_shading_language_packing_enable
||
200 state
->is_version(400, 0);
204 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
206 return state
->ARB_shading_language_packing_enable
||
207 state
->is_version(400, 300);
211 gpu_shader5(const _mesa_glsl_parse_state
*state
)
213 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
217 texture_array_lod(const _mesa_glsl_parse_state
*state
)
219 return lod_exists_in_stage(state
) &&
220 state
->EXT_texture_array_enable
;
224 fs_texture_array(const _mesa_glsl_parse_state
*state
)
226 return state
->stage
== MESA_SHADER_FRAGMENT
&&
227 state
->EXT_texture_array_enable
;
231 texture_array(const _mesa_glsl_parse_state
*state
)
233 return state
->EXT_texture_array_enable
;
237 texture_multisample(const _mesa_glsl_parse_state
*state
)
239 return state
->is_version(150, 0) ||
240 state
->ARB_texture_multisample_enable
;
244 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
246 return state
->stage
== MESA_SHADER_FRAGMENT
&&
247 (state
->is_version(400, 0) ||
248 state
->ARB_texture_cube_map_array_enable
);
252 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(400, 0) ||
255 state
->ARB_texture_cube_map_array_enable
;
259 texture_query_levels(const _mesa_glsl_parse_state
*state
)
261 return state
->is_version(430, 0) ||
262 state
->ARB_texture_query_levels_enable
;
266 texture_query_lod(const _mesa_glsl_parse_state
*state
)
268 return state
->stage
== MESA_SHADER_FRAGMENT
&&
269 state
->ARB_texture_query_lod_enable
;
273 texture_gather(const _mesa_glsl_parse_state
*state
)
275 return state
->is_version(400, 0) ||
276 state
->ARB_texture_gather_enable
||
277 state
->ARB_gpu_shader5_enable
;
280 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
281 * used for relaxation of const offset requirements.
284 texture_gather_only(const _mesa_glsl_parse_state
*state
)
286 return !state
->is_version(400, 0) &&
287 !state
->ARB_gpu_shader5_enable
&&
288 state
->ARB_texture_gather_enable
;
291 /* Desktop GL or OES_standard_derivatives + fragment shader only */
293 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
295 return state
->stage
== MESA_SHADER_FRAGMENT
&&
296 (state
->is_version(110, 300) ||
297 state
->OES_standard_derivatives_enable
);
301 tex1d_lod(const _mesa_glsl_parse_state
*state
)
303 return !state
->es_shader
&& lod_exists_in_stage(state
);
306 /** True if sampler3D exists */
308 tex3d(const _mesa_glsl_parse_state
*state
)
310 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
311 * OES_texture_3D extension, and in GLSL ES 3.00.
313 return !state
->es_shader
||
314 state
->OES_texture_3D_enable
||
315 state
->language_version
>= 300;
319 fs_tex3d(const _mesa_glsl_parse_state
*state
)
321 return state
->stage
== MESA_SHADER_FRAGMENT
&&
322 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
326 tex3d_lod(const _mesa_glsl_parse_state
*state
)
328 return tex3d(state
) && lod_exists_in_stage(state
);
332 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
334 return state
->ARB_shader_atomic_counters_enable
;
338 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
340 return state
->AMD_shader_trinary_minmax_enable
;
345 /******************************************************************************/
350 * builtin_builder: A singleton object representing the core of the built-in
353 * It generates IR for every built-in function signature, and organizes them
356 class builtin_builder
{
363 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
364 const char *name
, exec_list
*actual_parameters
);
367 * A shader to hold all the built-in signatures; created by this module.
369 * This includes signatures for every built-in, regardless of version or
370 * enabled extensions. The availability predicate associated with each
371 * signature allows matching_signature() to filter out the irrelevant ones.
378 /** Global variables used by built-in functions. */
379 ir_variable
*gl_ModelViewProjectionMatrix
;
380 ir_variable
*gl_Vertex
;
382 void create_shader();
383 void create_intrinsics();
384 void create_builtins();
387 * IR builder helpers:
389 * These convenience functions assist in emitting IR, but don't necessarily
390 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
393 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
394 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
395 ir_constant
*imm(float f
, unsigned vector_elements
=1);
396 ir_constant
*imm(int i
, unsigned vector_elements
=1);
397 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
398 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
399 ir_dereference_variable
*var_ref(ir_variable
*var
);
400 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
401 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
403 ir_expression
*asin_expr(ir_variable
*x
);
406 * Call function \param f with parameters specified as the linked
407 * list \param params of \c ir_variable objects. \param ret should
408 * point to the ir_variable that will hold the function return
409 * value, or be \c NULL if the function has void return type.
411 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
413 /** Create a new function and add the given signatures. */
414 void add_function(const char *name
, ...);
416 ir_function_signature
*new_sig(const glsl_type
*return_type
,
417 builtin_available_predicate avail
,
418 int num_params
, ...);
421 * Function signature generators:
424 ir_function_signature
*unop(builtin_available_predicate avail
,
425 ir_expression_operation opcode
,
426 const glsl_type
*return_type
,
427 const glsl_type
*param_type
);
428 ir_function_signature
*binop(ir_expression_operation opcode
,
429 builtin_available_predicate avail
,
430 const glsl_type
*return_type
,
431 const glsl_type
*param0_type
,
432 const glsl_type
*param1_type
);
434 #define B0(X) ir_function_signature *_##X();
435 #define B1(X) ir_function_signature *_##X(const glsl_type *);
436 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
437 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
438 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
439 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
476 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
477 const glsl_type
*val_type
,
478 const glsl_type
*blend_type
);
487 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
488 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
489 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
490 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
491 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
492 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
493 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
494 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
495 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
496 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
508 B0(determinant_mat2
);
509 B0(determinant_mat3
);
510 B0(determinant_mat4
);
518 BA1(greaterThanEqual
);
525 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
526 const glsl_type
*return_type
,
527 const glsl_type
*sampler_type
);
529 /** Flags to _texture() */
530 #define TEX_PROJECT 1
532 #define TEX_COMPONENT 4
533 #define TEX_OFFSET_NONCONST 8
534 #define TEX_OFFSET_ARRAY 16
536 ir_function_signature
*_texture(ir_texture_opcode opcode
,
537 builtin_available_predicate avail
,
538 const glsl_type
*return_type
,
539 const glsl_type
*sampler_type
,
540 const glsl_type
*coord_type
,
542 B0(textureCubeArrayShadow
);
543 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
544 const glsl_type
*return_type
,
545 const glsl_type
*sampler_type
,
546 const glsl_type
*coord_type
,
547 const glsl_type
*offset_type
= NULL
);
553 B1(textureQueryLevels
);
575 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
576 ir_function_signature
*_atomic_op(const char *intrinsic
,
577 builtin_available_predicate avail
);
579 ir_function_signature
*_min3(builtin_available_predicate avail
,
580 const glsl_type
*x_type
,
581 const glsl_type
*y_type
,
582 const glsl_type
*z_type
);
584 ir_function_signature
*_max3(builtin_available_predicate avail
,
585 const glsl_type
*x_type
,
586 const glsl_type
*y_type
,
587 const glsl_type
*z_type
);
589 ir_function_signature
*_mid3(builtin_available_predicate avail
,
590 const glsl_type
*x_type
,
591 const glsl_type
*y_type
,
592 const glsl_type
*z_type
);
603 } /* anonymous namespace */
606 * Core builtin_builder functionality:
609 builtin_builder::builtin_builder()
611 gl_ModelViewProjectionMatrix(NULL
),
617 builtin_builder::~builtin_builder()
619 ralloc_free(mem_ctx
);
622 ir_function_signature
*
623 builtin_builder::find(_mesa_glsl_parse_state
*state
,
624 const char *name
, exec_list
*actual_parameters
)
626 /* The shader currently being compiled requested a built-in function;
627 * it needs to link against builtin_builder::shader in order to get them.
629 * Even if we don't find a matching signature, we still need to do this so
630 * that the "no matching signature" error will list potential candidates
631 * from the available built-ins.
633 state
->uses_builtin_functions
= true;
635 ir_function
*f
= shader
->symbols
->get_function(name
);
639 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
647 builtin_builder::initialize()
649 /* If already initialized, don't do it again. */
653 mem_ctx
= ralloc_context(NULL
);
660 builtin_builder::release()
662 ralloc_free(mem_ctx
);
670 builtin_builder::create_shader()
672 /* The target doesn't actually matter. There's no target for generic
673 * GLSL utility code that could be linked against any stage, so just
674 * arbitrarily pick GL_VERTEX_SHADER.
676 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
677 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
679 gl_ModelViewProjectionMatrix
=
680 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
681 "gl_ModelViewProjectionMatrix",
684 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
686 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
687 shader
->symbols
->add_variable(gl_Vertex
);
693 * Create ir_function and ir_function_signature objects for each
697 builtin_builder::create_intrinsics()
699 add_function("__intrinsic_atomic_read",
700 _atomic_intrinsic(shader_atomic_counters
),
702 add_function("__intrinsic_atomic_increment",
703 _atomic_intrinsic(shader_atomic_counters
),
705 add_function("__intrinsic_atomic_predecrement",
706 _atomic_intrinsic(shader_atomic_counters
),
711 * Create ir_function and ir_function_signature objects for each built-in.
713 * Contains a list of every available built-in.
716 builtin_builder::create_builtins()
719 add_function(#NAME, \
720 _##NAME(glsl_type::float_type), \
721 _##NAME(glsl_type::vec2_type), \
722 _##NAME(glsl_type::vec3_type), \
723 _##NAME(glsl_type::vec4_type), \
727 add_function(#NAME, \
728 _##NAME(glsl_type::float_type), \
729 _##NAME(glsl_type::vec2_type), \
730 _##NAME(glsl_type::vec3_type), \
731 _##NAME(glsl_type::vec4_type), \
732 _##NAME(glsl_type::int_type), \
733 _##NAME(glsl_type::ivec2_type), \
734 _##NAME(glsl_type::ivec3_type), \
735 _##NAME(glsl_type::ivec4_type), \
739 add_function(#NAME, \
740 _##NAME(always_available, glsl_type::float_type), \
741 _##NAME(always_available, glsl_type::vec2_type), \
742 _##NAME(always_available, glsl_type::vec3_type), \
743 _##NAME(always_available, glsl_type::vec4_type), \
745 _##NAME(always_available, glsl_type::int_type), \
746 _##NAME(always_available, glsl_type::ivec2_type), \
747 _##NAME(always_available, glsl_type::ivec3_type), \
748 _##NAME(always_available, glsl_type::ivec4_type), \
750 _##NAME(v130, glsl_type::uint_type), \
751 _##NAME(v130, glsl_type::uvec2_type), \
752 _##NAME(v130, glsl_type::uvec3_type), \
753 _##NAME(v130, glsl_type::uvec4_type), \
757 add_function(#NAME, \
758 _##NAME(glsl_type::int_type), \
759 _##NAME(glsl_type::ivec2_type), \
760 _##NAME(glsl_type::ivec3_type), \
761 _##NAME(glsl_type::ivec4_type), \
763 _##NAME(glsl_type::uint_type), \
764 _##NAME(glsl_type::uvec2_type), \
765 _##NAME(glsl_type::uvec3_type), \
766 _##NAME(glsl_type::uvec4_type), \
770 add_function(#NAME, \
771 _##NAME(always_available, glsl_type::float_type), \
772 _##NAME(always_available, glsl_type::vec2_type), \
773 _##NAME(always_available, glsl_type::vec3_type), \
774 _##NAME(always_available, glsl_type::vec4_type), \
776 _##NAME(always_available, glsl_type::int_type), \
777 _##NAME(always_available, glsl_type::ivec2_type), \
778 _##NAME(always_available, glsl_type::ivec3_type), \
779 _##NAME(always_available, glsl_type::ivec4_type), \
781 _##NAME(v130, glsl_type::uint_type), \
782 _##NAME(v130, glsl_type::uvec2_type), \
783 _##NAME(v130, glsl_type::uvec3_type), \
784 _##NAME(v130, glsl_type::uvec4_type), \
786 _##NAME(always_available, glsl_type::bool_type), \
787 _##NAME(always_available, glsl_type::bvec2_type), \
788 _##NAME(always_available, glsl_type::bvec3_type), \
789 _##NAME(always_available, glsl_type::bvec4_type), \
792 #define FIU2_MIXED(NAME) \
793 add_function(#NAME, \
794 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
795 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
796 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
797 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
799 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
800 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
801 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
803 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
804 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
805 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
806 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
808 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
809 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
810 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
812 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
813 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
814 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
815 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
817 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
818 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
819 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
831 _atan(glsl_type::float_type
),
832 _atan(glsl_type::vec2_type
),
833 _atan(glsl_type::vec3_type
),
834 _atan(glsl_type::vec4_type
),
835 _atan2(glsl_type::float_type
),
836 _atan2(glsl_type::vec2_type
),
837 _atan2(glsl_type::vec3_type
),
838 _atan2(glsl_type::vec4_type
),
864 _mod(glsl_type::float_type
, glsl_type::float_type
),
865 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
866 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
867 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
869 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
870 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
871 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
881 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
882 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
883 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
884 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
886 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
887 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
888 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
890 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
891 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
892 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
893 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
895 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
896 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
897 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
898 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
900 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
901 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
902 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
903 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
905 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
906 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
907 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
908 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
912 _step(glsl_type::float_type
, glsl_type::float_type
),
913 _step(glsl_type::float_type
, glsl_type::vec2_type
),
914 _step(glsl_type::float_type
, glsl_type::vec3_type
),
915 _step(glsl_type::float_type
, glsl_type::vec4_type
),
917 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
918 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
919 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
922 add_function("smoothstep",
923 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
924 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
925 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
926 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
928 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
929 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
930 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
938 add_function("intBitsToFloat",
939 _intBitsToFloat(glsl_type::int_type
),
940 _intBitsToFloat(glsl_type::ivec2_type
),
941 _intBitsToFloat(glsl_type::ivec3_type
),
942 _intBitsToFloat(glsl_type::ivec4_type
),
944 add_function("uintBitsToFloat",
945 _uintBitsToFloat(glsl_type::uint_type
),
946 _uintBitsToFloat(glsl_type::uvec2_type
),
947 _uintBitsToFloat(glsl_type::uvec3_type
),
948 _uintBitsToFloat(glsl_type::uvec4_type
),
951 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3
), NULL
);
952 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
953 add_function("packUnorm4x8", _packUnorm4x8(shader_packing
), NULL
);
954 add_function("packSnorm4x8", _packSnorm4x8(shader_packing
), NULL
);
955 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3
), NULL
);
956 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
957 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing
), NULL
);
958 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing
), NULL
);
959 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
960 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
966 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
969 add_function("ftransform", _ftransform(), NULL
);
974 add_function("matrixCompMult",
975 _matrixCompMult(glsl_type::mat2_type
),
976 _matrixCompMult(glsl_type::mat3_type
),
977 _matrixCompMult(glsl_type::mat4_type
),
978 _matrixCompMult(glsl_type::mat2x3_type
),
979 _matrixCompMult(glsl_type::mat2x4_type
),
980 _matrixCompMult(glsl_type::mat3x2_type
),
981 _matrixCompMult(glsl_type::mat3x4_type
),
982 _matrixCompMult(glsl_type::mat4x2_type
),
983 _matrixCompMult(glsl_type::mat4x3_type
),
985 add_function("outerProduct",
986 _outerProduct(glsl_type::mat2_type
),
987 _outerProduct(glsl_type::mat3_type
),
988 _outerProduct(glsl_type::mat4_type
),
989 _outerProduct(glsl_type::mat2x3_type
),
990 _outerProduct(glsl_type::mat2x4_type
),
991 _outerProduct(glsl_type::mat3x2_type
),
992 _outerProduct(glsl_type::mat3x4_type
),
993 _outerProduct(glsl_type::mat4x2_type
),
994 _outerProduct(glsl_type::mat4x3_type
),
996 add_function("determinant",
1001 add_function("inverse",
1006 add_function("transpose",
1007 _transpose(glsl_type::mat2_type
),
1008 _transpose(glsl_type::mat3_type
),
1009 _transpose(glsl_type::mat4_type
),
1010 _transpose(glsl_type::mat2x3_type
),
1011 _transpose(glsl_type::mat2x4_type
),
1012 _transpose(glsl_type::mat3x2_type
),
1013 _transpose(glsl_type::mat3x4_type
),
1014 _transpose(glsl_type::mat4x2_type
),
1015 _transpose(glsl_type::mat4x3_type
),
1020 FIU(greaterThanEqual
)
1025 _any(glsl_type::bvec2_type
),
1026 _any(glsl_type::bvec3_type
),
1027 _any(glsl_type::bvec4_type
),
1031 _all(glsl_type::bvec2_type
),
1032 _all(glsl_type::bvec3_type
),
1033 _all(glsl_type::bvec4_type
),
1037 _not(glsl_type::bvec2_type
),
1038 _not(glsl_type::bvec3_type
),
1039 _not(glsl_type::bvec4_type
),
1042 add_function("textureSize",
1043 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1044 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1045 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1047 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1048 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1049 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1051 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1052 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1053 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1055 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1056 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1057 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1059 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1060 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1061 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1063 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1064 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1065 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1066 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1067 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1068 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1070 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1071 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1073 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1074 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1075 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1076 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1078 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1079 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1080 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1081 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1083 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1084 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1085 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1086 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1087 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1088 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1090 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1091 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1092 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1095 add_function("texture",
1096 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1097 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1098 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1100 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1101 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1102 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1104 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1105 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1106 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1108 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1109 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1110 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1112 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1113 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1114 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1116 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1117 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1118 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1120 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1121 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1122 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1124 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1125 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1126 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1128 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1129 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1130 /* samplerCubeArrayShadow is special; it has an extra parameter
1131 * for the shadow comparitor since there is no vec5 type.
1133 _textureCubeArrayShadow(),
1135 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1136 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1137 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1139 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1141 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1142 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1143 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1145 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1146 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1147 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1149 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1150 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1151 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1153 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1154 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1155 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1157 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1158 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1159 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1161 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1162 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1163 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1165 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1166 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1167 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1169 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1170 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1171 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1173 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1176 add_function("textureLod",
1177 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1178 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1179 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1181 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1182 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1183 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1185 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1186 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1187 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1189 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1190 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1191 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1193 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1194 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1196 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1197 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1198 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1200 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1201 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1202 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1204 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1205 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1206 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1208 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1211 add_function("textureOffset",
1212 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1213 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1214 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1216 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1217 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1218 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1220 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1221 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1222 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1224 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1225 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1226 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1228 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1230 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1231 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1233 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1234 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1235 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1237 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1238 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1239 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1241 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1243 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1244 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1245 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1247 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1248 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1249 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1251 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1252 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1253 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1255 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1256 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1258 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1259 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1260 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1262 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1263 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1264 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1266 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1269 add_function("textureProj",
1270 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1271 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1272 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1273 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1274 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1275 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1277 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1278 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1279 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1280 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1281 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1282 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1284 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1285 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1286 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1288 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1289 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1291 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1292 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1293 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1294 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1295 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1296 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1298 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1300 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1301 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1302 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1303 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1304 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1305 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1307 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1308 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1309 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1310 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1311 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1312 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1314 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1315 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1316 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1318 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1319 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1322 add_function("texelFetch",
1323 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1324 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1325 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1327 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1328 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1329 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1331 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1332 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1333 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1335 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1336 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1337 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1339 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1340 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1341 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1343 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1344 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1345 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1347 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1348 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1349 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1351 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1352 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1353 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1355 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1356 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1357 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1360 add_function("texelFetchOffset",
1361 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1362 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1363 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1365 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1366 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1367 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1369 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1370 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1371 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1373 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1374 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1375 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1377 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1378 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1379 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1381 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1382 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1383 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1387 add_function("textureProjOffset",
1388 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1389 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1390 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1391 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1392 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1393 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1395 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1396 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1397 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1398 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1399 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1400 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1402 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1403 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1404 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1406 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1407 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1409 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1410 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1411 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1412 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1413 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1414 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1416 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1418 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1419 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1420 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1421 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1422 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1423 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1425 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1426 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1427 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1428 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1429 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1430 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1432 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1433 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1434 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1436 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1437 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1440 add_function("textureLodOffset",
1441 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1442 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1443 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1445 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1446 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1447 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1449 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1450 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1451 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1453 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1454 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1456 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1457 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1458 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1460 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1461 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1462 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1464 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1467 add_function("textureProjLod",
1468 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1469 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1470 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1471 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1472 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1473 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1475 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1476 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1477 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1478 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1479 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1480 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1482 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1483 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1484 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1486 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1487 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1490 add_function("textureProjLodOffset",
1491 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1492 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1493 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1494 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1495 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1496 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1498 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1499 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1500 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1501 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1502 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1503 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1505 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1506 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1507 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1509 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1510 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1513 add_function("textureGrad",
1514 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1515 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1516 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1518 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1519 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1520 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1522 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1523 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1524 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1526 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1527 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1528 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1530 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1531 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1532 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1534 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1536 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1537 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1538 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1540 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1541 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1542 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1544 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1545 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1546 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1548 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1549 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1550 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1552 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1553 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1556 add_function("textureGradOffset",
1557 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1558 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1559 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1561 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1562 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1563 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1565 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1566 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1567 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1569 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1570 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1571 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1573 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1575 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1576 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1578 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1579 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1580 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1582 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1583 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1584 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1586 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1587 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1590 add_function("textureProjGrad",
1591 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1592 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1593 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1594 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1595 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1596 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1598 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1599 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1600 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1601 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1602 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1603 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1605 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1606 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1607 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1609 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1610 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1611 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1612 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1613 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1614 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1616 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1618 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1619 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1622 add_function("textureProjGradOffset",
1623 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1624 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1625 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1626 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1627 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1628 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1630 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1631 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1632 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1633 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1634 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1635 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1637 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1638 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1639 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1641 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1642 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1643 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1644 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1645 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1646 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1648 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1650 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1651 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1654 add_function("EmitVertex", _EmitVertex(), NULL
);
1655 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1657 add_function("textureQueryLOD",
1658 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1659 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1660 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1662 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1663 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1664 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1666 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1667 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1668 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1670 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1671 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1672 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1674 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1675 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1676 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1678 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1679 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1680 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1682 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1683 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1684 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1686 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1687 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1688 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1689 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1690 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1691 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1694 add_function("textureQueryLevels",
1695 _textureQueryLevels(glsl_type::sampler1D_type
),
1696 _textureQueryLevels(glsl_type::sampler2D_type
),
1697 _textureQueryLevels(glsl_type::sampler3D_type
),
1698 _textureQueryLevels(glsl_type::samplerCube_type
),
1699 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1700 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1701 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1702 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1703 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1704 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1705 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1706 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1707 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1709 _textureQueryLevels(glsl_type::isampler1D_type
),
1710 _textureQueryLevels(glsl_type::isampler2D_type
),
1711 _textureQueryLevels(glsl_type::isampler3D_type
),
1712 _textureQueryLevels(glsl_type::isamplerCube_type
),
1713 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1714 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1715 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1717 _textureQueryLevels(glsl_type::usampler1D_type
),
1718 _textureQueryLevels(glsl_type::usampler2D_type
),
1719 _textureQueryLevels(glsl_type::usampler3D_type
),
1720 _textureQueryLevels(glsl_type::usamplerCube_type
),
1721 _textureQueryLevels(glsl_type::usampler1DArray_type
),
1722 _textureQueryLevels(glsl_type::usampler2DArray_type
),
1723 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
1727 add_function("texture1D",
1728 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1729 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1732 add_function("texture1DArray",
1733 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1734 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1737 add_function("texture1DProj",
1738 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1739 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1740 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1741 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1744 add_function("texture1DLod",
1745 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1748 add_function("texture1DArrayLod",
1749 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1752 add_function("texture1DProjLod",
1753 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1754 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1757 add_function("texture2D",
1758 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1759 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1760 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1763 add_function("texture2DArray",
1764 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1765 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1768 add_function("texture2DProj",
1769 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1770 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1771 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1772 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1773 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1774 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1777 add_function("texture2DLod",
1778 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1781 add_function("texture2DArrayLod",
1782 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1785 add_function("texture2DProjLod",
1786 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1787 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1790 add_function("texture3D",
1791 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1792 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1795 add_function("texture3DProj",
1796 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1797 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1800 add_function("texture3DLod",
1801 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1804 add_function("texture3DProjLod",
1805 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1808 add_function("textureCube",
1809 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1810 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1813 add_function("textureCubeLod",
1814 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1817 add_function("texture2DRect",
1818 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1821 add_function("texture2DRectProj",
1822 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1823 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1826 add_function("shadow1D",
1827 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1828 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1831 add_function("shadow1DArray",
1832 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1833 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1836 add_function("shadow2D",
1837 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1838 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1841 add_function("shadow2DArray",
1842 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1843 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1846 add_function("shadow1DProj",
1847 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1848 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1851 add_function("shadow2DProj",
1852 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1853 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1856 add_function("shadow1DLod",
1857 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1860 add_function("shadow2DLod",
1861 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1864 add_function("shadow1DArrayLod",
1865 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1868 add_function("shadow1DProjLod",
1869 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1872 add_function("shadow2DProjLod",
1873 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1876 add_function("shadow2DRect",
1877 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1880 add_function("shadow2DRectProj",
1881 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1884 add_function("texture1DGradARB",
1885 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1888 add_function("texture1DProjGradARB",
1889 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1890 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1893 add_function("texture2DGradARB",
1894 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1897 add_function("texture2DProjGradARB",
1898 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1899 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1902 add_function("texture3DGradARB",
1903 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1906 add_function("texture3DProjGradARB",
1907 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1910 add_function("textureCubeGradARB",
1911 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1914 add_function("shadow1DGradARB",
1915 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1918 add_function("shadow1DProjGradARB",
1919 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1922 add_function("shadow2DGradARB",
1923 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1926 add_function("shadow2DProjGradARB",
1927 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1930 add_function("texture2DRectGradARB",
1931 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1934 add_function("texture2DRectProjGradARB",
1935 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1936 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1939 add_function("shadow2DRectGradARB",
1940 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1943 add_function("shadow2DRectProjGradARB",
1944 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1947 add_function("textureGather",
1948 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1949 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1950 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1952 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1953 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1954 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1956 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1957 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1958 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1960 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1961 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1962 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1964 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1965 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1966 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1968 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1969 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1970 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1972 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1973 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1974 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1976 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1977 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1978 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1980 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1981 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1982 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1984 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1985 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1986 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1988 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1989 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
1990 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1991 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
1992 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
1995 add_function("textureGatherOffset",
1996 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1997 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1998 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2000 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2001 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2002 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2004 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2005 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2006 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2008 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2009 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2010 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2012 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2013 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2014 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2016 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2017 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2018 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2020 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2021 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2022 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2024 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2025 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2026 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2028 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2029 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2030 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2033 add_function("textureGatherOffsets",
2034 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2035 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2036 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2038 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2039 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2040 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2042 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2043 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2044 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2046 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2047 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2048 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2050 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2051 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2052 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2054 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2055 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2056 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2058 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2059 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2060 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2079 add_function("ldexp",
2080 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2081 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2082 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2083 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2086 add_function("frexp",
2087 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2088 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2089 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2090 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2092 add_function("uaddCarry",
2093 _uaddCarry(glsl_type::uint_type
),
2094 _uaddCarry(glsl_type::uvec2_type
),
2095 _uaddCarry(glsl_type::uvec3_type
),
2096 _uaddCarry(glsl_type::uvec4_type
),
2098 add_function("usubBorrow",
2099 _usubBorrow(glsl_type::uint_type
),
2100 _usubBorrow(glsl_type::uvec2_type
),
2101 _usubBorrow(glsl_type::uvec3_type
),
2102 _usubBorrow(glsl_type::uvec4_type
),
2104 add_function("imulExtended",
2105 _mulExtended(glsl_type::int_type
),
2106 _mulExtended(glsl_type::ivec2_type
),
2107 _mulExtended(glsl_type::ivec3_type
),
2108 _mulExtended(glsl_type::ivec4_type
),
2110 add_function("umulExtended",
2111 _mulExtended(glsl_type::uint_type
),
2112 _mulExtended(glsl_type::uvec2_type
),
2113 _mulExtended(glsl_type::uvec3_type
),
2114 _mulExtended(glsl_type::uvec4_type
),
2117 add_function("atomicCounter",
2118 _atomic_op("__intrinsic_atomic_read",
2119 shader_atomic_counters
),
2121 add_function("atomicCounterIncrement",
2122 _atomic_op("__intrinsic_atomic_increment",
2123 shader_atomic_counters
),
2125 add_function("atomicCounterDecrement",
2126 _atomic_op("__intrinsic_atomic_predecrement",
2127 shader_atomic_counters
),
2130 add_function("min3",
2131 _min3(shader_trinary_minmax
, glsl_type::float_type
, glsl_type::float_type
, glsl_type::float_type
),
2132 _min3(shader_trinary_minmax
, glsl_type::vec2_type
, glsl_type::vec2_type
, glsl_type::vec2_type
),
2133 _min3(shader_trinary_minmax
, glsl_type::vec3_type
, glsl_type::vec3_type
, glsl_type::vec3_type
),
2134 _min3(shader_trinary_minmax
, glsl_type::vec4_type
, glsl_type::vec4_type
, glsl_type::vec4_type
),
2136 _min3(shader_trinary_minmax
, glsl_type::int_type
, glsl_type::int_type
, glsl_type::int_type
),
2137 _min3(shader_trinary_minmax
, glsl_type::ivec2_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2138 _min3(shader_trinary_minmax
, glsl_type::ivec3_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2139 _min3(shader_trinary_minmax
, glsl_type::ivec4_type
, glsl_type::ivec4_type
, glsl_type::ivec4_type
),
2141 _min3(shader_trinary_minmax
, glsl_type::uint_type
, glsl_type::uint_type
, glsl_type::uint_type
),
2142 _min3(shader_trinary_minmax
, glsl_type::uvec2_type
, glsl_type::uvec2_type
, glsl_type::uvec2_type
),
2143 _min3(shader_trinary_minmax
, glsl_type::uvec3_type
, glsl_type::uvec3_type
, glsl_type::uvec3_type
),
2144 _min3(shader_trinary_minmax
, glsl_type::uvec4_type
, glsl_type::uvec4_type
, glsl_type::uvec4_type
),
2147 add_function("max3",
2148 _max3(shader_trinary_minmax
, glsl_type::float_type
, glsl_type::float_type
, glsl_type::float_type
),
2149 _max3(shader_trinary_minmax
, glsl_type::vec2_type
, glsl_type::vec2_type
, glsl_type::vec2_type
),
2150 _max3(shader_trinary_minmax
, glsl_type::vec3_type
, glsl_type::vec3_type
, glsl_type::vec3_type
),
2151 _max3(shader_trinary_minmax
, glsl_type::vec4_type
, glsl_type::vec4_type
, glsl_type::vec4_type
),
2153 _max3(shader_trinary_minmax
, glsl_type::int_type
, glsl_type::int_type
, glsl_type::int_type
),
2154 _max3(shader_trinary_minmax
, glsl_type::ivec2_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2155 _max3(shader_trinary_minmax
, glsl_type::ivec3_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2156 _max3(shader_trinary_minmax
, glsl_type::ivec4_type
, glsl_type::ivec4_type
, glsl_type::ivec4_type
),
2158 _max3(shader_trinary_minmax
, glsl_type::uint_type
, glsl_type::uint_type
, glsl_type::uint_type
),
2159 _max3(shader_trinary_minmax
, glsl_type::uvec2_type
, glsl_type::uvec2_type
, glsl_type::uvec2_type
),
2160 _max3(shader_trinary_minmax
, glsl_type::uvec3_type
, glsl_type::uvec3_type
, glsl_type::uvec3_type
),
2161 _max3(shader_trinary_minmax
, glsl_type::uvec4_type
, glsl_type::uvec4_type
, glsl_type::uvec4_type
),
2164 add_function("mid3",
2165 _mid3(shader_trinary_minmax
, glsl_type::float_type
, glsl_type::float_type
, glsl_type::float_type
),
2166 _mid3(shader_trinary_minmax
, glsl_type::vec2_type
, glsl_type::vec2_type
, glsl_type::vec2_type
),
2167 _mid3(shader_trinary_minmax
, glsl_type::vec3_type
, glsl_type::vec3_type
, glsl_type::vec3_type
),
2168 _mid3(shader_trinary_minmax
, glsl_type::vec4_type
, glsl_type::vec4_type
, glsl_type::vec4_type
),
2170 _mid3(shader_trinary_minmax
, glsl_type::int_type
, glsl_type::int_type
, glsl_type::int_type
),
2171 _mid3(shader_trinary_minmax
, glsl_type::ivec2_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
2172 _mid3(shader_trinary_minmax
, glsl_type::ivec3_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
2173 _mid3(shader_trinary_minmax
, glsl_type::ivec4_type
, glsl_type::ivec4_type
, glsl_type::ivec4_type
),
2175 _mid3(shader_trinary_minmax
, glsl_type::uint_type
, glsl_type::uint_type
, glsl_type::uint_type
),
2176 _mid3(shader_trinary_minmax
, glsl_type::uvec2_type
, glsl_type::uvec2_type
, glsl_type::uvec2_type
),
2177 _mid3(shader_trinary_minmax
, glsl_type::uvec3_type
, glsl_type::uvec3_type
, glsl_type::uvec3_type
),
2178 _mid3(shader_trinary_minmax
, glsl_type::uvec4_type
, glsl_type::uvec4_type
, glsl_type::uvec4_type
),
2189 builtin_builder::add_function(const char *name
, ...)
2193 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2197 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2203 stuff
.push_tail(sig
);
2204 validate_ir_tree(&stuff
);
2207 f
->add_signature(sig
);
2211 shader
->symbols
->add_function(f
);
2215 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2217 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2221 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2223 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2227 builtin_builder::imm(float f
, unsigned vector_elements
)
2229 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2233 builtin_builder::imm(int i
, unsigned vector_elements
)
2235 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2239 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2241 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2245 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2247 return new(mem_ctx
) ir_constant(type
, &data
);
2250 ir_dereference_variable
*
2251 builtin_builder::var_ref(ir_variable
*var
)
2253 return new(mem_ctx
) ir_dereference_variable(var
);
2256 ir_dereference_array
*
2257 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2259 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2262 /** Return an element of a matrix */
2264 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2266 return swizzle(array_ref(var
, column
), row
, 1);
2270 * Implementations of built-in functions:
2273 ir_function_signature
*
2274 builtin_builder::new_sig(const glsl_type
*return_type
,
2275 builtin_available_predicate avail
,
2281 ir_function_signature
*sig
=
2282 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2285 va_start(ap
, num_params
);
2286 for (int i
= 0; i
< num_params
; i
++) {
2287 plist
.push_tail(va_arg(ap
, ir_variable
*));
2291 sig
->replace_parameters(&plist
);
2295 #define MAKE_SIG(return_type, avail, ...) \
2296 ir_function_signature *sig = \
2297 new_sig(return_type, avail, __VA_ARGS__); \
2298 ir_factory body(&sig->body, mem_ctx); \
2299 sig->is_defined = true;
2301 #define MAKE_INTRINSIC(return_type, avail, ...) \
2302 ir_function_signature *sig = \
2303 new_sig(return_type, avail, __VA_ARGS__); \
2304 sig->is_intrinsic = true;
2306 ir_function_signature
*
2307 builtin_builder::unop(builtin_available_predicate avail
,
2308 ir_expression_operation opcode
,
2309 const glsl_type
*return_type
,
2310 const glsl_type
*param_type
)
2312 ir_variable
*x
= in_var(param_type
, "x");
2313 MAKE_SIG(return_type
, avail
, 1, x
);
2314 body
.emit(ret(expr(opcode
, x
)));
2318 #define UNOP(NAME, OPCODE, AVAIL) \
2319 ir_function_signature * \
2320 builtin_builder::_##NAME(const glsl_type *type) \
2322 return unop(&AVAIL, OPCODE, type, type); \
2325 ir_function_signature
*
2326 builtin_builder::binop(ir_expression_operation opcode
,
2327 builtin_available_predicate avail
,
2328 const glsl_type
*return_type
,
2329 const glsl_type
*param0_type
,
2330 const glsl_type
*param1_type
)
2332 ir_variable
*x
= in_var(param0_type
, "x");
2333 ir_variable
*y
= in_var(param1_type
, "y");
2334 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2335 body
.emit(ret(expr(opcode
, x
, y
)));
2339 #define BINOP(NAME, OPCODE, AVAIL) \
2340 ir_function_signature * \
2341 builtin_builder::_##NAME(const glsl_type *return_type, \
2342 const glsl_type *param0_type, \
2343 const glsl_type *param1_type) \
2345 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2349 * Angle and Trigonometry Functions @{
2352 ir_function_signature
*
2353 builtin_builder::_radians(const glsl_type
*type
)
2355 ir_variable
*degrees
= in_var(type
, "degrees");
2356 MAKE_SIG(type
, always_available
, 1, degrees
);
2357 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2361 ir_function_signature
*
2362 builtin_builder::_degrees(const glsl_type
*type
)
2364 ir_variable
*radians
= in_var(type
, "radians");
2365 MAKE_SIG(type
, always_available
, 1, radians
);
2366 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2370 UNOP(sin
, ir_unop_sin
, always_available
)
2371 UNOP(cos
, ir_unop_cos
, always_available
)
2373 ir_function_signature
*
2374 builtin_builder::_tan(const glsl_type
*type
)
2376 ir_variable
*theta
= in_var(type
, "theta");
2377 MAKE_SIG(type
, always_available
, 1, theta
);
2378 body
.emit(ret(div(sin(theta
), cos(theta
))));
2383 builtin_builder::asin_expr(ir_variable
*x
)
2386 sub(imm(1.5707964f
),
2387 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2388 add(imm(1.5707964f
),
2390 add(imm(-0.21460183f
),
2392 add(imm(0.086566724f
),
2393 mul(abs(x
), imm(-0.03102955f
))))))))));
2397 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2399 exec_list actual_params
;
2401 foreach_iter(exec_list_iterator
, it
, params
) {
2402 ir_variable
*var
= ((ir_instruction
*)it
.get())->as_variable();
2403 actual_params
.push_tail(var_ref(var
));
2406 ir_function_signature
*sig
=
2407 f
->exact_matching_signature(NULL
, &actual_params
);
2411 ir_dereference_variable
*deref
=
2412 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2414 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2417 ir_function_signature
*
2418 builtin_builder::_asin(const glsl_type
*type
)
2420 ir_variable
*x
= in_var(type
, "x");
2421 MAKE_SIG(type
, always_available
, 1, x
);
2423 body
.emit(ret(asin_expr(x
)));
2428 ir_function_signature
*
2429 builtin_builder::_acos(const glsl_type
*type
)
2431 ir_variable
*x
= in_var(type
, "x");
2432 MAKE_SIG(type
, always_available
, 1, x
);
2434 body
.emit(ret(sub(imm(1.5707964f
), asin_expr(x
))));
2439 ir_function_signature
*
2440 builtin_builder::_atan2(const glsl_type
*type
)
2442 ir_variable
*vec_y
= in_var(type
, "vec_y");
2443 ir_variable
*vec_x
= in_var(type
, "vec_x");
2444 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2446 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2447 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2448 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2449 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2450 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2451 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2452 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2454 /* If |x| >= 1.0e-8 * |y|: */
2456 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2458 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2460 /* Then...call atan(y/x) */
2461 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2462 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2463 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2465 outer_then
.emit(assign(r
, asin_expr(r
)));
2467 /* ...and fix it up: */
2468 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2469 inner_if
->then_instructions
.push_tail(
2470 if_tree(gequal(y
, imm(0.0f
)),
2471 assign(r
, add(r
, imm(3.141593f
))),
2472 assign(r
, sub(r
, imm(3.141593f
)))));
2473 outer_then
.emit(inner_if
);
2476 outer_if
->else_instructions
.push_tail(
2477 assign(r
, mul(sign(y
), imm(1.5707965f
))));
2479 body
.emit(outer_if
);
2481 body
.emit(assign(vec_result
, r
, 1 << i
));
2483 body
.emit(ret(vec_result
));
2488 ir_function_signature
*
2489 builtin_builder::_atan(const glsl_type
*type
)
2491 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2492 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2494 ir_variable
*t
= body
.make_temp(type
, "t");
2495 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2498 body
.emit(ret(asin_expr(t
)));
2503 ir_function_signature
*
2504 builtin_builder::_sinh(const glsl_type
*type
)
2506 ir_variable
*x
= in_var(type
, "x");
2507 MAKE_SIG(type
, v130
, 1, x
);
2509 /* 0.5 * (e^x - e^(-x)) */
2510 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2515 ir_function_signature
*
2516 builtin_builder::_cosh(const glsl_type
*type
)
2518 ir_variable
*x
= in_var(type
, "x");
2519 MAKE_SIG(type
, v130
, 1, x
);
2521 /* 0.5 * (e^x + e^(-x)) */
2522 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2527 ir_function_signature
*
2528 builtin_builder::_tanh(const glsl_type
*type
)
2530 ir_variable
*x
= in_var(type
, "x");
2531 MAKE_SIG(type
, v130
, 1, x
);
2533 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2534 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2535 add(exp(x
), exp(neg(x
))))));
2540 ir_function_signature
*
2541 builtin_builder::_asinh(const glsl_type
*type
)
2543 ir_variable
*x
= in_var(type
, "x");
2544 MAKE_SIG(type
, v130
, 1, x
);
2546 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2551 ir_function_signature
*
2552 builtin_builder::_acosh(const glsl_type
*type
)
2554 ir_variable
*x
= in_var(type
, "x");
2555 MAKE_SIG(type
, v130
, 1, x
);
2557 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2561 ir_function_signature
*
2562 builtin_builder::_atanh(const glsl_type
*type
)
2564 ir_variable
*x
= in_var(type
, "x");
2565 MAKE_SIG(type
, v130
, 1, x
);
2567 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2568 sub(imm(1.0f
), x
))))));
2574 * Exponential Functions @{
2577 ir_function_signature
*
2578 builtin_builder::_pow(const glsl_type
*type
)
2580 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2583 UNOP(exp
, ir_unop_exp
, always_available
)
2584 UNOP(log
, ir_unop_log
, always_available
)
2585 UNOP(exp2
, ir_unop_exp2
, always_available
)
2586 UNOP(log2
, ir_unop_log2
, always_available
)
2587 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2588 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2592 UNOP(abs
, ir_unop_abs
, always_available
)
2593 UNOP(sign
, ir_unop_sign
, always_available
)
2594 UNOP(floor
, ir_unop_floor
, always_available
)
2595 UNOP(trunc
, ir_unop_trunc
, v130
)
2596 UNOP(round
, ir_unop_round_even
, always_available
)
2597 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2598 UNOP(ceil
, ir_unop_ceil
, always_available
)
2599 UNOP(fract
, ir_unop_fract
, always_available
)
2601 ir_function_signature
*
2602 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2604 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2607 ir_function_signature
*
2608 builtin_builder::_modf(const glsl_type
*type
)
2610 ir_variable
*x
= in_var(type
, "x");
2611 ir_variable
*i
= out_var(type
, "i");
2612 MAKE_SIG(type
, v130
, 2, x
, i
);
2614 ir_variable
*t
= body
.make_temp(type
, "t");
2615 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2616 body
.emit(assign(i
, t
));
2617 body
.emit(ret(sub(x
, t
)));
2622 ir_function_signature
*
2623 builtin_builder::_min(builtin_available_predicate avail
,
2624 const glsl_type
*x_type
, const glsl_type
*y_type
)
2626 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2629 ir_function_signature
*
2630 builtin_builder::_max(builtin_available_predicate avail
,
2631 const glsl_type
*x_type
, const glsl_type
*y_type
)
2633 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2636 ir_function_signature
*
2637 builtin_builder::_clamp(builtin_available_predicate avail
,
2638 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2640 ir_variable
*x
= in_var(val_type
, "x");
2641 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2642 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2643 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2645 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2650 ir_function_signature
*
2651 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2653 ir_variable
*x
= in_var(val_type
, "x");
2654 ir_variable
*y
= in_var(val_type
, "y");
2655 ir_variable
*a
= in_var(blend_type
, "a");
2656 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2658 body
.emit(ret(lrp(x
, y
, a
)));
2663 ir_function_signature
*
2664 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2665 const glsl_type
*val_type
,
2666 const glsl_type
*blend_type
)
2668 ir_variable
*x
= in_var(val_type
, "x");
2669 ir_variable
*y
= in_var(val_type
, "y");
2670 ir_variable
*a
= in_var(blend_type
, "a");
2671 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2673 /* csel matches the ternary operator in that a selector of true choses the
2674 * first argument. This differs from mix(x, y, false) which choses the
2675 * second argument (to remain consistent with the interpolating version of
2676 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2678 * To handle the behavior mismatch, reverse the x and y arguments.
2680 body
.emit(ret(csel(a
, y
, x
)));
2685 ir_function_signature
*
2686 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2688 ir_variable
*edge
= in_var(edge_type
, "edge");
2689 ir_variable
*x
= in_var(x_type
, "x");
2690 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2692 ir_variable
*t
= body
.make_temp(x_type
, "t");
2693 if (x_type
->vector_elements
== 1) {
2694 /* Both are floats */
2695 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2696 } else if (edge_type
->vector_elements
== 1) {
2697 /* x is a vector but edge is a float */
2698 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2699 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2702 /* Both are vectors */
2703 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2704 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2713 ir_function_signature
*
2714 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2716 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2717 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2718 ir_variable
*x
= in_var(x_type
, "x");
2719 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2721 /* From the GLSL 1.10 specification:
2724 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2725 * return t * t * (3 - 2 * t);
2728 ir_variable
*t
= body
.make_temp(x_type
, "t");
2729 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2730 imm(0.0f
), imm(1.0f
))));
2732 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2737 ir_function_signature
*
2738 builtin_builder::_isnan(const glsl_type
*type
)
2740 ir_variable
*x
= in_var(type
, "x");
2741 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2743 body
.emit(ret(nequal(x
, x
)));
2748 ir_function_signature
*
2749 builtin_builder::_isinf(const glsl_type
*type
)
2751 ir_variable
*x
= in_var(type
, "x");
2752 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2754 ir_constant_data infinities
;
2755 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2756 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2759 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2764 ir_function_signature
*
2765 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2767 ir_variable
*x
= in_var(type
, "x");
2768 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2769 body
.emit(ret(bitcast_f2i(x
)));
2773 ir_function_signature
*
2774 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2776 ir_variable
*x
= in_var(type
, "x");
2777 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2778 body
.emit(ret(bitcast_f2u(x
)));
2782 ir_function_signature
*
2783 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2785 ir_variable
*x
= in_var(type
, "x");
2786 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2787 body
.emit(ret(bitcast_i2f(x
)));
2791 ir_function_signature
*
2792 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2794 ir_variable
*x
= in_var(type
, "x");
2795 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2796 body
.emit(ret(bitcast_u2f(x
)));
2800 ir_function_signature
*
2801 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2803 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2804 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2805 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2809 ir_function_signature
*
2810 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2812 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2813 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2814 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2818 ir_function_signature
*
2819 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2821 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2822 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2823 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
2827 ir_function_signature
*
2828 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
2830 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2831 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2832 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
2836 ir_function_signature
*
2837 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
2839 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2840 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2841 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
2845 ir_function_signature
*
2846 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
2848 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2849 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2850 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
2855 ir_function_signature
*
2856 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
2858 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2859 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2860 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
2864 ir_function_signature
*
2865 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
2867 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2868 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2869 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
2873 ir_function_signature
*
2874 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
2876 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2877 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2878 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
2882 ir_function_signature
*
2883 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
2885 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2886 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2887 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
2891 ir_function_signature
*
2892 builtin_builder::_length(const glsl_type
*type
)
2894 ir_variable
*x
= in_var(type
, "x");
2895 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
2897 body
.emit(ret(sqrt(dotlike(x
, x
))));
2902 ir_function_signature
*
2903 builtin_builder::_distance(const glsl_type
*type
)
2905 ir_variable
*p0
= in_var(type
, "p0");
2906 ir_variable
*p1
= in_var(type
, "p1");
2907 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
2909 if (type
->vector_elements
== 1) {
2910 body
.emit(ret(abs(sub(p0
, p1
))));
2912 ir_variable
*p
= body
.make_temp(type
, "p");
2913 body
.emit(assign(p
, sub(p0
, p1
)));
2914 body
.emit(ret(sqrt(dot(p
, p
))));
2920 ir_function_signature
*
2921 builtin_builder::_dot(const glsl_type
*type
)
2923 if (type
->vector_elements
== 1)
2924 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
2926 return binop(ir_binop_dot
, always_available
,
2927 glsl_type::float_type
, type
, type
);
2930 ir_function_signature
*
2931 builtin_builder::_cross(const glsl_type
*type
)
2933 ir_variable
*a
= in_var(type
, "a");
2934 ir_variable
*b
= in_var(type
, "b");
2935 MAKE_SIG(type
, always_available
, 2, a
, b
);
2937 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
2938 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
2940 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
2941 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
2946 ir_function_signature
*
2947 builtin_builder::_normalize(const glsl_type
*type
)
2949 ir_variable
*x
= in_var(type
, "x");
2950 MAKE_SIG(type
, always_available
, 1, x
);
2952 if (type
->vector_elements
== 1) {
2953 body
.emit(ret(sign(x
)));
2955 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
2961 ir_function_signature
*
2962 builtin_builder::_ftransform()
2964 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
2966 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
2967 glsl_type::vec4_type
,
2968 var_ref(gl_ModelViewProjectionMatrix
),
2969 var_ref(gl_Vertex
))));
2971 /* FINISHME: Once the ir_expression() constructor handles type inference
2972 * for matrix operations, we can simplify this to:
2974 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
2979 ir_function_signature
*
2980 builtin_builder::_faceforward(const glsl_type
*type
)
2982 ir_variable
*N
= in_var(type
, "N");
2983 ir_variable
*I
= in_var(type
, "I");
2984 ir_variable
*Nref
= in_var(type
, "Nref");
2985 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
2987 body
.emit(if_tree(less(dotlike(Nref
, I
), imm(0.0f
)),
2988 ret(N
), ret(neg(N
))));
2993 ir_function_signature
*
2994 builtin_builder::_reflect(const glsl_type
*type
)
2996 ir_variable
*I
= in_var(type
, "I");
2997 ir_variable
*N
= in_var(type
, "N");
2998 MAKE_SIG(type
, always_available
, 2, I
, N
);
3000 /* I - 2 * dot(N, I) * N */
3001 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dotlike(N
, I
), N
)))));
3006 ir_function_signature
*
3007 builtin_builder::_refract(const glsl_type
*type
)
3009 ir_variable
*I
= in_var(type
, "I");
3010 ir_variable
*N
= in_var(type
, "N");
3011 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
3012 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
3014 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
3015 body
.emit(assign(n_dot_i
, dotlike(N
, I
)));
3017 /* From the GLSL 1.10 specification:
3018 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3020 * return genType(0.0)
3022 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3024 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
3025 body
.emit(assign(k
, sub(imm(1.0f
),
3026 mul(eta
, mul(eta
, sub(imm(1.0f
),
3027 mul(n_dot_i
, n_dot_i
)))))));
3028 body
.emit(if_tree(less(k
, imm(0.0f
)),
3029 ret(ir_constant::zero(mem_ctx
, type
)),
3030 ret(sub(mul(eta
, I
),
3031 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3036 ir_function_signature
*
3037 builtin_builder::_matrixCompMult(const glsl_type
*type
)
3039 ir_variable
*x
= in_var(type
, "x");
3040 ir_variable
*y
= in_var(type
, "y");
3041 MAKE_SIG(type
, always_available
, 2, x
, y
);
3043 ir_variable
*z
= body
.make_temp(type
, "z");
3044 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3045 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3052 ir_function_signature
*
3053 builtin_builder::_outerProduct(const glsl_type
*type
)
3055 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3056 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3057 MAKE_SIG(type
, v120
, 2, c
, r
);
3059 ir_variable
*m
= body
.make_temp(type
, "m");
3060 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3061 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3068 ir_function_signature
*
3069 builtin_builder::_transpose(const glsl_type
*orig_type
)
3071 const glsl_type
*transpose_type
=
3072 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
3073 orig_type
->matrix_columns
,
3074 orig_type
->vector_elements
);
3076 ir_variable
*m
= in_var(orig_type
, "m");
3077 MAKE_SIG(transpose_type
, v120
, 1, m
);
3079 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3080 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3081 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3082 body
.emit(assign(array_ref(t
, j
),
3083 matrix_elt(m
, i
, j
),
3092 ir_function_signature
*
3093 builtin_builder::_determinant_mat2()
3095 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3096 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3098 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3099 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3104 ir_function_signature
*
3105 builtin_builder::_determinant_mat3()
3107 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3108 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3111 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3112 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3115 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3116 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3119 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3120 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3122 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3123 mul(matrix_elt(m
, 0, 1), f2
)),
3124 mul(matrix_elt(m
, 0, 2), f3
))));
3129 ir_function_signature
*
3130 builtin_builder::_determinant_mat4()
3132 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3133 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3135 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3136 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3137 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3138 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3139 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3140 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3141 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3142 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3143 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3144 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3145 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3146 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3147 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3148 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3149 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3150 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3151 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3152 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3153 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3155 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)))));
3156 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)))));
3157 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)))));
3158 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)))));
3159 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)))));
3160 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)))));
3161 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)))));
3162 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)))));
3163 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)))));
3164 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)))));
3165 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)))));
3166 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)))));
3167 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)))));
3168 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)))));
3169 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)))));
3170 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)))));
3171 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)))));
3172 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)))));
3173 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)))));
3175 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
3177 body
.emit(assign(adj_0
,
3178 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3179 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3180 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3182 body
.emit(assign(adj_0
, neg(
3183 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3184 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3185 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3187 body
.emit(assign(adj_0
,
3188 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3189 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3190 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3192 body
.emit(assign(adj_0
, neg(
3193 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3194 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3195 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3198 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3203 ir_function_signature
*
3204 builtin_builder::_inverse_mat2()
3206 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3207 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
3209 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
3210 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3211 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3212 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3213 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3215 ir_expression
*det
=
3216 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3217 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3219 body
.emit(ret(div(adj
, det
)));
3223 ir_function_signature
*
3224 builtin_builder::_inverse_mat3()
3226 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3227 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
3229 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
3230 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
3231 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
3233 body
.emit(assign(f11_22_21_12
,
3234 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3235 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3236 body
.emit(assign(f10_22_20_12
,
3237 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3238 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3239 body
.emit(assign(f10_21_20_11
,
3240 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3241 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3243 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
3244 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3245 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3246 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3248 body
.emit(assign(array_ref(adj
, 0), neg(
3249 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3250 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3252 body
.emit(assign(array_ref(adj
, 1),
3253 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3254 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3256 body
.emit(assign(array_ref(adj
, 2), neg(
3257 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3258 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3261 body
.emit(assign(array_ref(adj
, 0),
3262 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3263 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3265 body
.emit(assign(array_ref(adj
, 1), neg(
3266 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3267 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3269 body
.emit(assign(array_ref(adj
, 2),
3270 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3271 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3274 ir_expression
*det
=
3275 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3276 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3277 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3279 body
.emit(ret(div(adj
, det
)));
3284 ir_function_signature
*
3285 builtin_builder::_inverse_mat4()
3287 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3288 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
3290 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3291 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3292 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3293 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3294 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3295 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3296 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3297 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3298 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3299 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3300 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3301 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3302 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3303 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3304 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3305 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3306 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3307 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3308 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3310 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)))));
3311 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)))));
3312 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)))));
3313 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)))));
3314 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)))));
3315 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)))));
3316 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)))));
3317 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)))));
3318 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)))));
3319 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)))));
3320 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)))));
3321 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)))));
3322 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)))));
3323 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)))));
3324 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)))));
3325 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)))));
3326 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)))));
3327 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)))));
3328 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)))));
3330 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
3331 body
.emit(assign(array_ref(adj
, 0),
3332 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3333 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3334 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3336 body
.emit(assign(array_ref(adj
, 1), neg(
3337 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3338 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3339 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3341 body
.emit(assign(array_ref(adj
, 2),
3342 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3343 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3344 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3346 body
.emit(assign(array_ref(adj
, 3), neg(
3347 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3348 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3349 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3352 body
.emit(assign(array_ref(adj
, 0), neg(
3353 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3354 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3355 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3357 body
.emit(assign(array_ref(adj
, 1),
3358 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3359 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3360 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3362 body
.emit(assign(array_ref(adj
, 2), neg(
3363 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3364 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3365 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3367 body
.emit(assign(array_ref(adj
, 3),
3368 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3369 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3370 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3373 body
.emit(assign(array_ref(adj
, 0),
3374 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3375 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3376 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3378 body
.emit(assign(array_ref(adj
, 1), neg(
3379 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3380 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3381 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3383 body
.emit(assign(array_ref(adj
, 2),
3384 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3385 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3386 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3388 body
.emit(assign(array_ref(adj
, 3), neg(
3389 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3390 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3391 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3394 body
.emit(assign(array_ref(adj
, 0), neg(
3395 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3396 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3397 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3399 body
.emit(assign(array_ref(adj
, 1),
3400 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3401 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3402 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3404 body
.emit(assign(array_ref(adj
, 2), neg(
3405 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3406 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3407 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3409 body
.emit(assign(array_ref(adj
, 3),
3410 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3411 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3412 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3415 ir_expression
*det
=
3416 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3417 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3418 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3419 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3421 body
.emit(ret(div(adj
, det
)));
3427 ir_function_signature
*
3428 builtin_builder::_lessThan(builtin_available_predicate avail
,
3429 const glsl_type
*type
)
3431 return binop(ir_binop_less
, avail
,
3432 glsl_type::bvec(type
->vector_elements
), type
, type
);
3435 ir_function_signature
*
3436 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3437 const glsl_type
*type
)
3439 return binop(ir_binop_lequal
, avail
,
3440 glsl_type::bvec(type
->vector_elements
), type
, type
);
3443 ir_function_signature
*
3444 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3445 const glsl_type
*type
)
3447 return binop(ir_binop_greater
, avail
,
3448 glsl_type::bvec(type
->vector_elements
), type
, type
);
3451 ir_function_signature
*
3452 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3453 const glsl_type
*type
)
3455 return binop(ir_binop_gequal
, avail
,
3456 glsl_type::bvec(type
->vector_elements
), type
, type
);
3459 ir_function_signature
*
3460 builtin_builder::_equal(builtin_available_predicate avail
,
3461 const glsl_type
*type
)
3463 return binop(ir_binop_equal
, avail
,
3464 glsl_type::bvec(type
->vector_elements
), type
, type
);
3467 ir_function_signature
*
3468 builtin_builder::_notEqual(builtin_available_predicate avail
,
3469 const glsl_type
*type
)
3471 return binop(ir_binop_nequal
, avail
,
3472 glsl_type::bvec(type
->vector_elements
), type
, type
);
3475 ir_function_signature
*
3476 builtin_builder::_any(const glsl_type
*type
)
3478 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3481 ir_function_signature
*
3482 builtin_builder::_all(const glsl_type
*type
)
3484 ir_variable
*v
= in_var(type
, "v");
3485 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3487 switch (type
->vector_elements
) {
3489 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3492 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3496 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3505 UNOP(not, ir_unop_logic_not
, always_available
)
3508 has_lod(const glsl_type
*sampler_type
)
3510 assert(sampler_type
->is_sampler());
3512 switch (sampler_type
->sampler_dimensionality
) {
3513 case GLSL_SAMPLER_DIM_RECT
:
3514 case GLSL_SAMPLER_DIM_BUF
:
3515 case GLSL_SAMPLER_DIM_MS
:
3522 ir_function_signature
*
3523 builtin_builder::_textureSize(builtin_available_predicate avail
,
3524 const glsl_type
*return_type
,
3525 const glsl_type
*sampler_type
)
3527 ir_variable
*s
= in_var(sampler_type
, "sampler");
3528 /* The sampler always exists; add optional lod later. */
3529 MAKE_SIG(return_type
, avail
, 1, s
);
3531 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3532 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3534 if (has_lod(sampler_type
)) {
3535 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3536 sig
->parameters
.push_tail(lod
);
3537 tex
->lod_info
.lod
= var_ref(lod
);
3539 tex
->lod_info
.lod
= imm(0u);
3542 body
.emit(ret(tex
));
3547 ir_function_signature
*
3548 builtin_builder::_texture(ir_texture_opcode opcode
,
3549 builtin_available_predicate avail
,
3550 const glsl_type
*return_type
,
3551 const glsl_type
*sampler_type
,
3552 const glsl_type
*coord_type
,
3555 ir_variable
*s
= in_var(sampler_type
, "sampler");
3556 ir_variable
*P
= in_var(coord_type
, "P");
3557 /* The sampler and coordinate always exist; add optional parameters later. */
3558 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3560 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3561 tex
->set_sampler(var_ref(s
), return_type
);
3563 const int coord_size
= sampler_type
->sampler_coordinate_components();
3565 if (coord_size
== coord_type
->vector_elements
) {
3566 tex
->coordinate
= var_ref(P
);
3568 /* The incoming coordinate also has the projector or shadow comparitor,
3569 * so we need to swizzle those away.
3571 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3574 /* The projector is always in the last component. */
3575 if (flags
& TEX_PROJECT
)
3576 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3578 if (sampler_type
->sampler_shadow
) {
3579 if (opcode
== ir_tg4
) {
3580 /* gather has refz as a separate parameter, immediately after the
3583 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
3584 sig
->parameters
.push_tail(refz
);
3585 tex
->shadow_comparitor
= var_ref(refz
);
3587 /* The shadow comparitor is normally in the Z component, but a few types
3588 * have sufficiently large coordinates that it's in W.
3590 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3594 if (opcode
== ir_txl
) {
3595 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3596 sig
->parameters
.push_tail(lod
);
3597 tex
->lod_info
.lod
= var_ref(lod
);
3598 } else if (opcode
== ir_txd
) {
3599 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3600 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3601 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3602 sig
->parameters
.push_tail(dPdx
);
3603 sig
->parameters
.push_tail(dPdy
);
3604 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3605 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3608 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
3609 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3610 ir_variable
*offset
=
3611 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
3612 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
3613 sig
->parameters
.push_tail(offset
);
3614 tex
->offset
= var_ref(offset
);
3617 if (flags
& TEX_OFFSET_ARRAY
) {
3618 ir_variable
*offsets
=
3619 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
3620 "offsets", ir_var_const_in
);
3621 sig
->parameters
.push_tail(offsets
);
3622 tex
->offset
= var_ref(offsets
);
3625 if (opcode
== ir_tg4
) {
3626 if (flags
& TEX_COMPONENT
) {
3627 ir_variable
*component
=
3628 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
3629 sig
->parameters
.push_tail(component
);
3630 tex
->lod_info
.component
= var_ref(component
);
3633 tex
->lod_info
.component
= imm(0);
3637 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3638 * inconsistent with both textureLodOffset and textureGradOffset.
3640 if (opcode
== ir_txb
) {
3641 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3642 sig
->parameters
.push_tail(bias
);
3643 tex
->lod_info
.bias
= var_ref(bias
);
3646 body
.emit(ret(tex
));
3651 ir_function_signature
*
3652 builtin_builder::_textureCubeArrayShadow()
3654 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3655 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3656 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3657 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3659 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3660 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3662 tex
->coordinate
= var_ref(P
);
3663 tex
->shadow_comparitor
= var_ref(compare
);
3665 body
.emit(ret(tex
));
3670 ir_function_signature
*
3671 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3672 const glsl_type
*return_type
,
3673 const glsl_type
*sampler_type
,
3674 const glsl_type
*coord_type
,
3675 const glsl_type
*offset_type
)
3677 ir_variable
*s
= in_var(sampler_type
, "sampler");
3678 ir_variable
*P
= in_var(coord_type
, "P");
3679 /* The sampler and coordinate always exist; add optional parameters later. */
3680 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3682 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3683 tex
->coordinate
= var_ref(P
);
3684 tex
->set_sampler(var_ref(s
), return_type
);
3686 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3687 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3688 sig
->parameters
.push_tail(sample
);
3689 tex
->lod_info
.sample_index
= var_ref(sample
);
3690 tex
->op
= ir_txf_ms
;
3691 } else if (has_lod(sampler_type
)) {
3692 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3693 sig
->parameters
.push_tail(lod
);
3694 tex
->lod_info
.lod
= var_ref(lod
);
3696 tex
->lod_info
.lod
= imm(0u);
3699 if (offset_type
!= NULL
) {
3700 ir_variable
*offset
=
3701 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3702 sig
->parameters
.push_tail(offset
);
3703 tex
->offset
= var_ref(offset
);
3706 body
.emit(ret(tex
));
3711 ir_function_signature
*
3712 builtin_builder::_EmitVertex()
3714 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3716 body
.emit(new(mem_ctx
) ir_emit_vertex());
3721 ir_function_signature
*
3722 builtin_builder::_EndPrimitive()
3724 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3726 body
.emit(new(mem_ctx
) ir_end_primitive());
3731 ir_function_signature
*
3732 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3733 const glsl_type
*coord_type
)
3735 ir_variable
*s
= in_var(sampler_type
, "sampler");
3736 ir_variable
*coord
= in_var(coord_type
, "coord");
3737 /* The sampler and coordinate always exist; add optional parameters later. */
3738 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3740 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3741 tex
->coordinate
= var_ref(coord
);
3742 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3744 body
.emit(ret(tex
));
3749 ir_function_signature
*
3750 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
3752 ir_variable
*s
= in_var(sampler_type
, "sampler");
3753 const glsl_type
*return_type
= glsl_type::int_type
;
3754 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
3756 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
3757 tex
->set_sampler(var_ref(s
), return_type
);
3759 body
.emit(ret(tex
));
3764 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3765 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3767 ir_function_signature
*
3768 builtin_builder::_fwidth(const glsl_type
*type
)
3770 ir_variable
*p
= in_var(type
, "p");
3771 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3773 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3778 ir_function_signature
*
3779 builtin_builder::_noise1(const glsl_type
*type
)
3781 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
3784 ir_function_signature
*
3785 builtin_builder::_noise2(const glsl_type
*type
)
3787 ir_variable
*p
= in_var(type
, "p");
3788 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
3790 ir_constant_data b_offset
;
3791 b_offset
.f
[0] = 601.0f
;
3792 b_offset
.f
[1] = 313.0f
;
3793 b_offset
.f
[2] = 29.0f
;
3794 b_offset
.f
[3] = 277.0f
;
3796 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3797 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3798 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
3799 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3800 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3801 body
.emit(assign(t
, a
, WRITEMASK_X
));
3802 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3808 ir_function_signature
*
3809 builtin_builder::_noise3(const glsl_type
*type
)
3811 ir_variable
*p
= in_var(type
, "p");
3812 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
3814 ir_constant_data b_offset
;
3815 b_offset
.f
[0] = 601.0f
;
3816 b_offset
.f
[1] = 313.0f
;
3817 b_offset
.f
[2] = 29.0f
;
3818 b_offset
.f
[3] = 277.0f
;
3820 ir_constant_data c_offset
;
3821 c_offset
.f
[0] = 1559.0f
;
3822 c_offset
.f
[1] = 113.0f
;
3823 c_offset
.f
[2] = 1861.0f
;
3824 c_offset
.f
[3] = 797.0f
;
3826 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3827 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3828 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3829 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
3830 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3831 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3832 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
3833 body
.emit(assign(t
, a
, WRITEMASK_X
));
3834 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3835 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3841 ir_function_signature
*
3842 builtin_builder::_noise4(const glsl_type
*type
)
3844 ir_variable
*p
= in_var(type
, "p");
3845 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
3847 ir_variable
*_p
= body
.make_temp(type
, "_p");
3849 ir_constant_data p_offset
;
3850 p_offset
.f
[0] = 1559.0f
;
3851 p_offset
.f
[1] = 113.0f
;
3852 p_offset
.f
[2] = 1861.0f
;
3853 p_offset
.f
[3] = 797.0f
;
3855 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
3857 ir_constant_data offset
;
3858 offset
.f
[0] = 601.0f
;
3859 offset
.f
[1] = 313.0f
;
3860 offset
.f
[2] = 29.0f
;
3861 offset
.f
[3] = 277.0f
;
3863 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3864 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3865 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3866 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
3867 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
3868 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3869 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
3870 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
3871 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
3872 body
.emit(assign(t
, a
, WRITEMASK_X
));
3873 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3874 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3875 body
.emit(assign(t
, d
, WRITEMASK_W
));
3881 ir_function_signature
*
3882 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
3884 ir_variable
*value
= in_var(type
, "value");
3885 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3886 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3887 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
3889 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
3894 ir_function_signature
*
3895 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
3897 ir_variable
*base
= in_var(type
, "base");
3898 ir_variable
*insert
= in_var(type
, "insert");
3899 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3900 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3901 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
3903 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
3908 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
3910 ir_function_signature
*
3911 builtin_builder::_bitCount(const glsl_type
*type
)
3913 return unop(gpu_shader5
, ir_unop_bit_count
,
3914 glsl_type::ivec(type
->vector_elements
), type
);
3917 ir_function_signature
*
3918 builtin_builder::_findLSB(const glsl_type
*type
)
3920 return unop(gpu_shader5
, ir_unop_find_lsb
,
3921 glsl_type::ivec(type
->vector_elements
), type
);
3924 ir_function_signature
*
3925 builtin_builder::_findMSB(const glsl_type
*type
)
3927 return unop(gpu_shader5
, ir_unop_find_msb
,
3928 glsl_type::ivec(type
->vector_elements
), type
);
3931 ir_function_signature
*
3932 builtin_builder::_fma(const glsl_type
*type
)
3934 ir_variable
*a
= in_var(type
, "a");
3935 ir_variable
*b
= in_var(type
, "b");
3936 ir_variable
*c
= in_var(type
, "c");
3937 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
3939 body
.emit(ret(fma(a
, b
, c
)));
3944 ir_function_signature
*
3945 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3947 return binop(ir_binop_ldexp
, gpu_shader5
, x_type
, x_type
, exp_type
);
3950 ir_function_signature
*
3951 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3953 ir_variable
*x
= in_var(x_type
, "x");
3954 ir_variable
*exponent
= out_var(exp_type
, "exp");
3955 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
3957 const unsigned vec_elem
= x_type
->vector_elements
;
3958 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
3959 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
3961 /* Single-precision floating-point values are stored as
3966 * An exponent shift of 23 will shift the mantissa out, leaving only the
3967 * exponent and sign bit (which itself may be zero, if the absolute value
3968 * was taken before the bitcast and shift.
3970 ir_constant
*exponent_shift
= imm(23);
3971 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
3973 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
3975 /* Exponent of floating-point values in the range [0.5, 1.0). */
3976 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
3978 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
3979 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
3981 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
3982 * to unsigned integers to ensure that 1 bits aren't shifted in.
3984 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
3985 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
3986 imm(0, vec_elem
)))));
3988 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
3989 body
.emit(assign(bits
, bitcast_f2u(x
)));
3990 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
3991 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
3992 imm(0u, vec_elem
)))));
3993 body
.emit(ret(bitcast_u2f(bits
)));
3998 ir_function_signature
*
3999 builtin_builder::_uaddCarry(const glsl_type
*type
)
4001 ir_variable
*x
= in_var(type
, "x");
4002 ir_variable
*y
= in_var(type
, "y");
4003 ir_variable
*carry
= out_var(type
, "carry");
4004 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
4006 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4007 body
.emit(ret(add(x
, y
)));
4012 ir_function_signature
*
4013 builtin_builder::_usubBorrow(const glsl_type
*type
)
4015 ir_variable
*x
= in_var(type
, "x");
4016 ir_variable
*y
= in_var(type
, "y");
4017 ir_variable
*borrow
= out_var(type
, "borrow");
4018 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
4020 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4021 body
.emit(ret(sub(x
, y
)));
4027 * For both imulExtended() and umulExtended() built-ins.
4029 ir_function_signature
*
4030 builtin_builder::_mulExtended(const glsl_type
*type
)
4032 ir_variable
*x
= in_var(type
, "x");
4033 ir_variable
*y
= in_var(type
, "y");
4034 ir_variable
*msb
= out_var(type
, "msb");
4035 ir_variable
*lsb
= out_var(type
, "lsb");
4036 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
4038 body
.emit(assign(msb
, imul_high(x
, y
)));
4039 body
.emit(assign(lsb
, mul(x
, y
)));
4044 ir_function_signature
*
4045 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4047 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4048 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4052 ir_function_signature
*
4053 builtin_builder::_atomic_op(const char *intrinsic
,
4054 builtin_available_predicate avail
)
4056 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4057 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4059 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4060 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4062 body
.emit(ret(retval
));
4066 ir_function_signature
*
4067 builtin_builder::_min3(builtin_available_predicate avail
,
4068 const glsl_type
*x_type
, const glsl_type
*y_type
,
4069 const glsl_type
*z_type
)
4071 ir_variable
*x
= in_var(x_type
, "x");
4072 ir_variable
*y
= in_var(y_type
, "y");
4073 ir_variable
*z
= in_var(z_type
, "z");
4074 MAKE_SIG(x_type
, avail
, 3, x
, y
, z
);
4076 ir_expression
*min3
= min2(x
, min2(y
,z
));
4077 body
.emit(ret(min3
));
4082 ir_function_signature
*
4083 builtin_builder::_max3(builtin_available_predicate avail
,
4084 const glsl_type
*x_type
, const glsl_type
*y_type
,
4085 const glsl_type
*z_type
)
4087 ir_variable
*x
= in_var(x_type
, "x");
4088 ir_variable
*y
= in_var(y_type
, "y");
4089 ir_variable
*z
= in_var(z_type
, "z");
4090 MAKE_SIG(x_type
, avail
, 3, x
, y
, z
);
4092 ir_expression
*max3
= max2(x
, max2(y
,z
));
4093 body
.emit(ret(max3
));
4098 ir_function_signature
*
4099 builtin_builder::_mid3(builtin_available_predicate avail
,
4100 const glsl_type
*x_type
, const glsl_type
*y_type
,
4101 const glsl_type
*z_type
)
4103 ir_variable
*x
= in_var(x_type
, "x");
4104 ir_variable
*y
= in_var(y_type
, "y");
4105 ir_variable
*z
= in_var(z_type
, "z");
4106 MAKE_SIG(x_type
, avail
, 3, x
, y
, z
);
4108 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4109 body
.emit(ret(mid3
));
4116 /******************************************************************************/
4118 /* The singleton instance of builtin_builder. */
4119 static builtin_builder builtins
;
4122 * External API (exposing the built-in module to the rest of the compiler):
4126 _mesa_glsl_initialize_builtin_functions()
4128 builtins
.initialize();
4132 _mesa_glsl_release_builtin_functions()
4137 ir_function_signature
*
4138 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4139 const char *name
, exec_list
*actual_parameters
)
4141 return builtins
.find(state
, name
, actual_parameters
);
4145 _mesa_glsl_get_builtin_function_shader()
4147 return builtins
.shader
;