2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 #define M_PIf ((float) M_PI)
66 #define M_PI_2f ((float) M_PI_2)
67 #define M_PI_4f ((float) M_PI_4)
69 using namespace ir_builder
;
72 * Availability predicates:
76 always_available(const _mesa_glsl_parse_state
*)
82 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
84 return state
->stage
== MESA_SHADER_VERTEX
&&
85 state
->language_version
<= 130 &&
90 fs_only(const _mesa_glsl_parse_state
*state
)
92 return state
->stage
== MESA_SHADER_FRAGMENT
;
96 gs_only(const _mesa_glsl_parse_state
*state
)
98 return state
->stage
== MESA_SHADER_GEOMETRY
;
102 v110(const _mesa_glsl_parse_state
*state
)
104 return !state
->es_shader
;
108 v110_fs_only(const _mesa_glsl_parse_state
*state
)
110 return !state
->es_shader
&& state
->stage
== MESA_SHADER_FRAGMENT
;
114 v120(const _mesa_glsl_parse_state
*state
)
116 return state
->is_version(120, 300);
120 v130(const _mesa_glsl_parse_state
*state
)
122 return state
->is_version(130, 300);
126 v130_fs_only(const _mesa_glsl_parse_state
*state
)
128 return state
->is_version(130, 300) &&
129 state
->stage
== MESA_SHADER_FRAGMENT
;
133 v140(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 0);
139 v400_fs_only(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(400, 0) &&
142 state
->stage
== MESA_SHADER_FRAGMENT
;
146 es31(const _mesa_glsl_parse_state
*state
)
148 return state
->is_version(0, 310);
152 texture_rectangle(const _mesa_glsl_parse_state
*state
)
154 return state
->ARB_texture_rectangle_enable
;
158 texture_external(const _mesa_glsl_parse_state
*state
)
160 return state
->OES_EGL_image_external_enable
;
163 /** True if texturing functions with explicit LOD are allowed. */
165 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
167 /* Texturing functions with "Lod" in their name exist:
168 * - In the vertex shader stage (for all languages)
169 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
170 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
172 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
173 * don't need to explicitly check state->es_shader.
175 return state
->stage
== MESA_SHADER_VERTEX
||
176 state
->is_version(130, 300) ||
177 state
->ARB_shader_texture_lod_enable
;
181 v110_lod(const _mesa_glsl_parse_state
*state
)
183 return !state
->es_shader
&& lod_exists_in_stage(state
);
187 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
189 return state
->ARB_shader_texture_lod_enable
;
193 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
195 return state
->ARB_shader_texture_lod_enable
&&
196 state
->ARB_texture_rectangle_enable
;
200 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
202 return state
->is_version(330, 300) ||
203 state
->ARB_shader_bit_encoding_enable
||
204 state
->ARB_gpu_shader5_enable
;
208 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
210 return state
->is_version(450, 310) ||
211 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
215 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
217 return state
->ARB_shading_language_packing_enable
||
218 state
->is_version(420, 300);
222 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
224 return state
->ARB_shading_language_packing_enable
||
225 state
->ARB_gpu_shader5_enable
||
226 state
->is_version(400, 300);
230 gpu_shader5(const _mesa_glsl_parse_state
*state
)
232 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
236 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
238 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
242 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
244 return state
->ARB_shading_language_packing_enable
||
245 state
->ARB_gpu_shader5_enable
||
246 state
->is_version(400, 310);
250 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
252 return state
->stage
== MESA_SHADER_FRAGMENT
&&
253 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
258 texture_array_lod(const _mesa_glsl_parse_state
*state
)
260 return lod_exists_in_stage(state
) &&
261 state
->EXT_texture_array_enable
;
265 fs_texture_array(const _mesa_glsl_parse_state
*state
)
267 return state
->stage
== MESA_SHADER_FRAGMENT
&&
268 state
->EXT_texture_array_enable
;
272 texture_array(const _mesa_glsl_parse_state
*state
)
274 return state
->EXT_texture_array_enable
;
278 texture_multisample(const _mesa_glsl_parse_state
*state
)
280 return state
->is_version(150, 310) ||
281 state
->ARB_texture_multisample_enable
;
285 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
287 return state
->is_version(150, 320) ||
288 state
->ARB_texture_multisample_enable
||
289 state
->OES_texture_storage_multisample_2d_array_enable
;
293 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
295 return state
->stage
== MESA_SHADER_FRAGMENT
&&
296 (state
->is_version(400, 0) ||
297 state
->ARB_texture_cube_map_array_enable
);
301 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
303 return state
->is_version(400, 0) ||
304 state
->ARB_texture_cube_map_array_enable
;
308 texture_query_levels(const _mesa_glsl_parse_state
*state
)
310 return state
->is_version(430, 0) ||
311 state
->ARB_texture_query_levels_enable
;
315 texture_query_lod(const _mesa_glsl_parse_state
*state
)
317 return state
->stage
== MESA_SHADER_FRAGMENT
&&
318 state
->ARB_texture_query_lod_enable
;
322 texture_gather(const _mesa_glsl_parse_state
*state
)
324 return state
->is_version(400, 0) ||
325 state
->ARB_texture_gather_enable
||
326 state
->ARB_gpu_shader5_enable
;
330 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
332 return state
->is_version(400, 310) ||
333 state
->ARB_texture_gather_enable
||
334 state
->ARB_gpu_shader5_enable
;
337 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
338 * used for relaxation of const offset requirements.
341 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
343 return !state
->is_version(400, 0) &&
344 !state
->ARB_gpu_shader5_enable
&&
345 (state
->ARB_texture_gather_enable
||
346 state
->is_version(0, 310));
349 /* Desktop GL or OES_standard_derivatives + fragment shader only */
351 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
353 return state
->stage
== MESA_SHADER_FRAGMENT
&&
354 (state
->is_version(110, 300) ||
355 state
->OES_standard_derivatives_enable
);
359 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
361 return state
->stage
== MESA_SHADER_FRAGMENT
&&
362 (state
->is_version(450, 0) ||
363 state
->ARB_derivative_control_enable
);
367 tex1d_lod(const _mesa_glsl_parse_state
*state
)
369 return !state
->es_shader
&& lod_exists_in_stage(state
);
372 /** True if sampler3D exists */
374 tex3d(const _mesa_glsl_parse_state
*state
)
376 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
377 * OES_texture_3D extension, and in GLSL ES 3.00.
379 return !state
->es_shader
||
380 state
->OES_texture_3D_enable
||
381 state
->language_version
>= 300;
385 fs_tex3d(const _mesa_glsl_parse_state
*state
)
387 return state
->stage
== MESA_SHADER_FRAGMENT
&&
388 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
392 tex3d_lod(const _mesa_glsl_parse_state
*state
)
394 return tex3d(state
) && lod_exists_in_stage(state
);
398 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
400 return state
->has_atomic_counters();
404 shader_clock(const _mesa_glsl_parse_state
*state
)
406 return state
->ARB_shader_clock_enable
;
410 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
412 return state
->has_shader_storage_buffer_objects();
416 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
418 return state
->AMD_shader_trinary_minmax_enable
;
422 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
424 return (state
->is_version(420, 310) ||
425 state
->ARB_shader_image_load_store_enable
);
429 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
431 return (state
->is_version(420, 0) ||
432 state
->ARB_shader_image_load_store_enable
);
436 shader_image_size(const _mesa_glsl_parse_state
*state
)
438 return state
->is_version(430, 310) ||
439 state
->ARB_shader_image_size_enable
;
443 shader_samples(const _mesa_glsl_parse_state
*state
)
445 return state
->is_version(450, 0) ||
446 state
->ARB_shader_texture_image_samples_enable
;
450 gs_streams(const _mesa_glsl_parse_state
*state
)
452 return gpu_shader5(state
) && gs_only(state
);
456 fp64(const _mesa_glsl_parse_state
*state
)
458 return state
->has_double();
462 barrier_supported(const _mesa_glsl_parse_state
*state
)
464 return state
->stage
== MESA_SHADER_COMPUTE
||
465 state
->stage
== MESA_SHADER_TESS_CTRL
;
470 /******************************************************************************/
475 * builtin_builder: A singleton object representing the core of the built-in
478 * It generates IR for every built-in function signature, and organizes them
481 class builtin_builder
{
488 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
489 const char *name
, exec_list
*actual_parameters
);
492 * A shader to hold all the built-in signatures; created by this module.
494 * This includes signatures for every built-in, regardless of version or
495 * enabled extensions. The availability predicate associated with each
496 * signature allows matching_signature() to filter out the irrelevant ones.
503 /** Global variables used by built-in functions. */
504 ir_variable
*gl_ModelViewProjectionMatrix
;
505 ir_variable
*gl_Vertex
;
507 void create_shader();
508 void create_intrinsics();
509 void create_builtins();
512 * IR builder helpers:
514 * These convenience functions assist in emitting IR, but don't necessarily
515 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
518 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
519 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
520 ir_constant
*imm(float f
, unsigned vector_elements
=1);
521 ir_constant
*imm(int i
, unsigned vector_elements
=1);
522 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
523 ir_constant
*imm(double d
, unsigned vector_elements
=1);
524 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
525 ir_dereference_variable
*var_ref(ir_variable
*var
);
526 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
527 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
529 ir_expression
*asin_expr(ir_variable
*x
);
530 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
533 * Call function \param f with parameters specified as the linked
534 * list \param params of \c ir_variable objects. \param ret should
535 * point to the ir_variable that will hold the function return
536 * value, or be \c NULL if the function has void return type.
538 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
540 /** Create a new function and add the given signatures. */
541 void add_function(const char *name
, ...);
543 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
544 unsigned num_arguments
,
547 enum image_function_flags
{
548 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
549 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
550 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
551 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
552 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
553 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
554 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
555 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
559 * Create a new image built-in function for all known image types.
560 * \p flags is a bitfield of \c image_function_flags flags.
562 void add_image_function(const char *name
,
563 const char *intrinsic_name
,
564 image_prototype_ctr prototype
,
565 unsigned num_arguments
,
569 * Create new functions for all known image built-ins and types.
570 * If \p glsl is \c true, use the GLSL built-in names and emit code
571 * to call into the actual compiler intrinsic. If \p glsl is
572 * false, emit a function prototype with no body for each image
575 void add_image_functions(bool glsl
);
577 ir_function_signature
*new_sig(const glsl_type
*return_type
,
578 builtin_available_predicate avail
,
579 int num_params
, ...);
582 * Function signature generators:
585 ir_function_signature
*unop(builtin_available_predicate avail
,
586 ir_expression_operation opcode
,
587 const glsl_type
*return_type
,
588 const glsl_type
*param_type
);
589 ir_function_signature
*binop(ir_expression_operation opcode
,
590 builtin_available_predicate avail
,
591 const glsl_type
*return_type
,
592 const glsl_type
*param0_type
,
593 const glsl_type
*param1_type
);
595 #define B0(X) ir_function_signature *_##X();
596 #define B1(X) ir_function_signature *_##X(const glsl_type *);
597 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
598 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
599 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
600 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
637 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
638 const glsl_type
*val_type
,
639 const glsl_type
*blend_type
);
648 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
649 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
650 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
651 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
652 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
653 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
654 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
655 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
656 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
657 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
658 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
659 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
672 BA1(determinant_mat2
);
673 BA1(determinant_mat3
);
674 BA1(determinant_mat4
);
682 BA1(greaterThanEqual
);
691 /** Flags to _texture() */
692 #define TEX_PROJECT 1
694 #define TEX_COMPONENT 4
695 #define TEX_OFFSET_NONCONST 8
696 #define TEX_OFFSET_ARRAY 16
698 ir_function_signature
*_texture(ir_texture_opcode opcode
,
699 builtin_available_predicate avail
,
700 const glsl_type
*return_type
,
701 const glsl_type
*sampler_type
,
702 const glsl_type
*coord_type
,
704 B0(textureCubeArrayShadow
);
705 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
706 const glsl_type
*return_type
,
707 const glsl_type
*sampler_type
,
708 const glsl_type
*coord_type
,
709 const glsl_type
*offset_type
= NULL
);
713 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
714 const glsl_type
*stream_type
);
715 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
716 const glsl_type
*stream_type
);
719 BA2(textureQueryLod
);
720 B1(textureQueryLevels
);
748 B1(interpolateAtCentroid
)
749 B1(interpolateAtOffset
)
750 B1(interpolateAtSample
)
752 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
753 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
754 builtin_available_predicate avail
);
756 ir_function_signature
*_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
757 const glsl_type
*type
);
758 ir_function_signature
*_atomic_ssbo_op2(const char *intrinsic
,
759 builtin_available_predicate avail
,
760 const glsl_type
*type
);
761 ir_function_signature
*_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
762 const glsl_type
*type
);
763 ir_function_signature
*_atomic_ssbo_op3(const char *intrinsic
,
764 builtin_available_predicate avail
,
765 const glsl_type
*type
);
771 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
772 unsigned num_arguments
,
774 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
775 unsigned num_arguments
,
777 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
778 unsigned num_arguments
,
780 ir_function_signature
*_image(image_prototype_ctr prototype
,
781 const glsl_type
*image_type
,
782 const char *intrinsic_name
,
783 unsigned num_arguments
,
786 ir_function_signature
*_memory_barrier_intrinsic(
787 builtin_available_predicate avail
);
788 ir_function_signature
*_memory_barrier(
789 builtin_available_predicate avail
);
791 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
792 const glsl_type
*type
);
793 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
794 const glsl_type
*type
);
805 } /* anonymous namespace */
808 * Core builtin_builder functionality:
811 builtin_builder::builtin_builder()
813 gl_ModelViewProjectionMatrix(NULL
),
819 builtin_builder::~builtin_builder()
821 ralloc_free(mem_ctx
);
824 ir_function_signature
*
825 builtin_builder::find(_mesa_glsl_parse_state
*state
,
826 const char *name
, exec_list
*actual_parameters
)
828 /* The shader currently being compiled requested a built-in function;
829 * it needs to link against builtin_builder::shader in order to get them.
831 * Even if we don't find a matching signature, we still need to do this so
832 * that the "no matching signature" error will list potential candidates
833 * from the available built-ins.
835 state
->uses_builtin_functions
= true;
837 ir_function
*f
= shader
->symbols
->get_function(name
);
841 ir_function_signature
*sig
=
842 f
->matching_signature(state
, actual_parameters
, true);
850 builtin_builder::initialize()
852 /* If already initialized, don't do it again. */
856 mem_ctx
= ralloc_context(NULL
);
863 builtin_builder::release()
865 ralloc_free(mem_ctx
);
873 builtin_builder::create_shader()
875 /* The target doesn't actually matter. There's no target for generic
876 * GLSL utility code that could be linked against any stage, so just
877 * arbitrarily pick GL_VERTEX_SHADER.
879 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
880 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
882 gl_ModelViewProjectionMatrix
=
883 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
884 "gl_ModelViewProjectionMatrix",
887 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
889 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
890 shader
->symbols
->add_variable(gl_Vertex
);
896 * Create ir_function and ir_function_signature objects for each
900 builtin_builder::create_intrinsics()
902 add_function("__intrinsic_atomic_read",
903 _atomic_counter_intrinsic(shader_atomic_counters
),
905 add_function("__intrinsic_atomic_increment",
906 _atomic_counter_intrinsic(shader_atomic_counters
),
908 add_function("__intrinsic_atomic_predecrement",
909 _atomic_counter_intrinsic(shader_atomic_counters
),
912 add_function("__intrinsic_ssbo_atomic_add",
913 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
914 glsl_type::uint_type
),
915 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
916 glsl_type::int_type
),
918 add_function("__intrinsic_ssbo_atomic_min",
919 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
920 glsl_type::uint_type
),
921 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
922 glsl_type::int_type
),
924 add_function("__intrinsic_ssbo_atomic_max",
925 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
926 glsl_type::uint_type
),
927 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
928 glsl_type::int_type
),
930 add_function("__intrinsic_ssbo_atomic_and",
931 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
932 glsl_type::uint_type
),
933 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
934 glsl_type::int_type
),
936 add_function("__intrinsic_ssbo_atomic_or",
937 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
938 glsl_type::uint_type
),
939 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
940 glsl_type::int_type
),
942 add_function("__intrinsic_ssbo_atomic_xor",
943 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
944 glsl_type::uint_type
),
945 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
946 glsl_type::int_type
),
948 add_function("__intrinsic_ssbo_atomic_exchange",
949 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
950 glsl_type::uint_type
),
951 _atomic_ssbo_intrinsic2(shader_storage_buffer_object
,
952 glsl_type::int_type
),
954 add_function("__intrinsic_ssbo_atomic_comp_swap",
955 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
956 glsl_type::uint_type
),
957 _atomic_ssbo_intrinsic3(shader_storage_buffer_object
,
958 glsl_type::int_type
),
961 add_image_functions(false);
963 add_function("__intrinsic_memory_barrier",
964 _memory_barrier_intrinsic(shader_image_load_store
),
967 add_function("__intrinsic_shader_clock",
968 _shader_clock_intrinsic(shader_clock
,
969 glsl_type::uvec2_type
),
974 * Create ir_function and ir_function_signature objects for each built-in.
976 * Contains a list of every available built-in.
979 builtin_builder::create_builtins()
982 add_function(#NAME, \
983 _##NAME(glsl_type::float_type), \
984 _##NAME(glsl_type::vec2_type), \
985 _##NAME(glsl_type::vec3_type), \
986 _##NAME(glsl_type::vec4_type), \
990 add_function(#NAME, \
991 _##NAME(always_available, glsl_type::float_type), \
992 _##NAME(always_available, glsl_type::vec2_type), \
993 _##NAME(always_available, glsl_type::vec3_type), \
994 _##NAME(always_available, glsl_type::vec4_type), \
995 _##NAME(fp64, glsl_type::double_type), \
996 _##NAME(fp64, glsl_type::dvec2_type), \
997 _##NAME(fp64, glsl_type::dvec3_type), \
998 _##NAME(fp64, glsl_type::dvec4_type), \
1001 #define FD130(NAME) \
1002 add_function(#NAME, \
1003 _##NAME(v130, glsl_type::float_type), \
1004 _##NAME(v130, glsl_type::vec2_type), \
1005 _##NAME(v130, glsl_type::vec3_type), \
1006 _##NAME(v130, glsl_type::vec4_type), \
1007 _##NAME(fp64, glsl_type::double_type), \
1008 _##NAME(fp64, glsl_type::dvec2_type), \
1009 _##NAME(fp64, glsl_type::dvec3_type), \
1010 _##NAME(fp64, glsl_type::dvec4_type), \
1013 #define FDGS5(NAME) \
1014 add_function(#NAME, \
1015 _##NAME(gpu_shader5, glsl_type::float_type), \
1016 _##NAME(gpu_shader5, glsl_type::vec2_type), \
1017 _##NAME(gpu_shader5, glsl_type::vec3_type), \
1018 _##NAME(gpu_shader5, glsl_type::vec4_type), \
1019 _##NAME(fp64, glsl_type::double_type), \
1020 _##NAME(fp64, glsl_type::dvec2_type), \
1021 _##NAME(fp64, glsl_type::dvec3_type), \
1022 _##NAME(fp64, glsl_type::dvec4_type), \
1026 add_function(#NAME, \
1027 _##NAME(glsl_type::float_type), \
1028 _##NAME(glsl_type::vec2_type), \
1029 _##NAME(glsl_type::vec3_type), \
1030 _##NAME(glsl_type::vec4_type), \
1031 _##NAME(glsl_type::int_type), \
1032 _##NAME(glsl_type::ivec2_type), \
1033 _##NAME(glsl_type::ivec3_type), \
1034 _##NAME(glsl_type::ivec4_type), \
1038 add_function(#NAME, \
1039 _##NAME(always_available, glsl_type::float_type), \
1040 _##NAME(always_available, glsl_type::vec2_type), \
1041 _##NAME(always_available, glsl_type::vec3_type), \
1042 _##NAME(always_available, glsl_type::vec4_type), \
1043 _##NAME(always_available, glsl_type::int_type), \
1044 _##NAME(always_available, glsl_type::ivec2_type), \
1045 _##NAME(always_available, glsl_type::ivec3_type), \
1046 _##NAME(always_available, glsl_type::ivec4_type), \
1047 _##NAME(fp64, glsl_type::double_type), \
1048 _##NAME(fp64, glsl_type::dvec2_type), \
1049 _##NAME(fp64, glsl_type::dvec3_type), \
1050 _##NAME(fp64, glsl_type::dvec4_type), \
1053 #define FIUD(NAME) \
1054 add_function(#NAME, \
1055 _##NAME(always_available, glsl_type::float_type), \
1056 _##NAME(always_available, glsl_type::vec2_type), \
1057 _##NAME(always_available, glsl_type::vec3_type), \
1058 _##NAME(always_available, glsl_type::vec4_type), \
1060 _##NAME(always_available, glsl_type::int_type), \
1061 _##NAME(always_available, glsl_type::ivec2_type), \
1062 _##NAME(always_available, glsl_type::ivec3_type), \
1063 _##NAME(always_available, glsl_type::ivec4_type), \
1065 _##NAME(v130, glsl_type::uint_type), \
1066 _##NAME(v130, glsl_type::uvec2_type), \
1067 _##NAME(v130, glsl_type::uvec3_type), \
1068 _##NAME(v130, glsl_type::uvec4_type), \
1069 _##NAME(fp64, glsl_type::double_type), \
1070 _##NAME(fp64, glsl_type::dvec2_type), \
1071 _##NAME(fp64, glsl_type::dvec3_type), \
1072 _##NAME(fp64, glsl_type::dvec4_type), \
1076 add_function(#NAME, \
1077 _##NAME(glsl_type::int_type), \
1078 _##NAME(glsl_type::ivec2_type), \
1079 _##NAME(glsl_type::ivec3_type), \
1080 _##NAME(glsl_type::ivec4_type), \
1082 _##NAME(glsl_type::uint_type), \
1083 _##NAME(glsl_type::uvec2_type), \
1084 _##NAME(glsl_type::uvec3_type), \
1085 _##NAME(glsl_type::uvec4_type), \
1088 #define FIUBD(NAME) \
1089 add_function(#NAME, \
1090 _##NAME(always_available, glsl_type::float_type), \
1091 _##NAME(always_available, glsl_type::vec2_type), \
1092 _##NAME(always_available, glsl_type::vec3_type), \
1093 _##NAME(always_available, glsl_type::vec4_type), \
1095 _##NAME(always_available, glsl_type::int_type), \
1096 _##NAME(always_available, glsl_type::ivec2_type), \
1097 _##NAME(always_available, glsl_type::ivec3_type), \
1098 _##NAME(always_available, glsl_type::ivec4_type), \
1100 _##NAME(v130, glsl_type::uint_type), \
1101 _##NAME(v130, glsl_type::uvec2_type), \
1102 _##NAME(v130, glsl_type::uvec3_type), \
1103 _##NAME(v130, glsl_type::uvec4_type), \
1105 _##NAME(always_available, glsl_type::bool_type), \
1106 _##NAME(always_available, glsl_type::bvec2_type), \
1107 _##NAME(always_available, glsl_type::bvec3_type), \
1108 _##NAME(always_available, glsl_type::bvec4_type), \
1110 _##NAME(fp64, glsl_type::double_type), \
1111 _##NAME(fp64, glsl_type::dvec2_type), \
1112 _##NAME(fp64, glsl_type::dvec3_type), \
1113 _##NAME(fp64, glsl_type::dvec4_type), \
1116 #define FIUD2_MIXED(NAME) \
1117 add_function(#NAME, \
1118 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1119 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1120 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1121 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1123 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1124 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1125 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1127 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1128 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1129 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1130 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1132 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1133 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1134 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1136 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1137 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1138 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1139 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1141 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1142 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1143 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1145 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1146 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1147 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1148 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1149 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1150 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1151 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1162 add_function("atan",
1163 _atan(glsl_type::float_type
),
1164 _atan(glsl_type::vec2_type
),
1165 _atan(glsl_type::vec3_type
),
1166 _atan(glsl_type::vec4_type
),
1167 _atan2(glsl_type::float_type
),
1168 _atan2(glsl_type::vec2_type
),
1169 _atan2(glsl_type::vec3_type
),
1170 _atan2(glsl_type::vec4_type
),
1196 _mod(glsl_type::float_type
, glsl_type::float_type
),
1197 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1198 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1199 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1201 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1202 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1203 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1205 _mod(glsl_type::double_type
, glsl_type::double_type
),
1206 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1207 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1208 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1210 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1211 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1212 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1222 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1223 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1224 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1225 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1227 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1228 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1229 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1231 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1232 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1233 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1234 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1236 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1237 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1238 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1240 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1241 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1242 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1243 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1245 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1246 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1247 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1248 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1250 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1251 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1252 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1253 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1255 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1256 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1257 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1258 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1260 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1261 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1262 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1263 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1266 add_function("step",
1267 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1268 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1269 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1270 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1272 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1273 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1274 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1275 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1276 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1277 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1278 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1280 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1281 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1282 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1285 add_function("smoothstep",
1286 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1287 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1288 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1289 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1291 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1292 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1293 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1294 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1295 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1296 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1297 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1299 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1300 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1301 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1309 add_function("intBitsToFloat",
1310 _intBitsToFloat(glsl_type::int_type
),
1311 _intBitsToFloat(glsl_type::ivec2_type
),
1312 _intBitsToFloat(glsl_type::ivec3_type
),
1313 _intBitsToFloat(glsl_type::ivec4_type
),
1315 add_function("uintBitsToFloat",
1316 _uintBitsToFloat(glsl_type::uint_type
),
1317 _uintBitsToFloat(glsl_type::uvec2_type
),
1318 _uintBitsToFloat(glsl_type::uvec3_type
),
1319 _uintBitsToFloat(glsl_type::uvec4_type
),
1322 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1323 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1324 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1325 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1326 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1327 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1328 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1329 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1330 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1331 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1332 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1333 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1340 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1341 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1344 add_function("ftransform", _ftransform(), NULL
);
1349 add_function("matrixCompMult",
1350 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1351 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1352 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1353 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1354 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1355 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1356 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1357 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1358 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1359 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1360 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1361 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1362 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1363 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1364 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1365 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1366 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1367 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1369 add_function("outerProduct",
1370 _outerProduct(v120
, glsl_type::mat2_type
),
1371 _outerProduct(v120
, glsl_type::mat3_type
),
1372 _outerProduct(v120
, glsl_type::mat4_type
),
1373 _outerProduct(v120
, glsl_type::mat2x3_type
),
1374 _outerProduct(v120
, glsl_type::mat2x4_type
),
1375 _outerProduct(v120
, glsl_type::mat3x2_type
),
1376 _outerProduct(v120
, glsl_type::mat3x4_type
),
1377 _outerProduct(v120
, glsl_type::mat4x2_type
),
1378 _outerProduct(v120
, glsl_type::mat4x3_type
),
1379 _outerProduct(fp64
, glsl_type::dmat2_type
),
1380 _outerProduct(fp64
, glsl_type::dmat3_type
),
1381 _outerProduct(fp64
, glsl_type::dmat4_type
),
1382 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1383 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1384 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1385 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1386 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1387 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1389 add_function("determinant",
1390 _determinant_mat2(v120
, glsl_type::mat2_type
),
1391 _determinant_mat3(v120
, glsl_type::mat3_type
),
1392 _determinant_mat4(v120
, glsl_type::mat4_type
),
1393 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1394 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1395 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1398 add_function("inverse",
1399 _inverse_mat2(v120
, glsl_type::mat2_type
),
1400 _inverse_mat3(v120
, glsl_type::mat3_type
),
1401 _inverse_mat4(v120
, glsl_type::mat4_type
),
1402 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1403 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1404 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1406 add_function("transpose",
1407 _transpose(v120
, glsl_type::mat2_type
),
1408 _transpose(v120
, glsl_type::mat3_type
),
1409 _transpose(v120
, glsl_type::mat4_type
),
1410 _transpose(v120
, glsl_type::mat2x3_type
),
1411 _transpose(v120
, glsl_type::mat2x4_type
),
1412 _transpose(v120
, glsl_type::mat3x2_type
),
1413 _transpose(v120
, glsl_type::mat3x4_type
),
1414 _transpose(v120
, glsl_type::mat4x2_type
),
1415 _transpose(v120
, glsl_type::mat4x3_type
),
1416 _transpose(fp64
, glsl_type::dmat2_type
),
1417 _transpose(fp64
, glsl_type::dmat3_type
),
1418 _transpose(fp64
, glsl_type::dmat4_type
),
1419 _transpose(fp64
, glsl_type::dmat2x3_type
),
1420 _transpose(fp64
, glsl_type::dmat2x4_type
),
1421 _transpose(fp64
, glsl_type::dmat3x2_type
),
1422 _transpose(fp64
, glsl_type::dmat3x4_type
),
1423 _transpose(fp64
, glsl_type::dmat4x2_type
),
1424 _transpose(fp64
, glsl_type::dmat4x3_type
),
1429 FIUD(greaterThanEqual
)
1434 _any(glsl_type::bvec2_type
),
1435 _any(glsl_type::bvec3_type
),
1436 _any(glsl_type::bvec4_type
),
1440 _all(glsl_type::bvec2_type
),
1441 _all(glsl_type::bvec3_type
),
1442 _all(glsl_type::bvec4_type
),
1446 _not(glsl_type::bvec2_type
),
1447 _not(glsl_type::bvec3_type
),
1448 _not(glsl_type::bvec4_type
),
1451 add_function("textureSize",
1452 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1453 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1454 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1456 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1457 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1458 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1460 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1461 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1462 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1464 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1465 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1466 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1468 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1469 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1470 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1472 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1473 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1474 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1475 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1476 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1477 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1479 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1480 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1482 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1483 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1484 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1485 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1487 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1488 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1489 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1490 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1492 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1493 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1494 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1495 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1496 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1497 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1499 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1500 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1501 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1504 add_function("textureSamples",
1505 _textureSamples(glsl_type::sampler2DMS_type
),
1506 _textureSamples(glsl_type::isampler2DMS_type
),
1507 _textureSamples(glsl_type::usampler2DMS_type
),
1509 _textureSamples(glsl_type::sampler2DMSArray_type
),
1510 _textureSamples(glsl_type::isampler2DMSArray_type
),
1511 _textureSamples(glsl_type::usampler2DMSArray_type
),
1514 add_function("texture",
1515 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1516 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1517 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1519 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1520 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1521 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1523 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1524 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1525 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1527 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1528 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1529 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1531 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1532 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1533 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1535 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1536 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1537 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1539 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1540 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1541 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1543 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1544 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1545 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1547 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1548 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1549 /* samplerCubeArrayShadow is special; it has an extra parameter
1550 * for the shadow comparitor since there is no vec5 type.
1552 _textureCubeArrayShadow(),
1554 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1555 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1556 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1558 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1560 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1561 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1562 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1564 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1565 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1566 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1568 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1569 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1570 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1572 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1573 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1574 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1576 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1577 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1578 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1580 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1581 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1582 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1584 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1585 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1586 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1588 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1589 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1590 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1592 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1595 add_function("textureLod",
1596 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1597 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1598 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1600 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1601 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1602 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1604 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1605 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1606 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1608 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1609 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1610 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1612 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1613 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1615 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1616 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1617 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1619 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1620 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1621 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1623 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1624 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1625 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1627 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1630 add_function("textureOffset",
1631 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1632 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1633 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1635 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1636 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1637 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1639 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1640 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1641 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1643 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1644 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1645 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1647 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1649 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1650 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1652 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1653 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1654 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1656 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1657 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1658 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1660 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1662 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1663 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1664 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1666 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1667 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1668 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1670 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1671 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1672 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1674 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1675 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1677 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1678 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1679 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1681 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1682 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1683 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1685 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1688 add_function("textureProj",
1689 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1690 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1691 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1692 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1693 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1694 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1696 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1697 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1698 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1699 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1700 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1701 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1703 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1704 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1705 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1707 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1708 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1710 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1711 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1712 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1713 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1714 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1715 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1717 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1719 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1720 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1721 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1722 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1723 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1724 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1726 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1727 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1728 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1729 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1730 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1731 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1733 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1734 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1735 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1737 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1738 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1741 add_function("texelFetch",
1742 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1743 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1744 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1746 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1747 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1748 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1750 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1751 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1752 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1754 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1755 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1756 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1758 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1759 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1760 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1762 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1763 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1764 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1766 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1767 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1768 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1770 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1771 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1772 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1774 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1775 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1776 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1779 add_function("texelFetchOffset",
1780 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1781 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1782 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1784 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1785 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1786 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1788 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1789 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1790 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1792 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1793 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1794 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1796 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1797 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1798 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1800 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1801 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1802 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1806 add_function("textureProjOffset",
1807 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1808 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1809 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1810 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1811 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1812 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1814 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1815 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1816 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1817 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1818 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1819 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1821 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1822 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1823 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1825 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1826 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1828 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1829 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1830 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1831 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1832 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1833 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1835 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1837 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1838 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1839 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1840 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1841 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1842 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1844 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1845 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1846 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1847 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1848 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1849 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1851 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1852 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1853 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1855 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1856 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1859 add_function("textureLodOffset",
1860 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1861 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1862 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1864 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1865 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1866 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1868 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1869 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1870 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1872 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1873 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1875 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1876 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1877 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1879 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1880 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1881 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1883 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1886 add_function("textureProjLod",
1887 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1888 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1889 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1890 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1891 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1892 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1894 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1895 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1896 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1897 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1898 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1899 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1901 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1902 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1903 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1905 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1906 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1909 add_function("textureProjLodOffset",
1910 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1911 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1912 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1914 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1915 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1918 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1919 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1920 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1921 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1922 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1924 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1925 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1926 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1928 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1929 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1932 add_function("textureGrad",
1933 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1934 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1935 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1937 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1938 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1939 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1941 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1942 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1943 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1945 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1946 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1947 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1949 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1950 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1951 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1953 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1955 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1956 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1957 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1959 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1960 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1961 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1963 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1964 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1965 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1967 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1968 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1969 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1971 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1972 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1975 add_function("textureGradOffset",
1976 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1977 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1978 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1980 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1981 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1982 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1984 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1985 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1986 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1988 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1989 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1990 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1992 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1994 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1995 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1997 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1998 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1999 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2001 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2002 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2003 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2005 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2006 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2009 add_function("textureProjGrad",
2010 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2011 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2012 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2013 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2014 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2015 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2017 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2018 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2019 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2020 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2021 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2022 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2024 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2025 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2026 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2028 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2029 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2030 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2031 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2032 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2033 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2035 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2037 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2038 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2041 add_function("textureProjGradOffset",
2042 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2043 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2044 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2045 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2046 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2047 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2049 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2050 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2051 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2052 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2053 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2054 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2056 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2057 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2058 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2060 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2061 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2062 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2063 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2064 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2065 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2067 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2069 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2070 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2073 add_function("EmitVertex", _EmitVertex(), NULL
);
2074 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2075 add_function("EmitStreamVertex",
2076 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2077 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2079 add_function("EndStreamPrimitive",
2080 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2081 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2083 add_function("barrier", _barrier(), NULL
);
2085 add_function("textureQueryLOD",
2086 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2087 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2088 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2090 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2091 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2092 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2094 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2095 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2096 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2098 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2099 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2100 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2102 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2103 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2104 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2106 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2107 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2108 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2110 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2111 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2112 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2114 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2115 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2116 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2117 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2118 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2119 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2122 add_function("textureQueryLod",
2123 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2124 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2125 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2127 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2128 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2129 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2131 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2132 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2133 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2135 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2136 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2137 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2139 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2140 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2141 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2143 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2144 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2145 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2147 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2148 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2149 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2151 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2152 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2153 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2154 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2155 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2156 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2159 add_function("textureQueryLevels",
2160 _textureQueryLevels(glsl_type::sampler1D_type
),
2161 _textureQueryLevels(glsl_type::sampler2D_type
),
2162 _textureQueryLevels(glsl_type::sampler3D_type
),
2163 _textureQueryLevels(glsl_type::samplerCube_type
),
2164 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2165 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2166 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2167 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2168 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2169 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2170 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2171 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2172 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2174 _textureQueryLevels(glsl_type::isampler1D_type
),
2175 _textureQueryLevels(glsl_type::isampler2D_type
),
2176 _textureQueryLevels(glsl_type::isampler3D_type
),
2177 _textureQueryLevels(glsl_type::isamplerCube_type
),
2178 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2179 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2180 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2182 _textureQueryLevels(glsl_type::usampler1D_type
),
2183 _textureQueryLevels(glsl_type::usampler2D_type
),
2184 _textureQueryLevels(glsl_type::usampler3D_type
),
2185 _textureQueryLevels(glsl_type::usamplerCube_type
),
2186 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2187 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2188 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2192 add_function("texture1D",
2193 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2194 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2197 add_function("texture1DArray",
2198 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2199 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2202 add_function("texture1DProj",
2203 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2204 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2205 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2206 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2209 add_function("texture1DLod",
2210 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2213 add_function("texture1DArrayLod",
2214 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2217 add_function("texture1DProjLod",
2218 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2219 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2222 add_function("texture2D",
2223 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2224 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2225 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2228 add_function("texture2DArray",
2229 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2230 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2233 add_function("texture2DProj",
2234 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2235 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2236 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2237 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2238 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2239 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2242 add_function("texture2DLod",
2243 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2246 add_function("texture2DArrayLod",
2247 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2250 add_function("texture2DProjLod",
2251 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2252 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2255 add_function("texture3D",
2256 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2257 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2260 add_function("texture3DProj",
2261 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2262 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2265 add_function("texture3DLod",
2266 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2269 add_function("texture3DProjLod",
2270 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2273 add_function("textureCube",
2274 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2275 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2278 add_function("textureCubeLod",
2279 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2282 add_function("texture2DRect",
2283 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2286 add_function("texture2DRectProj",
2287 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2288 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2291 add_function("shadow1D",
2292 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2293 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2296 add_function("shadow1DArray",
2297 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2298 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2301 add_function("shadow2D",
2302 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2303 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2306 add_function("shadow2DArray",
2307 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2308 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2311 add_function("shadow1DProj",
2312 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2313 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2316 add_function("shadow2DProj",
2317 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2318 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2321 add_function("shadow1DLod",
2322 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2325 add_function("shadow2DLod",
2326 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2329 add_function("shadow1DArrayLod",
2330 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2333 add_function("shadow1DProjLod",
2334 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2337 add_function("shadow2DProjLod",
2338 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2341 add_function("shadow2DRect",
2342 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2345 add_function("shadow2DRectProj",
2346 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2349 add_function("texture1DGradARB",
2350 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2353 add_function("texture1DProjGradARB",
2354 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2355 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2358 add_function("texture2DGradARB",
2359 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2362 add_function("texture2DProjGradARB",
2363 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2364 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2367 add_function("texture3DGradARB",
2368 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2371 add_function("texture3DProjGradARB",
2372 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2375 add_function("textureCubeGradARB",
2376 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2379 add_function("shadow1DGradARB",
2380 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2383 add_function("shadow1DProjGradARB",
2384 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2387 add_function("shadow2DGradARB",
2388 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2391 add_function("shadow2DProjGradARB",
2392 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2395 add_function("texture2DRectGradARB",
2396 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2399 add_function("texture2DRectProjGradARB",
2400 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2401 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2404 add_function("shadow2DRectGradARB",
2405 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2408 add_function("shadow2DRectProjGradARB",
2409 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2412 add_function("textureGather",
2413 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2414 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2415 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2417 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2418 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2419 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2421 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2422 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2423 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2425 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2426 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2427 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2429 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2430 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2431 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2433 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2434 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2435 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2437 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2438 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2439 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2441 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2442 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2443 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2445 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2446 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2447 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2449 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2450 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2451 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2453 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2454 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2455 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2456 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2457 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2460 add_function("textureGatherOffset",
2461 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2462 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2463 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2465 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2466 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2467 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2469 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2470 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2471 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2473 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2474 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2475 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2477 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2478 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2479 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2481 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2482 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2483 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2485 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2486 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2487 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2489 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2490 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2491 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2493 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2494 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2495 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2497 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2498 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2499 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2501 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2502 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2503 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2505 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2506 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2509 add_function("textureGatherOffsets",
2510 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2511 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2512 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2514 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2515 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2516 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2518 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2519 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2520 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2522 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2523 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2524 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2526 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2527 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2528 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2530 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2531 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2532 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2534 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2535 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2536 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2561 add_function("ldexp",
2562 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2563 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2564 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2565 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2566 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2567 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2568 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2569 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2572 add_function("frexp",
2573 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2574 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2575 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2576 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2577 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2578 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2579 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2580 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2582 add_function("uaddCarry",
2583 _uaddCarry(glsl_type::uint_type
),
2584 _uaddCarry(glsl_type::uvec2_type
),
2585 _uaddCarry(glsl_type::uvec3_type
),
2586 _uaddCarry(glsl_type::uvec4_type
),
2588 add_function("usubBorrow",
2589 _usubBorrow(glsl_type::uint_type
),
2590 _usubBorrow(glsl_type::uvec2_type
),
2591 _usubBorrow(glsl_type::uvec3_type
),
2592 _usubBorrow(glsl_type::uvec4_type
),
2594 add_function("imulExtended",
2595 _mulExtended(glsl_type::int_type
),
2596 _mulExtended(glsl_type::ivec2_type
),
2597 _mulExtended(glsl_type::ivec3_type
),
2598 _mulExtended(glsl_type::ivec4_type
),
2600 add_function("umulExtended",
2601 _mulExtended(glsl_type::uint_type
),
2602 _mulExtended(glsl_type::uvec2_type
),
2603 _mulExtended(glsl_type::uvec3_type
),
2604 _mulExtended(glsl_type::uvec4_type
),
2606 add_function("interpolateAtCentroid",
2607 _interpolateAtCentroid(glsl_type::float_type
),
2608 _interpolateAtCentroid(glsl_type::vec2_type
),
2609 _interpolateAtCentroid(glsl_type::vec3_type
),
2610 _interpolateAtCentroid(glsl_type::vec4_type
),
2612 add_function("interpolateAtOffset",
2613 _interpolateAtOffset(glsl_type::float_type
),
2614 _interpolateAtOffset(glsl_type::vec2_type
),
2615 _interpolateAtOffset(glsl_type::vec3_type
),
2616 _interpolateAtOffset(glsl_type::vec4_type
),
2618 add_function("interpolateAtSample",
2619 _interpolateAtSample(glsl_type::float_type
),
2620 _interpolateAtSample(glsl_type::vec2_type
),
2621 _interpolateAtSample(glsl_type::vec3_type
),
2622 _interpolateAtSample(glsl_type::vec4_type
),
2625 add_function("atomicCounter",
2626 _atomic_counter_op("__intrinsic_atomic_read",
2627 shader_atomic_counters
),
2629 add_function("atomicCounterIncrement",
2630 _atomic_counter_op("__intrinsic_atomic_increment",
2631 shader_atomic_counters
),
2633 add_function("atomicCounterDecrement",
2634 _atomic_counter_op("__intrinsic_atomic_predecrement",
2635 shader_atomic_counters
),
2638 add_function("atomicAdd",
2639 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2640 shader_storage_buffer_object
,
2641 glsl_type::uint_type
),
2642 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_add",
2643 shader_storage_buffer_object
,
2644 glsl_type::int_type
),
2646 add_function("atomicMin",
2647 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2648 shader_storage_buffer_object
,
2649 glsl_type::uint_type
),
2650 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_min",
2651 shader_storage_buffer_object
,
2652 glsl_type::int_type
),
2654 add_function("atomicMax",
2655 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2656 shader_storage_buffer_object
,
2657 glsl_type::uint_type
),
2658 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_max",
2659 shader_storage_buffer_object
,
2660 glsl_type::int_type
),
2662 add_function("atomicAnd",
2663 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2664 shader_storage_buffer_object
,
2665 glsl_type::uint_type
),
2666 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_and",
2667 shader_storage_buffer_object
,
2668 glsl_type::int_type
),
2670 add_function("atomicOr",
2671 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2672 shader_storage_buffer_object
,
2673 glsl_type::uint_type
),
2674 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_or",
2675 shader_storage_buffer_object
,
2676 glsl_type::int_type
),
2678 add_function("atomicXor",
2679 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2680 shader_storage_buffer_object
,
2681 glsl_type::uint_type
),
2682 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_xor",
2683 shader_storage_buffer_object
,
2684 glsl_type::int_type
),
2686 add_function("atomicExchange",
2687 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2688 shader_storage_buffer_object
,
2689 glsl_type::uint_type
),
2690 _atomic_ssbo_op2("__intrinsic_ssbo_atomic_exchange",
2691 shader_storage_buffer_object
,
2692 glsl_type::int_type
),
2694 add_function("atomicCompSwap",
2695 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2696 shader_storage_buffer_object
,
2697 glsl_type::uint_type
),
2698 _atomic_ssbo_op3("__intrinsic_ssbo_atomic_comp_swap",
2699 shader_storage_buffer_object
,
2700 glsl_type::int_type
),
2703 add_function("min3",
2704 _min3(glsl_type::float_type
),
2705 _min3(glsl_type::vec2_type
),
2706 _min3(glsl_type::vec3_type
),
2707 _min3(glsl_type::vec4_type
),
2709 _min3(glsl_type::int_type
),
2710 _min3(glsl_type::ivec2_type
),
2711 _min3(glsl_type::ivec3_type
),
2712 _min3(glsl_type::ivec4_type
),
2714 _min3(glsl_type::uint_type
),
2715 _min3(glsl_type::uvec2_type
),
2716 _min3(glsl_type::uvec3_type
),
2717 _min3(glsl_type::uvec4_type
),
2720 add_function("max3",
2721 _max3(glsl_type::float_type
),
2722 _max3(glsl_type::vec2_type
),
2723 _max3(glsl_type::vec3_type
),
2724 _max3(glsl_type::vec4_type
),
2726 _max3(glsl_type::int_type
),
2727 _max3(glsl_type::ivec2_type
),
2728 _max3(glsl_type::ivec3_type
),
2729 _max3(glsl_type::ivec4_type
),
2731 _max3(glsl_type::uint_type
),
2732 _max3(glsl_type::uvec2_type
),
2733 _max3(glsl_type::uvec3_type
),
2734 _max3(glsl_type::uvec4_type
),
2737 add_function("mid3",
2738 _mid3(glsl_type::float_type
),
2739 _mid3(glsl_type::vec2_type
),
2740 _mid3(glsl_type::vec3_type
),
2741 _mid3(glsl_type::vec4_type
),
2743 _mid3(glsl_type::int_type
),
2744 _mid3(glsl_type::ivec2_type
),
2745 _mid3(glsl_type::ivec3_type
),
2746 _mid3(glsl_type::ivec4_type
),
2748 _mid3(glsl_type::uint_type
),
2749 _mid3(glsl_type::uvec2_type
),
2750 _mid3(glsl_type::uvec3_type
),
2751 _mid3(glsl_type::uvec4_type
),
2754 add_image_functions(true);
2756 add_function("memoryBarrier",
2757 _memory_barrier(shader_image_load_store
),
2760 add_function("clock2x32ARB",
2761 _shader_clock(shader_clock
,
2762 glsl_type::uvec2_type
),
2773 builtin_builder::add_function(const char *name
, ...)
2777 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2781 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2787 stuff
.push_tail(sig
);
2788 validate_ir_tree(&stuff
);
2791 f
->add_signature(sig
);
2795 shader
->symbols
->add_function(f
);
2799 builtin_builder::add_image_function(const char *name
,
2800 const char *intrinsic_name
,
2801 image_prototype_ctr prototype
,
2802 unsigned num_arguments
,
2805 static const glsl_type
*const types
[] = {
2806 glsl_type::image1D_type
,
2807 glsl_type::image2D_type
,
2808 glsl_type::image3D_type
,
2809 glsl_type::image2DRect_type
,
2810 glsl_type::imageCube_type
,
2811 glsl_type::imageBuffer_type
,
2812 glsl_type::image1DArray_type
,
2813 glsl_type::image2DArray_type
,
2814 glsl_type::imageCubeArray_type
,
2815 glsl_type::image2DMS_type
,
2816 glsl_type::image2DMSArray_type
,
2817 glsl_type::iimage1D_type
,
2818 glsl_type::iimage2D_type
,
2819 glsl_type::iimage3D_type
,
2820 glsl_type::iimage2DRect_type
,
2821 glsl_type::iimageCube_type
,
2822 glsl_type::iimageBuffer_type
,
2823 glsl_type::iimage1DArray_type
,
2824 glsl_type::iimage2DArray_type
,
2825 glsl_type::iimageCubeArray_type
,
2826 glsl_type::iimage2DMS_type
,
2827 glsl_type::iimage2DMSArray_type
,
2828 glsl_type::uimage1D_type
,
2829 glsl_type::uimage2D_type
,
2830 glsl_type::uimage3D_type
,
2831 glsl_type::uimage2DRect_type
,
2832 glsl_type::uimageCube_type
,
2833 glsl_type::uimageBuffer_type
,
2834 glsl_type::uimage1DArray_type
,
2835 glsl_type::uimage2DArray_type
,
2836 glsl_type::uimageCubeArray_type
,
2837 glsl_type::uimage2DMS_type
,
2838 glsl_type::uimage2DMSArray_type
2841 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2843 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2844 if ((types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2845 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
2846 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
2847 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
2848 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2849 num_arguments
, flags
));
2852 shader
->symbols
->add_function(f
);
2856 builtin_builder::add_image_functions(bool glsl
)
2858 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2860 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2861 "__intrinsic_image_load",
2862 &builtin_builder::_image_prototype
, 0,
2863 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2864 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2865 IMAGE_FUNCTION_READ_ONLY
));
2867 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2868 "__intrinsic_image_store",
2869 &builtin_builder::_image_prototype
, 1,
2870 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2871 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2872 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2873 IMAGE_FUNCTION_WRITE_ONLY
));
2875 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2877 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2878 "__intrinsic_image_atomic_add",
2879 &builtin_builder::_image_prototype
, 1, atom_flags
);
2881 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2882 "__intrinsic_image_atomic_min",
2883 &builtin_builder::_image_prototype
, 1, atom_flags
);
2885 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2886 "__intrinsic_image_atomic_max",
2887 &builtin_builder::_image_prototype
, 1, atom_flags
);
2889 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2890 "__intrinsic_image_atomic_and",
2891 &builtin_builder::_image_prototype
, 1, atom_flags
);
2893 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2894 "__intrinsic_image_atomic_or",
2895 &builtin_builder::_image_prototype
, 1, atom_flags
);
2897 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2898 "__intrinsic_image_atomic_xor",
2899 &builtin_builder::_image_prototype
, 1, atom_flags
);
2901 add_image_function((glsl
? "imageAtomicExchange" :
2902 "__intrinsic_image_atomic_exchange"),
2903 "__intrinsic_image_atomic_exchange",
2904 &builtin_builder::_image_prototype
, 1, atom_flags
);
2906 add_image_function((glsl
? "imageAtomicCompSwap" :
2907 "__intrinsic_image_atomic_comp_swap"),
2908 "__intrinsic_image_atomic_comp_swap",
2909 &builtin_builder::_image_prototype
, 2, atom_flags
);
2911 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2912 "__intrinsic_image_size",
2913 &builtin_builder::_image_size_prototype
, 1,
2914 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2916 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
2917 "__intrinsic_image_samples",
2918 &builtin_builder::_image_samples_prototype
, 1,
2919 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2920 IMAGE_FUNCTION_MS_ONLY
);
2924 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2926 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2930 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2932 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2936 builtin_builder::imm(float f
, unsigned vector_elements
)
2938 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2942 builtin_builder::imm(int i
, unsigned vector_elements
)
2944 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2948 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2950 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2954 builtin_builder::imm(double d
, unsigned vector_elements
)
2956 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2960 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2962 return new(mem_ctx
) ir_constant(type
, &data
);
2965 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2967 ir_dereference_variable
*
2968 builtin_builder::var_ref(ir_variable
*var
)
2970 return new(mem_ctx
) ir_dereference_variable(var
);
2973 ir_dereference_array
*
2974 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2976 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2979 /** Return an element of a matrix */
2981 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2983 return swizzle(array_ref(var
, column
), row
, 1);
2987 * Implementations of built-in functions:
2990 ir_function_signature
*
2991 builtin_builder::new_sig(const glsl_type
*return_type
,
2992 builtin_available_predicate avail
,
2998 ir_function_signature
*sig
=
2999 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3002 va_start(ap
, num_params
);
3003 for (int i
= 0; i
< num_params
; i
++) {
3004 plist
.push_tail(va_arg(ap
, ir_variable
*));
3008 sig
->replace_parameters(&plist
);
3012 #define MAKE_SIG(return_type, avail, ...) \
3013 ir_function_signature *sig = \
3014 new_sig(return_type, avail, __VA_ARGS__); \
3015 ir_factory body(&sig->body, mem_ctx); \
3016 sig->is_defined = true;
3018 #define MAKE_INTRINSIC(return_type, avail, ...) \
3019 ir_function_signature *sig = \
3020 new_sig(return_type, avail, __VA_ARGS__); \
3021 sig->is_intrinsic = true;
3023 ir_function_signature
*
3024 builtin_builder::unop(builtin_available_predicate avail
,
3025 ir_expression_operation opcode
,
3026 const glsl_type
*return_type
,
3027 const glsl_type
*param_type
)
3029 ir_variable
*x
= in_var(param_type
, "x");
3030 MAKE_SIG(return_type
, avail
, 1, x
);
3031 body
.emit(ret(expr(opcode
, x
)));
3035 #define UNOP(NAME, OPCODE, AVAIL) \
3036 ir_function_signature * \
3037 builtin_builder::_##NAME(const glsl_type *type) \
3039 return unop(&AVAIL, OPCODE, type, type); \
3042 #define UNOPA(NAME, OPCODE) \
3043 ir_function_signature * \
3044 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3046 return unop(avail, OPCODE, type, type); \
3049 ir_function_signature
*
3050 builtin_builder::binop(ir_expression_operation opcode
,
3051 builtin_available_predicate avail
,
3052 const glsl_type
*return_type
,
3053 const glsl_type
*param0_type
,
3054 const glsl_type
*param1_type
)
3056 ir_variable
*x
= in_var(param0_type
, "x");
3057 ir_variable
*y
= in_var(param1_type
, "y");
3058 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3059 body
.emit(ret(expr(opcode
, x
, y
)));
3063 #define BINOP(NAME, OPCODE, AVAIL) \
3064 ir_function_signature * \
3065 builtin_builder::_##NAME(const glsl_type *return_type, \
3066 const glsl_type *param0_type, \
3067 const glsl_type *param1_type) \
3069 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3073 * Angle and Trigonometry Functions @{
3076 ir_function_signature
*
3077 builtin_builder::_radians(const glsl_type
*type
)
3079 ir_variable
*degrees
= in_var(type
, "degrees");
3080 MAKE_SIG(type
, always_available
, 1, degrees
);
3081 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3085 ir_function_signature
*
3086 builtin_builder::_degrees(const glsl_type
*type
)
3088 ir_variable
*radians
= in_var(type
, "radians");
3089 MAKE_SIG(type
, always_available
, 1, radians
);
3090 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3094 UNOP(sin
, ir_unop_sin
, always_available
)
3095 UNOP(cos
, ir_unop_cos
, always_available
)
3097 ir_function_signature
*
3098 builtin_builder::_tan(const glsl_type
*type
)
3100 ir_variable
*theta
= in_var(type
, "theta");
3101 MAKE_SIG(type
, always_available
, 1, theta
);
3102 body
.emit(ret(div(sin(theta
), cos(theta
))));
3107 builtin_builder::asin_expr(ir_variable
*x
)
3111 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3114 add(imm(M_PI_4f
- 1.0f
),
3116 add(imm(0.086566724f
),
3117 mul(abs(x
), imm(-0.03102955f
))))))))));
3121 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3123 exec_list actual_params
;
3125 foreach_in_list(ir_variable
, var
, ¶ms
) {
3126 actual_params
.push_tail(var_ref(var
));
3129 ir_function_signature
*sig
=
3130 f
->exact_matching_signature(NULL
, &actual_params
);
3134 ir_dereference_variable
*deref
=
3135 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3137 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3140 ir_function_signature
*
3141 builtin_builder::_asin(const glsl_type
*type
)
3143 ir_variable
*x
= in_var(type
, "x");
3144 MAKE_SIG(type
, always_available
, 1, x
);
3146 body
.emit(ret(asin_expr(x
)));
3151 ir_function_signature
*
3152 builtin_builder::_acos(const glsl_type
*type
)
3154 ir_variable
*x
= in_var(type
, "x");
3155 MAKE_SIG(type
, always_available
, 1, x
);
3157 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
3162 ir_function_signature
*
3163 builtin_builder::_atan2(const glsl_type
*type
)
3165 ir_variable
*vec_y
= in_var(type
, "vec_y");
3166 ir_variable
*vec_x
= in_var(type
, "vec_x");
3167 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3169 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3170 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3171 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3172 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3173 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3174 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3175 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3177 /* If |x| >= 1.0e-8 * |y|: */
3179 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3181 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3183 /* Then...call atan(y/x) */
3184 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3186 /* ...and fix it up: */
3187 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3188 inner_if
->then_instructions
.push_tail(
3189 if_tree(gequal(y
, imm(0.0f
)),
3190 assign(r
, add(r
, imm(M_PIf
))),
3191 assign(r
, sub(r
, imm(M_PIf
)))));
3192 outer_then
.emit(inner_if
);
3195 outer_if
->else_instructions
.push_tail(
3196 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3198 body
.emit(outer_if
);
3200 body
.emit(assign(vec_result
, r
, 1 << i
));
3202 body
.emit(ret(vec_result
));
3208 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3211 * range-reduction, first step:
3213 * / y_over_x if |y_over_x| <= 1.0;
3215 * \ 1.0 / y_over_x otherwise
3217 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3218 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3224 * approximate atan by evaluating polynomial:
3226 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3227 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3228 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3230 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3231 body
.emit(assign(tmp
, mul(x
, x
)));
3232 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3234 imm(0.0536813784310406f
)),
3236 imm(0.1173503194786851f
)),
3238 imm(0.1938924977115610f
)),
3240 imm(0.3326756418091246f
)),
3242 imm(0.9999793128310355f
)),
3245 /* range-reduction fixup */
3246 body
.emit(assign(tmp
, add(tmp
,
3247 mul(b2f(greater(abs(y_over_x
),
3248 imm(1.0f
, type
->components()))),
3254 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3257 ir_function_signature
*
3258 builtin_builder::_atan(const glsl_type
*type
)
3260 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3261 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3263 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3264 do_atan(body
, type
, tmp
, y_over_x
);
3265 body
.emit(ret(tmp
));
3270 ir_function_signature
*
3271 builtin_builder::_sinh(const glsl_type
*type
)
3273 ir_variable
*x
= in_var(type
, "x");
3274 MAKE_SIG(type
, v130
, 1, x
);
3276 /* 0.5 * (e^x - e^(-x)) */
3277 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3282 ir_function_signature
*
3283 builtin_builder::_cosh(const glsl_type
*type
)
3285 ir_variable
*x
= in_var(type
, "x");
3286 MAKE_SIG(type
, v130
, 1, x
);
3288 /* 0.5 * (e^x + e^(-x)) */
3289 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3294 ir_function_signature
*
3295 builtin_builder::_tanh(const glsl_type
*type
)
3297 ir_variable
*x
= in_var(type
, "x");
3298 MAKE_SIG(type
, v130
, 1, x
);
3300 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3301 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3302 add(exp(x
), exp(neg(x
))))));
3307 ir_function_signature
*
3308 builtin_builder::_asinh(const glsl_type
*type
)
3310 ir_variable
*x
= in_var(type
, "x");
3311 MAKE_SIG(type
, v130
, 1, x
);
3313 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3318 ir_function_signature
*
3319 builtin_builder::_acosh(const glsl_type
*type
)
3321 ir_variable
*x
= in_var(type
, "x");
3322 MAKE_SIG(type
, v130
, 1, x
);
3324 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3328 ir_function_signature
*
3329 builtin_builder::_atanh(const glsl_type
*type
)
3331 ir_variable
*x
= in_var(type
, "x");
3332 MAKE_SIG(type
, v130
, 1, x
);
3334 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3335 sub(imm(1.0f
), x
))))));
3341 * Exponential Functions @{
3344 ir_function_signature
*
3345 builtin_builder::_pow(const glsl_type
*type
)
3347 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3350 UNOP(exp
, ir_unop_exp
, always_available
)
3351 UNOP(log
, ir_unop_log
, always_available
)
3352 UNOP(exp2
, ir_unop_exp2
, always_available
)
3353 UNOP(log2
, ir_unop_log2
, always_available
)
3354 UNOPA(sqrt
, ir_unop_sqrt
)
3355 UNOPA(inversesqrt
, ir_unop_rsq
)
3359 UNOPA(abs
, ir_unop_abs
)
3360 UNOPA(sign
, ir_unop_sign
)
3361 UNOPA(floor
, ir_unop_floor
)
3362 UNOPA(trunc
, ir_unop_trunc
)
3363 UNOPA(round
, ir_unop_round_even
)
3364 UNOPA(roundEven
, ir_unop_round_even
)
3365 UNOPA(ceil
, ir_unop_ceil
)
3366 UNOPA(fract
, ir_unop_fract
)
3368 ir_function_signature
*
3369 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3371 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3374 ir_function_signature
*
3375 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3377 ir_variable
*x
= in_var(type
, "x");
3378 ir_variable
*i
= out_var(type
, "i");
3379 MAKE_SIG(type
, avail
, 2, x
, i
);
3381 ir_variable
*t
= body
.make_temp(type
, "t");
3382 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3383 body
.emit(assign(i
, t
));
3384 body
.emit(ret(sub(x
, t
)));
3389 ir_function_signature
*
3390 builtin_builder::_min(builtin_available_predicate avail
,
3391 const glsl_type
*x_type
, const glsl_type
*y_type
)
3393 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3396 ir_function_signature
*
3397 builtin_builder::_max(builtin_available_predicate avail
,
3398 const glsl_type
*x_type
, const glsl_type
*y_type
)
3400 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3403 ir_function_signature
*
3404 builtin_builder::_clamp(builtin_available_predicate avail
,
3405 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3407 ir_variable
*x
= in_var(val_type
, "x");
3408 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3409 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3410 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3412 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3417 ir_function_signature
*
3418 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3420 ir_variable
*x
= in_var(val_type
, "x");
3421 ir_variable
*y
= in_var(val_type
, "y");
3422 ir_variable
*a
= in_var(blend_type
, "a");
3423 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3425 body
.emit(ret(lrp(x
, y
, a
)));
3430 ir_function_signature
*
3431 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3432 const glsl_type
*val_type
,
3433 const glsl_type
*blend_type
)
3435 ir_variable
*x
= in_var(val_type
, "x");
3436 ir_variable
*y
= in_var(val_type
, "y");
3437 ir_variable
*a
= in_var(blend_type
, "a");
3438 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3440 /* csel matches the ternary operator in that a selector of true choses the
3441 * first argument. This differs from mix(x, y, false) which choses the
3442 * second argument (to remain consistent with the interpolating version of
3443 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3445 * To handle the behavior mismatch, reverse the x and y arguments.
3447 body
.emit(ret(csel(a
, y
, x
)));
3452 ir_function_signature
*
3453 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3455 ir_variable
*edge
= in_var(edge_type
, "edge");
3456 ir_variable
*x
= in_var(x_type
, "x");
3457 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3459 ir_variable
*t
= body
.make_temp(x_type
, "t");
3460 if (x_type
->vector_elements
== 1) {
3461 /* Both are floats */
3462 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3463 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3465 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3466 } else if (edge_type
->vector_elements
== 1) {
3467 /* x is a vector but edge is a float */
3468 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3469 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3470 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3472 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3475 /* Both are vectors */
3476 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3477 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3478 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3481 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3491 ir_function_signature
*
3492 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3494 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3495 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3496 ir_variable
*x
= in_var(x_type
, "x");
3497 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3499 /* From the GLSL 1.10 specification:
3502 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3503 * return t * t * (3 - 2 * t);
3506 ir_variable
*t
= body
.make_temp(x_type
, "t");
3507 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3508 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3510 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3515 ir_function_signature
*
3516 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3518 ir_variable
*x
= in_var(type
, "x");
3519 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3521 body
.emit(ret(nequal(x
, x
)));
3526 ir_function_signature
*
3527 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3529 ir_variable
*x
= in_var(type
, "x");
3530 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3532 ir_constant_data infinities
;
3533 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3534 infinities
.f
[i
] = INFINITY
;
3537 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3542 ir_function_signature
*
3543 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3545 ir_variable
*x
= in_var(type
, "x");
3546 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3547 body
.emit(ret(bitcast_f2i(x
)));
3551 ir_function_signature
*
3552 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3554 ir_variable
*x
= in_var(type
, "x");
3555 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3556 body
.emit(ret(bitcast_f2u(x
)));
3560 ir_function_signature
*
3561 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3563 ir_variable
*x
= in_var(type
, "x");
3564 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3565 body
.emit(ret(bitcast_i2f(x
)));
3569 ir_function_signature
*
3570 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3572 ir_variable
*x
= in_var(type
, "x");
3573 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3574 body
.emit(ret(bitcast_u2f(x
)));
3578 ir_function_signature
*
3579 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3581 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3582 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3583 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3587 ir_function_signature
*
3588 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3590 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3591 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3592 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3596 ir_function_signature
*
3597 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3599 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3600 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3601 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3605 ir_function_signature
*
3606 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3608 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3609 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3610 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3614 ir_function_signature
*
3615 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3617 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3618 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3619 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3623 ir_function_signature
*
3624 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3626 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3627 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3628 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3633 ir_function_signature
*
3634 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3636 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3637 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3638 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3642 ir_function_signature
*
3643 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3645 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3646 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3647 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3651 ir_function_signature
*
3652 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3654 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3655 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3656 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3660 ir_function_signature
*
3661 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3663 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3664 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3665 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3669 ir_function_signature
*
3670 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3672 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3673 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3674 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3678 ir_function_signature
*
3679 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3681 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3682 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3683 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3687 ir_function_signature
*
3688 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3690 ir_variable
*x
= in_var(type
, "x");
3691 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3693 body
.emit(ret(sqrt(dot(x
, x
))));
3698 ir_function_signature
*
3699 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3701 ir_variable
*p0
= in_var(type
, "p0");
3702 ir_variable
*p1
= in_var(type
, "p1");
3703 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3705 if (type
->vector_elements
== 1) {
3706 body
.emit(ret(abs(sub(p0
, p1
))));
3708 ir_variable
*p
= body
.make_temp(type
, "p");
3709 body
.emit(assign(p
, sub(p0
, p1
)));
3710 body
.emit(ret(sqrt(dot(p
, p
))));
3716 ir_function_signature
*
3717 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3719 if (type
->vector_elements
== 1)
3720 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3722 return binop(ir_binop_dot
, avail
,
3723 type
->get_base_type(), type
, type
);
3726 ir_function_signature
*
3727 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3729 ir_variable
*a
= in_var(type
, "a");
3730 ir_variable
*b
= in_var(type
, "b");
3731 MAKE_SIG(type
, avail
, 2, a
, b
);
3733 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3734 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3736 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3737 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3742 ir_function_signature
*
3743 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3745 ir_variable
*x
= in_var(type
, "x");
3746 MAKE_SIG(type
, avail
, 1, x
);
3748 if (type
->vector_elements
== 1) {
3749 body
.emit(ret(sign(x
)));
3751 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3757 ir_function_signature
*
3758 builtin_builder::_ftransform()
3760 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3762 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3763 glsl_type::vec4_type
,
3764 var_ref(gl_ModelViewProjectionMatrix
),
3765 var_ref(gl_Vertex
))));
3767 /* FINISHME: Once the ir_expression() constructor handles type inference
3768 * for matrix operations, we can simplify this to:
3770 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3775 ir_function_signature
*
3776 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3778 ir_variable
*N
= in_var(type
, "N");
3779 ir_variable
*I
= in_var(type
, "I");
3780 ir_variable
*Nref
= in_var(type
, "Nref");
3781 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3783 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3784 ret(N
), ret(neg(N
))));
3789 ir_function_signature
*
3790 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3792 ir_variable
*I
= in_var(type
, "I");
3793 ir_variable
*N
= in_var(type
, "N");
3794 MAKE_SIG(type
, avail
, 2, I
, N
);
3796 /* I - 2 * dot(N, I) * N */
3797 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3802 ir_function_signature
*
3803 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3805 ir_variable
*I
= in_var(type
, "I");
3806 ir_variable
*N
= in_var(type
, "N");
3807 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3808 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3810 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3811 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3813 /* From the GLSL 1.10 specification:
3814 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3816 * return genType(0.0)
3818 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3820 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3821 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3822 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3823 mul(n_dot_i
, n_dot_i
)))))));
3824 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3825 ret(ir_constant::zero(mem_ctx
, type
)),
3826 ret(sub(mul(eta
, I
),
3827 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3832 ir_function_signature
*
3833 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3835 ir_variable
*x
= in_var(type
, "x");
3836 ir_variable
*y
= in_var(type
, "y");
3837 MAKE_SIG(type
, avail
, 2, x
, y
);
3839 ir_variable
*z
= body
.make_temp(type
, "z");
3840 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3841 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3848 ir_function_signature
*
3849 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3854 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3855 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3856 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3858 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3859 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3861 MAKE_SIG(type
, avail
, 2, c
, r
);
3863 ir_variable
*m
= body
.make_temp(type
, "m");
3864 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3865 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3872 ir_function_signature
*
3873 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3875 const glsl_type
*transpose_type
=
3876 glsl_type::get_instance(orig_type
->base_type
,
3877 orig_type
->matrix_columns
,
3878 orig_type
->vector_elements
);
3880 ir_variable
*m
= in_var(orig_type
, "m");
3881 MAKE_SIG(transpose_type
, avail
, 1, m
);
3883 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3884 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3885 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3886 body
.emit(assign(array_ref(t
, j
),
3887 matrix_elt(m
, i
, j
),
3896 ir_function_signature
*
3897 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3899 ir_variable
*m
= in_var(type
, "m");
3900 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3902 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3903 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3908 ir_function_signature
*
3909 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3911 ir_variable
*m
= in_var(type
, "m");
3912 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3915 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3916 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3919 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3920 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3923 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3924 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3926 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3927 mul(matrix_elt(m
, 0, 1), f2
)),
3928 mul(matrix_elt(m
, 0, 2), f3
))));
3933 ir_function_signature
*
3934 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3936 ir_variable
*m
= in_var(type
, "m");
3937 const glsl_type
*btype
= type
->get_base_type();
3938 MAKE_SIG(btype
, avail
, 1, m
);
3940 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3941 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3942 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3943 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3944 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3945 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3946 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3947 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3948 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3949 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3950 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3951 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3952 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3953 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3954 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3955 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3956 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3957 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3958 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3960 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)))));
3961 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)))));
3962 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)))));
3963 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)))));
3964 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)))));
3965 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)))));
3966 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)))));
3967 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)))));
3968 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)))));
3969 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)))));
3970 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)))));
3971 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)))));
3972 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)))));
3973 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)))));
3974 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)))));
3975 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)))));
3976 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)))));
3977 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)))));
3978 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)))));
3980 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3982 body
.emit(assign(adj_0
,
3983 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3984 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3985 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3987 body
.emit(assign(adj_0
, neg(
3988 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3989 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3990 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3992 body
.emit(assign(adj_0
,
3993 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3994 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3995 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3997 body
.emit(assign(adj_0
, neg(
3998 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3999 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4000 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4003 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4008 ir_function_signature
*
4009 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4011 ir_variable
*m
= in_var(type
, "m");
4012 MAKE_SIG(type
, avail
, 1, m
);
4014 ir_variable
*adj
= body
.make_temp(type
, "adj");
4015 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4016 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4017 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4018 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4020 ir_expression
*det
=
4021 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4022 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4024 body
.emit(ret(div(adj
, det
)));
4028 ir_function_signature
*
4029 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4031 ir_variable
*m
= in_var(type
, "m");
4032 const glsl_type
*btype
= type
->get_base_type();
4033 MAKE_SIG(type
, avail
, 1, m
);
4035 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4036 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4037 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4039 body
.emit(assign(f11_22_21_12
,
4040 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4041 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4042 body
.emit(assign(f10_22_20_12
,
4043 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4044 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4045 body
.emit(assign(f10_21_20_11
,
4046 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4047 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4049 ir_variable
*adj
= body
.make_temp(type
, "adj");
4050 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4051 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4052 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4054 body
.emit(assign(array_ref(adj
, 0), neg(
4055 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4056 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4058 body
.emit(assign(array_ref(adj
, 1),
4059 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4060 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4062 body
.emit(assign(array_ref(adj
, 2), neg(
4063 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4064 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4067 body
.emit(assign(array_ref(adj
, 0),
4068 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4069 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4071 body
.emit(assign(array_ref(adj
, 1), neg(
4072 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4073 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4075 body
.emit(assign(array_ref(adj
, 2),
4076 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4077 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4080 ir_expression
*det
=
4081 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4082 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4083 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4085 body
.emit(ret(div(adj
, det
)));
4090 ir_function_signature
*
4091 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4093 ir_variable
*m
= in_var(type
, "m");
4094 const glsl_type
*btype
= type
->get_base_type();
4095 MAKE_SIG(type
, avail
, 1, m
);
4097 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4098 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4099 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4100 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4101 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4102 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4103 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4104 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4105 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4106 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4107 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4108 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4109 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4110 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4111 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4112 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4113 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4114 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4115 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4117 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)))));
4118 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)))));
4119 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)))));
4120 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)))));
4121 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)))));
4122 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)))));
4123 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)))));
4124 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)))));
4125 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)))));
4126 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)))));
4127 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)))));
4128 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)))));
4129 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)))));
4130 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)))));
4131 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)))));
4132 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)))));
4133 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)))));
4134 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)))));
4135 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)))));
4137 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4138 body
.emit(assign(array_ref(adj
, 0),
4139 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4140 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4141 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4143 body
.emit(assign(array_ref(adj
, 1), neg(
4144 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4145 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4146 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4148 body
.emit(assign(array_ref(adj
, 2),
4149 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4150 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4151 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4153 body
.emit(assign(array_ref(adj
, 3), neg(
4154 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4155 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4156 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4159 body
.emit(assign(array_ref(adj
, 0), neg(
4160 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4161 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4162 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4164 body
.emit(assign(array_ref(adj
, 1),
4165 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4166 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4167 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4169 body
.emit(assign(array_ref(adj
, 2), neg(
4170 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4171 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4172 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4174 body
.emit(assign(array_ref(adj
, 3),
4175 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4176 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4177 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4180 body
.emit(assign(array_ref(adj
, 0),
4181 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4182 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4183 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4185 body
.emit(assign(array_ref(adj
, 1), neg(
4186 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4187 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4188 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4190 body
.emit(assign(array_ref(adj
, 2),
4191 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4192 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4193 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4195 body
.emit(assign(array_ref(adj
, 3), neg(
4196 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4197 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4198 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4201 body
.emit(assign(array_ref(adj
, 0), neg(
4202 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4203 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4204 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4206 body
.emit(assign(array_ref(adj
, 1),
4207 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4208 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4209 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4211 body
.emit(assign(array_ref(adj
, 2), neg(
4212 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4213 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4214 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4216 body
.emit(assign(array_ref(adj
, 3),
4217 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4218 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4219 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4222 ir_expression
*det
=
4223 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4224 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4225 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4226 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4228 body
.emit(ret(div(adj
, det
)));
4234 ir_function_signature
*
4235 builtin_builder::_lessThan(builtin_available_predicate avail
,
4236 const glsl_type
*type
)
4238 return binop(ir_binop_less
, avail
,
4239 glsl_type::bvec(type
->vector_elements
), type
, type
);
4242 ir_function_signature
*
4243 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4244 const glsl_type
*type
)
4246 return binop(ir_binop_lequal
, avail
,
4247 glsl_type::bvec(type
->vector_elements
), type
, type
);
4250 ir_function_signature
*
4251 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4252 const glsl_type
*type
)
4254 return binop(ir_binop_greater
, avail
,
4255 glsl_type::bvec(type
->vector_elements
), type
, type
);
4258 ir_function_signature
*
4259 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4260 const glsl_type
*type
)
4262 return binop(ir_binop_gequal
, avail
,
4263 glsl_type::bvec(type
->vector_elements
), type
, type
);
4266 ir_function_signature
*
4267 builtin_builder::_equal(builtin_available_predicate avail
,
4268 const glsl_type
*type
)
4270 return binop(ir_binop_equal
, avail
,
4271 glsl_type::bvec(type
->vector_elements
), type
, type
);
4274 ir_function_signature
*
4275 builtin_builder::_notEqual(builtin_available_predicate avail
,
4276 const glsl_type
*type
)
4278 return binop(ir_binop_nequal
, avail
,
4279 glsl_type::bvec(type
->vector_elements
), type
, type
);
4282 ir_function_signature
*
4283 builtin_builder::_any(const glsl_type
*type
)
4285 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4288 ir_function_signature
*
4289 builtin_builder::_all(const glsl_type
*type
)
4291 ir_variable
*v
= in_var(type
, "v");
4292 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4294 switch (type
->vector_elements
) {
4296 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4299 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4303 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4312 UNOP(not, ir_unop_logic_not
, always_available
)
4315 has_lod(const glsl_type
*sampler_type
)
4317 assert(sampler_type
->is_sampler());
4319 switch (sampler_type
->sampler_dimensionality
) {
4320 case GLSL_SAMPLER_DIM_RECT
:
4321 case GLSL_SAMPLER_DIM_BUF
:
4322 case GLSL_SAMPLER_DIM_MS
:
4329 ir_function_signature
*
4330 builtin_builder::_textureSize(builtin_available_predicate avail
,
4331 const glsl_type
*return_type
,
4332 const glsl_type
*sampler_type
)
4334 ir_variable
*s
= in_var(sampler_type
, "sampler");
4335 /* The sampler always exists; add optional lod later. */
4336 MAKE_SIG(return_type
, avail
, 1, s
);
4338 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4339 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4341 if (has_lod(sampler_type
)) {
4342 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4343 sig
->parameters
.push_tail(lod
);
4344 tex
->lod_info
.lod
= var_ref(lod
);
4346 tex
->lod_info
.lod
= imm(0u);
4349 body
.emit(ret(tex
));
4354 ir_function_signature
*
4355 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4357 ir_variable
*s
= in_var(sampler_type
, "sampler");
4358 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4360 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4361 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4362 body
.emit(ret(tex
));
4367 ir_function_signature
*
4368 builtin_builder::_texture(ir_texture_opcode opcode
,
4369 builtin_available_predicate avail
,
4370 const glsl_type
*return_type
,
4371 const glsl_type
*sampler_type
,
4372 const glsl_type
*coord_type
,
4375 ir_variable
*s
= in_var(sampler_type
, "sampler");
4376 ir_variable
*P
= in_var(coord_type
, "P");
4377 /* The sampler and coordinate always exist; add optional parameters later. */
4378 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4380 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4381 tex
->set_sampler(var_ref(s
), return_type
);
4383 const int coord_size
= sampler_type
->coordinate_components();
4385 if (coord_size
== coord_type
->vector_elements
) {
4386 tex
->coordinate
= var_ref(P
);
4388 /* The incoming coordinate also has the projector or shadow comparitor,
4389 * so we need to swizzle those away.
4391 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4394 /* The projector is always in the last component. */
4395 if (flags
& TEX_PROJECT
)
4396 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4398 if (sampler_type
->sampler_shadow
) {
4399 if (opcode
== ir_tg4
) {
4400 /* gather has refz as a separate parameter, immediately after the
4403 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4404 sig
->parameters
.push_tail(refz
);
4405 tex
->shadow_comparitor
= var_ref(refz
);
4407 /* The shadow comparitor is normally in the Z component, but a few types
4408 * have sufficiently large coordinates that it's in W.
4410 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4414 if (opcode
== ir_txl
) {
4415 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4416 sig
->parameters
.push_tail(lod
);
4417 tex
->lod_info
.lod
= var_ref(lod
);
4418 } else if (opcode
== ir_txd
) {
4419 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4420 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4421 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4422 sig
->parameters
.push_tail(dPdx
);
4423 sig
->parameters
.push_tail(dPdy
);
4424 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4425 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4428 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4429 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4430 ir_variable
*offset
=
4431 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4432 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4433 sig
->parameters
.push_tail(offset
);
4434 tex
->offset
= var_ref(offset
);
4437 if (flags
& TEX_OFFSET_ARRAY
) {
4438 ir_variable
*offsets
=
4439 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4440 "offsets", ir_var_const_in
);
4441 sig
->parameters
.push_tail(offsets
);
4442 tex
->offset
= var_ref(offsets
);
4445 if (opcode
== ir_tg4
) {
4446 if (flags
& TEX_COMPONENT
) {
4447 ir_variable
*component
=
4448 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4449 sig
->parameters
.push_tail(component
);
4450 tex
->lod_info
.component
= var_ref(component
);
4453 tex
->lod_info
.component
= imm(0);
4457 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4458 * inconsistent with both textureLodOffset and textureGradOffset.
4460 if (opcode
== ir_txb
) {
4461 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4462 sig
->parameters
.push_tail(bias
);
4463 tex
->lod_info
.bias
= var_ref(bias
);
4466 body
.emit(ret(tex
));
4471 ir_function_signature
*
4472 builtin_builder::_textureCubeArrayShadow()
4474 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4475 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4476 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4477 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4479 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4480 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4482 tex
->coordinate
= var_ref(P
);
4483 tex
->shadow_comparitor
= var_ref(compare
);
4485 body
.emit(ret(tex
));
4490 ir_function_signature
*
4491 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4492 const glsl_type
*return_type
,
4493 const glsl_type
*sampler_type
,
4494 const glsl_type
*coord_type
,
4495 const glsl_type
*offset_type
)
4497 ir_variable
*s
= in_var(sampler_type
, "sampler");
4498 ir_variable
*P
= in_var(coord_type
, "P");
4499 /* The sampler and coordinate always exist; add optional parameters later. */
4500 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4502 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4503 tex
->coordinate
= var_ref(P
);
4504 tex
->set_sampler(var_ref(s
), return_type
);
4506 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4507 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4508 sig
->parameters
.push_tail(sample
);
4509 tex
->lod_info
.sample_index
= var_ref(sample
);
4510 tex
->op
= ir_txf_ms
;
4511 } else if (has_lod(sampler_type
)) {
4512 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4513 sig
->parameters
.push_tail(lod
);
4514 tex
->lod_info
.lod
= var_ref(lod
);
4516 tex
->lod_info
.lod
= imm(0u);
4519 if (offset_type
!= NULL
) {
4520 ir_variable
*offset
=
4521 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4522 sig
->parameters
.push_tail(offset
);
4523 tex
->offset
= var_ref(offset
);
4526 body
.emit(ret(tex
));
4531 ir_function_signature
*
4532 builtin_builder::_EmitVertex()
4534 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4536 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4537 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4542 ir_function_signature
*
4543 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4544 const glsl_type
*stream_type
)
4546 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4548 * "Emit the current values of output variables to the current output
4549 * primitive on stream stream. The argument to stream must be a constant
4550 * integral expression."
4552 ir_variable
*stream
=
4553 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4555 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4557 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4562 ir_function_signature
*
4563 builtin_builder::_EndPrimitive()
4565 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4567 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4568 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4573 ir_function_signature
*
4574 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4575 const glsl_type
*stream_type
)
4577 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4579 * "Completes the current output primitive on stream stream and starts
4580 * a new one. The argument to stream must be a constant integral
4583 ir_variable
*stream
=
4584 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4586 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4588 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4593 ir_function_signature
*
4594 builtin_builder::_barrier()
4596 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4598 body
.emit(new(mem_ctx
) ir_barrier());
4602 ir_function_signature
*
4603 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4604 const glsl_type
*sampler_type
,
4605 const glsl_type
*coord_type
)
4607 ir_variable
*s
= in_var(sampler_type
, "sampler");
4608 ir_variable
*coord
= in_var(coord_type
, "coord");
4609 /* The sampler and coordinate always exist; add optional parameters later. */
4610 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4612 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4613 tex
->coordinate
= var_ref(coord
);
4614 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4616 body
.emit(ret(tex
));
4621 ir_function_signature
*
4622 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4624 ir_variable
*s
= in_var(sampler_type
, "sampler");
4625 const glsl_type
*return_type
= glsl_type::int_type
;
4626 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4628 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4629 tex
->set_sampler(var_ref(s
), return_type
);
4631 body
.emit(ret(tex
));
4636 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4637 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4638 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4639 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4640 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4641 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4643 ir_function_signature
*
4644 builtin_builder::_fwidth(const glsl_type
*type
)
4646 ir_variable
*p
= in_var(type
, "p");
4647 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4649 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4654 ir_function_signature
*
4655 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4657 ir_variable
*p
= in_var(type
, "p");
4658 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4660 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4661 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4666 ir_function_signature
*
4667 builtin_builder::_fwidthFine(const glsl_type
*type
)
4669 ir_variable
*p
= in_var(type
, "p");
4670 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4672 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4673 abs(expr(ir_unop_dFdy_fine
, p
)))));
4678 ir_function_signature
*
4679 builtin_builder::_noise1(const glsl_type
*type
)
4681 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4684 ir_function_signature
*
4685 builtin_builder::_noise2(const glsl_type
*type
)
4687 ir_variable
*p
= in_var(type
, "p");
4688 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4690 ir_constant_data b_offset
;
4691 b_offset
.f
[0] = 601.0f
;
4692 b_offset
.f
[1] = 313.0f
;
4693 b_offset
.f
[2] = 29.0f
;
4694 b_offset
.f
[3] = 277.0f
;
4696 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4697 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4698 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4699 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4700 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4701 body
.emit(assign(t
, a
, WRITEMASK_X
));
4702 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4708 ir_function_signature
*
4709 builtin_builder::_noise3(const glsl_type
*type
)
4711 ir_variable
*p
= in_var(type
, "p");
4712 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4714 ir_constant_data b_offset
;
4715 b_offset
.f
[0] = 601.0f
;
4716 b_offset
.f
[1] = 313.0f
;
4717 b_offset
.f
[2] = 29.0f
;
4718 b_offset
.f
[3] = 277.0f
;
4720 ir_constant_data c_offset
;
4721 c_offset
.f
[0] = 1559.0f
;
4722 c_offset
.f
[1] = 113.0f
;
4723 c_offset
.f
[2] = 1861.0f
;
4724 c_offset
.f
[3] = 797.0f
;
4726 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4727 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4728 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4729 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4730 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4731 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4732 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4733 body
.emit(assign(t
, a
, WRITEMASK_X
));
4734 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4735 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4741 ir_function_signature
*
4742 builtin_builder::_noise4(const glsl_type
*type
)
4744 ir_variable
*p
= in_var(type
, "p");
4745 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4747 ir_variable
*_p
= body
.make_temp(type
, "_p");
4749 ir_constant_data p_offset
;
4750 p_offset
.f
[0] = 1559.0f
;
4751 p_offset
.f
[1] = 113.0f
;
4752 p_offset
.f
[2] = 1861.0f
;
4753 p_offset
.f
[3] = 797.0f
;
4755 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4757 ir_constant_data offset
;
4758 offset
.f
[0] = 601.0f
;
4759 offset
.f
[1] = 313.0f
;
4760 offset
.f
[2] = 29.0f
;
4761 offset
.f
[3] = 277.0f
;
4763 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4764 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4765 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4766 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4767 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4768 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4769 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4770 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4771 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4772 body
.emit(assign(t
, a
, WRITEMASK_X
));
4773 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4774 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4775 body
.emit(assign(t
, d
, WRITEMASK_W
));
4781 ir_function_signature
*
4782 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4784 ir_variable
*value
= in_var(type
, "value");
4785 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4786 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4787 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4789 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4794 ir_function_signature
*
4795 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4797 ir_variable
*base
= in_var(type
, "base");
4798 ir_variable
*insert
= in_var(type
, "insert");
4799 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4800 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4801 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4803 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4808 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4810 ir_function_signature
*
4811 builtin_builder::_bitCount(const glsl_type
*type
)
4813 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4814 glsl_type::ivec(type
->vector_elements
), type
);
4817 ir_function_signature
*
4818 builtin_builder::_findLSB(const glsl_type
*type
)
4820 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4821 glsl_type::ivec(type
->vector_elements
), type
);
4824 ir_function_signature
*
4825 builtin_builder::_findMSB(const glsl_type
*type
)
4827 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4828 glsl_type::ivec(type
->vector_elements
), type
);
4831 ir_function_signature
*
4832 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4834 ir_variable
*a
= in_var(type
, "a");
4835 ir_variable
*b
= in_var(type
, "b");
4836 ir_variable
*c
= in_var(type
, "c");
4837 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4839 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4844 ir_function_signature
*
4845 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4847 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4850 ir_function_signature
*
4851 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4853 ir_variable
*x
= in_var(x_type
, "x");
4854 ir_variable
*exponent
= out_var(exp_type
, "exp");
4855 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4857 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4859 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4863 ir_function_signature
*
4864 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4866 ir_variable
*x
= in_var(x_type
, "x");
4867 ir_variable
*exponent
= out_var(exp_type
, "exp");
4868 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4870 const unsigned vec_elem
= x_type
->vector_elements
;
4871 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4872 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4874 /* Single-precision floating-point values are stored as
4879 * An exponent shift of 23 will shift the mantissa out, leaving only the
4880 * exponent and sign bit (which itself may be zero, if the absolute value
4881 * was taken before the bitcast and shift.
4883 ir_constant
*exponent_shift
= imm(23);
4884 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4886 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4888 /* Exponent of floating-point values in the range [0.5, 1.0). */
4889 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4891 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4892 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4894 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4895 * to unsigned integers to ensure that 1 bits aren't shifted in.
4897 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4898 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4899 imm(0, vec_elem
)))));
4901 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4902 body
.emit(assign(bits
, bitcast_f2u(x
)));
4903 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4904 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4905 imm(0u, vec_elem
)))));
4906 body
.emit(ret(bitcast_u2f(bits
)));
4911 ir_function_signature
*
4912 builtin_builder::_uaddCarry(const glsl_type
*type
)
4914 ir_variable
*x
= in_var(type
, "x");
4915 ir_variable
*y
= in_var(type
, "y");
4916 ir_variable
*carry
= out_var(type
, "carry");
4917 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4919 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4920 body
.emit(ret(add(x
, y
)));
4925 ir_function_signature
*
4926 builtin_builder::_usubBorrow(const glsl_type
*type
)
4928 ir_variable
*x
= in_var(type
, "x");
4929 ir_variable
*y
= in_var(type
, "y");
4930 ir_variable
*borrow
= out_var(type
, "borrow");
4931 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4933 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4934 body
.emit(ret(sub(x
, y
)));
4940 * For both imulExtended() and umulExtended() built-ins.
4942 ir_function_signature
*
4943 builtin_builder::_mulExtended(const glsl_type
*type
)
4945 ir_variable
*x
= in_var(type
, "x");
4946 ir_variable
*y
= in_var(type
, "y");
4947 ir_variable
*msb
= out_var(type
, "msb");
4948 ir_variable
*lsb
= out_var(type
, "lsb");
4949 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
4951 body
.emit(assign(msb
, imul_high(x
, y
)));
4952 body
.emit(assign(lsb
, mul(x
, y
)));
4957 ir_function_signature
*
4958 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4960 ir_variable
*interpolant
= in_var(type
, "interpolant");
4961 interpolant
->data
.must_be_shader_input
= 1;
4962 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4964 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4969 ir_function_signature
*
4970 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4972 ir_variable
*interpolant
= in_var(type
, "interpolant");
4973 interpolant
->data
.must_be_shader_input
= 1;
4974 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4975 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4977 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4982 ir_function_signature
*
4983 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4985 ir_variable
*interpolant
= in_var(type
, "interpolant");
4986 interpolant
->data
.must_be_shader_input
= 1;
4987 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4988 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4990 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4995 ir_function_signature
*
4996 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
4998 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4999 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5003 ir_function_signature
*
5004 builtin_builder::_atomic_ssbo_intrinsic2(builtin_available_predicate avail
,
5005 const glsl_type
*type
)
5007 ir_variable
*atomic
= in_var(type
, "atomic");
5008 ir_variable
*data
= in_var(type
, "data");
5009 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5013 ir_function_signature
*
5014 builtin_builder::_atomic_ssbo_intrinsic3(builtin_available_predicate avail
,
5015 const glsl_type
*type
)
5017 ir_variable
*atomic
= in_var(type
, "atomic");
5018 ir_variable
*data1
= in_var(type
, "data1");
5019 ir_variable
*data2
= in_var(type
, "data2");
5020 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5024 ir_function_signature
*
5025 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5026 builtin_available_predicate avail
)
5028 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5029 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5031 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5032 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5034 body
.emit(ret(retval
));
5038 ir_function_signature
*
5039 builtin_builder::_atomic_ssbo_op2(const char *intrinsic
,
5040 builtin_available_predicate avail
,
5041 const glsl_type
*type
)
5043 ir_variable
*atomic
= in_var(type
, "atomic_var");
5044 ir_variable
*data
= in_var(type
, "atomic_data");
5045 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5047 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5048 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5050 body
.emit(ret(retval
));
5054 ir_function_signature
*
5055 builtin_builder::_atomic_ssbo_op3(const char *intrinsic
,
5056 builtin_available_predicate avail
,
5057 const glsl_type
*type
)
5059 ir_variable
*atomic
= in_var(type
, "atomic_var");
5060 ir_variable
*data1
= in_var(type
, "atomic_data1");
5061 ir_variable
*data2
= in_var(type
, "atomic_data2");
5062 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5064 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5065 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5067 body
.emit(ret(retval
));
5071 ir_function_signature
*
5072 builtin_builder::_min3(const glsl_type
*type
)
5074 ir_variable
*x
= in_var(type
, "x");
5075 ir_variable
*y
= in_var(type
, "y");
5076 ir_variable
*z
= in_var(type
, "z");
5077 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5079 ir_expression
*min3
= min2(x
, min2(y
,z
));
5080 body
.emit(ret(min3
));
5085 ir_function_signature
*
5086 builtin_builder::_max3(const glsl_type
*type
)
5088 ir_variable
*x
= in_var(type
, "x");
5089 ir_variable
*y
= in_var(type
, "y");
5090 ir_variable
*z
= in_var(type
, "z");
5091 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5093 ir_expression
*max3
= max2(x
, max2(y
,z
));
5094 body
.emit(ret(max3
));
5099 ir_function_signature
*
5100 builtin_builder::_mid3(const glsl_type
*type
)
5102 ir_variable
*x
= in_var(type
, "x");
5103 ir_variable
*y
= in_var(type
, "y");
5104 ir_variable
*z
= in_var(type
, "z");
5105 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5107 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5108 body
.emit(ret(mid3
));
5113 ir_function_signature
*
5114 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5115 unsigned num_arguments
,
5118 const glsl_type
*data_type
= glsl_type::get_instance(
5119 image_type
->sampler_type
,
5120 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5122 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5123 glsl_type::void_type
: data_type
);
5125 /* Addressing arguments that are always present. */
5126 ir_variable
*image
= in_var(image_type
, "image");
5127 ir_variable
*coord
= in_var(
5128 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5130 const builtin_available_predicate avail
=
5131 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
5132 shader_image_load_store
);
5133 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
5135 /* Sample index for multisample images. */
5136 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5137 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5139 /* Data arguments. */
5140 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5141 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5142 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5143 ralloc_free(arg_name
);
5146 /* Set the maximal set of qualifiers allowed for this image
5147 * built-in. Function calls with arguments having fewer
5148 * qualifiers than present in the prototype are allowed by the
5149 * spec, but not with more, i.e. this will make the compiler
5150 * accept everything that needs to be accepted, and reject cases
5151 * like loads from write-only or stores to read-only images.
5153 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5154 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5155 image
->data
.image_coherent
= true;
5156 image
->data
.image_volatile
= true;
5157 image
->data
.image_restrict
= true;
5162 ir_function_signature
*
5163 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5164 unsigned /* num_arguments */,
5165 unsigned /* flags */)
5167 const glsl_type
*ret_type
;
5168 unsigned num_components
= image_type
->coordinate_components();
5170 /* From the ARB_shader_image_size extension:
5171 * "Cube images return the dimensions of one face."
5173 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5174 !image_type
->sampler_array
) {
5178 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5179 * supported by mesa.
5181 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5183 ir_variable
*image
= in_var(image_type
, "image");
5184 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5186 /* Set the maximal set of qualifiers allowed for this image
5187 * built-in. Function calls with arguments having fewer
5188 * qualifiers than present in the prototype are allowed by the
5189 * spec, but not with more, i.e. this will make the compiler
5190 * accept everything that needs to be accepted, and reject cases
5191 * like loads from write-only or stores to read-only images.
5193 image
->data
.image_read_only
= true;
5194 image
->data
.image_write_only
= true;
5195 image
->data
.image_coherent
= true;
5196 image
->data
.image_volatile
= true;
5197 image
->data
.image_restrict
= true;
5202 ir_function_signature
*
5203 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5204 unsigned num_arguments
,
5207 ir_variable
*image
= in_var(image_type
, "image");
5208 ir_function_signature
*sig
=
5209 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5211 /* Set the maximal set of qualifiers allowed for this image
5212 * built-in. Function calls with arguments having fewer
5213 * qualifiers than present in the prototype are allowed by the
5214 * spec, but not with more, i.e. this will make the compiler
5215 * accept everything that needs to be accepted, and reject cases
5216 * like loads from write-only or stores to read-only images.
5218 image
->data
.image_read_only
= true;
5219 image
->data
.image_write_only
= true;
5220 image
->data
.image_coherent
= true;
5221 image
->data
.image_volatile
= true;
5222 image
->data
.image_restrict
= true;
5227 ir_function_signature
*
5228 builtin_builder::_image(image_prototype_ctr prototype
,
5229 const glsl_type
*image_type
,
5230 const char *intrinsic_name
,
5231 unsigned num_arguments
,
5234 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5235 num_arguments
, flags
);
5237 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5238 ir_factory
body(&sig
->body
, mem_ctx
);
5239 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5241 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5242 body
.emit(call(f
, NULL
, sig
->parameters
));
5244 ir_variable
*ret_val
=
5245 body
.make_temp(sig
->return_type
, "_ret_val");
5246 body
.emit(call(f
, ret_val
, sig
->parameters
));
5247 body
.emit(ret(ret_val
));
5250 sig
->is_defined
= true;
5253 sig
->is_intrinsic
= true;
5259 ir_function_signature
*
5260 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5262 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5266 ir_function_signature
*
5267 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
5269 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5270 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
5271 NULL
, sig
->parameters
));
5275 ir_function_signature
*
5276 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5277 const glsl_type
*type
)
5279 MAKE_INTRINSIC(type
, avail
, 0);
5283 ir_function_signature
*
5284 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5285 const glsl_type
*type
)
5287 MAKE_SIG(type
, avail
, 0);
5289 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5291 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5292 retval
, sig
->parameters
));
5293 body
.emit(ret(retval
));
5299 /******************************************************************************/
5301 /* The singleton instance of builtin_builder. */
5302 static builtin_builder builtins
;
5303 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5306 * External API (exposing the built-in module to the rest of the compiler):
5310 _mesa_glsl_initialize_builtin_functions()
5312 mtx_lock(&builtins_lock
);
5313 builtins
.initialize();
5314 mtx_unlock(&builtins_lock
);
5318 _mesa_glsl_release_builtin_functions()
5320 mtx_lock(&builtins_lock
);
5322 mtx_unlock(&builtins_lock
);
5325 ir_function_signature
*
5326 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5327 const char *name
, exec_list
*actual_parameters
)
5329 ir_function_signature
* s
;
5330 mtx_lock(&builtins_lock
);
5331 s
= builtins
.find(state
, name
, actual_parameters
);
5332 mtx_unlock(&builtins_lock
);
5337 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5340 mtx_lock(&builtins_lock
);
5341 f
= builtins
.shader
->symbols
->get_function(name
);
5342 mtx_unlock(&builtins_lock
);
5347 _mesa_glsl_get_builtin_function_shader()
5349 return builtins
.shader
;
5354 * Get the function signature for main from a shader
5356 ir_function_signature
*
5357 _mesa_get_main_function_signature(gl_shader
*sh
)
5359 ir_function
*const f
= sh
->symbols
->get_function("main");
5361 exec_list void_parameters
;
5363 /* Look for the 'void main()' signature and ensure that it's defined.
5364 * This keeps the linker from accidentally pick a shader that just
5365 * contains a prototype for main.
5367 * We don't have to check for multiple definitions of main (in multiple
5368 * shaders) because that would have already been caught above.
5370 ir_function_signature
*sig
=
5371 f
->matching_signature(NULL
, &void_parameters
, false);
5372 if ((sig
!= NULL
) && sig
->is_defined
) {