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
);
592 } /* anonymous namespace */
595 * Core builtin_builder functionality:
598 builtin_builder::builtin_builder()
600 gl_ModelViewProjectionMatrix(NULL
),
606 builtin_builder::~builtin_builder()
608 ralloc_free(mem_ctx
);
611 ir_function_signature
*
612 builtin_builder::find(_mesa_glsl_parse_state
*state
,
613 const char *name
, exec_list
*actual_parameters
)
615 /* The shader currently being compiled requested a built-in function;
616 * it needs to link against builtin_builder::shader in order to get them.
618 * Even if we don't find a matching signature, we still need to do this so
619 * that the "no matching signature" error will list potential candidates
620 * from the available built-ins.
622 state
->uses_builtin_functions
= true;
624 ir_function
*f
= shader
->symbols
->get_function(name
);
628 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
636 builtin_builder::initialize()
638 /* If already initialized, don't do it again. */
642 mem_ctx
= ralloc_context(NULL
);
649 builtin_builder::release()
651 ralloc_free(mem_ctx
);
659 builtin_builder::create_shader()
661 /* The target doesn't actually matter. There's no target for generic
662 * GLSL utility code that could be linked against any stage, so just
663 * arbitrarily pick GL_VERTEX_SHADER.
665 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
666 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
668 gl_ModelViewProjectionMatrix
=
669 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
670 "gl_ModelViewProjectionMatrix",
673 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
675 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
676 shader
->symbols
->add_variable(gl_Vertex
);
682 * Create ir_function and ir_function_signature objects for each
686 builtin_builder::create_intrinsics()
688 add_function("__intrinsic_atomic_read",
689 _atomic_intrinsic(shader_atomic_counters
),
691 add_function("__intrinsic_atomic_increment",
692 _atomic_intrinsic(shader_atomic_counters
),
694 add_function("__intrinsic_atomic_predecrement",
695 _atomic_intrinsic(shader_atomic_counters
),
700 * Create ir_function and ir_function_signature objects for each built-in.
702 * Contains a list of every available built-in.
705 builtin_builder::create_builtins()
708 add_function(#NAME, \
709 _##NAME(glsl_type::float_type), \
710 _##NAME(glsl_type::vec2_type), \
711 _##NAME(glsl_type::vec3_type), \
712 _##NAME(glsl_type::vec4_type), \
716 add_function(#NAME, \
717 _##NAME(glsl_type::float_type), \
718 _##NAME(glsl_type::vec2_type), \
719 _##NAME(glsl_type::vec3_type), \
720 _##NAME(glsl_type::vec4_type), \
721 _##NAME(glsl_type::int_type), \
722 _##NAME(glsl_type::ivec2_type), \
723 _##NAME(glsl_type::ivec3_type), \
724 _##NAME(glsl_type::ivec4_type), \
728 add_function(#NAME, \
729 _##NAME(always_available, glsl_type::float_type), \
730 _##NAME(always_available, glsl_type::vec2_type), \
731 _##NAME(always_available, glsl_type::vec3_type), \
732 _##NAME(always_available, glsl_type::vec4_type), \
734 _##NAME(always_available, glsl_type::int_type), \
735 _##NAME(always_available, glsl_type::ivec2_type), \
736 _##NAME(always_available, glsl_type::ivec3_type), \
737 _##NAME(always_available, glsl_type::ivec4_type), \
739 _##NAME(v130, glsl_type::uint_type), \
740 _##NAME(v130, glsl_type::uvec2_type), \
741 _##NAME(v130, glsl_type::uvec3_type), \
742 _##NAME(v130, glsl_type::uvec4_type), \
746 add_function(#NAME, \
747 _##NAME(glsl_type::int_type), \
748 _##NAME(glsl_type::ivec2_type), \
749 _##NAME(glsl_type::ivec3_type), \
750 _##NAME(glsl_type::ivec4_type), \
752 _##NAME(glsl_type::uint_type), \
753 _##NAME(glsl_type::uvec2_type), \
754 _##NAME(glsl_type::uvec3_type), \
755 _##NAME(glsl_type::uvec4_type), \
759 add_function(#NAME, \
760 _##NAME(always_available, glsl_type::float_type), \
761 _##NAME(always_available, glsl_type::vec2_type), \
762 _##NAME(always_available, glsl_type::vec3_type), \
763 _##NAME(always_available, glsl_type::vec4_type), \
765 _##NAME(always_available, glsl_type::int_type), \
766 _##NAME(always_available, glsl_type::ivec2_type), \
767 _##NAME(always_available, glsl_type::ivec3_type), \
768 _##NAME(always_available, glsl_type::ivec4_type), \
770 _##NAME(v130, glsl_type::uint_type), \
771 _##NAME(v130, glsl_type::uvec2_type), \
772 _##NAME(v130, glsl_type::uvec3_type), \
773 _##NAME(v130, glsl_type::uvec4_type), \
775 _##NAME(always_available, glsl_type::bool_type), \
776 _##NAME(always_available, glsl_type::bvec2_type), \
777 _##NAME(always_available, glsl_type::bvec3_type), \
778 _##NAME(always_available, glsl_type::bvec4_type), \
781 #define FIU2_MIXED(NAME) \
782 add_function(#NAME, \
783 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
784 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
785 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
786 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
788 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
789 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
790 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
792 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
793 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
794 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
795 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
797 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
798 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
799 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
801 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
802 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
803 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
804 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
806 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
807 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
808 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
820 _atan(glsl_type::float_type
),
821 _atan(glsl_type::vec2_type
),
822 _atan(glsl_type::vec3_type
),
823 _atan(glsl_type::vec4_type
),
824 _atan2(glsl_type::float_type
),
825 _atan2(glsl_type::vec2_type
),
826 _atan2(glsl_type::vec3_type
),
827 _atan2(glsl_type::vec4_type
),
853 _mod(glsl_type::float_type
, glsl_type::float_type
),
854 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
855 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
856 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
858 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
859 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
860 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
870 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
871 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
872 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
873 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
875 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
876 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
877 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
879 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
880 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
881 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
882 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
884 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
885 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
886 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
887 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
889 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
890 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
891 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
892 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
894 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
895 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
896 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
897 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
901 _step(glsl_type::float_type
, glsl_type::float_type
),
902 _step(glsl_type::float_type
, glsl_type::vec2_type
),
903 _step(glsl_type::float_type
, glsl_type::vec3_type
),
904 _step(glsl_type::float_type
, glsl_type::vec4_type
),
906 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
907 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
908 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
911 add_function("smoothstep",
912 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
913 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
914 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
915 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
917 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
918 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
919 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
927 add_function("intBitsToFloat",
928 _intBitsToFloat(glsl_type::int_type
),
929 _intBitsToFloat(glsl_type::ivec2_type
),
930 _intBitsToFloat(glsl_type::ivec3_type
),
931 _intBitsToFloat(glsl_type::ivec4_type
),
933 add_function("uintBitsToFloat",
934 _uintBitsToFloat(glsl_type::uint_type
),
935 _uintBitsToFloat(glsl_type::uvec2_type
),
936 _uintBitsToFloat(glsl_type::uvec3_type
),
937 _uintBitsToFloat(glsl_type::uvec4_type
),
940 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3
), NULL
);
941 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
942 add_function("packUnorm4x8", _packUnorm4x8(shader_packing
), NULL
);
943 add_function("packSnorm4x8", _packSnorm4x8(shader_packing
), NULL
);
944 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3
), NULL
);
945 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
946 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing
), NULL
);
947 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing
), NULL
);
948 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
949 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
955 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
958 add_function("ftransform", _ftransform(), NULL
);
963 add_function("matrixCompMult",
964 _matrixCompMult(glsl_type::mat2_type
),
965 _matrixCompMult(glsl_type::mat3_type
),
966 _matrixCompMult(glsl_type::mat4_type
),
967 _matrixCompMult(glsl_type::mat2x3_type
),
968 _matrixCompMult(glsl_type::mat2x4_type
),
969 _matrixCompMult(glsl_type::mat3x2_type
),
970 _matrixCompMult(glsl_type::mat3x4_type
),
971 _matrixCompMult(glsl_type::mat4x2_type
),
972 _matrixCompMult(glsl_type::mat4x3_type
),
974 add_function("outerProduct",
975 _outerProduct(glsl_type::mat2_type
),
976 _outerProduct(glsl_type::mat3_type
),
977 _outerProduct(glsl_type::mat4_type
),
978 _outerProduct(glsl_type::mat2x3_type
),
979 _outerProduct(glsl_type::mat2x4_type
),
980 _outerProduct(glsl_type::mat3x2_type
),
981 _outerProduct(glsl_type::mat3x4_type
),
982 _outerProduct(glsl_type::mat4x2_type
),
983 _outerProduct(glsl_type::mat4x3_type
),
985 add_function("determinant",
990 add_function("inverse",
995 add_function("transpose",
996 _transpose(glsl_type::mat2_type
),
997 _transpose(glsl_type::mat3_type
),
998 _transpose(glsl_type::mat4_type
),
999 _transpose(glsl_type::mat2x3_type
),
1000 _transpose(glsl_type::mat2x4_type
),
1001 _transpose(glsl_type::mat3x2_type
),
1002 _transpose(glsl_type::mat3x4_type
),
1003 _transpose(glsl_type::mat4x2_type
),
1004 _transpose(glsl_type::mat4x3_type
),
1009 FIU(greaterThanEqual
)
1014 _any(glsl_type::bvec2_type
),
1015 _any(glsl_type::bvec3_type
),
1016 _any(glsl_type::bvec4_type
),
1020 _all(glsl_type::bvec2_type
),
1021 _all(glsl_type::bvec3_type
),
1022 _all(glsl_type::bvec4_type
),
1026 _not(glsl_type::bvec2_type
),
1027 _not(glsl_type::bvec3_type
),
1028 _not(glsl_type::bvec4_type
),
1031 add_function("textureSize",
1032 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1033 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1034 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1036 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1037 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1038 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1040 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1041 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1042 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1044 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1045 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1046 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1048 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1049 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1050 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1052 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1053 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1054 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1055 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1056 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1057 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1059 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1060 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1062 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1063 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1064 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1065 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1067 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1068 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1069 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1070 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1072 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1073 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1074 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1075 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1076 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1077 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1079 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1080 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1081 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1084 add_function("texture",
1085 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1086 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1087 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1089 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1090 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1091 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1093 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1094 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1095 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1097 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1098 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1099 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1101 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1102 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1103 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1105 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1106 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1107 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1109 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1110 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1111 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1113 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1114 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1115 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1117 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1118 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1119 /* samplerCubeArrayShadow is special; it has an extra parameter
1120 * for the shadow comparitor since there is no vec5 type.
1122 _textureCubeArrayShadow(),
1124 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1125 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1126 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1128 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1130 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1131 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1132 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1134 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1135 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1136 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1138 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1139 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1140 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1142 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1143 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1144 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1146 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1147 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1148 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1150 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1151 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1152 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1154 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1155 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1156 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1158 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1159 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1160 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1162 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1165 add_function("textureLod",
1166 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1167 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1168 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1170 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1171 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1172 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1174 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1175 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1176 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1178 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1179 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1180 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1182 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1183 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1185 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1186 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1187 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1189 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1190 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1191 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1193 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1194 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1195 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1197 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1200 add_function("textureOffset",
1201 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1202 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1203 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1205 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1206 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1207 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1209 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1210 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1211 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1213 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1214 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1215 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1217 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1219 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1220 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1222 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1223 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1224 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1226 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1227 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1228 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1230 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1232 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1233 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1234 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1236 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1237 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1238 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1240 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1241 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1242 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1244 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1245 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1247 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1248 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1249 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1251 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1252 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1253 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1255 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1258 add_function("textureProj",
1259 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1260 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1261 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1262 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1263 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1264 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1266 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1267 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1268 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1269 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1270 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1271 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1273 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1274 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1275 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1277 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1278 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1280 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1281 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1282 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1283 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1284 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1285 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1287 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1289 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1290 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1291 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1292 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1293 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1294 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1296 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1297 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1298 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1299 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1300 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1301 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1303 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1304 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1305 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1307 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1308 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1311 add_function("texelFetch",
1312 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1313 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1314 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1316 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1317 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1318 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1320 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1321 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1322 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1324 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1325 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1326 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1328 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1329 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1330 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1332 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1333 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1334 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1336 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1337 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1338 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1340 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1341 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1342 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1344 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1345 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1346 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1349 add_function("texelFetchOffset",
1350 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1351 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1352 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1354 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1355 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1356 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1358 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1359 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1360 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1362 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1363 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1364 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1366 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1367 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1368 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1370 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1371 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1372 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1376 add_function("textureProjOffset",
1377 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1378 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1379 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1380 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1381 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1382 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1384 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1385 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1386 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1387 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1388 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1389 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1391 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1392 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1393 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1395 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1396 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1398 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1399 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1400 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1401 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1402 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1403 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1405 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1407 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1408 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1409 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1410 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1411 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1412 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1414 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1415 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1416 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1417 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1418 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1419 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1421 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1422 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1423 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1425 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1426 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1429 add_function("textureLodOffset",
1430 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1431 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1432 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1434 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1435 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1436 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1438 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1439 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1440 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1442 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1443 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1445 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1446 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1447 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1449 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1450 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1451 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1453 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1456 add_function("textureProjLod",
1457 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1458 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1459 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1460 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1461 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1462 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1464 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1465 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1466 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1467 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1468 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1469 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1471 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1472 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1473 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1475 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1476 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1479 add_function("textureProjLodOffset",
1480 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1481 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1482 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1483 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1484 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1485 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1487 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1488 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1489 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1490 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1491 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1492 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1494 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1495 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1496 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1498 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1499 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1502 add_function("textureGrad",
1503 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1504 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1505 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1507 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1508 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1509 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1511 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1512 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1513 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1515 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1516 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1517 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1519 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1520 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1521 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1523 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1525 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1526 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1527 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1529 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1530 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1531 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1533 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1534 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1535 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1537 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1538 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1539 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1541 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1542 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1545 add_function("textureGradOffset",
1546 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1547 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1548 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1550 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1551 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1552 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1554 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1555 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1556 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1558 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1559 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1560 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1562 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1564 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1565 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1567 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1568 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1569 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1571 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1572 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1573 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1575 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1576 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1579 add_function("textureProjGrad",
1580 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1581 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1582 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1583 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1584 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1585 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1587 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1588 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1589 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1590 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1591 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1592 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1594 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1595 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1596 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1598 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1599 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1600 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1601 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1602 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1603 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1605 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1607 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1608 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1611 add_function("textureProjGradOffset",
1612 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1613 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1614 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1615 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1616 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1617 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1619 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1620 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1621 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1622 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1623 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1624 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1626 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1627 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1628 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1630 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1631 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1632 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1633 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1634 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1635 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1637 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1639 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1640 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1643 add_function("EmitVertex", _EmitVertex(), NULL
);
1644 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1646 add_function("textureQueryLOD",
1647 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1648 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1649 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1651 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1652 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1653 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1655 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1656 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1657 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1659 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1660 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1661 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1663 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1664 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1665 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1667 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1668 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1669 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1671 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1672 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1673 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1675 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1676 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1677 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1678 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1679 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1680 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1683 add_function("textureQueryLevels",
1684 _textureQueryLevels(glsl_type::sampler1D_type
),
1685 _textureQueryLevels(glsl_type::sampler2D_type
),
1686 _textureQueryLevels(glsl_type::sampler3D_type
),
1687 _textureQueryLevels(glsl_type::samplerCube_type
),
1688 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1689 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1690 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1691 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1692 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1693 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1694 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1695 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1696 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1698 _textureQueryLevels(glsl_type::isampler1D_type
),
1699 _textureQueryLevels(glsl_type::isampler2D_type
),
1700 _textureQueryLevels(glsl_type::isampler3D_type
),
1701 _textureQueryLevels(glsl_type::isamplerCube_type
),
1702 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1703 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1704 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1706 _textureQueryLevels(glsl_type::usampler1D_type
),
1707 _textureQueryLevels(glsl_type::usampler2D_type
),
1708 _textureQueryLevels(glsl_type::usampler3D_type
),
1709 _textureQueryLevels(glsl_type::usamplerCube_type
),
1710 _textureQueryLevels(glsl_type::usampler1DArray_type
),
1711 _textureQueryLevels(glsl_type::usampler2DArray_type
),
1712 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
1716 add_function("texture1D",
1717 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1718 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1721 add_function("texture1DArray",
1722 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1723 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1726 add_function("texture1DProj",
1727 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1728 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1729 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1730 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1733 add_function("texture1DLod",
1734 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1737 add_function("texture1DArrayLod",
1738 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1741 add_function("texture1DProjLod",
1742 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1743 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1746 add_function("texture2D",
1747 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1748 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1749 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1752 add_function("texture2DArray",
1753 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1754 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1757 add_function("texture2DProj",
1758 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1759 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1760 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1761 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1762 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1763 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1766 add_function("texture2DLod",
1767 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1770 add_function("texture2DArrayLod",
1771 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1774 add_function("texture2DProjLod",
1775 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1776 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1779 add_function("texture3D",
1780 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1781 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1784 add_function("texture3DProj",
1785 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1786 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1789 add_function("texture3DLod",
1790 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1793 add_function("texture3DProjLod",
1794 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1797 add_function("textureCube",
1798 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1799 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1802 add_function("textureCubeLod",
1803 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1806 add_function("texture2DRect",
1807 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1810 add_function("texture2DRectProj",
1811 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1812 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1815 add_function("shadow1D",
1816 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1817 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1820 add_function("shadow1DArray",
1821 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1822 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1825 add_function("shadow2D",
1826 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1827 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1830 add_function("shadow2DArray",
1831 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1832 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1835 add_function("shadow1DProj",
1836 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1837 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1840 add_function("shadow2DProj",
1841 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1842 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1845 add_function("shadow1DLod",
1846 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1849 add_function("shadow2DLod",
1850 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1853 add_function("shadow1DArrayLod",
1854 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1857 add_function("shadow1DProjLod",
1858 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1861 add_function("shadow2DProjLod",
1862 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1865 add_function("shadow2DRect",
1866 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1869 add_function("shadow2DRectProj",
1870 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1873 add_function("texture1DGradARB",
1874 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1877 add_function("texture1DProjGradARB",
1878 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1879 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1882 add_function("texture2DGradARB",
1883 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1886 add_function("texture2DProjGradARB",
1887 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1888 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1891 add_function("texture3DGradARB",
1892 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1895 add_function("texture3DProjGradARB",
1896 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1899 add_function("textureCubeGradARB",
1900 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1903 add_function("shadow1DGradARB",
1904 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1907 add_function("shadow1DProjGradARB",
1908 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1911 add_function("shadow2DGradARB",
1912 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1915 add_function("shadow2DProjGradARB",
1916 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1919 add_function("texture2DRectGradARB",
1920 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1923 add_function("texture2DRectProjGradARB",
1924 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1925 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1928 add_function("shadow2DRectGradARB",
1929 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1932 add_function("shadow2DRectProjGradARB",
1933 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1936 add_function("textureGather",
1937 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1938 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1939 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1941 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1942 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1943 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1945 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1946 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1947 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1949 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1950 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1951 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1953 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1954 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1955 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1957 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1958 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1959 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1961 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1962 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1963 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1965 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1966 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1967 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1969 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1970 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1971 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1973 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1974 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1975 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1977 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1978 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
1979 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1980 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
1981 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
1984 add_function("textureGatherOffset",
1985 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1986 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1987 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1989 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1990 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1991 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1993 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1994 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1995 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1997 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1998 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1999 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2001 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2002 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2003 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2005 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2006 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2007 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2009 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2010 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2011 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2013 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2014 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2015 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2017 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2018 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2019 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2022 add_function("textureGatherOffsets",
2023 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2024 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2025 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2027 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2028 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2029 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2031 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2032 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2033 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2035 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2036 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2037 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2039 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2040 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2041 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2043 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2044 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2045 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2047 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2048 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2049 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2068 add_function("ldexp",
2069 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2070 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2071 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2072 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2075 add_function("frexp",
2076 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2077 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2078 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2079 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2081 add_function("uaddCarry",
2082 _uaddCarry(glsl_type::uint_type
),
2083 _uaddCarry(glsl_type::uvec2_type
),
2084 _uaddCarry(glsl_type::uvec3_type
),
2085 _uaddCarry(glsl_type::uvec4_type
),
2087 add_function("usubBorrow",
2088 _usubBorrow(glsl_type::uint_type
),
2089 _usubBorrow(glsl_type::uvec2_type
),
2090 _usubBorrow(glsl_type::uvec3_type
),
2091 _usubBorrow(glsl_type::uvec4_type
),
2093 add_function("imulExtended",
2094 _mulExtended(glsl_type::int_type
),
2095 _mulExtended(glsl_type::ivec2_type
),
2096 _mulExtended(glsl_type::ivec3_type
),
2097 _mulExtended(glsl_type::ivec4_type
),
2099 add_function("umulExtended",
2100 _mulExtended(glsl_type::uint_type
),
2101 _mulExtended(glsl_type::uvec2_type
),
2102 _mulExtended(glsl_type::uvec3_type
),
2103 _mulExtended(glsl_type::uvec4_type
),
2106 add_function("atomicCounter",
2107 _atomic_op("__intrinsic_atomic_read",
2108 shader_atomic_counters
),
2110 add_function("atomicCounterIncrement",
2111 _atomic_op("__intrinsic_atomic_increment",
2112 shader_atomic_counters
),
2114 add_function("atomicCounterDecrement",
2115 _atomic_op("__intrinsic_atomic_predecrement",
2116 shader_atomic_counters
),
2119 add_function("min3",
2120 _min3(glsl_type::float_type
),
2121 _min3(glsl_type::vec2_type
),
2122 _min3(glsl_type::vec3_type
),
2123 _min3(glsl_type::vec4_type
),
2125 _min3(glsl_type::int_type
),
2126 _min3(glsl_type::ivec2_type
),
2127 _min3(glsl_type::ivec3_type
),
2128 _min3(glsl_type::ivec4_type
),
2130 _min3(glsl_type::uint_type
),
2131 _min3(glsl_type::uvec2_type
),
2132 _min3(glsl_type::uvec3_type
),
2133 _min3(glsl_type::uvec4_type
),
2136 add_function("max3",
2137 _max3(glsl_type::float_type
),
2138 _max3(glsl_type::vec2_type
),
2139 _max3(glsl_type::vec3_type
),
2140 _max3(glsl_type::vec4_type
),
2142 _max3(glsl_type::int_type
),
2143 _max3(glsl_type::ivec2_type
),
2144 _max3(glsl_type::ivec3_type
),
2145 _max3(glsl_type::ivec4_type
),
2147 _max3(glsl_type::uint_type
),
2148 _max3(glsl_type::uvec2_type
),
2149 _max3(glsl_type::uvec3_type
),
2150 _max3(glsl_type::uvec4_type
),
2153 add_function("mid3",
2154 _mid3(glsl_type::float_type
),
2155 _mid3(glsl_type::vec2_type
),
2156 _mid3(glsl_type::vec3_type
),
2157 _mid3(glsl_type::vec4_type
),
2159 _mid3(glsl_type::int_type
),
2160 _mid3(glsl_type::ivec2_type
),
2161 _mid3(glsl_type::ivec3_type
),
2162 _mid3(glsl_type::ivec4_type
),
2164 _mid3(glsl_type::uint_type
),
2165 _mid3(glsl_type::uvec2_type
),
2166 _mid3(glsl_type::uvec3_type
),
2167 _mid3(glsl_type::uvec4_type
),
2178 builtin_builder::add_function(const char *name
, ...)
2182 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2186 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2192 stuff
.push_tail(sig
);
2193 validate_ir_tree(&stuff
);
2196 f
->add_signature(sig
);
2200 shader
->symbols
->add_function(f
);
2204 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2206 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2210 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2212 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2216 builtin_builder::imm(float f
, unsigned vector_elements
)
2218 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2222 builtin_builder::imm(int i
, unsigned vector_elements
)
2224 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2228 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2230 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2234 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2236 return new(mem_ctx
) ir_constant(type
, &data
);
2239 ir_dereference_variable
*
2240 builtin_builder::var_ref(ir_variable
*var
)
2242 return new(mem_ctx
) ir_dereference_variable(var
);
2245 ir_dereference_array
*
2246 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2248 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2251 /** Return an element of a matrix */
2253 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2255 return swizzle(array_ref(var
, column
), row
, 1);
2259 * Implementations of built-in functions:
2262 ir_function_signature
*
2263 builtin_builder::new_sig(const glsl_type
*return_type
,
2264 builtin_available_predicate avail
,
2270 ir_function_signature
*sig
=
2271 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2274 va_start(ap
, num_params
);
2275 for (int i
= 0; i
< num_params
; i
++) {
2276 plist
.push_tail(va_arg(ap
, ir_variable
*));
2280 sig
->replace_parameters(&plist
);
2284 #define MAKE_SIG(return_type, avail, ...) \
2285 ir_function_signature *sig = \
2286 new_sig(return_type, avail, __VA_ARGS__); \
2287 ir_factory body(&sig->body, mem_ctx); \
2288 sig->is_defined = true;
2290 #define MAKE_INTRINSIC(return_type, avail, ...) \
2291 ir_function_signature *sig = \
2292 new_sig(return_type, avail, __VA_ARGS__); \
2293 sig->is_intrinsic = true;
2295 ir_function_signature
*
2296 builtin_builder::unop(builtin_available_predicate avail
,
2297 ir_expression_operation opcode
,
2298 const glsl_type
*return_type
,
2299 const glsl_type
*param_type
)
2301 ir_variable
*x
= in_var(param_type
, "x");
2302 MAKE_SIG(return_type
, avail
, 1, x
);
2303 body
.emit(ret(expr(opcode
, x
)));
2307 #define UNOP(NAME, OPCODE, AVAIL) \
2308 ir_function_signature * \
2309 builtin_builder::_##NAME(const glsl_type *type) \
2311 return unop(&AVAIL, OPCODE, type, type); \
2314 ir_function_signature
*
2315 builtin_builder::binop(ir_expression_operation opcode
,
2316 builtin_available_predicate avail
,
2317 const glsl_type
*return_type
,
2318 const glsl_type
*param0_type
,
2319 const glsl_type
*param1_type
)
2321 ir_variable
*x
= in_var(param0_type
, "x");
2322 ir_variable
*y
= in_var(param1_type
, "y");
2323 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2324 body
.emit(ret(expr(opcode
, x
, y
)));
2328 #define BINOP(NAME, OPCODE, AVAIL) \
2329 ir_function_signature * \
2330 builtin_builder::_##NAME(const glsl_type *return_type, \
2331 const glsl_type *param0_type, \
2332 const glsl_type *param1_type) \
2334 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2338 * Angle and Trigonometry Functions @{
2341 ir_function_signature
*
2342 builtin_builder::_radians(const glsl_type
*type
)
2344 ir_variable
*degrees
= in_var(type
, "degrees");
2345 MAKE_SIG(type
, always_available
, 1, degrees
);
2346 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2350 ir_function_signature
*
2351 builtin_builder::_degrees(const glsl_type
*type
)
2353 ir_variable
*radians
= in_var(type
, "radians");
2354 MAKE_SIG(type
, always_available
, 1, radians
);
2355 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2359 UNOP(sin
, ir_unop_sin
, always_available
)
2360 UNOP(cos
, ir_unop_cos
, always_available
)
2362 ir_function_signature
*
2363 builtin_builder::_tan(const glsl_type
*type
)
2365 ir_variable
*theta
= in_var(type
, "theta");
2366 MAKE_SIG(type
, always_available
, 1, theta
);
2367 body
.emit(ret(div(sin(theta
), cos(theta
))));
2372 builtin_builder::asin_expr(ir_variable
*x
)
2375 sub(imm(1.5707964f
),
2376 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2377 add(imm(1.5707964f
),
2379 add(imm(-0.21460183f
),
2381 add(imm(0.086566724f
),
2382 mul(abs(x
), imm(-0.03102955f
))))))))));
2386 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2388 exec_list actual_params
;
2390 foreach_list(node
, ¶ms
) {
2391 ir_variable
*var
= (ir_variable
*) node
;
2392 actual_params
.push_tail(var_ref(var
));
2395 ir_function_signature
*sig
=
2396 f
->exact_matching_signature(NULL
, &actual_params
);
2400 ir_dereference_variable
*deref
=
2401 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2403 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2406 ir_function_signature
*
2407 builtin_builder::_asin(const glsl_type
*type
)
2409 ir_variable
*x
= in_var(type
, "x");
2410 MAKE_SIG(type
, always_available
, 1, x
);
2412 body
.emit(ret(asin_expr(x
)));
2417 ir_function_signature
*
2418 builtin_builder::_acos(const glsl_type
*type
)
2420 ir_variable
*x
= in_var(type
, "x");
2421 MAKE_SIG(type
, always_available
, 1, x
);
2423 body
.emit(ret(sub(imm(1.5707964f
), asin_expr(x
))));
2428 ir_function_signature
*
2429 builtin_builder::_atan2(const glsl_type
*type
)
2431 ir_variable
*vec_y
= in_var(type
, "vec_y");
2432 ir_variable
*vec_x
= in_var(type
, "vec_x");
2433 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2435 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2436 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2437 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2438 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2439 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2440 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2441 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2443 /* If |x| >= 1.0e-8 * |y|: */
2445 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2447 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2449 /* Then...call atan(y/x) */
2450 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2451 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2452 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2454 outer_then
.emit(assign(r
, asin_expr(r
)));
2456 /* ...and fix it up: */
2457 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2458 inner_if
->then_instructions
.push_tail(
2459 if_tree(gequal(y
, imm(0.0f
)),
2460 assign(r
, add(r
, imm(3.141593f
))),
2461 assign(r
, sub(r
, imm(3.141593f
)))));
2462 outer_then
.emit(inner_if
);
2465 outer_if
->else_instructions
.push_tail(
2466 assign(r
, mul(sign(y
), imm(1.5707965f
))));
2468 body
.emit(outer_if
);
2470 body
.emit(assign(vec_result
, r
, 1 << i
));
2472 body
.emit(ret(vec_result
));
2477 ir_function_signature
*
2478 builtin_builder::_atan(const glsl_type
*type
)
2480 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2481 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2483 ir_variable
*t
= body
.make_temp(type
, "t");
2484 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2487 body
.emit(ret(asin_expr(t
)));
2492 ir_function_signature
*
2493 builtin_builder::_sinh(const glsl_type
*type
)
2495 ir_variable
*x
= in_var(type
, "x");
2496 MAKE_SIG(type
, v130
, 1, x
);
2498 /* 0.5 * (e^x - e^(-x)) */
2499 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2504 ir_function_signature
*
2505 builtin_builder::_cosh(const glsl_type
*type
)
2507 ir_variable
*x
= in_var(type
, "x");
2508 MAKE_SIG(type
, v130
, 1, x
);
2510 /* 0.5 * (e^x + e^(-x)) */
2511 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2516 ir_function_signature
*
2517 builtin_builder::_tanh(const glsl_type
*type
)
2519 ir_variable
*x
= in_var(type
, "x");
2520 MAKE_SIG(type
, v130
, 1, x
);
2522 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2523 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2524 add(exp(x
), exp(neg(x
))))));
2529 ir_function_signature
*
2530 builtin_builder::_asinh(const glsl_type
*type
)
2532 ir_variable
*x
= in_var(type
, "x");
2533 MAKE_SIG(type
, v130
, 1, x
);
2535 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2540 ir_function_signature
*
2541 builtin_builder::_acosh(const glsl_type
*type
)
2543 ir_variable
*x
= in_var(type
, "x");
2544 MAKE_SIG(type
, v130
, 1, x
);
2546 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2550 ir_function_signature
*
2551 builtin_builder::_atanh(const glsl_type
*type
)
2553 ir_variable
*x
= in_var(type
, "x");
2554 MAKE_SIG(type
, v130
, 1, x
);
2556 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2557 sub(imm(1.0f
), x
))))));
2563 * Exponential Functions @{
2566 ir_function_signature
*
2567 builtin_builder::_pow(const glsl_type
*type
)
2569 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2572 UNOP(exp
, ir_unop_exp
, always_available
)
2573 UNOP(log
, ir_unop_log
, always_available
)
2574 UNOP(exp2
, ir_unop_exp2
, always_available
)
2575 UNOP(log2
, ir_unop_log2
, always_available
)
2576 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2577 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2581 UNOP(abs
, ir_unop_abs
, always_available
)
2582 UNOP(sign
, ir_unop_sign
, always_available
)
2583 UNOP(floor
, ir_unop_floor
, always_available
)
2584 UNOP(trunc
, ir_unop_trunc
, v130
)
2585 UNOP(round
, ir_unop_round_even
, always_available
)
2586 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2587 UNOP(ceil
, ir_unop_ceil
, always_available
)
2588 UNOP(fract
, ir_unop_fract
, always_available
)
2590 ir_function_signature
*
2591 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2593 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2596 ir_function_signature
*
2597 builtin_builder::_modf(const glsl_type
*type
)
2599 ir_variable
*x
= in_var(type
, "x");
2600 ir_variable
*i
= out_var(type
, "i");
2601 MAKE_SIG(type
, v130
, 2, x
, i
);
2603 ir_variable
*t
= body
.make_temp(type
, "t");
2604 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2605 body
.emit(assign(i
, t
));
2606 body
.emit(ret(sub(x
, t
)));
2611 ir_function_signature
*
2612 builtin_builder::_min(builtin_available_predicate avail
,
2613 const glsl_type
*x_type
, const glsl_type
*y_type
)
2615 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2618 ir_function_signature
*
2619 builtin_builder::_max(builtin_available_predicate avail
,
2620 const glsl_type
*x_type
, const glsl_type
*y_type
)
2622 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2625 ir_function_signature
*
2626 builtin_builder::_clamp(builtin_available_predicate avail
,
2627 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2629 ir_variable
*x
= in_var(val_type
, "x");
2630 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2631 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2632 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2634 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2639 ir_function_signature
*
2640 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2642 ir_variable
*x
= in_var(val_type
, "x");
2643 ir_variable
*y
= in_var(val_type
, "y");
2644 ir_variable
*a
= in_var(blend_type
, "a");
2645 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2647 body
.emit(ret(lrp(x
, y
, a
)));
2652 ir_function_signature
*
2653 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2654 const glsl_type
*val_type
,
2655 const glsl_type
*blend_type
)
2657 ir_variable
*x
= in_var(val_type
, "x");
2658 ir_variable
*y
= in_var(val_type
, "y");
2659 ir_variable
*a
= in_var(blend_type
, "a");
2660 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2662 /* csel matches the ternary operator in that a selector of true choses the
2663 * first argument. This differs from mix(x, y, false) which choses the
2664 * second argument (to remain consistent with the interpolating version of
2665 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2667 * To handle the behavior mismatch, reverse the x and y arguments.
2669 body
.emit(ret(csel(a
, y
, x
)));
2674 ir_function_signature
*
2675 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2677 ir_variable
*edge
= in_var(edge_type
, "edge");
2678 ir_variable
*x
= in_var(x_type
, "x");
2679 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2681 ir_variable
*t
= body
.make_temp(x_type
, "t");
2682 if (x_type
->vector_elements
== 1) {
2683 /* Both are floats */
2684 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2685 } else if (edge_type
->vector_elements
== 1) {
2686 /* x is a vector but edge is a float */
2687 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2688 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2691 /* Both are vectors */
2692 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2693 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2702 ir_function_signature
*
2703 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2705 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2706 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2707 ir_variable
*x
= in_var(x_type
, "x");
2708 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2710 /* From the GLSL 1.10 specification:
2713 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2714 * return t * t * (3 - 2 * t);
2717 ir_variable
*t
= body
.make_temp(x_type
, "t");
2718 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2719 imm(0.0f
), imm(1.0f
))));
2721 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2726 ir_function_signature
*
2727 builtin_builder::_isnan(const glsl_type
*type
)
2729 ir_variable
*x
= in_var(type
, "x");
2730 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2732 body
.emit(ret(nequal(x
, x
)));
2737 ir_function_signature
*
2738 builtin_builder::_isinf(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 ir_constant_data infinities
;
2744 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2745 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2748 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2753 ir_function_signature
*
2754 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2756 ir_variable
*x
= in_var(type
, "x");
2757 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2758 body
.emit(ret(bitcast_f2i(x
)));
2762 ir_function_signature
*
2763 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2765 ir_variable
*x
= in_var(type
, "x");
2766 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2767 body
.emit(ret(bitcast_f2u(x
)));
2771 ir_function_signature
*
2772 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2774 ir_variable
*x
= in_var(type
, "x");
2775 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2776 body
.emit(ret(bitcast_i2f(x
)));
2780 ir_function_signature
*
2781 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2783 ir_variable
*x
= in_var(type
, "x");
2784 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2785 body
.emit(ret(bitcast_u2f(x
)));
2789 ir_function_signature
*
2790 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2792 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2793 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2794 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2798 ir_function_signature
*
2799 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2801 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2802 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2803 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2807 ir_function_signature
*
2808 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2810 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2811 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2812 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
2816 ir_function_signature
*
2817 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
2819 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2820 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2821 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
2825 ir_function_signature
*
2826 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
2828 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2829 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2830 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
2834 ir_function_signature
*
2835 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
2837 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2838 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2839 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
2844 ir_function_signature
*
2845 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
2847 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2848 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2849 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
2853 ir_function_signature
*
2854 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
2856 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2857 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2858 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
2862 ir_function_signature
*
2863 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
2865 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2866 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2867 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
2871 ir_function_signature
*
2872 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
2874 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2875 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2876 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
2880 ir_function_signature
*
2881 builtin_builder::_length(const glsl_type
*type
)
2883 ir_variable
*x
= in_var(type
, "x");
2884 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
2886 body
.emit(ret(sqrt(dotlike(x
, x
))));
2891 ir_function_signature
*
2892 builtin_builder::_distance(const glsl_type
*type
)
2894 ir_variable
*p0
= in_var(type
, "p0");
2895 ir_variable
*p1
= in_var(type
, "p1");
2896 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
2898 if (type
->vector_elements
== 1) {
2899 body
.emit(ret(abs(sub(p0
, p1
))));
2901 ir_variable
*p
= body
.make_temp(type
, "p");
2902 body
.emit(assign(p
, sub(p0
, p1
)));
2903 body
.emit(ret(sqrt(dot(p
, p
))));
2909 ir_function_signature
*
2910 builtin_builder::_dot(const glsl_type
*type
)
2912 if (type
->vector_elements
== 1)
2913 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
2915 return binop(ir_binop_dot
, always_available
,
2916 glsl_type::float_type
, type
, type
);
2919 ir_function_signature
*
2920 builtin_builder::_cross(const glsl_type
*type
)
2922 ir_variable
*a
= in_var(type
, "a");
2923 ir_variable
*b
= in_var(type
, "b");
2924 MAKE_SIG(type
, always_available
, 2, a
, b
);
2926 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
2927 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
2929 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
2930 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
2935 ir_function_signature
*
2936 builtin_builder::_normalize(const glsl_type
*type
)
2938 ir_variable
*x
= in_var(type
, "x");
2939 MAKE_SIG(type
, always_available
, 1, x
);
2941 if (type
->vector_elements
== 1) {
2942 body
.emit(ret(sign(x
)));
2944 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
2950 ir_function_signature
*
2951 builtin_builder::_ftransform()
2953 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
2955 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
2956 glsl_type::vec4_type
,
2957 var_ref(gl_ModelViewProjectionMatrix
),
2958 var_ref(gl_Vertex
))));
2960 /* FINISHME: Once the ir_expression() constructor handles type inference
2961 * for matrix operations, we can simplify this to:
2963 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
2968 ir_function_signature
*
2969 builtin_builder::_faceforward(const glsl_type
*type
)
2971 ir_variable
*N
= in_var(type
, "N");
2972 ir_variable
*I
= in_var(type
, "I");
2973 ir_variable
*Nref
= in_var(type
, "Nref");
2974 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
2976 body
.emit(if_tree(less(dotlike(Nref
, I
), imm(0.0f
)),
2977 ret(N
), ret(neg(N
))));
2982 ir_function_signature
*
2983 builtin_builder::_reflect(const glsl_type
*type
)
2985 ir_variable
*I
= in_var(type
, "I");
2986 ir_variable
*N
= in_var(type
, "N");
2987 MAKE_SIG(type
, always_available
, 2, I
, N
);
2989 /* I - 2 * dot(N, I) * N */
2990 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dotlike(N
, I
), N
)))));
2995 ir_function_signature
*
2996 builtin_builder::_refract(const glsl_type
*type
)
2998 ir_variable
*I
= in_var(type
, "I");
2999 ir_variable
*N
= in_var(type
, "N");
3000 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
3001 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
3003 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
3004 body
.emit(assign(n_dot_i
, dotlike(N
, I
)));
3006 /* From the GLSL 1.10 specification:
3007 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3009 * return genType(0.0)
3011 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3013 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
3014 body
.emit(assign(k
, sub(imm(1.0f
),
3015 mul(eta
, mul(eta
, sub(imm(1.0f
),
3016 mul(n_dot_i
, n_dot_i
)))))));
3017 body
.emit(if_tree(less(k
, imm(0.0f
)),
3018 ret(ir_constant::zero(mem_ctx
, type
)),
3019 ret(sub(mul(eta
, I
),
3020 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3025 ir_function_signature
*
3026 builtin_builder::_matrixCompMult(const glsl_type
*type
)
3028 ir_variable
*x
= in_var(type
, "x");
3029 ir_variable
*y
= in_var(type
, "y");
3030 MAKE_SIG(type
, always_available
, 2, x
, y
);
3032 ir_variable
*z
= body
.make_temp(type
, "z");
3033 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3034 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3041 ir_function_signature
*
3042 builtin_builder::_outerProduct(const glsl_type
*type
)
3044 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3045 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3046 MAKE_SIG(type
, v120
, 2, c
, r
);
3048 ir_variable
*m
= body
.make_temp(type
, "m");
3049 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3050 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3057 ir_function_signature
*
3058 builtin_builder::_transpose(const glsl_type
*orig_type
)
3060 const glsl_type
*transpose_type
=
3061 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
3062 orig_type
->matrix_columns
,
3063 orig_type
->vector_elements
);
3065 ir_variable
*m
= in_var(orig_type
, "m");
3066 MAKE_SIG(transpose_type
, v120
, 1, m
);
3068 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3069 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3070 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3071 body
.emit(assign(array_ref(t
, j
),
3072 matrix_elt(m
, i
, j
),
3081 ir_function_signature
*
3082 builtin_builder::_determinant_mat2()
3084 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3085 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3087 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3088 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3093 ir_function_signature
*
3094 builtin_builder::_determinant_mat3()
3096 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3097 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3100 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3101 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3104 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3105 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3108 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3109 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3111 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3112 mul(matrix_elt(m
, 0, 1), f2
)),
3113 mul(matrix_elt(m
, 0, 2), f3
))));
3118 ir_function_signature
*
3119 builtin_builder::_determinant_mat4()
3121 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3122 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3124 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3125 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3126 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3127 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3128 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3129 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3130 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3131 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3132 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3133 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3134 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3135 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3136 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3137 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3138 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3139 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3140 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3141 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3142 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3144 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)))));
3145 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)))));
3146 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)))));
3147 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)))));
3148 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)))));
3149 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)))));
3150 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)))));
3151 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)))));
3152 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)))));
3153 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)))));
3154 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)))));
3155 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)))));
3156 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)))));
3157 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)))));
3158 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)))));
3159 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)))));
3160 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)))));
3161 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)))));
3162 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)))));
3164 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
3166 body
.emit(assign(adj_0
,
3167 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3168 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3169 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3171 body
.emit(assign(adj_0
, neg(
3172 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3173 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3174 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3176 body
.emit(assign(adj_0
,
3177 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3178 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3179 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3181 body
.emit(assign(adj_0
, neg(
3182 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3183 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3184 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3187 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3192 ir_function_signature
*
3193 builtin_builder::_inverse_mat2()
3195 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3196 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
3198 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
3199 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3200 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3201 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3202 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3204 ir_expression
*det
=
3205 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3206 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3208 body
.emit(ret(div(adj
, det
)));
3212 ir_function_signature
*
3213 builtin_builder::_inverse_mat3()
3215 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3216 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
3218 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
3219 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
3220 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
3222 body
.emit(assign(f11_22_21_12
,
3223 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3224 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3225 body
.emit(assign(f10_22_20_12
,
3226 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3227 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3228 body
.emit(assign(f10_21_20_11
,
3229 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3230 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3232 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
3233 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3234 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3235 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3237 body
.emit(assign(array_ref(adj
, 0), neg(
3238 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3239 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3241 body
.emit(assign(array_ref(adj
, 1),
3242 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3243 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3245 body
.emit(assign(array_ref(adj
, 2), neg(
3246 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3247 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3250 body
.emit(assign(array_ref(adj
, 0),
3251 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3252 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3254 body
.emit(assign(array_ref(adj
, 1), neg(
3255 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3256 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3258 body
.emit(assign(array_ref(adj
, 2),
3259 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3260 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3263 ir_expression
*det
=
3264 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3265 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3266 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3268 body
.emit(ret(div(adj
, det
)));
3273 ir_function_signature
*
3274 builtin_builder::_inverse_mat4()
3276 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3277 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
3279 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3280 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3281 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3282 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3283 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3284 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3285 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3286 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3287 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3288 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3289 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3290 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3291 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3292 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3293 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3294 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3295 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3296 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3297 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3299 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)))));
3300 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)))));
3301 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)))));
3302 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)))));
3303 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)))));
3304 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)))));
3305 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)))));
3306 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)))));
3307 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)))));
3308 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)))));
3309 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)))));
3310 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)))));
3311 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)))));
3312 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)))));
3313 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)))));
3314 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)))));
3315 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)))));
3316 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)))));
3317 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)))));
3319 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
3320 body
.emit(assign(array_ref(adj
, 0),
3321 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3322 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3323 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3325 body
.emit(assign(array_ref(adj
, 1), neg(
3326 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3327 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3328 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3330 body
.emit(assign(array_ref(adj
, 2),
3331 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3332 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3333 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3335 body
.emit(assign(array_ref(adj
, 3), neg(
3336 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3337 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3338 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3341 body
.emit(assign(array_ref(adj
, 0), neg(
3342 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3343 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3344 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3346 body
.emit(assign(array_ref(adj
, 1),
3347 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3348 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3349 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3351 body
.emit(assign(array_ref(adj
, 2), neg(
3352 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3353 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3354 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3356 body
.emit(assign(array_ref(adj
, 3),
3357 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3358 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3359 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3362 body
.emit(assign(array_ref(adj
, 0),
3363 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3364 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3365 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3367 body
.emit(assign(array_ref(adj
, 1), neg(
3368 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3369 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3370 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3372 body
.emit(assign(array_ref(adj
, 2),
3373 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3374 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3375 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3377 body
.emit(assign(array_ref(adj
, 3), neg(
3378 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3379 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3380 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3383 body
.emit(assign(array_ref(adj
, 0), neg(
3384 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3385 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3386 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3388 body
.emit(assign(array_ref(adj
, 1),
3389 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3390 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3391 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3393 body
.emit(assign(array_ref(adj
, 2), neg(
3394 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3395 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3396 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3398 body
.emit(assign(array_ref(adj
, 3),
3399 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3400 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3401 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3404 ir_expression
*det
=
3405 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3406 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3407 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3408 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3410 body
.emit(ret(div(adj
, det
)));
3416 ir_function_signature
*
3417 builtin_builder::_lessThan(builtin_available_predicate avail
,
3418 const glsl_type
*type
)
3420 return binop(ir_binop_less
, avail
,
3421 glsl_type::bvec(type
->vector_elements
), type
, type
);
3424 ir_function_signature
*
3425 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3426 const glsl_type
*type
)
3428 return binop(ir_binop_lequal
, avail
,
3429 glsl_type::bvec(type
->vector_elements
), type
, type
);
3432 ir_function_signature
*
3433 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3434 const glsl_type
*type
)
3436 return binop(ir_binop_greater
, avail
,
3437 glsl_type::bvec(type
->vector_elements
), type
, type
);
3440 ir_function_signature
*
3441 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3442 const glsl_type
*type
)
3444 return binop(ir_binop_gequal
, avail
,
3445 glsl_type::bvec(type
->vector_elements
), type
, type
);
3448 ir_function_signature
*
3449 builtin_builder::_equal(builtin_available_predicate avail
,
3450 const glsl_type
*type
)
3452 return binop(ir_binop_equal
, avail
,
3453 glsl_type::bvec(type
->vector_elements
), type
, type
);
3456 ir_function_signature
*
3457 builtin_builder::_notEqual(builtin_available_predicate avail
,
3458 const glsl_type
*type
)
3460 return binop(ir_binop_nequal
, avail
,
3461 glsl_type::bvec(type
->vector_elements
), type
, type
);
3464 ir_function_signature
*
3465 builtin_builder::_any(const glsl_type
*type
)
3467 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3470 ir_function_signature
*
3471 builtin_builder::_all(const glsl_type
*type
)
3473 ir_variable
*v
= in_var(type
, "v");
3474 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3476 switch (type
->vector_elements
) {
3478 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3481 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3485 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3494 UNOP(not, ir_unop_logic_not
, always_available
)
3497 has_lod(const glsl_type
*sampler_type
)
3499 assert(sampler_type
->is_sampler());
3501 switch (sampler_type
->sampler_dimensionality
) {
3502 case GLSL_SAMPLER_DIM_RECT
:
3503 case GLSL_SAMPLER_DIM_BUF
:
3504 case GLSL_SAMPLER_DIM_MS
:
3511 ir_function_signature
*
3512 builtin_builder::_textureSize(builtin_available_predicate avail
,
3513 const glsl_type
*return_type
,
3514 const glsl_type
*sampler_type
)
3516 ir_variable
*s
= in_var(sampler_type
, "sampler");
3517 /* The sampler always exists; add optional lod later. */
3518 MAKE_SIG(return_type
, avail
, 1, s
);
3520 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3521 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3523 if (has_lod(sampler_type
)) {
3524 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3525 sig
->parameters
.push_tail(lod
);
3526 tex
->lod_info
.lod
= var_ref(lod
);
3528 tex
->lod_info
.lod
= imm(0u);
3531 body
.emit(ret(tex
));
3536 ir_function_signature
*
3537 builtin_builder::_texture(ir_texture_opcode opcode
,
3538 builtin_available_predicate avail
,
3539 const glsl_type
*return_type
,
3540 const glsl_type
*sampler_type
,
3541 const glsl_type
*coord_type
,
3544 ir_variable
*s
= in_var(sampler_type
, "sampler");
3545 ir_variable
*P
= in_var(coord_type
, "P");
3546 /* The sampler and coordinate always exist; add optional parameters later. */
3547 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3549 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3550 tex
->set_sampler(var_ref(s
), return_type
);
3552 const int coord_size
= sampler_type
->coordinate_components();
3554 if (coord_size
== coord_type
->vector_elements
) {
3555 tex
->coordinate
= var_ref(P
);
3557 /* The incoming coordinate also has the projector or shadow comparitor,
3558 * so we need to swizzle those away.
3560 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3563 /* The projector is always in the last component. */
3564 if (flags
& TEX_PROJECT
)
3565 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3567 if (sampler_type
->sampler_shadow
) {
3568 if (opcode
== ir_tg4
) {
3569 /* gather has refz as a separate parameter, immediately after the
3572 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
3573 sig
->parameters
.push_tail(refz
);
3574 tex
->shadow_comparitor
= var_ref(refz
);
3576 /* The shadow comparitor is normally in the Z component, but a few types
3577 * have sufficiently large coordinates that it's in W.
3579 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3583 if (opcode
== ir_txl
) {
3584 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3585 sig
->parameters
.push_tail(lod
);
3586 tex
->lod_info
.lod
= var_ref(lod
);
3587 } else if (opcode
== ir_txd
) {
3588 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3589 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3590 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3591 sig
->parameters
.push_tail(dPdx
);
3592 sig
->parameters
.push_tail(dPdy
);
3593 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3594 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3597 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
3598 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3599 ir_variable
*offset
=
3600 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
3601 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
3602 sig
->parameters
.push_tail(offset
);
3603 tex
->offset
= var_ref(offset
);
3606 if (flags
& TEX_OFFSET_ARRAY
) {
3607 ir_variable
*offsets
=
3608 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
3609 "offsets", ir_var_const_in
);
3610 sig
->parameters
.push_tail(offsets
);
3611 tex
->offset
= var_ref(offsets
);
3614 if (opcode
== ir_tg4
) {
3615 if (flags
& TEX_COMPONENT
) {
3616 ir_variable
*component
=
3617 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
3618 sig
->parameters
.push_tail(component
);
3619 tex
->lod_info
.component
= var_ref(component
);
3622 tex
->lod_info
.component
= imm(0);
3626 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3627 * inconsistent with both textureLodOffset and textureGradOffset.
3629 if (opcode
== ir_txb
) {
3630 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3631 sig
->parameters
.push_tail(bias
);
3632 tex
->lod_info
.bias
= var_ref(bias
);
3635 body
.emit(ret(tex
));
3640 ir_function_signature
*
3641 builtin_builder::_textureCubeArrayShadow()
3643 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3644 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3645 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3646 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3648 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3649 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3651 tex
->coordinate
= var_ref(P
);
3652 tex
->shadow_comparitor
= var_ref(compare
);
3654 body
.emit(ret(tex
));
3659 ir_function_signature
*
3660 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3661 const glsl_type
*return_type
,
3662 const glsl_type
*sampler_type
,
3663 const glsl_type
*coord_type
,
3664 const glsl_type
*offset_type
)
3666 ir_variable
*s
= in_var(sampler_type
, "sampler");
3667 ir_variable
*P
= in_var(coord_type
, "P");
3668 /* The sampler and coordinate always exist; add optional parameters later. */
3669 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3671 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3672 tex
->coordinate
= var_ref(P
);
3673 tex
->set_sampler(var_ref(s
), return_type
);
3675 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3676 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3677 sig
->parameters
.push_tail(sample
);
3678 tex
->lod_info
.sample_index
= var_ref(sample
);
3679 tex
->op
= ir_txf_ms
;
3680 } else if (has_lod(sampler_type
)) {
3681 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3682 sig
->parameters
.push_tail(lod
);
3683 tex
->lod_info
.lod
= var_ref(lod
);
3685 tex
->lod_info
.lod
= imm(0u);
3688 if (offset_type
!= NULL
) {
3689 ir_variable
*offset
=
3690 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3691 sig
->parameters
.push_tail(offset
);
3692 tex
->offset
= var_ref(offset
);
3695 body
.emit(ret(tex
));
3700 ir_function_signature
*
3701 builtin_builder::_EmitVertex()
3703 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3705 body
.emit(new(mem_ctx
) ir_emit_vertex());
3710 ir_function_signature
*
3711 builtin_builder::_EndPrimitive()
3713 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3715 body
.emit(new(mem_ctx
) ir_end_primitive());
3720 ir_function_signature
*
3721 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3722 const glsl_type
*coord_type
)
3724 ir_variable
*s
= in_var(sampler_type
, "sampler");
3725 ir_variable
*coord
= in_var(coord_type
, "coord");
3726 /* The sampler and coordinate always exist; add optional parameters later. */
3727 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3729 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3730 tex
->coordinate
= var_ref(coord
);
3731 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3733 body
.emit(ret(tex
));
3738 ir_function_signature
*
3739 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
3741 ir_variable
*s
= in_var(sampler_type
, "sampler");
3742 const glsl_type
*return_type
= glsl_type::int_type
;
3743 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
3745 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
3746 tex
->set_sampler(var_ref(s
), return_type
);
3748 body
.emit(ret(tex
));
3753 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3754 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3756 ir_function_signature
*
3757 builtin_builder::_fwidth(const glsl_type
*type
)
3759 ir_variable
*p
= in_var(type
, "p");
3760 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3762 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3767 ir_function_signature
*
3768 builtin_builder::_noise1(const glsl_type
*type
)
3770 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
3773 ir_function_signature
*
3774 builtin_builder::_noise2(const glsl_type
*type
)
3776 ir_variable
*p
= in_var(type
, "p");
3777 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
3779 ir_constant_data b_offset
;
3780 b_offset
.f
[0] = 601.0f
;
3781 b_offset
.f
[1] = 313.0f
;
3782 b_offset
.f
[2] = 29.0f
;
3783 b_offset
.f
[3] = 277.0f
;
3785 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3786 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3787 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
3788 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3789 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3790 body
.emit(assign(t
, a
, WRITEMASK_X
));
3791 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3797 ir_function_signature
*
3798 builtin_builder::_noise3(const glsl_type
*type
)
3800 ir_variable
*p
= in_var(type
, "p");
3801 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
3803 ir_constant_data b_offset
;
3804 b_offset
.f
[0] = 601.0f
;
3805 b_offset
.f
[1] = 313.0f
;
3806 b_offset
.f
[2] = 29.0f
;
3807 b_offset
.f
[3] = 277.0f
;
3809 ir_constant_data c_offset
;
3810 c_offset
.f
[0] = 1559.0f
;
3811 c_offset
.f
[1] = 113.0f
;
3812 c_offset
.f
[2] = 1861.0f
;
3813 c_offset
.f
[3] = 797.0f
;
3815 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3816 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3817 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3818 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
3819 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3820 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3821 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
3822 body
.emit(assign(t
, a
, WRITEMASK_X
));
3823 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3824 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3830 ir_function_signature
*
3831 builtin_builder::_noise4(const glsl_type
*type
)
3833 ir_variable
*p
= in_var(type
, "p");
3834 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
3836 ir_variable
*_p
= body
.make_temp(type
, "_p");
3838 ir_constant_data p_offset
;
3839 p_offset
.f
[0] = 1559.0f
;
3840 p_offset
.f
[1] = 113.0f
;
3841 p_offset
.f
[2] = 1861.0f
;
3842 p_offset
.f
[3] = 797.0f
;
3844 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
3846 ir_constant_data offset
;
3847 offset
.f
[0] = 601.0f
;
3848 offset
.f
[1] = 313.0f
;
3849 offset
.f
[2] = 29.0f
;
3850 offset
.f
[3] = 277.0f
;
3852 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3853 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3854 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3855 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
3856 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
3857 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3858 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
3859 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
3860 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
3861 body
.emit(assign(t
, a
, WRITEMASK_X
));
3862 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3863 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3864 body
.emit(assign(t
, d
, WRITEMASK_W
));
3870 ir_function_signature
*
3871 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
3873 ir_variable
*value
= in_var(type
, "value");
3874 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3875 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3876 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
3878 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
3883 ir_function_signature
*
3884 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
3886 ir_variable
*base
= in_var(type
, "base");
3887 ir_variable
*insert
= in_var(type
, "insert");
3888 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3889 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3890 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
3892 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
3897 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
3899 ir_function_signature
*
3900 builtin_builder::_bitCount(const glsl_type
*type
)
3902 return unop(gpu_shader5
, ir_unop_bit_count
,
3903 glsl_type::ivec(type
->vector_elements
), type
);
3906 ir_function_signature
*
3907 builtin_builder::_findLSB(const glsl_type
*type
)
3909 return unop(gpu_shader5
, ir_unop_find_lsb
,
3910 glsl_type::ivec(type
->vector_elements
), type
);
3913 ir_function_signature
*
3914 builtin_builder::_findMSB(const glsl_type
*type
)
3916 return unop(gpu_shader5
, ir_unop_find_msb
,
3917 glsl_type::ivec(type
->vector_elements
), type
);
3920 ir_function_signature
*
3921 builtin_builder::_fma(const glsl_type
*type
)
3923 ir_variable
*a
= in_var(type
, "a");
3924 ir_variable
*b
= in_var(type
, "b");
3925 ir_variable
*c
= in_var(type
, "c");
3926 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
3928 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
3933 ir_function_signature
*
3934 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3936 return binop(ir_binop_ldexp
, gpu_shader5
, x_type
, x_type
, exp_type
);
3939 ir_function_signature
*
3940 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3942 ir_variable
*x
= in_var(x_type
, "x");
3943 ir_variable
*exponent
= out_var(exp_type
, "exp");
3944 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
3946 const unsigned vec_elem
= x_type
->vector_elements
;
3947 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
3948 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
3950 /* Single-precision floating-point values are stored as
3955 * An exponent shift of 23 will shift the mantissa out, leaving only the
3956 * exponent and sign bit (which itself may be zero, if the absolute value
3957 * was taken before the bitcast and shift.
3959 ir_constant
*exponent_shift
= imm(23);
3960 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
3962 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
3964 /* Exponent of floating-point values in the range [0.5, 1.0). */
3965 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
3967 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
3968 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
3970 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
3971 * to unsigned integers to ensure that 1 bits aren't shifted in.
3973 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
3974 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
3975 imm(0, vec_elem
)))));
3977 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
3978 body
.emit(assign(bits
, bitcast_f2u(x
)));
3979 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
3980 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
3981 imm(0u, vec_elem
)))));
3982 body
.emit(ret(bitcast_u2f(bits
)));
3987 ir_function_signature
*
3988 builtin_builder::_uaddCarry(const glsl_type
*type
)
3990 ir_variable
*x
= in_var(type
, "x");
3991 ir_variable
*y
= in_var(type
, "y");
3992 ir_variable
*carry
= out_var(type
, "carry");
3993 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
3995 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
3996 body
.emit(ret(add(x
, y
)));
4001 ir_function_signature
*
4002 builtin_builder::_usubBorrow(const glsl_type
*type
)
4004 ir_variable
*x
= in_var(type
, "x");
4005 ir_variable
*y
= in_var(type
, "y");
4006 ir_variable
*borrow
= out_var(type
, "borrow");
4007 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
4009 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4010 body
.emit(ret(sub(x
, y
)));
4016 * For both imulExtended() and umulExtended() built-ins.
4018 ir_function_signature
*
4019 builtin_builder::_mulExtended(const glsl_type
*type
)
4021 ir_variable
*x
= in_var(type
, "x");
4022 ir_variable
*y
= in_var(type
, "y");
4023 ir_variable
*msb
= out_var(type
, "msb");
4024 ir_variable
*lsb
= out_var(type
, "lsb");
4025 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
4027 body
.emit(assign(msb
, imul_high(x
, y
)));
4028 body
.emit(assign(lsb
, mul(x
, y
)));
4033 ir_function_signature
*
4034 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4036 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4037 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4041 ir_function_signature
*
4042 builtin_builder::_atomic_op(const char *intrinsic
,
4043 builtin_available_predicate avail
)
4045 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4046 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4048 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4049 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4051 body
.emit(ret(retval
));
4055 ir_function_signature
*
4056 builtin_builder::_min3(const glsl_type
*type
)
4058 ir_variable
*x
= in_var(type
, "x");
4059 ir_variable
*y
= in_var(type
, "y");
4060 ir_variable
*z
= in_var(type
, "z");
4061 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4063 ir_expression
*min3
= min2(x
, min2(y
,z
));
4064 body
.emit(ret(min3
));
4069 ir_function_signature
*
4070 builtin_builder::_max3(const glsl_type
*type
)
4072 ir_variable
*x
= in_var(type
, "x");
4073 ir_variable
*y
= in_var(type
, "y");
4074 ir_variable
*z
= in_var(type
, "z");
4075 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4077 ir_expression
*max3
= max2(x
, max2(y
,z
));
4078 body
.emit(ret(max3
));
4083 ir_function_signature
*
4084 builtin_builder::_mid3(const glsl_type
*type
)
4086 ir_variable
*x
= in_var(type
, "x");
4087 ir_variable
*y
= in_var(type
, "y");
4088 ir_variable
*z
= in_var(type
, "z");
4089 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4091 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4092 body
.emit(ret(mid3
));
4099 /******************************************************************************/
4101 /* The singleton instance of builtin_builder. */
4102 static builtin_builder builtins
;
4103 _glthread_DECLARE_STATIC_MUTEX(builtins_lock
);
4106 * External API (exposing the built-in module to the rest of the compiler):
4110 _mesa_glsl_initialize_builtin_functions()
4112 _glthread_LOCK_MUTEX(builtins_lock
);
4113 builtins
.initialize();
4114 _glthread_UNLOCK_MUTEX(builtins_lock
);
4118 _mesa_glsl_release_builtin_functions()
4120 _glthread_LOCK_MUTEX(builtins_lock
);
4122 _glthread_UNLOCK_MUTEX(builtins_lock
);
4125 ir_function_signature
*
4126 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4127 const char *name
, exec_list
*actual_parameters
)
4129 ir_function_signature
* s
;
4130 _glthread_LOCK_MUTEX(builtins_lock
);
4131 s
= builtins
.find(state
, name
, actual_parameters
);
4132 _glthread_UNLOCK_MUTEX(builtins_lock
);
4137 _mesa_glsl_get_builtin_function_shader()
4139 return builtins
.shader
;