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
->target
== vertex_shader
&&
81 state
->language_version
<= 130 &&
86 fs_only(const _mesa_glsl_parse_state
*state
)
88 return state
->target
== fragment_shader
;
92 gs_only(const _mesa_glsl_parse_state
*state
)
94 return state
->target
== geometry_shader
;
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
->target
== fragment_shader
;
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
->target
== fragment_shader
;
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
->target
== vertex_shader
||
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
->target
== fragment_shader
&&
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
->target
== fragment_shader
&&
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
->target
== fragment_shader
&&
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
->target
== fragment_shader
&&
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
->target
== fragment_shader
&&
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
;
339 /******************************************************************************/
344 * builtin_builder: A singleton object representing the core of the built-in
347 * It generates IR for every built-in function signature, and organizes them
350 class builtin_builder
{
357 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
358 const char *name
, exec_list
*actual_parameters
);
361 * A shader to hold all the built-in signatures; created by this module.
363 * This includes signatures for every built-in, regardless of version or
364 * enabled extensions. The availability predicate associated with each
365 * signature allows matching_signature() to filter out the irrelevant ones.
372 /** Global variables used by built-in functions. */
373 ir_variable
*gl_ModelViewProjectionMatrix
;
374 ir_variable
*gl_Vertex
;
376 void create_shader();
377 void create_intrinsics();
378 void create_builtins();
381 * IR builder helpers:
383 * These convenience functions assist in emitting IR, but don't necessarily
384 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
387 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
388 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
389 ir_constant
*imm(float f
, unsigned vector_elements
=1);
390 ir_constant
*imm(int i
, unsigned vector_elements
=1);
391 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
392 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
393 ir_dereference_variable
*var_ref(ir_variable
*var
);
394 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
395 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
397 ir_expression
*asin_expr(ir_variable
*x
);
400 * Call function \param f with parameters specified as the linked
401 * list \param params of \c ir_variable objects. \param ret should
402 * point to the ir_variable that will hold the function return
403 * value, or be \c NULL if the function has void return type.
405 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
407 /** Create a new function and add the given signatures. */
408 void add_function(const char *name
, ...);
410 ir_function_signature
*new_sig(const glsl_type
*return_type
,
411 builtin_available_predicate avail
,
412 int num_params
, ...);
415 * Function signature generators:
418 ir_function_signature
*unop(builtin_available_predicate avail
,
419 ir_expression_operation opcode
,
420 const glsl_type
*return_type
,
421 const glsl_type
*param_type
);
422 ir_function_signature
*binop(ir_expression_operation opcode
,
423 builtin_available_predicate avail
,
424 const glsl_type
*return_type
,
425 const glsl_type
*param0_type
,
426 const glsl_type
*param1_type
);
428 #define B0(X) ir_function_signature *_##X();
429 #define B1(X) ir_function_signature *_##X(const glsl_type *);
430 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
431 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
432 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
433 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
470 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
471 const glsl_type
*val_type
,
472 const glsl_type
*blend_type
);
481 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
482 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
483 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
484 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
485 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
486 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
487 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
488 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
489 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
490 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
502 B0(determinant_mat2
);
503 B0(determinant_mat3
);
504 B0(determinant_mat4
);
512 BA1(greaterThanEqual
);
519 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
520 const glsl_type
*return_type
,
521 const glsl_type
*sampler_type
);
523 /** Flags to _texture() */
524 #define TEX_PROJECT 1
526 #define TEX_COMPONENT 4
527 #define TEX_OFFSET_NONCONST 8
528 #define TEX_OFFSET_ARRAY 16
530 ir_function_signature
*_texture(ir_texture_opcode opcode
,
531 builtin_available_predicate avail
,
532 const glsl_type
*return_type
,
533 const glsl_type
*sampler_type
,
534 const glsl_type
*coord_type
,
536 B0(textureCubeArrayShadow
);
537 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
538 const glsl_type
*return_type
,
539 const glsl_type
*sampler_type
,
540 const glsl_type
*coord_type
,
541 const glsl_type
*offset_type
= NULL
);
547 B1(textureQueryLevels
);
569 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
570 ir_function_signature
*_atomic_op(const char *intrinsic
,
571 builtin_available_predicate avail
);
582 } /* anonymous namespace */
585 * Core builtin_builder functionality:
588 builtin_builder::builtin_builder()
590 gl_ModelViewProjectionMatrix(NULL
),
596 builtin_builder::~builtin_builder()
598 ralloc_free(mem_ctx
);
601 ir_function_signature
*
602 builtin_builder::find(_mesa_glsl_parse_state
*state
,
603 const char *name
, exec_list
*actual_parameters
)
605 /* The shader currently being compiled requested a built-in function;
606 * it needs to link against builtin_builder::shader in order to get them.
608 * Even if we don't find a matching signature, we still need to do this so
609 * that the "no matching signature" error will list potential candidates
610 * from the available built-ins.
612 state
->uses_builtin_functions
= true;
614 ir_function
*f
= shader
->symbols
->get_function(name
);
618 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
626 builtin_builder::initialize()
628 /* If already initialized, don't do it again. */
632 mem_ctx
= ralloc_context(NULL
);
639 builtin_builder::release()
641 ralloc_free(mem_ctx
);
649 builtin_builder::create_shader()
651 /* The target doesn't actually matter. There's no target for generic
652 * GLSL utility code that could be linked against any stage, so just
653 * arbitrarily pick GL_VERTEX_SHADER.
655 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
656 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
658 gl_ModelViewProjectionMatrix
=
659 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
660 "gl_ModelViewProjectionMatrix",
663 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
665 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
666 shader
->symbols
->add_variable(gl_Vertex
);
672 * Create ir_function and ir_function_signature objects for each
676 builtin_builder::create_intrinsics()
678 add_function("__intrinsic_atomic_read",
679 _atomic_intrinsic(shader_atomic_counters
),
681 add_function("__intrinsic_atomic_increment",
682 _atomic_intrinsic(shader_atomic_counters
),
684 add_function("__intrinsic_atomic_predecrement",
685 _atomic_intrinsic(shader_atomic_counters
),
690 * Create ir_function and ir_function_signature objects for each built-in.
692 * Contains a list of every available built-in.
695 builtin_builder::create_builtins()
698 add_function(#NAME, \
699 _##NAME(glsl_type::float_type), \
700 _##NAME(glsl_type::vec2_type), \
701 _##NAME(glsl_type::vec3_type), \
702 _##NAME(glsl_type::vec4_type), \
706 add_function(#NAME, \
707 _##NAME(glsl_type::float_type), \
708 _##NAME(glsl_type::vec2_type), \
709 _##NAME(glsl_type::vec3_type), \
710 _##NAME(glsl_type::vec4_type), \
711 _##NAME(glsl_type::int_type), \
712 _##NAME(glsl_type::ivec2_type), \
713 _##NAME(glsl_type::ivec3_type), \
714 _##NAME(glsl_type::ivec4_type), \
718 add_function(#NAME, \
719 _##NAME(always_available, glsl_type::float_type), \
720 _##NAME(always_available, glsl_type::vec2_type), \
721 _##NAME(always_available, glsl_type::vec3_type), \
722 _##NAME(always_available, glsl_type::vec4_type), \
724 _##NAME(always_available, glsl_type::int_type), \
725 _##NAME(always_available, glsl_type::ivec2_type), \
726 _##NAME(always_available, glsl_type::ivec3_type), \
727 _##NAME(always_available, glsl_type::ivec4_type), \
729 _##NAME(v130, glsl_type::uint_type), \
730 _##NAME(v130, glsl_type::uvec2_type), \
731 _##NAME(v130, glsl_type::uvec3_type), \
732 _##NAME(v130, glsl_type::uvec4_type), \
736 add_function(#NAME, \
737 _##NAME(glsl_type::int_type), \
738 _##NAME(glsl_type::ivec2_type), \
739 _##NAME(glsl_type::ivec3_type), \
740 _##NAME(glsl_type::ivec4_type), \
742 _##NAME(glsl_type::uint_type), \
743 _##NAME(glsl_type::uvec2_type), \
744 _##NAME(glsl_type::uvec3_type), \
745 _##NAME(glsl_type::uvec4_type), \
749 add_function(#NAME, \
750 _##NAME(always_available, glsl_type::float_type), \
751 _##NAME(always_available, glsl_type::vec2_type), \
752 _##NAME(always_available, glsl_type::vec3_type), \
753 _##NAME(always_available, glsl_type::vec4_type), \
755 _##NAME(always_available, glsl_type::int_type), \
756 _##NAME(always_available, glsl_type::ivec2_type), \
757 _##NAME(always_available, glsl_type::ivec3_type), \
758 _##NAME(always_available, glsl_type::ivec4_type), \
760 _##NAME(v130, glsl_type::uint_type), \
761 _##NAME(v130, glsl_type::uvec2_type), \
762 _##NAME(v130, glsl_type::uvec3_type), \
763 _##NAME(v130, glsl_type::uvec4_type), \
765 _##NAME(always_available, glsl_type::bool_type), \
766 _##NAME(always_available, glsl_type::bvec2_type), \
767 _##NAME(always_available, glsl_type::bvec3_type), \
768 _##NAME(always_available, glsl_type::bvec4_type), \
771 #define FIU2_MIXED(NAME) \
772 add_function(#NAME, \
773 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
774 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
775 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
776 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
778 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
779 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
780 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
782 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
783 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
784 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
785 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
787 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
788 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
789 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
791 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
792 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
793 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
794 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
796 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
797 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
798 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
810 _atan(glsl_type::float_type
),
811 _atan(glsl_type::vec2_type
),
812 _atan(glsl_type::vec3_type
),
813 _atan(glsl_type::vec4_type
),
814 _atan2(glsl_type::float_type
),
815 _atan2(glsl_type::vec2_type
),
816 _atan2(glsl_type::vec3_type
),
817 _atan2(glsl_type::vec4_type
),
843 _mod(glsl_type::float_type
, glsl_type::float_type
),
844 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
845 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
846 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
848 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
849 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
850 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
860 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
861 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
862 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
863 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
865 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
866 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
867 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
869 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
870 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
871 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
872 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
874 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
875 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
876 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
877 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
879 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
880 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
881 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
882 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
884 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
885 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
886 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
887 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
891 _step(glsl_type::float_type
, glsl_type::float_type
),
892 _step(glsl_type::float_type
, glsl_type::vec2_type
),
893 _step(glsl_type::float_type
, glsl_type::vec3_type
),
894 _step(glsl_type::float_type
, glsl_type::vec4_type
),
896 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
897 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
898 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
901 add_function("smoothstep",
902 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
903 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
904 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
905 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
907 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
908 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
909 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
917 add_function("intBitsToFloat",
918 _intBitsToFloat(glsl_type::int_type
),
919 _intBitsToFloat(glsl_type::ivec2_type
),
920 _intBitsToFloat(glsl_type::ivec3_type
),
921 _intBitsToFloat(glsl_type::ivec4_type
),
923 add_function("uintBitsToFloat",
924 _uintBitsToFloat(glsl_type::uint_type
),
925 _uintBitsToFloat(glsl_type::uvec2_type
),
926 _uintBitsToFloat(glsl_type::uvec3_type
),
927 _uintBitsToFloat(glsl_type::uvec4_type
),
930 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3
), NULL
);
931 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
932 add_function("packUnorm4x8", _packUnorm4x8(shader_packing
), NULL
);
933 add_function("packSnorm4x8", _packSnorm4x8(shader_packing
), NULL
);
934 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3
), NULL
);
935 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
936 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing
), NULL
);
937 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing
), NULL
);
938 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
939 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
945 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
948 add_function("ftransform", _ftransform(), NULL
);
953 add_function("matrixCompMult",
954 _matrixCompMult(glsl_type::mat2_type
),
955 _matrixCompMult(glsl_type::mat3_type
),
956 _matrixCompMult(glsl_type::mat4_type
),
957 _matrixCompMult(glsl_type::mat2x3_type
),
958 _matrixCompMult(glsl_type::mat2x4_type
),
959 _matrixCompMult(glsl_type::mat3x2_type
),
960 _matrixCompMult(glsl_type::mat3x4_type
),
961 _matrixCompMult(glsl_type::mat4x2_type
),
962 _matrixCompMult(glsl_type::mat4x3_type
),
964 add_function("outerProduct",
965 _outerProduct(glsl_type::mat2_type
),
966 _outerProduct(glsl_type::mat3_type
),
967 _outerProduct(glsl_type::mat4_type
),
968 _outerProduct(glsl_type::mat2x3_type
),
969 _outerProduct(glsl_type::mat2x4_type
),
970 _outerProduct(glsl_type::mat3x2_type
),
971 _outerProduct(glsl_type::mat3x4_type
),
972 _outerProduct(glsl_type::mat4x2_type
),
973 _outerProduct(glsl_type::mat4x3_type
),
975 add_function("determinant",
980 add_function("inverse",
985 add_function("transpose",
986 _transpose(glsl_type::mat2_type
),
987 _transpose(glsl_type::mat3_type
),
988 _transpose(glsl_type::mat4_type
),
989 _transpose(glsl_type::mat2x3_type
),
990 _transpose(glsl_type::mat2x4_type
),
991 _transpose(glsl_type::mat3x2_type
),
992 _transpose(glsl_type::mat3x4_type
),
993 _transpose(glsl_type::mat4x2_type
),
994 _transpose(glsl_type::mat4x3_type
),
999 FIU(greaterThanEqual
)
1004 _any(glsl_type::bvec2_type
),
1005 _any(glsl_type::bvec3_type
),
1006 _any(glsl_type::bvec4_type
),
1010 _all(glsl_type::bvec2_type
),
1011 _all(glsl_type::bvec3_type
),
1012 _all(glsl_type::bvec4_type
),
1016 _not(glsl_type::bvec2_type
),
1017 _not(glsl_type::bvec3_type
),
1018 _not(glsl_type::bvec4_type
),
1021 add_function("textureSize",
1022 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1023 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1024 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1026 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1027 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1028 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1030 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1031 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1032 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1034 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1035 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1036 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1038 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1039 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1040 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1042 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1043 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1044 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1045 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1046 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1047 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1049 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1050 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1052 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1053 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1054 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1055 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1057 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1058 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1059 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1060 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1062 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1063 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1064 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1065 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1066 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1067 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1069 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1070 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1071 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1074 add_function("texture",
1075 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1076 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1077 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1079 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1080 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1081 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1083 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1084 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1085 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1087 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1088 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1089 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1091 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1092 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1093 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1095 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1096 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1097 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1099 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1100 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1101 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1103 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1104 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1105 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1107 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1108 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1109 /* samplerCubeArrayShadow is special; it has an extra parameter
1110 * for the shadow comparitor since there is no vec5 type.
1112 _textureCubeArrayShadow(),
1114 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1115 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1116 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1118 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1120 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1121 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1122 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1124 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1125 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1126 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1128 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1129 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1130 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1132 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1133 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1134 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1136 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1137 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1138 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1140 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1141 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1142 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1144 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1145 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1146 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1148 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1149 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1150 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1152 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1155 add_function("textureLod",
1156 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1157 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1158 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1160 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1161 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1162 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1164 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1165 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1166 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1168 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1169 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1170 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1172 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1173 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1175 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1176 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1177 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1179 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1180 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1181 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1183 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1184 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1185 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1187 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1190 add_function("textureOffset",
1191 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1192 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1193 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1195 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1196 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1197 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1199 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1200 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1201 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1203 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1204 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1205 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1207 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1209 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1210 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1212 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1213 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1214 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1216 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1217 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1218 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1220 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1222 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1223 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1224 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1226 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1227 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1228 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1230 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1231 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1232 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1234 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1235 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1237 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1238 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1239 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1241 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1242 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1243 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1245 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1248 add_function("textureProj",
1249 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1250 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1251 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1252 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1253 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1254 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1256 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1257 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1258 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1259 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1260 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1261 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1263 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1264 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1265 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1267 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1268 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1270 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1271 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1272 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1273 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1274 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1275 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1277 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1279 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1280 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1281 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1282 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1283 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1284 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1286 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1287 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1288 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1289 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1290 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1291 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1293 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1294 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1295 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1297 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1298 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1301 add_function("texelFetch",
1302 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1303 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1304 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1306 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1307 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1308 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1310 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1311 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1312 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1314 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1315 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1316 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1318 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1319 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1320 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1322 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1323 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1324 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1326 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1327 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1328 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1330 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1331 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1332 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1334 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1335 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1336 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1339 add_function("texelFetchOffset",
1340 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1341 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1342 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1344 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1345 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1346 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1348 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1349 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1350 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1352 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1353 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1354 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1356 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1357 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1358 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1360 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1361 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1362 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1366 add_function("textureProjOffset",
1367 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1368 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1369 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1370 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1371 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1372 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1374 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1375 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1376 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1377 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1378 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1379 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1381 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1382 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1383 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1385 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1386 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1388 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1389 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1390 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1391 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1392 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1393 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1395 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1397 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1398 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1399 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1400 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1401 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1402 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1404 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1405 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1406 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1407 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1408 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1409 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1411 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1412 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1413 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1415 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1416 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1419 add_function("textureLodOffset",
1420 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1421 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1422 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1424 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1425 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1426 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1428 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1429 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1430 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1432 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1433 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1435 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1436 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1437 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1439 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1440 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1441 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1443 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1446 add_function("textureProjLod",
1447 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1448 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1449 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1450 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1451 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1452 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1454 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1455 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1456 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1457 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1458 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1459 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1461 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1462 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1463 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1465 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1466 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1469 add_function("textureProjLodOffset",
1470 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1471 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1472 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1473 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1474 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1475 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1477 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1478 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1479 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1480 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1481 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1482 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1484 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1485 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1486 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1488 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1489 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1492 add_function("textureGrad",
1493 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1494 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1495 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1497 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1498 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1499 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1501 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1502 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1503 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1505 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1506 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1507 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1509 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1510 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1511 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1513 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1515 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1516 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1517 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1519 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1520 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1521 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1523 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1524 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1525 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1527 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1528 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1529 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1531 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1532 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1535 add_function("textureGradOffset",
1536 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1537 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1538 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1540 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1541 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1542 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1544 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1545 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1546 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1548 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1549 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1550 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1552 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1554 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1555 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1557 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1558 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1559 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1561 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1562 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1563 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1565 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1566 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1569 add_function("textureProjGrad",
1570 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1571 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1572 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1573 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1574 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1575 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1577 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1578 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1579 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1580 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1581 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1582 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1584 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1585 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1586 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1588 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1589 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1590 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1591 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1592 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1593 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1595 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1597 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1598 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1601 add_function("textureProjGradOffset",
1602 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1603 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1604 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1605 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1606 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1607 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1609 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1610 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1611 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1612 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1613 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1614 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1616 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1617 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1618 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1620 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1621 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1622 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1623 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1624 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1625 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1627 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1629 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1630 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1633 add_function("EmitVertex", _EmitVertex(), NULL
);
1634 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1636 add_function("textureQueryLOD",
1637 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1638 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1639 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1641 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1642 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1643 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1645 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1646 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1647 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1649 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1650 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1651 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1653 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1654 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1655 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1657 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1658 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1659 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1661 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1662 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1663 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1665 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1666 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1667 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1668 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1669 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1670 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1673 add_function("textureQueryLevels",
1674 _textureQueryLevels(glsl_type::sampler1D_type
),
1675 _textureQueryLevels(glsl_type::sampler2D_type
),
1676 _textureQueryLevels(glsl_type::sampler3D_type
),
1677 _textureQueryLevels(glsl_type::samplerCube_type
),
1678 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1679 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1680 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1681 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1682 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1683 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1684 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1685 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1686 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1688 _textureQueryLevels(glsl_type::isampler1D_type
),
1689 _textureQueryLevels(glsl_type::isampler2D_type
),
1690 _textureQueryLevels(glsl_type::isampler3D_type
),
1691 _textureQueryLevels(glsl_type::isamplerCube_type
),
1692 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1693 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1694 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1696 _textureQueryLevels(glsl_type::usampler1D_type
),
1697 _textureQueryLevels(glsl_type::usampler2D_type
),
1698 _textureQueryLevels(glsl_type::usampler3D_type
),
1699 _textureQueryLevels(glsl_type::usamplerCube_type
),
1700 _textureQueryLevels(glsl_type::usampler1DArray_type
),
1701 _textureQueryLevels(glsl_type::usampler2DArray_type
),
1702 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
1706 add_function("texture1D",
1707 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1708 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1711 add_function("texture1DArray",
1712 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1713 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1716 add_function("texture1DProj",
1717 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1718 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1719 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1720 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1723 add_function("texture1DLod",
1724 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1727 add_function("texture1DArrayLod",
1728 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1731 add_function("texture1DProjLod",
1732 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1733 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1736 add_function("texture2D",
1737 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1738 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1739 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1742 add_function("texture2DArray",
1743 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1744 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1747 add_function("texture2DProj",
1748 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1749 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1750 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1751 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1752 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1753 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1756 add_function("texture2DLod",
1757 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1760 add_function("texture2DArrayLod",
1761 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1764 add_function("texture2DProjLod",
1765 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1766 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1769 add_function("texture3D",
1770 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1771 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1774 add_function("texture3DProj",
1775 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1776 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1779 add_function("texture3DLod",
1780 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1783 add_function("texture3DProjLod",
1784 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1787 add_function("textureCube",
1788 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1789 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1792 add_function("textureCubeLod",
1793 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1796 add_function("texture2DRect",
1797 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1800 add_function("texture2DRectProj",
1801 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1802 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1805 add_function("shadow1D",
1806 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1807 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1810 add_function("shadow1DArray",
1811 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1812 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1815 add_function("shadow2D",
1816 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1817 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1820 add_function("shadow2DArray",
1821 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1822 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1825 add_function("shadow1DProj",
1826 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1827 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1830 add_function("shadow2DProj",
1831 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1832 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1835 add_function("shadow1DLod",
1836 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1839 add_function("shadow2DLod",
1840 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1843 add_function("shadow1DArrayLod",
1844 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1847 add_function("shadow1DProjLod",
1848 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1851 add_function("shadow2DProjLod",
1852 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1855 add_function("shadow2DRect",
1856 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1859 add_function("shadow2DRectProj",
1860 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1863 add_function("texture1DGradARB",
1864 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1867 add_function("texture1DProjGradARB",
1868 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1869 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1872 add_function("texture2DGradARB",
1873 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1876 add_function("texture2DProjGradARB",
1877 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1878 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1881 add_function("texture3DGradARB",
1882 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1885 add_function("texture3DProjGradARB",
1886 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1889 add_function("textureCubeGradARB",
1890 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1893 add_function("shadow1DGradARB",
1894 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1897 add_function("shadow1DProjGradARB",
1898 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1901 add_function("shadow2DGradARB",
1902 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1905 add_function("shadow2DProjGradARB",
1906 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1909 add_function("texture2DRectGradARB",
1910 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1913 add_function("texture2DRectProjGradARB",
1914 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1915 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1918 add_function("shadow2DRectGradARB",
1919 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1922 add_function("shadow2DRectProjGradARB",
1923 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1926 add_function("textureGather",
1927 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1928 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1929 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1931 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1932 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1933 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1935 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1936 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1937 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1939 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1940 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1941 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1943 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1944 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1945 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1947 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1948 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1949 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1951 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1952 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1953 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1955 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1956 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1957 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1959 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1960 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1961 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1963 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1964 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1965 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1967 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1968 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
1969 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1970 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
1971 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
1974 add_function("textureGatherOffset",
1975 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1976 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1977 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1979 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1980 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1981 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1983 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1984 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1985 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1987 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1988 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1989 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1991 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1992 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1993 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1995 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1996 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1997 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1999 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2000 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2001 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2003 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2004 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2005 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2007 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2008 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2009 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2012 add_function("textureGatherOffsets",
2013 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2014 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2015 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2017 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2018 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2019 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2021 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2022 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2023 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2025 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2026 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2027 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2029 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2030 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2031 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2033 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2034 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2035 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2037 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2038 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2039 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2058 add_function("ldexp",
2059 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2060 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2061 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2062 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2065 add_function("frexp",
2066 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2067 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2068 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2069 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2071 add_function("uaddCarry",
2072 _uaddCarry(glsl_type::uint_type
),
2073 _uaddCarry(glsl_type::uvec2_type
),
2074 _uaddCarry(glsl_type::uvec3_type
),
2075 _uaddCarry(glsl_type::uvec4_type
),
2077 add_function("usubBorrow",
2078 _usubBorrow(glsl_type::uint_type
),
2079 _usubBorrow(glsl_type::uvec2_type
),
2080 _usubBorrow(glsl_type::uvec3_type
),
2081 _usubBorrow(glsl_type::uvec4_type
),
2083 add_function("imulExtended",
2084 _mulExtended(glsl_type::int_type
),
2085 _mulExtended(glsl_type::ivec2_type
),
2086 _mulExtended(glsl_type::ivec3_type
),
2087 _mulExtended(glsl_type::ivec4_type
),
2089 add_function("umulExtended",
2090 _mulExtended(glsl_type::uint_type
),
2091 _mulExtended(glsl_type::uvec2_type
),
2092 _mulExtended(glsl_type::uvec3_type
),
2093 _mulExtended(glsl_type::uvec4_type
),
2096 add_function("atomicCounter",
2097 _atomic_op("__intrinsic_atomic_read",
2098 shader_atomic_counters
),
2100 add_function("atomicCounterIncrement",
2101 _atomic_op("__intrinsic_atomic_increment",
2102 shader_atomic_counters
),
2104 add_function("atomicCounterDecrement",
2105 _atomic_op("__intrinsic_atomic_predecrement",
2106 shader_atomic_counters
),
2117 builtin_builder::add_function(const char *name
, ...)
2121 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2125 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2131 stuff
.push_tail(sig
);
2132 validate_ir_tree(&stuff
);
2135 f
->add_signature(sig
);
2139 shader
->symbols
->add_function(f
);
2143 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2145 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2149 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2151 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2155 builtin_builder::imm(float f
, unsigned vector_elements
)
2157 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2161 builtin_builder::imm(int i
, unsigned vector_elements
)
2163 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2167 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2169 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2173 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2175 return new(mem_ctx
) ir_constant(type
, &data
);
2178 ir_dereference_variable
*
2179 builtin_builder::var_ref(ir_variable
*var
)
2181 return new(mem_ctx
) ir_dereference_variable(var
);
2184 ir_dereference_array
*
2185 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2187 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2190 /** Return an element of a matrix */
2192 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2194 return swizzle(array_ref(var
, column
), row
, 1);
2198 * Implementations of built-in functions:
2201 ir_function_signature
*
2202 builtin_builder::new_sig(const glsl_type
*return_type
,
2203 builtin_available_predicate avail
,
2209 ir_function_signature
*sig
=
2210 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2213 va_start(ap
, num_params
);
2214 for (int i
= 0; i
< num_params
; i
++) {
2215 plist
.push_tail(va_arg(ap
, ir_variable
*));
2219 sig
->replace_parameters(&plist
);
2223 #define MAKE_SIG(return_type, avail, ...) \
2224 ir_function_signature *sig = \
2225 new_sig(return_type, avail, __VA_ARGS__); \
2226 ir_factory body(&sig->body, mem_ctx); \
2227 sig->is_defined = true;
2229 #define MAKE_INTRINSIC(return_type, avail, ...) \
2230 ir_function_signature *sig = \
2231 new_sig(return_type, avail, __VA_ARGS__); \
2232 sig->is_intrinsic = true;
2234 ir_function_signature
*
2235 builtin_builder::unop(builtin_available_predicate avail
,
2236 ir_expression_operation opcode
,
2237 const glsl_type
*return_type
,
2238 const glsl_type
*param_type
)
2240 ir_variable
*x
= in_var(param_type
, "x");
2241 MAKE_SIG(return_type
, avail
, 1, x
);
2242 body
.emit(ret(expr(opcode
, x
)));
2246 #define UNOP(NAME, OPCODE, AVAIL) \
2247 ir_function_signature * \
2248 builtin_builder::_##NAME(const glsl_type *type) \
2250 return unop(&AVAIL, OPCODE, type, type); \
2253 ir_function_signature
*
2254 builtin_builder::binop(ir_expression_operation opcode
,
2255 builtin_available_predicate avail
,
2256 const glsl_type
*return_type
,
2257 const glsl_type
*param0_type
,
2258 const glsl_type
*param1_type
)
2260 ir_variable
*x
= in_var(param0_type
, "x");
2261 ir_variable
*y
= in_var(param1_type
, "y");
2262 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2263 body
.emit(ret(expr(opcode
, x
, y
)));
2267 #define BINOP(NAME, OPCODE, AVAIL) \
2268 ir_function_signature * \
2269 builtin_builder::_##NAME(const glsl_type *return_type, \
2270 const glsl_type *param0_type, \
2271 const glsl_type *param1_type) \
2273 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2277 * Angle and Trigonometry Functions @{
2280 ir_function_signature
*
2281 builtin_builder::_radians(const glsl_type
*type
)
2283 ir_variable
*degrees
= in_var(type
, "degrees");
2284 MAKE_SIG(type
, always_available
, 1, degrees
);
2285 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2289 ir_function_signature
*
2290 builtin_builder::_degrees(const glsl_type
*type
)
2292 ir_variable
*radians
= in_var(type
, "radians");
2293 MAKE_SIG(type
, always_available
, 1, radians
);
2294 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2298 UNOP(sin
, ir_unop_sin
, always_available
)
2299 UNOP(cos
, ir_unop_cos
, always_available
)
2301 ir_function_signature
*
2302 builtin_builder::_tan(const glsl_type
*type
)
2304 ir_variable
*theta
= in_var(type
, "theta");
2305 MAKE_SIG(type
, always_available
, 1, theta
);
2306 body
.emit(ret(div(sin(theta
), cos(theta
))));
2311 builtin_builder::asin_expr(ir_variable
*x
)
2314 sub(imm(1.5707964f
),
2315 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2316 add(imm(1.5707964f
),
2318 add(imm(-0.21460183f
),
2320 add(imm(0.086566724f
),
2321 mul(abs(x
), imm(-0.03102955f
))))))))));
2325 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2327 exec_list actual_params
;
2329 foreach_iter(exec_list_iterator
, it
, params
) {
2330 ir_variable
*var
= ((ir_instruction
*)it
.get())->as_variable();
2331 actual_params
.push_tail(var_ref(var
));
2334 ir_function_signature
*sig
=
2335 f
->exact_matching_signature(NULL
, &actual_params
);
2339 ir_dereference_variable
*deref
=
2340 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2342 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2345 ir_function_signature
*
2346 builtin_builder::_asin(const glsl_type
*type
)
2348 ir_variable
*x
= in_var(type
, "x");
2349 MAKE_SIG(type
, always_available
, 1, x
);
2351 body
.emit(ret(asin_expr(x
)));
2356 ir_function_signature
*
2357 builtin_builder::_acos(const glsl_type
*type
)
2359 ir_variable
*x
= in_var(type
, "x");
2360 MAKE_SIG(type
, always_available
, 1, x
);
2362 body
.emit(ret(sub(imm(1.5707964f
), asin_expr(x
))));
2367 ir_function_signature
*
2368 builtin_builder::_atan2(const glsl_type
*type
)
2370 ir_variable
*vec_y
= in_var(type
, "vec_y");
2371 ir_variable
*vec_x
= in_var(type
, "vec_x");
2372 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2374 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2375 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2376 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2377 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2378 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2379 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2380 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2382 /* If |x| >= 1.0e-8 * |y|: */
2384 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2386 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2388 /* Then...call atan(y/x) */
2389 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2390 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2391 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2393 outer_then
.emit(assign(r
, asin_expr(r
)));
2395 /* ...and fix it up: */
2396 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2397 inner_if
->then_instructions
.push_tail(
2398 if_tree(gequal(y
, imm(0.0f
)),
2399 assign(r
, add(r
, imm(3.141593f
))),
2400 assign(r
, sub(r
, imm(3.141593f
)))));
2401 outer_then
.emit(inner_if
);
2404 outer_if
->else_instructions
.push_tail(
2405 assign(r
, mul(sign(y
), imm(1.5707965f
))));
2407 body
.emit(outer_if
);
2409 body
.emit(assign(vec_result
, r
, 1 << i
));
2411 body
.emit(ret(vec_result
));
2416 ir_function_signature
*
2417 builtin_builder::_atan(const glsl_type
*type
)
2419 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2420 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2422 ir_variable
*t
= body
.make_temp(type
, "t");
2423 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2426 body
.emit(ret(asin_expr(t
)));
2431 ir_function_signature
*
2432 builtin_builder::_sinh(const glsl_type
*type
)
2434 ir_variable
*x
= in_var(type
, "x");
2435 MAKE_SIG(type
, v130
, 1, x
);
2437 /* 0.5 * (e^x - e^(-x)) */
2438 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2443 ir_function_signature
*
2444 builtin_builder::_cosh(const glsl_type
*type
)
2446 ir_variable
*x
= in_var(type
, "x");
2447 MAKE_SIG(type
, v130
, 1, x
);
2449 /* 0.5 * (e^x + e^(-x)) */
2450 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2455 ir_function_signature
*
2456 builtin_builder::_tanh(const glsl_type
*type
)
2458 ir_variable
*x
= in_var(type
, "x");
2459 MAKE_SIG(type
, v130
, 1, x
);
2461 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2462 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2463 add(exp(x
), exp(neg(x
))))));
2468 ir_function_signature
*
2469 builtin_builder::_asinh(const glsl_type
*type
)
2471 ir_variable
*x
= in_var(type
, "x");
2472 MAKE_SIG(type
, v130
, 1, x
);
2474 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2479 ir_function_signature
*
2480 builtin_builder::_acosh(const glsl_type
*type
)
2482 ir_variable
*x
= in_var(type
, "x");
2483 MAKE_SIG(type
, v130
, 1, x
);
2485 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2489 ir_function_signature
*
2490 builtin_builder::_atanh(const glsl_type
*type
)
2492 ir_variable
*x
= in_var(type
, "x");
2493 MAKE_SIG(type
, v130
, 1, x
);
2495 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2496 sub(imm(1.0f
), x
))))));
2502 * Exponential Functions @{
2505 ir_function_signature
*
2506 builtin_builder::_pow(const glsl_type
*type
)
2508 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2511 UNOP(exp
, ir_unop_exp
, always_available
)
2512 UNOP(log
, ir_unop_log
, always_available
)
2513 UNOP(exp2
, ir_unop_exp2
, always_available
)
2514 UNOP(log2
, ir_unop_log2
, always_available
)
2515 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2516 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2520 UNOP(abs
, ir_unop_abs
, always_available
)
2521 UNOP(sign
, ir_unop_sign
, always_available
)
2522 UNOP(floor
, ir_unop_floor
, always_available
)
2523 UNOP(trunc
, ir_unop_trunc
, v130
)
2524 UNOP(round
, ir_unop_round_even
, always_available
)
2525 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2526 UNOP(ceil
, ir_unop_ceil
, always_available
)
2527 UNOP(fract
, ir_unop_fract
, always_available
)
2529 ir_function_signature
*
2530 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2532 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2535 ir_function_signature
*
2536 builtin_builder::_modf(const glsl_type
*type
)
2538 ir_variable
*x
= in_var(type
, "x");
2539 ir_variable
*i
= out_var(type
, "i");
2540 MAKE_SIG(type
, v130
, 2, x
, i
);
2542 ir_variable
*t
= body
.make_temp(type
, "t");
2543 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2544 body
.emit(assign(i
, t
));
2545 body
.emit(ret(sub(x
, t
)));
2550 ir_function_signature
*
2551 builtin_builder::_min(builtin_available_predicate avail
,
2552 const glsl_type
*x_type
, const glsl_type
*y_type
)
2554 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2557 ir_function_signature
*
2558 builtin_builder::_max(builtin_available_predicate avail
,
2559 const glsl_type
*x_type
, const glsl_type
*y_type
)
2561 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2564 ir_function_signature
*
2565 builtin_builder::_clamp(builtin_available_predicate avail
,
2566 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2568 ir_variable
*x
= in_var(val_type
, "x");
2569 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2570 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2571 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2573 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2578 ir_function_signature
*
2579 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2581 ir_variable
*x
= in_var(val_type
, "x");
2582 ir_variable
*y
= in_var(val_type
, "y");
2583 ir_variable
*a
= in_var(blend_type
, "a");
2584 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2586 body
.emit(ret(lrp(x
, y
, a
)));
2591 ir_function_signature
*
2592 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2593 const glsl_type
*val_type
,
2594 const glsl_type
*blend_type
)
2596 ir_variable
*x
= in_var(val_type
, "x");
2597 ir_variable
*y
= in_var(val_type
, "y");
2598 ir_variable
*a
= in_var(blend_type
, "a");
2599 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2601 /* csel matches the ternary operator in that a selector of true choses the
2602 * first argument. This differs from mix(x, y, false) which choses the
2603 * second argument (to remain consistent with the interpolating version of
2604 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2606 * To handle the behavior mismatch, reverse the x and y arguments.
2608 body
.emit(ret(csel(a
, y
, x
)));
2613 ir_function_signature
*
2614 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2616 ir_variable
*edge
= in_var(edge_type
, "edge");
2617 ir_variable
*x
= in_var(x_type
, "x");
2618 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2620 ir_variable
*t
= body
.make_temp(x_type
, "t");
2621 if (x_type
->vector_elements
== 1) {
2622 /* Both are floats */
2623 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2624 } else if (edge_type
->vector_elements
== 1) {
2625 /* x is a vector but edge is a float */
2626 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2627 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2630 /* Both are vectors */
2631 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2632 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2641 ir_function_signature
*
2642 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2644 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2645 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2646 ir_variable
*x
= in_var(x_type
, "x");
2647 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2649 /* From the GLSL 1.10 specification:
2652 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2653 * return t * t * (3 - 2 * t);
2656 ir_variable
*t
= body
.make_temp(x_type
, "t");
2657 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2658 imm(0.0f
), imm(1.0f
))));
2660 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2665 ir_function_signature
*
2666 builtin_builder::_isnan(const glsl_type
*type
)
2668 ir_variable
*x
= in_var(type
, "x");
2669 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2671 body
.emit(ret(nequal(x
, x
)));
2676 ir_function_signature
*
2677 builtin_builder::_isinf(const glsl_type
*type
)
2679 ir_variable
*x
= in_var(type
, "x");
2680 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2682 ir_constant_data infinities
;
2683 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2684 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2687 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2692 ir_function_signature
*
2693 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2695 ir_variable
*x
= in_var(type
, "x");
2696 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2697 body
.emit(ret(bitcast_f2i(x
)));
2701 ir_function_signature
*
2702 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2704 ir_variable
*x
= in_var(type
, "x");
2705 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2706 body
.emit(ret(bitcast_f2u(x
)));
2710 ir_function_signature
*
2711 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2713 ir_variable
*x
= in_var(type
, "x");
2714 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2715 body
.emit(ret(bitcast_i2f(x
)));
2719 ir_function_signature
*
2720 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2722 ir_variable
*x
= in_var(type
, "x");
2723 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2724 body
.emit(ret(bitcast_u2f(x
)));
2728 ir_function_signature
*
2729 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2731 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2732 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2733 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2737 ir_function_signature
*
2738 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2740 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2741 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2742 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2746 ir_function_signature
*
2747 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2749 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2750 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2751 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
2755 ir_function_signature
*
2756 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
2758 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2759 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2760 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
2764 ir_function_signature
*
2765 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
2767 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2768 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2769 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
2773 ir_function_signature
*
2774 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
2776 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2777 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2778 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
2783 ir_function_signature
*
2784 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
2786 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2787 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2788 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
2792 ir_function_signature
*
2793 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
2795 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2796 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2797 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
2801 ir_function_signature
*
2802 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
2804 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2805 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2806 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
2810 ir_function_signature
*
2811 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
2813 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2814 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2815 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
2819 ir_function_signature
*
2820 builtin_builder::_length(const glsl_type
*type
)
2822 ir_variable
*x
= in_var(type
, "x");
2823 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
2825 body
.emit(ret(sqrt(dotlike(x
, x
))));
2830 ir_function_signature
*
2831 builtin_builder::_distance(const glsl_type
*type
)
2833 ir_variable
*p0
= in_var(type
, "p0");
2834 ir_variable
*p1
= in_var(type
, "p1");
2835 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
2837 if (type
->vector_elements
== 1) {
2838 body
.emit(ret(abs(sub(p0
, p1
))));
2840 ir_variable
*p
= body
.make_temp(type
, "p");
2841 body
.emit(assign(p
, sub(p0
, p1
)));
2842 body
.emit(ret(sqrt(dot(p
, p
))));
2848 ir_function_signature
*
2849 builtin_builder::_dot(const glsl_type
*type
)
2851 if (type
->vector_elements
== 1)
2852 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
2854 return binop(ir_binop_dot
, always_available
,
2855 glsl_type::float_type
, type
, type
);
2858 ir_function_signature
*
2859 builtin_builder::_cross(const glsl_type
*type
)
2861 ir_variable
*a
= in_var(type
, "a");
2862 ir_variable
*b
= in_var(type
, "b");
2863 MAKE_SIG(type
, always_available
, 2, a
, b
);
2865 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
2866 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
2868 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
2869 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
2874 ir_function_signature
*
2875 builtin_builder::_normalize(const glsl_type
*type
)
2877 ir_variable
*x
= in_var(type
, "x");
2878 MAKE_SIG(type
, always_available
, 1, x
);
2880 if (type
->vector_elements
== 1) {
2881 body
.emit(ret(sign(x
)));
2883 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
2889 ir_function_signature
*
2890 builtin_builder::_ftransform()
2892 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
2894 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
2895 glsl_type::vec4_type
,
2896 var_ref(gl_ModelViewProjectionMatrix
),
2897 var_ref(gl_Vertex
))));
2899 /* FINISHME: Once the ir_expression() constructor handles type inference
2900 * for matrix operations, we can simplify this to:
2902 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
2907 ir_function_signature
*
2908 builtin_builder::_faceforward(const glsl_type
*type
)
2910 ir_variable
*N
= in_var(type
, "N");
2911 ir_variable
*I
= in_var(type
, "I");
2912 ir_variable
*Nref
= in_var(type
, "Nref");
2913 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
2915 body
.emit(if_tree(less(dotlike(Nref
, I
), imm(0.0f
)),
2916 ret(N
), ret(neg(N
))));
2921 ir_function_signature
*
2922 builtin_builder::_reflect(const glsl_type
*type
)
2924 ir_variable
*I
= in_var(type
, "I");
2925 ir_variable
*N
= in_var(type
, "N");
2926 MAKE_SIG(type
, always_available
, 2, I
, N
);
2928 /* I - 2 * dot(N, I) * N */
2929 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dotlike(N
, I
), N
)))));
2934 ir_function_signature
*
2935 builtin_builder::_refract(const glsl_type
*type
)
2937 ir_variable
*I
= in_var(type
, "I");
2938 ir_variable
*N
= in_var(type
, "N");
2939 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
2940 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
2942 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
2943 body
.emit(assign(n_dot_i
, dotlike(N
, I
)));
2945 /* From the GLSL 1.10 specification:
2946 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
2948 * return genType(0.0)
2950 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
2952 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
2953 body
.emit(assign(k
, sub(imm(1.0f
),
2954 mul(eta
, mul(eta
, sub(imm(1.0f
),
2955 mul(n_dot_i
, n_dot_i
)))))));
2956 body
.emit(if_tree(less(k
, imm(0.0f
)),
2957 ret(ir_constant::zero(mem_ctx
, type
)),
2958 ret(sub(mul(eta
, I
),
2959 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
2964 ir_function_signature
*
2965 builtin_builder::_matrixCompMult(const glsl_type
*type
)
2967 ir_variable
*x
= in_var(type
, "x");
2968 ir_variable
*y
= in_var(type
, "y");
2969 MAKE_SIG(type
, always_available
, 2, x
, y
);
2971 ir_variable
*z
= body
.make_temp(type
, "z");
2972 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2973 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
2980 ir_function_signature
*
2981 builtin_builder::_outerProduct(const glsl_type
*type
)
2983 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
2984 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
2985 MAKE_SIG(type
, v120
, 2, c
, r
);
2987 ir_variable
*m
= body
.make_temp(type
, "m");
2988 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2989 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
2996 ir_function_signature
*
2997 builtin_builder::_transpose(const glsl_type
*orig_type
)
2999 const glsl_type
*transpose_type
=
3000 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
3001 orig_type
->matrix_columns
,
3002 orig_type
->vector_elements
);
3004 ir_variable
*m
= in_var(orig_type
, "m");
3005 MAKE_SIG(transpose_type
, v120
, 1, m
);
3007 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3008 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3009 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3010 body
.emit(assign(array_ref(t
, j
),
3011 matrix_elt(m
, i
, j
),
3020 ir_function_signature
*
3021 builtin_builder::_determinant_mat2()
3023 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3024 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3026 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3027 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3032 ir_function_signature
*
3033 builtin_builder::_determinant_mat3()
3035 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3036 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3039 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3040 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3043 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3044 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3047 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3048 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3050 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3051 mul(matrix_elt(m
, 0, 1), f2
)),
3052 mul(matrix_elt(m
, 0, 2), f3
))));
3057 ir_function_signature
*
3058 builtin_builder::_determinant_mat4()
3060 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3061 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
3063 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3064 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3065 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3066 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3067 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3068 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3069 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3070 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3071 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3072 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3073 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3074 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3075 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3076 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3077 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3078 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3079 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3080 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3081 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3083 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)))));
3084 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)))));
3085 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)))));
3086 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)))));
3087 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)))));
3088 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)))));
3089 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)))));
3090 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)))));
3091 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)))));
3092 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)))));
3093 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)))));
3094 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)))));
3095 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)))));
3096 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)))));
3097 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)))));
3098 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)))));
3099 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)))));
3100 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)))));
3101 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)))));
3103 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
3105 body
.emit(assign(adj_0
,
3106 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3107 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3108 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3110 body
.emit(assign(adj_0
, neg(
3111 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3112 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3113 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3115 body
.emit(assign(adj_0
,
3116 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3117 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3118 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3120 body
.emit(assign(adj_0
, neg(
3121 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3122 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3123 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3126 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3131 ir_function_signature
*
3132 builtin_builder::_inverse_mat2()
3134 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3135 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
3137 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
3138 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3139 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3140 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3141 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3143 ir_expression
*det
=
3144 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3145 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3147 body
.emit(ret(div(adj
, det
)));
3151 ir_function_signature
*
3152 builtin_builder::_inverse_mat3()
3154 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3155 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
3157 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
3158 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
3159 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
3161 body
.emit(assign(f11_22_21_12
,
3162 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3163 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3164 body
.emit(assign(f10_22_20_12
,
3165 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3166 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3167 body
.emit(assign(f10_21_20_11
,
3168 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3169 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3171 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
3172 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3173 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3174 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3176 body
.emit(assign(array_ref(adj
, 0), neg(
3177 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3178 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3180 body
.emit(assign(array_ref(adj
, 1),
3181 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3182 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3184 body
.emit(assign(array_ref(adj
, 2), neg(
3185 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3186 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3189 body
.emit(assign(array_ref(adj
, 0),
3190 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3191 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3193 body
.emit(assign(array_ref(adj
, 1), neg(
3194 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3195 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3197 body
.emit(assign(array_ref(adj
, 2),
3198 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3199 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3202 ir_expression
*det
=
3203 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3204 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3205 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3207 body
.emit(ret(div(adj
, det
)));
3212 ir_function_signature
*
3213 builtin_builder::_inverse_mat4()
3215 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3216 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
3218 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3219 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3220 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3221 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3222 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3223 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3224 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3225 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3226 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3227 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3228 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3229 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3230 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3231 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3232 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3233 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3234 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3235 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3236 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3238 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)))));
3239 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)))));
3240 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)))));
3241 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)))));
3242 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)))));
3243 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)))));
3244 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)))));
3245 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)))));
3246 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)))));
3247 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)))));
3248 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)))));
3249 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)))));
3250 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)))));
3251 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)))));
3252 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)))));
3253 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)))));
3254 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)))));
3255 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)))));
3256 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)))));
3258 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
3259 body
.emit(assign(array_ref(adj
, 0),
3260 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3261 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3262 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3264 body
.emit(assign(array_ref(adj
, 1), neg(
3265 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3266 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3267 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3269 body
.emit(assign(array_ref(adj
, 2),
3270 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3271 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3272 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3274 body
.emit(assign(array_ref(adj
, 3), neg(
3275 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3276 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3277 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3280 body
.emit(assign(array_ref(adj
, 0), neg(
3281 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3282 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3283 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3285 body
.emit(assign(array_ref(adj
, 1),
3286 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3287 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3288 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3290 body
.emit(assign(array_ref(adj
, 2), neg(
3291 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3292 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3293 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3295 body
.emit(assign(array_ref(adj
, 3),
3296 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3297 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3298 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3301 body
.emit(assign(array_ref(adj
, 0),
3302 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3303 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3304 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3306 body
.emit(assign(array_ref(adj
, 1), neg(
3307 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3308 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3309 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3311 body
.emit(assign(array_ref(adj
, 2),
3312 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3313 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3314 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3316 body
.emit(assign(array_ref(adj
, 3), neg(
3317 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3318 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3319 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3322 body
.emit(assign(array_ref(adj
, 0), neg(
3323 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3324 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3325 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3327 body
.emit(assign(array_ref(adj
, 1),
3328 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3329 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3330 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3332 body
.emit(assign(array_ref(adj
, 2), neg(
3333 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3334 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3335 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3337 body
.emit(assign(array_ref(adj
, 3),
3338 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3339 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3340 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3343 ir_expression
*det
=
3344 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3345 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3346 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3347 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3349 body
.emit(ret(div(adj
, det
)));
3355 ir_function_signature
*
3356 builtin_builder::_lessThan(builtin_available_predicate avail
,
3357 const glsl_type
*type
)
3359 return binop(ir_binop_less
, avail
,
3360 glsl_type::bvec(type
->vector_elements
), type
, type
);
3363 ir_function_signature
*
3364 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3365 const glsl_type
*type
)
3367 return binop(ir_binop_lequal
, avail
,
3368 glsl_type::bvec(type
->vector_elements
), type
, type
);
3371 ir_function_signature
*
3372 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3373 const glsl_type
*type
)
3375 return binop(ir_binop_greater
, avail
,
3376 glsl_type::bvec(type
->vector_elements
), type
, type
);
3379 ir_function_signature
*
3380 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3381 const glsl_type
*type
)
3383 return binop(ir_binop_gequal
, avail
,
3384 glsl_type::bvec(type
->vector_elements
), type
, type
);
3387 ir_function_signature
*
3388 builtin_builder::_equal(builtin_available_predicate avail
,
3389 const glsl_type
*type
)
3391 return binop(ir_binop_equal
, avail
,
3392 glsl_type::bvec(type
->vector_elements
), type
, type
);
3395 ir_function_signature
*
3396 builtin_builder::_notEqual(builtin_available_predicate avail
,
3397 const glsl_type
*type
)
3399 return binop(ir_binop_nequal
, avail
,
3400 glsl_type::bvec(type
->vector_elements
), type
, type
);
3403 ir_function_signature
*
3404 builtin_builder::_any(const glsl_type
*type
)
3406 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3409 ir_function_signature
*
3410 builtin_builder::_all(const glsl_type
*type
)
3412 ir_variable
*v
= in_var(type
, "v");
3413 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3415 switch (type
->vector_elements
) {
3417 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3420 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3424 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3433 UNOP(not, ir_unop_logic_not
, always_available
)
3436 has_lod(const glsl_type
*sampler_type
)
3438 assert(sampler_type
->is_sampler());
3440 switch (sampler_type
->sampler_dimensionality
) {
3441 case GLSL_SAMPLER_DIM_RECT
:
3442 case GLSL_SAMPLER_DIM_BUF
:
3443 case GLSL_SAMPLER_DIM_MS
:
3450 ir_function_signature
*
3451 builtin_builder::_textureSize(builtin_available_predicate avail
,
3452 const glsl_type
*return_type
,
3453 const glsl_type
*sampler_type
)
3455 ir_variable
*s
= in_var(sampler_type
, "sampler");
3456 /* The sampler always exists; add optional lod later. */
3457 MAKE_SIG(return_type
, avail
, 1, s
);
3459 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3460 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3462 if (has_lod(sampler_type
)) {
3463 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3464 sig
->parameters
.push_tail(lod
);
3465 tex
->lod_info
.lod
= var_ref(lod
);
3467 tex
->lod_info
.lod
= imm(0u);
3470 body
.emit(ret(tex
));
3475 ir_function_signature
*
3476 builtin_builder::_texture(ir_texture_opcode opcode
,
3477 builtin_available_predicate avail
,
3478 const glsl_type
*return_type
,
3479 const glsl_type
*sampler_type
,
3480 const glsl_type
*coord_type
,
3483 ir_variable
*s
= in_var(sampler_type
, "sampler");
3484 ir_variable
*P
= in_var(coord_type
, "P");
3485 /* The sampler and coordinate always exist; add optional parameters later. */
3486 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3488 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3489 tex
->set_sampler(var_ref(s
), return_type
);
3491 const int coord_size
= sampler_type
->sampler_coordinate_components();
3493 if (coord_size
== coord_type
->vector_elements
) {
3494 tex
->coordinate
= var_ref(P
);
3496 /* The incoming coordinate also has the projector or shadow comparitor,
3497 * so we need to swizzle those away.
3499 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3502 /* The projector is always in the last component. */
3503 if (flags
& TEX_PROJECT
)
3504 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3506 if (sampler_type
->sampler_shadow
) {
3507 if (opcode
== ir_tg4
) {
3508 /* gather has refz as a separate parameter, immediately after the
3511 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
3512 sig
->parameters
.push_tail(refz
);
3513 tex
->shadow_comparitor
= var_ref(refz
);
3515 /* The shadow comparitor is normally in the Z component, but a few types
3516 * have sufficiently large coordinates that it's in W.
3518 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3522 if (opcode
== ir_txl
) {
3523 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3524 sig
->parameters
.push_tail(lod
);
3525 tex
->lod_info
.lod
= var_ref(lod
);
3526 } else if (opcode
== ir_txd
) {
3527 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3528 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3529 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3530 sig
->parameters
.push_tail(dPdx
);
3531 sig
->parameters
.push_tail(dPdy
);
3532 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3533 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3536 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
3537 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3538 ir_variable
*offset
=
3539 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
3540 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
3541 sig
->parameters
.push_tail(offset
);
3542 tex
->offset
= var_ref(offset
);
3545 if (flags
& TEX_OFFSET_ARRAY
) {
3546 ir_variable
*offsets
=
3547 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
3548 "offsets", ir_var_const_in
);
3549 sig
->parameters
.push_tail(offsets
);
3550 tex
->offset
= var_ref(offsets
);
3553 if (opcode
== ir_tg4
) {
3554 if (flags
& TEX_COMPONENT
) {
3555 ir_variable
*component
=
3556 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
3557 sig
->parameters
.push_tail(component
);
3558 tex
->lod_info
.component
= var_ref(component
);
3561 tex
->lod_info
.component
= imm(0);
3565 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3566 * inconsistent with both textureLodOffset and textureGradOffset.
3568 if (opcode
== ir_txb
) {
3569 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3570 sig
->parameters
.push_tail(bias
);
3571 tex
->lod_info
.bias
= var_ref(bias
);
3574 body
.emit(ret(tex
));
3579 ir_function_signature
*
3580 builtin_builder::_textureCubeArrayShadow()
3582 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3583 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3584 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3585 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3587 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3588 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3590 tex
->coordinate
= var_ref(P
);
3591 tex
->shadow_comparitor
= var_ref(compare
);
3593 body
.emit(ret(tex
));
3598 ir_function_signature
*
3599 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3600 const glsl_type
*return_type
,
3601 const glsl_type
*sampler_type
,
3602 const glsl_type
*coord_type
,
3603 const glsl_type
*offset_type
)
3605 ir_variable
*s
= in_var(sampler_type
, "sampler");
3606 ir_variable
*P
= in_var(coord_type
, "P");
3607 /* The sampler and coordinate always exist; add optional parameters later. */
3608 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3610 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3611 tex
->coordinate
= var_ref(P
);
3612 tex
->set_sampler(var_ref(s
), return_type
);
3614 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3615 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3616 sig
->parameters
.push_tail(sample
);
3617 tex
->lod_info
.sample_index
= var_ref(sample
);
3618 tex
->op
= ir_txf_ms
;
3619 } else if (has_lod(sampler_type
)) {
3620 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3621 sig
->parameters
.push_tail(lod
);
3622 tex
->lod_info
.lod
= var_ref(lod
);
3624 tex
->lod_info
.lod
= imm(0u);
3627 if (offset_type
!= NULL
) {
3628 ir_variable
*offset
=
3629 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3630 sig
->parameters
.push_tail(offset
);
3631 tex
->offset
= var_ref(offset
);
3634 body
.emit(ret(tex
));
3639 ir_function_signature
*
3640 builtin_builder::_EmitVertex()
3642 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3644 body
.emit(new(mem_ctx
) ir_emit_vertex());
3649 ir_function_signature
*
3650 builtin_builder::_EndPrimitive()
3652 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3654 body
.emit(new(mem_ctx
) ir_end_primitive());
3659 ir_function_signature
*
3660 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3661 const glsl_type
*coord_type
)
3663 ir_variable
*s
= in_var(sampler_type
, "sampler");
3664 ir_variable
*coord
= in_var(coord_type
, "coord");
3665 /* The sampler and coordinate always exist; add optional parameters later. */
3666 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3668 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3669 tex
->coordinate
= var_ref(coord
);
3670 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3672 body
.emit(ret(tex
));
3677 ir_function_signature
*
3678 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
3680 ir_variable
*s
= in_var(sampler_type
, "sampler");
3681 const glsl_type
*return_type
= glsl_type::int_type
;
3682 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
3684 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
3685 tex
->set_sampler(var_ref(s
), return_type
);
3687 body
.emit(ret(tex
));
3692 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3693 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3695 ir_function_signature
*
3696 builtin_builder::_fwidth(const glsl_type
*type
)
3698 ir_variable
*p
= in_var(type
, "p");
3699 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3701 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3706 ir_function_signature
*
3707 builtin_builder::_noise1(const glsl_type
*type
)
3709 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
3712 ir_function_signature
*
3713 builtin_builder::_noise2(const glsl_type
*type
)
3715 ir_variable
*p
= in_var(type
, "p");
3716 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
3718 ir_constant_data b_offset
;
3719 b_offset
.f
[0] = 601.0f
;
3720 b_offset
.f
[1] = 313.0f
;
3721 b_offset
.f
[2] = 29.0f
;
3722 b_offset
.f
[3] = 277.0f
;
3724 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3725 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3726 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
3727 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3728 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3729 body
.emit(assign(t
, a
, WRITEMASK_X
));
3730 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3736 ir_function_signature
*
3737 builtin_builder::_noise3(const glsl_type
*type
)
3739 ir_variable
*p
= in_var(type
, "p");
3740 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
3742 ir_constant_data b_offset
;
3743 b_offset
.f
[0] = 601.0f
;
3744 b_offset
.f
[1] = 313.0f
;
3745 b_offset
.f
[2] = 29.0f
;
3746 b_offset
.f
[3] = 277.0f
;
3748 ir_constant_data c_offset
;
3749 c_offset
.f
[0] = 1559.0f
;
3750 c_offset
.f
[1] = 113.0f
;
3751 c_offset
.f
[2] = 1861.0f
;
3752 c_offset
.f
[3] = 797.0f
;
3754 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3755 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3756 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3757 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
3758 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3759 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3760 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
3761 body
.emit(assign(t
, a
, WRITEMASK_X
));
3762 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3763 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3769 ir_function_signature
*
3770 builtin_builder::_noise4(const glsl_type
*type
)
3772 ir_variable
*p
= in_var(type
, "p");
3773 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
3775 ir_variable
*_p
= body
.make_temp(type
, "_p");
3777 ir_constant_data p_offset
;
3778 p_offset
.f
[0] = 1559.0f
;
3779 p_offset
.f
[1] = 113.0f
;
3780 p_offset
.f
[2] = 1861.0f
;
3781 p_offset
.f
[3] = 797.0f
;
3783 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
3785 ir_constant_data offset
;
3786 offset
.f
[0] = 601.0f
;
3787 offset
.f
[1] = 313.0f
;
3788 offset
.f
[2] = 29.0f
;
3789 offset
.f
[3] = 277.0f
;
3791 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3792 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3793 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3794 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
3795 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
3796 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3797 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
3798 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
3799 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
3800 body
.emit(assign(t
, a
, WRITEMASK_X
));
3801 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3802 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3803 body
.emit(assign(t
, d
, WRITEMASK_W
));
3809 ir_function_signature
*
3810 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
3812 ir_variable
*value
= in_var(type
, "value");
3813 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3814 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3815 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
3817 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
3822 ir_function_signature
*
3823 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
3825 ir_variable
*base
= in_var(type
, "base");
3826 ir_variable
*insert
= in_var(type
, "insert");
3827 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3828 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3829 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
3831 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
3836 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
3838 ir_function_signature
*
3839 builtin_builder::_bitCount(const glsl_type
*type
)
3841 return unop(gpu_shader5
, ir_unop_bit_count
,
3842 glsl_type::ivec(type
->vector_elements
), type
);
3845 ir_function_signature
*
3846 builtin_builder::_findLSB(const glsl_type
*type
)
3848 return unop(gpu_shader5
, ir_unop_find_lsb
,
3849 glsl_type::ivec(type
->vector_elements
), type
);
3852 ir_function_signature
*
3853 builtin_builder::_findMSB(const glsl_type
*type
)
3855 return unop(gpu_shader5
, ir_unop_find_msb
,
3856 glsl_type::ivec(type
->vector_elements
), type
);
3859 ir_function_signature
*
3860 builtin_builder::_fma(const glsl_type
*type
)
3862 ir_variable
*a
= in_var(type
, "a");
3863 ir_variable
*b
= in_var(type
, "b");
3864 ir_variable
*c
= in_var(type
, "c");
3865 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
3867 body
.emit(ret(fma(a
, b
, c
)));
3872 ir_function_signature
*
3873 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3875 return binop(ir_binop_ldexp
, gpu_shader5
, x_type
, x_type
, exp_type
);
3878 ir_function_signature
*
3879 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3881 ir_variable
*x
= in_var(x_type
, "x");
3882 ir_variable
*exponent
= out_var(exp_type
, "exp");
3883 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
3885 const unsigned vec_elem
= x_type
->vector_elements
;
3886 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
3887 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
3889 /* Single-precision floating-point values are stored as
3894 * An exponent shift of 23 will shift the mantissa out, leaving only the
3895 * exponent and sign bit (which itself may be zero, if the absolute value
3896 * was taken before the bitcast and shift.
3898 ir_constant
*exponent_shift
= imm(23);
3899 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
3901 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
3903 /* Exponent of floating-point values in the range [0.5, 1.0). */
3904 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
3906 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
3907 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
3909 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
3910 * to unsigned integers to ensure that 1 bits aren't shifted in.
3912 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
3913 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
3914 imm(0, vec_elem
)))));
3916 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
3917 body
.emit(assign(bits
, bitcast_f2u(x
)));
3918 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
3919 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
3920 imm(0u, vec_elem
)))));
3921 body
.emit(ret(bitcast_u2f(bits
)));
3926 ir_function_signature
*
3927 builtin_builder::_uaddCarry(const glsl_type
*type
)
3929 ir_variable
*x
= in_var(type
, "x");
3930 ir_variable
*y
= in_var(type
, "y");
3931 ir_variable
*carry
= out_var(type
, "carry");
3932 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
3934 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
3935 body
.emit(ret(add(x
, y
)));
3940 ir_function_signature
*
3941 builtin_builder::_usubBorrow(const glsl_type
*type
)
3943 ir_variable
*x
= in_var(type
, "x");
3944 ir_variable
*y
= in_var(type
, "y");
3945 ir_variable
*borrow
= out_var(type
, "borrow");
3946 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
3948 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
3949 body
.emit(ret(sub(x
, y
)));
3955 * For both imulExtended() and umulExtended() built-ins.
3957 ir_function_signature
*
3958 builtin_builder::_mulExtended(const glsl_type
*type
)
3960 ir_variable
*x
= in_var(type
, "x");
3961 ir_variable
*y
= in_var(type
, "y");
3962 ir_variable
*msb
= out_var(type
, "msb");
3963 ir_variable
*lsb
= out_var(type
, "lsb");
3964 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
3966 body
.emit(assign(msb
, imul_high(x
, y
)));
3967 body
.emit(assign(lsb
, mul(x
, y
)));
3972 ir_function_signature
*
3973 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
3975 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
3976 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
3980 ir_function_signature
*
3981 builtin_builder::_atomic_op(const char *intrinsic
,
3982 builtin_available_predicate avail
)
3984 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
3985 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
3987 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
3988 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
3990 body
.emit(ret(retval
));
3996 /******************************************************************************/
3998 /* The singleton instance of builtin_builder. */
3999 static builtin_builder builtins
;
4002 * External API (exposing the built-in module to the rest of the compiler):
4006 _mesa_glsl_initialize_builtin_functions()
4008 builtins
.initialize();
4012 _mesa_glsl_release_builtin_functions()
4017 ir_function_signature
*
4018 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
4019 const char *name
, exec_list
*actual_parameters
)
4021 return builtins
.find(state
, name
, actual_parameters
);
4025 _mesa_glsl_get_builtin_function_shader()
4027 return builtins
.shader
;