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_trinary_minmax(const _mesa_glsl_parse_state
*state
)
406 return state
->AMD_shader_trinary_minmax_enable
;
410 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
412 return (state
->is_version(420, 310) ||
413 state
->ARB_shader_image_load_store_enable
);
417 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
419 return (state
->is_version(420, 0) ||
420 state
->ARB_shader_image_load_store_enable
);
424 shader_image_size(const _mesa_glsl_parse_state
*state
)
426 return state
->is_version(430, 310) ||
427 state
->ARB_shader_image_size_enable
;
431 shader_samples(const _mesa_glsl_parse_state
*state
)
433 return state
->is_version(450, 0) ||
434 state
->ARB_shader_texture_image_samples_enable
;
438 gs_streams(const _mesa_glsl_parse_state
*state
)
440 return gpu_shader5(state
) && gs_only(state
);
444 fp64(const _mesa_glsl_parse_state
*state
)
446 return state
->has_double();
450 barrier_supported(const _mesa_glsl_parse_state
*state
)
452 return state
->stage
== MESA_SHADER_COMPUTE
||
453 state
->stage
== MESA_SHADER_TESS_CTRL
;
458 /******************************************************************************/
463 * builtin_builder: A singleton object representing the core of the built-in
466 * It generates IR for every built-in function signature, and organizes them
469 class builtin_builder
{
476 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
477 const char *name
, exec_list
*actual_parameters
);
480 * A shader to hold all the built-in signatures; created by this module.
482 * This includes signatures for every built-in, regardless of version or
483 * enabled extensions. The availability predicate associated with each
484 * signature allows matching_signature() to filter out the irrelevant ones.
491 /** Global variables used by built-in functions. */
492 ir_variable
*gl_ModelViewProjectionMatrix
;
493 ir_variable
*gl_Vertex
;
495 void create_shader();
496 void create_intrinsics();
497 void create_builtins();
500 * IR builder helpers:
502 * These convenience functions assist in emitting IR, but don't necessarily
503 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
506 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
507 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
508 ir_constant
*imm(float f
, unsigned vector_elements
=1);
509 ir_constant
*imm(int i
, unsigned vector_elements
=1);
510 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
511 ir_constant
*imm(double d
, unsigned vector_elements
=1);
512 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
513 ir_dereference_variable
*var_ref(ir_variable
*var
);
514 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
515 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
517 ir_expression
*asin_expr(ir_variable
*x
);
518 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
521 * Call function \param f with parameters specified as the linked
522 * list \param params of \c ir_variable objects. \param ret should
523 * point to the ir_variable that will hold the function return
524 * value, or be \c NULL if the function has void return type.
526 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
528 /** Create a new function and add the given signatures. */
529 void add_function(const char *name
, ...);
531 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
532 unsigned num_arguments
,
535 enum image_function_flags
{
536 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
537 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
538 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
539 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
540 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
541 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
542 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6)
546 * Create a new image built-in function for all known image types.
547 * \p flags is a bitfield of \c image_function_flags flags.
549 void add_image_function(const char *name
,
550 const char *intrinsic_name
,
551 image_prototype_ctr prototype
,
552 unsigned num_arguments
,
556 * Create new functions for all known image built-ins and types.
557 * If \p glsl is \c true, use the GLSL built-in names and emit code
558 * to call into the actual compiler intrinsic. If \p glsl is
559 * false, emit a function prototype with no body for each image
562 void add_image_functions(bool glsl
);
564 ir_function_signature
*new_sig(const glsl_type
*return_type
,
565 builtin_available_predicate avail
,
566 int num_params
, ...);
569 * Function signature generators:
572 ir_function_signature
*unop(builtin_available_predicate avail
,
573 ir_expression_operation opcode
,
574 const glsl_type
*return_type
,
575 const glsl_type
*param_type
);
576 ir_function_signature
*binop(ir_expression_operation opcode
,
577 builtin_available_predicate avail
,
578 const glsl_type
*return_type
,
579 const glsl_type
*param0_type
,
580 const glsl_type
*param1_type
);
582 #define B0(X) ir_function_signature *_##X();
583 #define B1(X) ir_function_signature *_##X(const glsl_type *);
584 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
585 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
586 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
587 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
624 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
625 const glsl_type
*val_type
,
626 const glsl_type
*blend_type
);
635 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
636 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
637 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
638 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
639 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
640 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
641 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
642 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
643 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
644 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
645 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
646 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
659 BA1(determinant_mat2
);
660 BA1(determinant_mat3
);
661 BA1(determinant_mat4
);
669 BA1(greaterThanEqual
);
678 /** Flags to _texture() */
679 #define TEX_PROJECT 1
681 #define TEX_COMPONENT 4
682 #define TEX_OFFSET_NONCONST 8
683 #define TEX_OFFSET_ARRAY 16
685 ir_function_signature
*_texture(ir_texture_opcode opcode
,
686 builtin_available_predicate avail
,
687 const glsl_type
*return_type
,
688 const glsl_type
*sampler_type
,
689 const glsl_type
*coord_type
,
691 B0(textureCubeArrayShadow
);
692 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
693 const glsl_type
*return_type
,
694 const glsl_type
*sampler_type
,
695 const glsl_type
*coord_type
,
696 const glsl_type
*offset_type
= NULL
);
700 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
701 const glsl_type
*stream_type
);
702 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
703 const glsl_type
*stream_type
);
706 BA2(textureQueryLod
);
707 B1(textureQueryLevels
);
735 B1(interpolateAtCentroid
)
736 B1(interpolateAtOffset
)
737 B1(interpolateAtSample
)
739 ir_function_signature
*_atomic_intrinsic(builtin_available_predicate avail
);
740 ir_function_signature
*_atomic_op(const char *intrinsic
,
741 builtin_available_predicate avail
);
747 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
748 unsigned num_arguments
,
750 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
751 unsigned num_arguments
,
753 ir_function_signature
*_image(image_prototype_ctr prototype
,
754 const glsl_type
*image_type
,
755 const char *intrinsic_name
,
756 unsigned num_arguments
,
759 ir_function_signature
*_memory_barrier_intrinsic(
760 builtin_available_predicate avail
);
761 ir_function_signature
*_memory_barrier(
762 builtin_available_predicate avail
);
773 } /* anonymous namespace */
776 * Core builtin_builder functionality:
779 builtin_builder::builtin_builder()
781 gl_ModelViewProjectionMatrix(NULL
),
787 builtin_builder::~builtin_builder()
789 ralloc_free(mem_ctx
);
792 ir_function_signature
*
793 builtin_builder::find(_mesa_glsl_parse_state
*state
,
794 const char *name
, exec_list
*actual_parameters
)
796 /* The shader currently being compiled requested a built-in function;
797 * it needs to link against builtin_builder::shader in order to get them.
799 * Even if we don't find a matching signature, we still need to do this so
800 * that the "no matching signature" error will list potential candidates
801 * from the available built-ins.
803 state
->uses_builtin_functions
= true;
805 ir_function
*f
= shader
->symbols
->get_function(name
);
809 ir_function_signature
*sig
=
810 f
->matching_signature(state
, actual_parameters
, true);
818 builtin_builder::initialize()
820 /* If already initialized, don't do it again. */
824 mem_ctx
= ralloc_context(NULL
);
831 builtin_builder::release()
833 ralloc_free(mem_ctx
);
841 builtin_builder::create_shader()
843 /* The target doesn't actually matter. There's no target for generic
844 * GLSL utility code that could be linked against any stage, so just
845 * arbitrarily pick GL_VERTEX_SHADER.
847 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
848 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
850 gl_ModelViewProjectionMatrix
=
851 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
852 "gl_ModelViewProjectionMatrix",
855 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
857 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
858 shader
->symbols
->add_variable(gl_Vertex
);
864 * Create ir_function and ir_function_signature objects for each
868 builtin_builder::create_intrinsics()
870 add_function("__intrinsic_atomic_read",
871 _atomic_intrinsic(shader_atomic_counters
),
873 add_function("__intrinsic_atomic_increment",
874 _atomic_intrinsic(shader_atomic_counters
),
876 add_function("__intrinsic_atomic_predecrement",
877 _atomic_intrinsic(shader_atomic_counters
),
880 add_image_functions(false);
882 add_function("__intrinsic_memory_barrier",
883 _memory_barrier_intrinsic(shader_image_load_store
),
888 * Create ir_function and ir_function_signature objects for each built-in.
890 * Contains a list of every available built-in.
893 builtin_builder::create_builtins()
896 add_function(#NAME, \
897 _##NAME(glsl_type::float_type), \
898 _##NAME(glsl_type::vec2_type), \
899 _##NAME(glsl_type::vec3_type), \
900 _##NAME(glsl_type::vec4_type), \
904 add_function(#NAME, \
905 _##NAME(always_available, glsl_type::float_type), \
906 _##NAME(always_available, glsl_type::vec2_type), \
907 _##NAME(always_available, glsl_type::vec3_type), \
908 _##NAME(always_available, glsl_type::vec4_type), \
909 _##NAME(fp64, glsl_type::double_type), \
910 _##NAME(fp64, glsl_type::dvec2_type), \
911 _##NAME(fp64, glsl_type::dvec3_type), \
912 _##NAME(fp64, glsl_type::dvec4_type), \
915 #define FD130(NAME) \
916 add_function(#NAME, \
917 _##NAME(v130, glsl_type::float_type), \
918 _##NAME(v130, glsl_type::vec2_type), \
919 _##NAME(v130, glsl_type::vec3_type), \
920 _##NAME(v130, glsl_type::vec4_type), \
921 _##NAME(fp64, glsl_type::double_type), \
922 _##NAME(fp64, glsl_type::dvec2_type), \
923 _##NAME(fp64, glsl_type::dvec3_type), \
924 _##NAME(fp64, glsl_type::dvec4_type), \
927 #define FDGS5(NAME) \
928 add_function(#NAME, \
929 _##NAME(gpu_shader5, glsl_type::float_type), \
930 _##NAME(gpu_shader5, glsl_type::vec2_type), \
931 _##NAME(gpu_shader5, glsl_type::vec3_type), \
932 _##NAME(gpu_shader5, glsl_type::vec4_type), \
933 _##NAME(fp64, glsl_type::double_type), \
934 _##NAME(fp64, glsl_type::dvec2_type), \
935 _##NAME(fp64, glsl_type::dvec3_type), \
936 _##NAME(fp64, glsl_type::dvec4_type), \
940 add_function(#NAME, \
941 _##NAME(glsl_type::float_type), \
942 _##NAME(glsl_type::vec2_type), \
943 _##NAME(glsl_type::vec3_type), \
944 _##NAME(glsl_type::vec4_type), \
945 _##NAME(glsl_type::int_type), \
946 _##NAME(glsl_type::ivec2_type), \
947 _##NAME(glsl_type::ivec3_type), \
948 _##NAME(glsl_type::ivec4_type), \
952 add_function(#NAME, \
953 _##NAME(always_available, glsl_type::float_type), \
954 _##NAME(always_available, glsl_type::vec2_type), \
955 _##NAME(always_available, glsl_type::vec3_type), \
956 _##NAME(always_available, glsl_type::vec4_type), \
957 _##NAME(always_available, glsl_type::int_type), \
958 _##NAME(always_available, glsl_type::ivec2_type), \
959 _##NAME(always_available, glsl_type::ivec3_type), \
960 _##NAME(always_available, glsl_type::ivec4_type), \
961 _##NAME(fp64, glsl_type::double_type), \
962 _##NAME(fp64, glsl_type::dvec2_type), \
963 _##NAME(fp64, glsl_type::dvec3_type), \
964 _##NAME(fp64, glsl_type::dvec4_type), \
968 add_function(#NAME, \
969 _##NAME(always_available, glsl_type::float_type), \
970 _##NAME(always_available, glsl_type::vec2_type), \
971 _##NAME(always_available, glsl_type::vec3_type), \
972 _##NAME(always_available, glsl_type::vec4_type), \
974 _##NAME(always_available, glsl_type::int_type), \
975 _##NAME(always_available, glsl_type::ivec2_type), \
976 _##NAME(always_available, glsl_type::ivec3_type), \
977 _##NAME(always_available, glsl_type::ivec4_type), \
979 _##NAME(v130, glsl_type::uint_type), \
980 _##NAME(v130, glsl_type::uvec2_type), \
981 _##NAME(v130, glsl_type::uvec3_type), \
982 _##NAME(v130, glsl_type::uvec4_type), \
983 _##NAME(fp64, glsl_type::double_type), \
984 _##NAME(fp64, glsl_type::dvec2_type), \
985 _##NAME(fp64, glsl_type::dvec3_type), \
986 _##NAME(fp64, glsl_type::dvec4_type), \
990 add_function(#NAME, \
991 _##NAME(glsl_type::int_type), \
992 _##NAME(glsl_type::ivec2_type), \
993 _##NAME(glsl_type::ivec3_type), \
994 _##NAME(glsl_type::ivec4_type), \
996 _##NAME(glsl_type::uint_type), \
997 _##NAME(glsl_type::uvec2_type), \
998 _##NAME(glsl_type::uvec3_type), \
999 _##NAME(glsl_type::uvec4_type), \
1002 #define FIUBD(NAME) \
1003 add_function(#NAME, \
1004 _##NAME(always_available, glsl_type::float_type), \
1005 _##NAME(always_available, glsl_type::vec2_type), \
1006 _##NAME(always_available, glsl_type::vec3_type), \
1007 _##NAME(always_available, glsl_type::vec4_type), \
1009 _##NAME(always_available, glsl_type::int_type), \
1010 _##NAME(always_available, glsl_type::ivec2_type), \
1011 _##NAME(always_available, glsl_type::ivec3_type), \
1012 _##NAME(always_available, glsl_type::ivec4_type), \
1014 _##NAME(v130, glsl_type::uint_type), \
1015 _##NAME(v130, glsl_type::uvec2_type), \
1016 _##NAME(v130, glsl_type::uvec3_type), \
1017 _##NAME(v130, glsl_type::uvec4_type), \
1019 _##NAME(always_available, glsl_type::bool_type), \
1020 _##NAME(always_available, glsl_type::bvec2_type), \
1021 _##NAME(always_available, glsl_type::bvec3_type), \
1022 _##NAME(always_available, glsl_type::bvec4_type), \
1024 _##NAME(fp64, glsl_type::double_type), \
1025 _##NAME(fp64, glsl_type::dvec2_type), \
1026 _##NAME(fp64, glsl_type::dvec3_type), \
1027 _##NAME(fp64, glsl_type::dvec4_type), \
1030 #define FIUD2_MIXED(NAME) \
1031 add_function(#NAME, \
1032 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1033 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1034 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1035 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1037 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1038 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1039 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1041 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1042 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1043 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1044 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1046 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1047 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1048 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1050 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1051 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1052 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1053 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1055 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1056 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1057 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1059 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1060 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1061 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1062 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1063 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1064 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1065 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1076 add_function("atan",
1077 _atan(glsl_type::float_type
),
1078 _atan(glsl_type::vec2_type
),
1079 _atan(glsl_type::vec3_type
),
1080 _atan(glsl_type::vec4_type
),
1081 _atan2(glsl_type::float_type
),
1082 _atan2(glsl_type::vec2_type
),
1083 _atan2(glsl_type::vec3_type
),
1084 _atan2(glsl_type::vec4_type
),
1110 _mod(glsl_type::float_type
, glsl_type::float_type
),
1111 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
1112 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
1113 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
1115 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
1116 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
1117 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
1119 _mod(glsl_type::double_type
, glsl_type::double_type
),
1120 _mod(glsl_type::dvec2_type
, glsl_type::double_type
),
1121 _mod(glsl_type::dvec3_type
, glsl_type::double_type
),
1122 _mod(glsl_type::dvec4_type
, glsl_type::double_type
),
1124 _mod(glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1125 _mod(glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1126 _mod(glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1136 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1137 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1138 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1139 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1141 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1142 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1143 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1145 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1146 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1147 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1148 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1150 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1151 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1152 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1154 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1155 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1156 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1157 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1159 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1160 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1161 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1162 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1164 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1165 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1166 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1167 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1169 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1170 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1171 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1172 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1174 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1175 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1176 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1177 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1180 add_function("step",
1181 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1182 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1183 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1184 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1186 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1187 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1188 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1189 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1190 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1191 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1192 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1194 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1195 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1196 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1199 add_function("smoothstep",
1200 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1201 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1202 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1203 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1205 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1206 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1207 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1208 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1209 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1210 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1211 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1213 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1214 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1215 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1223 add_function("intBitsToFloat",
1224 _intBitsToFloat(glsl_type::int_type
),
1225 _intBitsToFloat(glsl_type::ivec2_type
),
1226 _intBitsToFloat(glsl_type::ivec3_type
),
1227 _intBitsToFloat(glsl_type::ivec4_type
),
1229 add_function("uintBitsToFloat",
1230 _uintBitsToFloat(glsl_type::uint_type
),
1231 _uintBitsToFloat(glsl_type::uvec2_type
),
1232 _uintBitsToFloat(glsl_type::uvec3_type
),
1233 _uintBitsToFloat(glsl_type::uvec4_type
),
1236 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1237 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1238 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1239 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1240 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1241 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1242 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1243 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1244 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1245 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1246 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1247 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1254 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1255 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1258 add_function("ftransform", _ftransform(), NULL
);
1263 add_function("matrixCompMult",
1264 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1265 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1266 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1267 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1268 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1269 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1270 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1271 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1272 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1273 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1274 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1275 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1276 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1277 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1278 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1279 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1280 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1281 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1283 add_function("outerProduct",
1284 _outerProduct(v120
, glsl_type::mat2_type
),
1285 _outerProduct(v120
, glsl_type::mat3_type
),
1286 _outerProduct(v120
, glsl_type::mat4_type
),
1287 _outerProduct(v120
, glsl_type::mat2x3_type
),
1288 _outerProduct(v120
, glsl_type::mat2x4_type
),
1289 _outerProduct(v120
, glsl_type::mat3x2_type
),
1290 _outerProduct(v120
, glsl_type::mat3x4_type
),
1291 _outerProduct(v120
, glsl_type::mat4x2_type
),
1292 _outerProduct(v120
, glsl_type::mat4x3_type
),
1293 _outerProduct(fp64
, glsl_type::dmat2_type
),
1294 _outerProduct(fp64
, glsl_type::dmat3_type
),
1295 _outerProduct(fp64
, glsl_type::dmat4_type
),
1296 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1297 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1298 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1299 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1300 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1301 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1303 add_function("determinant",
1304 _determinant_mat2(v120
, glsl_type::mat2_type
),
1305 _determinant_mat3(v120
, glsl_type::mat3_type
),
1306 _determinant_mat4(v120
, glsl_type::mat4_type
),
1307 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1308 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1309 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1312 add_function("inverse",
1313 _inverse_mat2(v120
, glsl_type::mat2_type
),
1314 _inverse_mat3(v120
, glsl_type::mat3_type
),
1315 _inverse_mat4(v120
, glsl_type::mat4_type
),
1316 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1317 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1318 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1320 add_function("transpose",
1321 _transpose(v120
, glsl_type::mat2_type
),
1322 _transpose(v120
, glsl_type::mat3_type
),
1323 _transpose(v120
, glsl_type::mat4_type
),
1324 _transpose(v120
, glsl_type::mat2x3_type
),
1325 _transpose(v120
, glsl_type::mat2x4_type
),
1326 _transpose(v120
, glsl_type::mat3x2_type
),
1327 _transpose(v120
, glsl_type::mat3x4_type
),
1328 _transpose(v120
, glsl_type::mat4x2_type
),
1329 _transpose(v120
, glsl_type::mat4x3_type
),
1330 _transpose(fp64
, glsl_type::dmat2_type
),
1331 _transpose(fp64
, glsl_type::dmat3_type
),
1332 _transpose(fp64
, glsl_type::dmat4_type
),
1333 _transpose(fp64
, glsl_type::dmat2x3_type
),
1334 _transpose(fp64
, glsl_type::dmat2x4_type
),
1335 _transpose(fp64
, glsl_type::dmat3x2_type
),
1336 _transpose(fp64
, glsl_type::dmat3x4_type
),
1337 _transpose(fp64
, glsl_type::dmat4x2_type
),
1338 _transpose(fp64
, glsl_type::dmat4x3_type
),
1343 FIUD(greaterThanEqual
)
1348 _any(glsl_type::bvec2_type
),
1349 _any(glsl_type::bvec3_type
),
1350 _any(glsl_type::bvec4_type
),
1354 _all(glsl_type::bvec2_type
),
1355 _all(glsl_type::bvec3_type
),
1356 _all(glsl_type::bvec4_type
),
1360 _not(glsl_type::bvec2_type
),
1361 _not(glsl_type::bvec3_type
),
1362 _not(glsl_type::bvec4_type
),
1365 add_function("textureSize",
1366 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1367 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1368 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1370 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1371 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1372 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1374 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1375 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1376 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1378 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1379 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1380 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1382 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1383 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1384 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1386 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1387 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1388 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1389 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1390 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1391 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1393 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1394 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1396 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1397 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1398 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1399 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1401 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1402 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1403 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1404 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1406 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1407 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1408 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1409 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1410 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1411 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1413 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1414 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1415 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1418 add_function("textureSamples",
1419 _textureSamples(glsl_type::sampler2DMS_type
),
1420 _textureSamples(glsl_type::isampler2DMS_type
),
1421 _textureSamples(glsl_type::usampler2DMS_type
),
1423 _textureSamples(glsl_type::sampler2DMSArray_type
),
1424 _textureSamples(glsl_type::isampler2DMSArray_type
),
1425 _textureSamples(glsl_type::usampler2DMSArray_type
),
1428 add_function("texture",
1429 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1430 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1431 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1433 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1434 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1435 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1437 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1438 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1439 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1441 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1442 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1443 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1445 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1446 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1447 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1449 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1450 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1451 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1453 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1454 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1455 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1457 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1458 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1459 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1461 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1462 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1463 /* samplerCubeArrayShadow is special; it has an extra parameter
1464 * for the shadow comparitor since there is no vec5 type.
1466 _textureCubeArrayShadow(),
1468 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1469 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1470 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1472 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1474 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1475 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1476 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1478 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1479 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1480 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1482 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1483 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1484 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1486 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1487 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1488 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1490 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1491 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1492 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1494 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1495 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1496 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1498 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1499 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1500 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1502 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1503 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1504 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1506 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1509 add_function("textureLod",
1510 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1511 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1512 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1514 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1515 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1516 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1518 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1519 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1520 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1522 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1523 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1524 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1526 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1527 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1529 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1530 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1531 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1533 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1534 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1535 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1537 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1538 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1539 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1541 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1544 add_function("textureOffset",
1545 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1546 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1547 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1549 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1550 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1551 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1553 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1554 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1555 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1557 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1558 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1559 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1561 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1563 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1564 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1566 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1567 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1568 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1570 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1571 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1572 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1574 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1576 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1577 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1578 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1580 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1581 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1582 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1584 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1585 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1586 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1588 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1589 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1591 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1592 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1593 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1595 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1596 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1597 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1599 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1602 add_function("textureProj",
1603 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1604 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1605 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1606 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1607 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1608 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1610 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1611 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1612 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1613 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1614 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1615 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1617 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1618 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1619 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1621 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1622 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1624 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1625 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1626 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1627 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1628 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1629 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1631 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1633 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1634 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1635 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1636 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1637 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1638 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1640 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1641 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1642 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1643 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1644 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1645 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1647 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1648 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1649 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1651 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1652 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1655 add_function("texelFetch",
1656 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1657 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1658 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1660 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1661 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1662 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1664 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1665 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1666 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1668 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1669 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1670 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1672 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1673 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1674 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1676 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1677 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1678 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1680 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1681 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1682 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1684 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1685 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1686 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1688 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1689 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1690 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1693 add_function("texelFetchOffset",
1694 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1695 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1696 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1698 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1699 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1700 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1702 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1703 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1704 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1706 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1707 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1708 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1710 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1711 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1712 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1714 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1715 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1716 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1720 add_function("textureProjOffset",
1721 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1722 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1723 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1724 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1725 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1726 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1728 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1729 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1730 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1731 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1732 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1733 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1735 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1736 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1737 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1739 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1740 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1742 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1743 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1744 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1745 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1746 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1747 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1749 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1751 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1752 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1753 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1754 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1755 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1756 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1758 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1759 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1760 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1761 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1762 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1763 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1765 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1766 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1767 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1769 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1770 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1773 add_function("textureLodOffset",
1774 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1775 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1776 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1778 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1779 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1780 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1782 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1783 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1784 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1786 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1787 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1789 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1790 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1791 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1793 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1794 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1795 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1797 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1800 add_function("textureProjLod",
1801 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1802 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1803 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1804 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1805 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1806 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1808 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1809 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1810 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1811 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1812 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1813 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1815 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1816 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1817 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1819 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1820 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1823 add_function("textureProjLodOffset",
1824 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1825 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1826 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1827 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1828 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1829 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1831 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1832 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1833 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1834 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1835 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1836 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1838 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1839 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1840 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1842 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1843 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1846 add_function("textureGrad",
1847 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1848 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1849 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1851 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1852 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1853 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1855 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1856 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1857 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1859 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1860 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1861 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1863 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1864 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1865 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1867 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1869 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1870 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1871 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1873 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1874 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1875 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1877 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1878 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1879 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1881 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1882 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1883 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1885 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1886 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1889 add_function("textureGradOffset",
1890 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1891 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1892 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1894 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1895 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1896 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1898 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1899 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1900 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1902 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1903 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1904 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1906 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1908 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1909 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1911 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1912 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1913 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1915 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1916 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1917 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1919 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1920 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1923 add_function("textureProjGrad",
1924 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1925 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1926 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1927 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1928 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1929 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1931 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1932 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1933 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1934 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1935 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1936 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1938 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1939 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1940 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1942 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1943 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1944 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1945 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1946 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1947 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1949 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1951 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1952 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1955 add_function("textureProjGradOffset",
1956 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1957 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1958 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1959 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1960 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1963 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1965 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1966 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1967 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1971 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1972 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1974 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1975 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1976 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1977 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1978 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1979 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1981 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1983 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1984 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1987 add_function("EmitVertex", _EmitVertex(), NULL
);
1988 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1989 add_function("EmitStreamVertex",
1990 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
1991 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
1993 add_function("EndStreamPrimitive",
1994 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
1995 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
1997 add_function("barrier", _barrier(), NULL
);
1999 add_function("textureQueryLOD",
2000 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2001 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2002 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2004 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2005 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2006 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2008 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2009 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2010 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2012 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2013 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2014 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2016 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2017 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2018 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2020 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2021 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2022 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2024 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2025 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2026 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2028 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2029 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2030 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2031 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2032 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2033 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2036 add_function("textureQueryLod",
2037 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2038 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2039 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2041 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2042 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2043 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2045 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2046 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2047 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2049 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2050 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2051 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2053 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2054 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2055 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2057 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2058 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2059 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2061 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2062 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2063 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2065 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2066 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2067 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2068 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2069 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2070 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2073 add_function("textureQueryLevels",
2074 _textureQueryLevels(glsl_type::sampler1D_type
),
2075 _textureQueryLevels(glsl_type::sampler2D_type
),
2076 _textureQueryLevels(glsl_type::sampler3D_type
),
2077 _textureQueryLevels(glsl_type::samplerCube_type
),
2078 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2079 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2080 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2081 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2082 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2083 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2084 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2085 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2086 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2088 _textureQueryLevels(glsl_type::isampler1D_type
),
2089 _textureQueryLevels(glsl_type::isampler2D_type
),
2090 _textureQueryLevels(glsl_type::isampler3D_type
),
2091 _textureQueryLevels(glsl_type::isamplerCube_type
),
2092 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2093 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2094 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2096 _textureQueryLevels(glsl_type::usampler1D_type
),
2097 _textureQueryLevels(glsl_type::usampler2D_type
),
2098 _textureQueryLevels(glsl_type::usampler3D_type
),
2099 _textureQueryLevels(glsl_type::usamplerCube_type
),
2100 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2101 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2102 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2106 add_function("texture1D",
2107 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2108 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2111 add_function("texture1DArray",
2112 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2113 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2116 add_function("texture1DProj",
2117 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2118 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2119 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2120 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2123 add_function("texture1DLod",
2124 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2127 add_function("texture1DArrayLod",
2128 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2131 add_function("texture1DProjLod",
2132 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2133 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2136 add_function("texture2D",
2137 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2138 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2139 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2142 add_function("texture2DArray",
2143 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2144 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2147 add_function("texture2DProj",
2148 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2149 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2150 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2151 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2152 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2153 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2156 add_function("texture2DLod",
2157 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2160 add_function("texture2DArrayLod",
2161 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2164 add_function("texture2DProjLod",
2165 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2166 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2169 add_function("texture3D",
2170 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2171 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2174 add_function("texture3DProj",
2175 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2176 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2179 add_function("texture3DLod",
2180 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2183 add_function("texture3DProjLod",
2184 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2187 add_function("textureCube",
2188 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2189 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2192 add_function("textureCubeLod",
2193 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2196 add_function("texture2DRect",
2197 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2200 add_function("texture2DRectProj",
2201 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2202 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2205 add_function("shadow1D",
2206 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2207 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2210 add_function("shadow1DArray",
2211 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2212 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2215 add_function("shadow2D",
2216 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2217 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2220 add_function("shadow2DArray",
2221 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2222 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2225 add_function("shadow1DProj",
2226 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2227 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2230 add_function("shadow2DProj",
2231 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2232 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2235 add_function("shadow1DLod",
2236 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2239 add_function("shadow2DLod",
2240 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2243 add_function("shadow1DArrayLod",
2244 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2247 add_function("shadow1DProjLod",
2248 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2251 add_function("shadow2DProjLod",
2252 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2255 add_function("shadow2DRect",
2256 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2259 add_function("shadow2DRectProj",
2260 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2263 add_function("texture1DGradARB",
2264 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2267 add_function("texture1DProjGradARB",
2268 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2269 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2272 add_function("texture2DGradARB",
2273 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2276 add_function("texture2DProjGradARB",
2277 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2278 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2281 add_function("texture3DGradARB",
2282 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2285 add_function("texture3DProjGradARB",
2286 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2289 add_function("textureCubeGradARB",
2290 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2293 add_function("shadow1DGradARB",
2294 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2297 add_function("shadow1DProjGradARB",
2298 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2301 add_function("shadow2DGradARB",
2302 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2305 add_function("shadow2DProjGradARB",
2306 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2309 add_function("texture2DRectGradARB",
2310 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2313 add_function("texture2DRectProjGradARB",
2314 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2315 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2318 add_function("shadow2DRectGradARB",
2319 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2322 add_function("shadow2DRectProjGradARB",
2323 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2326 add_function("textureGather",
2327 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2328 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2329 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2331 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2332 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2333 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2335 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2336 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2337 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2339 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2340 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2341 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2343 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2344 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2345 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2347 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2348 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2349 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2351 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2352 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2353 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2355 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2356 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2357 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2359 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2360 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2361 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2363 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2364 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2365 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2367 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2368 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2369 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2370 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2371 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2374 add_function("textureGatherOffset",
2375 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2376 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2377 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2379 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2380 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2381 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2383 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2384 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2385 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2387 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2388 _texture(ir_tg4
, es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2389 _texture(ir_tg4
, es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2391 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2392 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2393 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2395 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2396 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2397 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2399 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2400 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2401 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2403 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2404 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2405 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2407 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2408 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2409 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2411 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2412 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2413 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2415 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2416 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2417 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2419 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2420 _texture(ir_tg4
, es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2423 add_function("textureGatherOffsets",
2424 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2425 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2426 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2428 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2429 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2430 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2432 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2433 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2434 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2436 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2437 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2438 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2440 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2441 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2442 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2444 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2445 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2446 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2448 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2449 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2450 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2475 add_function("ldexp",
2476 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2477 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2478 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2479 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2480 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2481 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2482 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2483 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2486 add_function("frexp",
2487 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2488 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2489 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2490 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2491 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2492 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2493 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2494 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2496 add_function("uaddCarry",
2497 _uaddCarry(glsl_type::uint_type
),
2498 _uaddCarry(glsl_type::uvec2_type
),
2499 _uaddCarry(glsl_type::uvec3_type
),
2500 _uaddCarry(glsl_type::uvec4_type
),
2502 add_function("usubBorrow",
2503 _usubBorrow(glsl_type::uint_type
),
2504 _usubBorrow(glsl_type::uvec2_type
),
2505 _usubBorrow(glsl_type::uvec3_type
),
2506 _usubBorrow(glsl_type::uvec4_type
),
2508 add_function("imulExtended",
2509 _mulExtended(glsl_type::int_type
),
2510 _mulExtended(glsl_type::ivec2_type
),
2511 _mulExtended(glsl_type::ivec3_type
),
2512 _mulExtended(glsl_type::ivec4_type
),
2514 add_function("umulExtended",
2515 _mulExtended(glsl_type::uint_type
),
2516 _mulExtended(glsl_type::uvec2_type
),
2517 _mulExtended(glsl_type::uvec3_type
),
2518 _mulExtended(glsl_type::uvec4_type
),
2520 add_function("interpolateAtCentroid",
2521 _interpolateAtCentroid(glsl_type::float_type
),
2522 _interpolateAtCentroid(glsl_type::vec2_type
),
2523 _interpolateAtCentroid(glsl_type::vec3_type
),
2524 _interpolateAtCentroid(glsl_type::vec4_type
),
2526 add_function("interpolateAtOffset",
2527 _interpolateAtOffset(glsl_type::float_type
),
2528 _interpolateAtOffset(glsl_type::vec2_type
),
2529 _interpolateAtOffset(glsl_type::vec3_type
),
2530 _interpolateAtOffset(glsl_type::vec4_type
),
2532 add_function("interpolateAtSample",
2533 _interpolateAtSample(glsl_type::float_type
),
2534 _interpolateAtSample(glsl_type::vec2_type
),
2535 _interpolateAtSample(glsl_type::vec3_type
),
2536 _interpolateAtSample(glsl_type::vec4_type
),
2539 add_function("atomicCounter",
2540 _atomic_op("__intrinsic_atomic_read",
2541 shader_atomic_counters
),
2543 add_function("atomicCounterIncrement",
2544 _atomic_op("__intrinsic_atomic_increment",
2545 shader_atomic_counters
),
2547 add_function("atomicCounterDecrement",
2548 _atomic_op("__intrinsic_atomic_predecrement",
2549 shader_atomic_counters
),
2552 add_function("min3",
2553 _min3(glsl_type::float_type
),
2554 _min3(glsl_type::vec2_type
),
2555 _min3(glsl_type::vec3_type
),
2556 _min3(glsl_type::vec4_type
),
2558 _min3(glsl_type::int_type
),
2559 _min3(glsl_type::ivec2_type
),
2560 _min3(glsl_type::ivec3_type
),
2561 _min3(glsl_type::ivec4_type
),
2563 _min3(glsl_type::uint_type
),
2564 _min3(glsl_type::uvec2_type
),
2565 _min3(glsl_type::uvec3_type
),
2566 _min3(glsl_type::uvec4_type
),
2569 add_function("max3",
2570 _max3(glsl_type::float_type
),
2571 _max3(glsl_type::vec2_type
),
2572 _max3(glsl_type::vec3_type
),
2573 _max3(glsl_type::vec4_type
),
2575 _max3(glsl_type::int_type
),
2576 _max3(glsl_type::ivec2_type
),
2577 _max3(glsl_type::ivec3_type
),
2578 _max3(glsl_type::ivec4_type
),
2580 _max3(glsl_type::uint_type
),
2581 _max3(glsl_type::uvec2_type
),
2582 _max3(glsl_type::uvec3_type
),
2583 _max3(glsl_type::uvec4_type
),
2586 add_function("mid3",
2587 _mid3(glsl_type::float_type
),
2588 _mid3(glsl_type::vec2_type
),
2589 _mid3(glsl_type::vec3_type
),
2590 _mid3(glsl_type::vec4_type
),
2592 _mid3(glsl_type::int_type
),
2593 _mid3(glsl_type::ivec2_type
),
2594 _mid3(glsl_type::ivec3_type
),
2595 _mid3(glsl_type::ivec4_type
),
2597 _mid3(glsl_type::uint_type
),
2598 _mid3(glsl_type::uvec2_type
),
2599 _mid3(glsl_type::uvec3_type
),
2600 _mid3(glsl_type::uvec4_type
),
2603 add_image_functions(true);
2605 add_function("memoryBarrier",
2606 _memory_barrier(shader_image_load_store
),
2617 builtin_builder::add_function(const char *name
, ...)
2621 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2625 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2631 stuff
.push_tail(sig
);
2632 validate_ir_tree(&stuff
);
2635 f
->add_signature(sig
);
2639 shader
->symbols
->add_function(f
);
2643 builtin_builder::add_image_function(const char *name
,
2644 const char *intrinsic_name
,
2645 image_prototype_ctr prototype
,
2646 unsigned num_arguments
,
2649 static const glsl_type
*const types
[] = {
2650 glsl_type::image1D_type
,
2651 glsl_type::image2D_type
,
2652 glsl_type::image3D_type
,
2653 glsl_type::image2DRect_type
,
2654 glsl_type::imageCube_type
,
2655 glsl_type::imageBuffer_type
,
2656 glsl_type::image1DArray_type
,
2657 glsl_type::image2DArray_type
,
2658 glsl_type::imageCubeArray_type
,
2659 glsl_type::image2DMS_type
,
2660 glsl_type::image2DMSArray_type
,
2661 glsl_type::iimage1D_type
,
2662 glsl_type::iimage2D_type
,
2663 glsl_type::iimage3D_type
,
2664 glsl_type::iimage2DRect_type
,
2665 glsl_type::iimageCube_type
,
2666 glsl_type::iimageBuffer_type
,
2667 glsl_type::iimage1DArray_type
,
2668 glsl_type::iimage2DArray_type
,
2669 glsl_type::iimageCubeArray_type
,
2670 glsl_type::iimage2DMS_type
,
2671 glsl_type::iimage2DMSArray_type
,
2672 glsl_type::uimage1D_type
,
2673 glsl_type::uimage2D_type
,
2674 glsl_type::uimage3D_type
,
2675 glsl_type::uimage2DRect_type
,
2676 glsl_type::uimageCube_type
,
2677 glsl_type::uimageBuffer_type
,
2678 glsl_type::uimage1DArray_type
,
2679 glsl_type::uimage2DArray_type
,
2680 glsl_type::uimageCubeArray_type
,
2681 glsl_type::uimage2DMS_type
,
2682 glsl_type::uimage2DMSArray_type
2685 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2687 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
2688 if (types
[i
]->sampler_type
!= GLSL_TYPE_FLOAT
||
2689 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
))
2690 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
2691 num_arguments
, flags
));
2694 shader
->symbols
->add_function(f
);
2698 builtin_builder::add_image_functions(bool glsl
)
2700 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
2702 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
2703 "__intrinsic_image_load",
2704 &builtin_builder::_image_prototype
, 0,
2705 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2706 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2707 IMAGE_FUNCTION_READ_ONLY
));
2709 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
2710 "__intrinsic_image_store",
2711 &builtin_builder::_image_prototype
, 1,
2712 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
2713 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
2714 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
2715 IMAGE_FUNCTION_WRITE_ONLY
));
2717 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
2719 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
2720 "__intrinsic_image_atomic_add",
2721 &builtin_builder::_image_prototype
, 1, atom_flags
);
2723 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
2724 "__intrinsic_image_atomic_min",
2725 &builtin_builder::_image_prototype
, 1, atom_flags
);
2727 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
2728 "__intrinsic_image_atomic_max",
2729 &builtin_builder::_image_prototype
, 1, atom_flags
);
2731 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
2732 "__intrinsic_image_atomic_and",
2733 &builtin_builder::_image_prototype
, 1, atom_flags
);
2735 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
2736 "__intrinsic_image_atomic_or",
2737 &builtin_builder::_image_prototype
, 1, atom_flags
);
2739 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
2740 "__intrinsic_image_atomic_xor",
2741 &builtin_builder::_image_prototype
, 1, atom_flags
);
2743 add_image_function((glsl
? "imageAtomicExchange" :
2744 "__intrinsic_image_atomic_exchange"),
2745 "__intrinsic_image_atomic_exchange",
2746 &builtin_builder::_image_prototype
, 1, atom_flags
);
2748 add_image_function((glsl
? "imageAtomicCompSwap" :
2749 "__intrinsic_image_atomic_comp_swap"),
2750 "__intrinsic_image_atomic_comp_swap",
2751 &builtin_builder::_image_prototype
, 2, atom_flags
);
2753 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
2754 "__intrinsic_image_size",
2755 &builtin_builder::_image_size_prototype
, 1,
2756 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
2760 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2762 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2766 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2768 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2772 builtin_builder::imm(float f
, unsigned vector_elements
)
2774 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2778 builtin_builder::imm(int i
, unsigned vector_elements
)
2780 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2784 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2786 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2790 builtin_builder::imm(double d
, unsigned vector_elements
)
2792 return new(mem_ctx
) ir_constant(d
, vector_elements
);
2796 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2798 return new(mem_ctx
) ir_constant(type
, &data
);
2801 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
2803 ir_dereference_variable
*
2804 builtin_builder::var_ref(ir_variable
*var
)
2806 return new(mem_ctx
) ir_dereference_variable(var
);
2809 ir_dereference_array
*
2810 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2812 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2815 /** Return an element of a matrix */
2817 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2819 return swizzle(array_ref(var
, column
), row
, 1);
2823 * Implementations of built-in functions:
2826 ir_function_signature
*
2827 builtin_builder::new_sig(const glsl_type
*return_type
,
2828 builtin_available_predicate avail
,
2834 ir_function_signature
*sig
=
2835 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2838 va_start(ap
, num_params
);
2839 for (int i
= 0; i
< num_params
; i
++) {
2840 plist
.push_tail(va_arg(ap
, ir_variable
*));
2844 sig
->replace_parameters(&plist
);
2848 #define MAKE_SIG(return_type, avail, ...) \
2849 ir_function_signature *sig = \
2850 new_sig(return_type, avail, __VA_ARGS__); \
2851 ir_factory body(&sig->body, mem_ctx); \
2852 sig->is_defined = true;
2854 #define MAKE_INTRINSIC(return_type, avail, ...) \
2855 ir_function_signature *sig = \
2856 new_sig(return_type, avail, __VA_ARGS__); \
2857 sig->is_intrinsic = true;
2859 ir_function_signature
*
2860 builtin_builder::unop(builtin_available_predicate avail
,
2861 ir_expression_operation opcode
,
2862 const glsl_type
*return_type
,
2863 const glsl_type
*param_type
)
2865 ir_variable
*x
= in_var(param_type
, "x");
2866 MAKE_SIG(return_type
, avail
, 1, x
);
2867 body
.emit(ret(expr(opcode
, x
)));
2871 #define UNOP(NAME, OPCODE, AVAIL) \
2872 ir_function_signature * \
2873 builtin_builder::_##NAME(const glsl_type *type) \
2875 return unop(&AVAIL, OPCODE, type, type); \
2878 #define UNOPA(NAME, OPCODE) \
2879 ir_function_signature * \
2880 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
2882 return unop(avail, OPCODE, type, type); \
2885 ir_function_signature
*
2886 builtin_builder::binop(ir_expression_operation opcode
,
2887 builtin_available_predicate avail
,
2888 const glsl_type
*return_type
,
2889 const glsl_type
*param0_type
,
2890 const glsl_type
*param1_type
)
2892 ir_variable
*x
= in_var(param0_type
, "x");
2893 ir_variable
*y
= in_var(param1_type
, "y");
2894 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2895 body
.emit(ret(expr(opcode
, x
, y
)));
2899 #define BINOP(NAME, OPCODE, AVAIL) \
2900 ir_function_signature * \
2901 builtin_builder::_##NAME(const glsl_type *return_type, \
2902 const glsl_type *param0_type, \
2903 const glsl_type *param1_type) \
2905 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2909 * Angle and Trigonometry Functions @{
2912 ir_function_signature
*
2913 builtin_builder::_radians(const glsl_type
*type
)
2915 ir_variable
*degrees
= in_var(type
, "degrees");
2916 MAKE_SIG(type
, always_available
, 1, degrees
);
2917 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2921 ir_function_signature
*
2922 builtin_builder::_degrees(const glsl_type
*type
)
2924 ir_variable
*radians
= in_var(type
, "radians");
2925 MAKE_SIG(type
, always_available
, 1, radians
);
2926 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2930 UNOP(sin
, ir_unop_sin
, always_available
)
2931 UNOP(cos
, ir_unop_cos
, always_available
)
2933 ir_function_signature
*
2934 builtin_builder::_tan(const glsl_type
*type
)
2936 ir_variable
*theta
= in_var(type
, "theta");
2937 MAKE_SIG(type
, always_available
, 1, theta
);
2938 body
.emit(ret(div(sin(theta
), cos(theta
))));
2943 builtin_builder::asin_expr(ir_variable
*x
)
2947 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2950 add(imm(M_PI_4f
- 1.0f
),
2952 add(imm(0.086566724f
),
2953 mul(abs(x
), imm(-0.03102955f
))))))))));
2957 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
2959 exec_list actual_params
;
2961 foreach_in_list(ir_variable
, var
, ¶ms
) {
2962 actual_params
.push_tail(var_ref(var
));
2965 ir_function_signature
*sig
=
2966 f
->exact_matching_signature(NULL
, &actual_params
);
2970 ir_dereference_variable
*deref
=
2971 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
2973 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
2976 ir_function_signature
*
2977 builtin_builder::_asin(const glsl_type
*type
)
2979 ir_variable
*x
= in_var(type
, "x");
2980 MAKE_SIG(type
, always_available
, 1, x
);
2982 body
.emit(ret(asin_expr(x
)));
2987 ir_function_signature
*
2988 builtin_builder::_acos(const glsl_type
*type
)
2990 ir_variable
*x
= in_var(type
, "x");
2991 MAKE_SIG(type
, always_available
, 1, x
);
2993 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
))));
2998 ir_function_signature
*
2999 builtin_builder::_atan2(const glsl_type
*type
)
3001 ir_variable
*vec_y
= in_var(type
, "vec_y");
3002 ir_variable
*vec_x
= in_var(type
, "vec_x");
3003 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3005 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3006 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3007 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3008 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3009 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3010 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3011 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3013 /* If |x| >= 1.0e-8 * |y|: */
3015 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3017 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3019 /* Then...call atan(y/x) */
3020 do_atan(body
, glsl_type::float_type
, r
, div(y
, x
));
3022 /* ...and fix it up: */
3023 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3024 inner_if
->then_instructions
.push_tail(
3025 if_tree(gequal(y
, imm(0.0f
)),
3026 assign(r
, add(r
, imm(M_PIf
))),
3027 assign(r
, sub(r
, imm(M_PIf
)))));
3028 outer_then
.emit(inner_if
);
3031 outer_if
->else_instructions
.push_tail(
3032 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3034 body
.emit(outer_if
);
3036 body
.emit(assign(vec_result
, r
, 1 << i
));
3038 body
.emit(ret(vec_result
));
3044 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3047 * range-reduction, first step:
3049 * / y_over_x if |y_over_x| <= 1.0;
3051 * \ 1.0 / y_over_x otherwise
3053 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3054 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3060 * approximate atan by evaluating polynomial:
3062 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3063 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3064 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3066 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3067 body
.emit(assign(tmp
, mul(x
, x
)));
3068 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3070 imm(0.0536813784310406f
)),
3072 imm(0.1173503194786851f
)),
3074 imm(0.1938924977115610f
)),
3076 imm(0.3326756418091246f
)),
3078 imm(0.9999793128310355f
)),
3081 /* range-reduction fixup */
3082 body
.emit(assign(tmp
, add(tmp
,
3083 mul(b2f(greater(abs(y_over_x
),
3084 imm(1.0f
, type
->components()))),
3090 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3093 ir_function_signature
*
3094 builtin_builder::_atan(const glsl_type
*type
)
3096 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3097 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3099 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3100 do_atan(body
, type
, tmp
, y_over_x
);
3101 body
.emit(ret(tmp
));
3106 ir_function_signature
*
3107 builtin_builder::_sinh(const glsl_type
*type
)
3109 ir_variable
*x
= in_var(type
, "x");
3110 MAKE_SIG(type
, v130
, 1, x
);
3112 /* 0.5 * (e^x - e^(-x)) */
3113 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3118 ir_function_signature
*
3119 builtin_builder::_cosh(const glsl_type
*type
)
3121 ir_variable
*x
= in_var(type
, "x");
3122 MAKE_SIG(type
, v130
, 1, x
);
3124 /* 0.5 * (e^x + e^(-x)) */
3125 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3130 ir_function_signature
*
3131 builtin_builder::_tanh(const glsl_type
*type
)
3133 ir_variable
*x
= in_var(type
, "x");
3134 MAKE_SIG(type
, v130
, 1, x
);
3136 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3137 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3138 add(exp(x
), exp(neg(x
))))));
3143 ir_function_signature
*
3144 builtin_builder::_asinh(const glsl_type
*type
)
3146 ir_variable
*x
= in_var(type
, "x");
3147 MAKE_SIG(type
, v130
, 1, x
);
3149 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3154 ir_function_signature
*
3155 builtin_builder::_acosh(const glsl_type
*type
)
3157 ir_variable
*x
= in_var(type
, "x");
3158 MAKE_SIG(type
, v130
, 1, x
);
3160 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3164 ir_function_signature
*
3165 builtin_builder::_atanh(const glsl_type
*type
)
3167 ir_variable
*x
= in_var(type
, "x");
3168 MAKE_SIG(type
, v130
, 1, x
);
3170 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3171 sub(imm(1.0f
), x
))))));
3177 * Exponential Functions @{
3180 ir_function_signature
*
3181 builtin_builder::_pow(const glsl_type
*type
)
3183 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
3186 UNOP(exp
, ir_unop_exp
, always_available
)
3187 UNOP(log
, ir_unop_log
, always_available
)
3188 UNOP(exp2
, ir_unop_exp2
, always_available
)
3189 UNOP(log2
, ir_unop_log2
, always_available
)
3190 UNOPA(sqrt
, ir_unop_sqrt
)
3191 UNOPA(inversesqrt
, ir_unop_rsq
)
3195 UNOPA(abs
, ir_unop_abs
)
3196 UNOPA(sign
, ir_unop_sign
)
3197 UNOPA(floor
, ir_unop_floor
)
3198 UNOPA(trunc
, ir_unop_trunc
)
3199 UNOPA(round
, ir_unop_round_even
)
3200 UNOPA(roundEven
, ir_unop_round_even
)
3201 UNOPA(ceil
, ir_unop_ceil
)
3202 UNOPA(fract
, ir_unop_fract
)
3204 ir_function_signature
*
3205 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
3207 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
3210 ir_function_signature
*
3211 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3213 ir_variable
*x
= in_var(type
, "x");
3214 ir_variable
*i
= out_var(type
, "i");
3215 MAKE_SIG(type
, avail
, 2, x
, i
);
3217 ir_variable
*t
= body
.make_temp(type
, "t");
3218 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3219 body
.emit(assign(i
, t
));
3220 body
.emit(ret(sub(x
, t
)));
3225 ir_function_signature
*
3226 builtin_builder::_min(builtin_available_predicate avail
,
3227 const glsl_type
*x_type
, const glsl_type
*y_type
)
3229 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
3232 ir_function_signature
*
3233 builtin_builder::_max(builtin_available_predicate avail
,
3234 const glsl_type
*x_type
, const glsl_type
*y_type
)
3236 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
3239 ir_function_signature
*
3240 builtin_builder::_clamp(builtin_available_predicate avail
,
3241 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3243 ir_variable
*x
= in_var(val_type
, "x");
3244 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3245 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3246 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3248 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3253 ir_function_signature
*
3254 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3256 ir_variable
*x
= in_var(val_type
, "x");
3257 ir_variable
*y
= in_var(val_type
, "y");
3258 ir_variable
*a
= in_var(blend_type
, "a");
3259 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3261 body
.emit(ret(lrp(x
, y
, a
)));
3266 ir_function_signature
*
3267 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3268 const glsl_type
*val_type
,
3269 const glsl_type
*blend_type
)
3271 ir_variable
*x
= in_var(val_type
, "x");
3272 ir_variable
*y
= in_var(val_type
, "y");
3273 ir_variable
*a
= in_var(blend_type
, "a");
3274 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3276 /* csel matches the ternary operator in that a selector of true choses the
3277 * first argument. This differs from mix(x, y, false) which choses the
3278 * second argument (to remain consistent with the interpolating version of
3279 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3281 * To handle the behavior mismatch, reverse the x and y arguments.
3283 body
.emit(ret(csel(a
, y
, x
)));
3288 ir_function_signature
*
3289 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3291 ir_variable
*edge
= in_var(edge_type
, "edge");
3292 ir_variable
*x
= in_var(x_type
, "x");
3293 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3295 ir_variable
*t
= body
.make_temp(x_type
, "t");
3296 if (x_type
->vector_elements
== 1) {
3297 /* Both are floats */
3298 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3299 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3301 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3302 } else if (edge_type
->vector_elements
== 1) {
3303 /* x is a vector but edge is a float */
3304 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3305 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3306 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3308 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3311 /* Both are vectors */
3312 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3313 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3314 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3317 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3327 ir_function_signature
*
3328 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3330 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3331 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3332 ir_variable
*x
= in_var(x_type
, "x");
3333 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3335 /* From the GLSL 1.10 specification:
3338 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3339 * return t * t * (3 - 2 * t);
3342 ir_variable
*t
= body
.make_temp(x_type
, "t");
3343 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3344 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3346 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3351 ir_function_signature
*
3352 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3354 ir_variable
*x
= in_var(type
, "x");
3355 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3357 body
.emit(ret(nequal(x
, x
)));
3362 ir_function_signature
*
3363 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3365 ir_variable
*x
= in_var(type
, "x");
3366 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3368 ir_constant_data infinities
;
3369 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3370 infinities
.f
[i
] = INFINITY
;
3373 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3378 ir_function_signature
*
3379 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3381 ir_variable
*x
= in_var(type
, "x");
3382 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3383 body
.emit(ret(bitcast_f2i(x
)));
3387 ir_function_signature
*
3388 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3390 ir_variable
*x
= in_var(type
, "x");
3391 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3392 body
.emit(ret(bitcast_f2u(x
)));
3396 ir_function_signature
*
3397 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3399 ir_variable
*x
= in_var(type
, "x");
3400 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3401 body
.emit(ret(bitcast_i2f(x
)));
3405 ir_function_signature
*
3406 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3408 ir_variable
*x
= in_var(type
, "x");
3409 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3410 body
.emit(ret(bitcast_u2f(x
)));
3414 ir_function_signature
*
3415 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3417 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3418 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3419 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3423 ir_function_signature
*
3424 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3426 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3427 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3428 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3432 ir_function_signature
*
3433 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3435 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3436 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3437 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3441 ir_function_signature
*
3442 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3444 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3445 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3446 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3450 ir_function_signature
*
3451 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3453 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3454 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3455 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3459 ir_function_signature
*
3460 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3462 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3463 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3464 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3469 ir_function_signature
*
3470 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3472 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3473 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3474 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3478 ir_function_signature
*
3479 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3481 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3482 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3483 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3487 ir_function_signature
*
3488 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3490 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3491 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3492 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3496 ir_function_signature
*
3497 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3499 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3500 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3501 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3505 ir_function_signature
*
3506 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3508 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3509 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3510 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3514 ir_function_signature
*
3515 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3517 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3518 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3519 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3523 ir_function_signature
*
3524 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3526 ir_variable
*x
= in_var(type
, "x");
3527 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3529 body
.emit(ret(sqrt(dot(x
, x
))));
3534 ir_function_signature
*
3535 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3537 ir_variable
*p0
= in_var(type
, "p0");
3538 ir_variable
*p1
= in_var(type
, "p1");
3539 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3541 if (type
->vector_elements
== 1) {
3542 body
.emit(ret(abs(sub(p0
, p1
))));
3544 ir_variable
*p
= body
.make_temp(type
, "p");
3545 body
.emit(assign(p
, sub(p0
, p1
)));
3546 body
.emit(ret(sqrt(dot(p
, p
))));
3552 ir_function_signature
*
3553 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3555 if (type
->vector_elements
== 1)
3556 return binop(ir_binop_mul
, avail
, type
, type
, type
);
3558 return binop(ir_binop_dot
, avail
,
3559 type
->get_base_type(), type
, type
);
3562 ir_function_signature
*
3563 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3565 ir_variable
*a
= in_var(type
, "a");
3566 ir_variable
*b
= in_var(type
, "b");
3567 MAKE_SIG(type
, avail
, 2, a
, b
);
3569 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3570 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3572 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3573 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3578 ir_function_signature
*
3579 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3581 ir_variable
*x
= in_var(type
, "x");
3582 MAKE_SIG(type
, avail
, 1, x
);
3584 if (type
->vector_elements
== 1) {
3585 body
.emit(ret(sign(x
)));
3587 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3593 ir_function_signature
*
3594 builtin_builder::_ftransform()
3596 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3598 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3599 glsl_type::vec4_type
,
3600 var_ref(gl_ModelViewProjectionMatrix
),
3601 var_ref(gl_Vertex
))));
3603 /* FINISHME: Once the ir_expression() constructor handles type inference
3604 * for matrix operations, we can simplify this to:
3606 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3611 ir_function_signature
*
3612 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3614 ir_variable
*N
= in_var(type
, "N");
3615 ir_variable
*I
= in_var(type
, "I");
3616 ir_variable
*Nref
= in_var(type
, "Nref");
3617 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3619 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3620 ret(N
), ret(neg(N
))));
3625 ir_function_signature
*
3626 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3628 ir_variable
*I
= in_var(type
, "I");
3629 ir_variable
*N
= in_var(type
, "N");
3630 MAKE_SIG(type
, avail
, 2, I
, N
);
3632 /* I - 2 * dot(N, I) * N */
3633 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3638 ir_function_signature
*
3639 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3641 ir_variable
*I
= in_var(type
, "I");
3642 ir_variable
*N
= in_var(type
, "N");
3643 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3644 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3646 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3647 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3649 /* From the GLSL 1.10 specification:
3650 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3652 * return genType(0.0)
3654 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
3656 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
3657 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
3658 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
3659 mul(n_dot_i
, n_dot_i
)))))));
3660 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
3661 ret(ir_constant::zero(mem_ctx
, type
)),
3662 ret(sub(mul(eta
, I
),
3663 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
3668 ir_function_signature
*
3669 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
3671 ir_variable
*x
= in_var(type
, "x");
3672 ir_variable
*y
= in_var(type
, "y");
3673 MAKE_SIG(type
, avail
, 2, x
, y
);
3675 ir_variable
*z
= body
.make_temp(type
, "z");
3676 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3677 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
3684 ir_function_signature
*
3685 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
3690 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
3691 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
3692 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
3694 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
3695 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
3697 MAKE_SIG(type
, avail
, 2, c
, r
);
3699 ir_variable
*m
= body
.make_temp(type
, "m");
3700 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
3701 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
3708 ir_function_signature
*
3709 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
3711 const glsl_type
*transpose_type
=
3712 glsl_type::get_instance(orig_type
->base_type
,
3713 orig_type
->matrix_columns
,
3714 orig_type
->vector_elements
);
3716 ir_variable
*m
= in_var(orig_type
, "m");
3717 MAKE_SIG(transpose_type
, avail
, 1, m
);
3719 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
3720 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
3721 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
3722 body
.emit(assign(array_ref(t
, j
),
3723 matrix_elt(m
, i
, j
),
3732 ir_function_signature
*
3733 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3735 ir_variable
*m
= in_var(type
, "m");
3736 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3738 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3739 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
3744 ir_function_signature
*
3745 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3747 ir_variable
*m
= in_var(type
, "m");
3748 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
3751 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3752 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
3755 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3756 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
3759 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3760 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
3762 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
3763 mul(matrix_elt(m
, 0, 1), f2
)),
3764 mul(matrix_elt(m
, 0, 2), f3
))));
3769 ir_function_signature
*
3770 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3772 ir_variable
*m
= in_var(type
, "m");
3773 const glsl_type
*btype
= type
->get_base_type();
3774 MAKE_SIG(btype
, avail
, 1, m
);
3776 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3777 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3778 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3779 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3780 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3781 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3782 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3783 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3784 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3785 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3786 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3787 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3788 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3789 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3790 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3791 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3792 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3793 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3794 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3796 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)))));
3797 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)))));
3798 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)))));
3799 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)))));
3800 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)))));
3801 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)))));
3802 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)))));
3803 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)))));
3804 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)))));
3805 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)))));
3806 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)))));
3807 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)))));
3808 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)))));
3809 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)))));
3810 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)))));
3811 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)))));
3812 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)))));
3813 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)))));
3814 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)))));
3816 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
3818 body
.emit(assign(adj_0
,
3819 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3820 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3821 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3823 body
.emit(assign(adj_0
, neg(
3824 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3825 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3826 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3828 body
.emit(assign(adj_0
,
3829 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3830 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3831 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3833 body
.emit(assign(adj_0
, neg(
3834 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3835 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3836 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3839 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3844 ir_function_signature
*
3845 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
3847 ir_variable
*m
= in_var(type
, "m");
3848 MAKE_SIG(type
, avail
, 1, m
);
3850 ir_variable
*adj
= body
.make_temp(type
, "adj");
3851 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3852 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3853 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3854 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3856 ir_expression
*det
=
3857 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3858 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3860 body
.emit(ret(div(adj
, det
)));
3864 ir_function_signature
*
3865 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
3867 ir_variable
*m
= in_var(type
, "m");
3868 const glsl_type
*btype
= type
->get_base_type();
3869 MAKE_SIG(type
, avail
, 1, m
);
3871 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
3872 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
3873 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
3875 body
.emit(assign(f11_22_21_12
,
3876 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3877 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3878 body
.emit(assign(f10_22_20_12
,
3879 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3880 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3881 body
.emit(assign(f10_21_20_11
,
3882 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3883 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3885 ir_variable
*adj
= body
.make_temp(type
, "adj");
3886 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3887 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3888 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3890 body
.emit(assign(array_ref(adj
, 0), neg(
3891 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3892 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3894 body
.emit(assign(array_ref(adj
, 1),
3895 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3896 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3898 body
.emit(assign(array_ref(adj
, 2), neg(
3899 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3900 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3903 body
.emit(assign(array_ref(adj
, 0),
3904 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3905 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3907 body
.emit(assign(array_ref(adj
, 1), neg(
3908 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3909 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3911 body
.emit(assign(array_ref(adj
, 2),
3912 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3913 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3916 ir_expression
*det
=
3917 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3918 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3919 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3921 body
.emit(ret(div(adj
, det
)));
3926 ir_function_signature
*
3927 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
3929 ir_variable
*m
= in_var(type
, "m");
3930 const glsl_type
*btype
= type
->get_base_type();
3931 MAKE_SIG(type
, avail
, 1, m
);
3933 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
3934 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
3935 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
3936 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
3937 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
3938 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
3939 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
3940 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
3941 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
3942 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
3943 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
3944 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
3945 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
3946 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
3947 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
3948 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
3949 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
3950 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
3951 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
3953 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)))));
3954 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)))));
3955 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)))));
3956 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)))));
3957 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)))));
3958 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)))));
3959 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)))));
3960 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)))));
3961 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)))));
3962 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)))));
3963 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)))));
3964 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)))));
3965 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)))));
3966 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)))));
3967 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)))));
3968 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)))));
3969 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)))));
3970 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)))));
3971 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)))));
3973 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
3974 body
.emit(assign(array_ref(adj
, 0),
3975 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3976 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3977 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3979 body
.emit(assign(array_ref(adj
, 1), neg(
3980 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3981 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3982 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3984 body
.emit(assign(array_ref(adj
, 2),
3985 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3986 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3987 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3989 body
.emit(assign(array_ref(adj
, 3), neg(
3990 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3991 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3992 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3995 body
.emit(assign(array_ref(adj
, 0), neg(
3996 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3997 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3998 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4000 body
.emit(assign(array_ref(adj
, 1),
4001 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4002 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4003 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4005 body
.emit(assign(array_ref(adj
, 2), neg(
4006 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4007 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4008 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4010 body
.emit(assign(array_ref(adj
, 3),
4011 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4012 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4013 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4016 body
.emit(assign(array_ref(adj
, 0),
4017 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4018 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4019 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4021 body
.emit(assign(array_ref(adj
, 1), neg(
4022 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4023 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4024 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4026 body
.emit(assign(array_ref(adj
, 2),
4027 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4028 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4029 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4031 body
.emit(assign(array_ref(adj
, 3), neg(
4032 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4033 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4034 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4037 body
.emit(assign(array_ref(adj
, 0), neg(
4038 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4039 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4040 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4042 body
.emit(assign(array_ref(adj
, 1),
4043 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4044 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4045 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4047 body
.emit(assign(array_ref(adj
, 2), neg(
4048 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4049 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4050 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4052 body
.emit(assign(array_ref(adj
, 3),
4053 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4054 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4055 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4058 ir_expression
*det
=
4059 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4060 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4061 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4062 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4064 body
.emit(ret(div(adj
, det
)));
4070 ir_function_signature
*
4071 builtin_builder::_lessThan(builtin_available_predicate avail
,
4072 const glsl_type
*type
)
4074 return binop(ir_binop_less
, avail
,
4075 glsl_type::bvec(type
->vector_elements
), type
, type
);
4078 ir_function_signature
*
4079 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4080 const glsl_type
*type
)
4082 return binop(ir_binop_lequal
, avail
,
4083 glsl_type::bvec(type
->vector_elements
), type
, type
);
4086 ir_function_signature
*
4087 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4088 const glsl_type
*type
)
4090 return binop(ir_binop_greater
, avail
,
4091 glsl_type::bvec(type
->vector_elements
), type
, type
);
4094 ir_function_signature
*
4095 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4096 const glsl_type
*type
)
4098 return binop(ir_binop_gequal
, avail
,
4099 glsl_type::bvec(type
->vector_elements
), type
, type
);
4102 ir_function_signature
*
4103 builtin_builder::_equal(builtin_available_predicate avail
,
4104 const glsl_type
*type
)
4106 return binop(ir_binop_equal
, avail
,
4107 glsl_type::bvec(type
->vector_elements
), type
, type
);
4110 ir_function_signature
*
4111 builtin_builder::_notEqual(builtin_available_predicate avail
,
4112 const glsl_type
*type
)
4114 return binop(ir_binop_nequal
, avail
,
4115 glsl_type::bvec(type
->vector_elements
), type
, type
);
4118 ir_function_signature
*
4119 builtin_builder::_any(const glsl_type
*type
)
4121 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
4124 ir_function_signature
*
4125 builtin_builder::_all(const glsl_type
*type
)
4127 ir_variable
*v
= in_var(type
, "v");
4128 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4130 switch (type
->vector_elements
) {
4132 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
4135 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4139 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
4148 UNOP(not, ir_unop_logic_not
, always_available
)
4151 has_lod(const glsl_type
*sampler_type
)
4153 assert(sampler_type
->is_sampler());
4155 switch (sampler_type
->sampler_dimensionality
) {
4156 case GLSL_SAMPLER_DIM_RECT
:
4157 case GLSL_SAMPLER_DIM_BUF
:
4158 case GLSL_SAMPLER_DIM_MS
:
4165 ir_function_signature
*
4166 builtin_builder::_textureSize(builtin_available_predicate avail
,
4167 const glsl_type
*return_type
,
4168 const glsl_type
*sampler_type
)
4170 ir_variable
*s
= in_var(sampler_type
, "sampler");
4171 /* The sampler always exists; add optional lod later. */
4172 MAKE_SIG(return_type
, avail
, 1, s
);
4174 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4175 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4177 if (has_lod(sampler_type
)) {
4178 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4179 sig
->parameters
.push_tail(lod
);
4180 tex
->lod_info
.lod
= var_ref(lod
);
4182 tex
->lod_info
.lod
= imm(0u);
4185 body
.emit(ret(tex
));
4190 ir_function_signature
*
4191 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4193 ir_variable
*s
= in_var(sampler_type
, "sampler");
4194 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4196 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4197 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4198 body
.emit(ret(tex
));
4203 ir_function_signature
*
4204 builtin_builder::_texture(ir_texture_opcode opcode
,
4205 builtin_available_predicate avail
,
4206 const glsl_type
*return_type
,
4207 const glsl_type
*sampler_type
,
4208 const glsl_type
*coord_type
,
4211 ir_variable
*s
= in_var(sampler_type
, "sampler");
4212 ir_variable
*P
= in_var(coord_type
, "P");
4213 /* The sampler and coordinate always exist; add optional parameters later. */
4214 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4216 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4217 tex
->set_sampler(var_ref(s
), return_type
);
4219 const int coord_size
= sampler_type
->coordinate_components();
4221 if (coord_size
== coord_type
->vector_elements
) {
4222 tex
->coordinate
= var_ref(P
);
4224 /* The incoming coordinate also has the projector or shadow comparitor,
4225 * so we need to swizzle those away.
4227 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4230 /* The projector is always in the last component. */
4231 if (flags
& TEX_PROJECT
)
4232 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4234 if (sampler_type
->sampler_shadow
) {
4235 if (opcode
== ir_tg4
) {
4236 /* gather has refz as a separate parameter, immediately after the
4239 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4240 sig
->parameters
.push_tail(refz
);
4241 tex
->shadow_comparitor
= var_ref(refz
);
4243 /* The shadow comparitor is normally in the Z component, but a few types
4244 * have sufficiently large coordinates that it's in W.
4246 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4250 if (opcode
== ir_txl
) {
4251 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4252 sig
->parameters
.push_tail(lod
);
4253 tex
->lod_info
.lod
= var_ref(lod
);
4254 } else if (opcode
== ir_txd
) {
4255 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4256 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4257 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4258 sig
->parameters
.push_tail(dPdx
);
4259 sig
->parameters
.push_tail(dPdy
);
4260 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4261 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4264 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4265 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4266 ir_variable
*offset
=
4267 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4268 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4269 sig
->parameters
.push_tail(offset
);
4270 tex
->offset
= var_ref(offset
);
4273 if (flags
& TEX_OFFSET_ARRAY
) {
4274 ir_variable
*offsets
=
4275 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4276 "offsets", ir_var_const_in
);
4277 sig
->parameters
.push_tail(offsets
);
4278 tex
->offset
= var_ref(offsets
);
4281 if (opcode
== ir_tg4
) {
4282 if (flags
& TEX_COMPONENT
) {
4283 ir_variable
*component
=
4284 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4285 sig
->parameters
.push_tail(component
);
4286 tex
->lod_info
.component
= var_ref(component
);
4289 tex
->lod_info
.component
= imm(0);
4293 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4294 * inconsistent with both textureLodOffset and textureGradOffset.
4296 if (opcode
== ir_txb
) {
4297 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4298 sig
->parameters
.push_tail(bias
);
4299 tex
->lod_info
.bias
= var_ref(bias
);
4302 body
.emit(ret(tex
));
4307 ir_function_signature
*
4308 builtin_builder::_textureCubeArrayShadow()
4310 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4311 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4312 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4313 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4315 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4316 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4318 tex
->coordinate
= var_ref(P
);
4319 tex
->shadow_comparitor
= var_ref(compare
);
4321 body
.emit(ret(tex
));
4326 ir_function_signature
*
4327 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4328 const glsl_type
*return_type
,
4329 const glsl_type
*sampler_type
,
4330 const glsl_type
*coord_type
,
4331 const glsl_type
*offset_type
)
4333 ir_variable
*s
= in_var(sampler_type
, "sampler");
4334 ir_variable
*P
= in_var(coord_type
, "P");
4335 /* The sampler and coordinate always exist; add optional parameters later. */
4336 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4338 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4339 tex
->coordinate
= var_ref(P
);
4340 tex
->set_sampler(var_ref(s
), return_type
);
4342 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4343 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4344 sig
->parameters
.push_tail(sample
);
4345 tex
->lod_info
.sample_index
= var_ref(sample
);
4346 tex
->op
= ir_txf_ms
;
4347 } else if (has_lod(sampler_type
)) {
4348 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4349 sig
->parameters
.push_tail(lod
);
4350 tex
->lod_info
.lod
= var_ref(lod
);
4352 tex
->lod_info
.lod
= imm(0u);
4355 if (offset_type
!= NULL
) {
4356 ir_variable
*offset
=
4357 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4358 sig
->parameters
.push_tail(offset
);
4359 tex
->offset
= var_ref(offset
);
4362 body
.emit(ret(tex
));
4367 ir_function_signature
*
4368 builtin_builder::_EmitVertex()
4370 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4372 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4373 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4378 ir_function_signature
*
4379 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4380 const glsl_type
*stream_type
)
4382 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4384 * "Emit the current values of output variables to the current output
4385 * primitive on stream stream. The argument to stream must be a constant
4386 * integral expression."
4388 ir_variable
*stream
=
4389 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4391 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4393 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4398 ir_function_signature
*
4399 builtin_builder::_EndPrimitive()
4401 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4403 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4404 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4409 ir_function_signature
*
4410 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4411 const glsl_type
*stream_type
)
4413 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4415 * "Completes the current output primitive on stream stream and starts
4416 * a new one. The argument to stream must be a constant integral
4419 ir_variable
*stream
=
4420 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4422 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4424 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4429 ir_function_signature
*
4430 builtin_builder::_barrier()
4432 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4434 body
.emit(new(mem_ctx
) ir_barrier());
4438 ir_function_signature
*
4439 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4440 const glsl_type
*sampler_type
,
4441 const glsl_type
*coord_type
)
4443 ir_variable
*s
= in_var(sampler_type
, "sampler");
4444 ir_variable
*coord
= in_var(coord_type
, "coord");
4445 /* The sampler and coordinate always exist; add optional parameters later. */
4446 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4448 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4449 tex
->coordinate
= var_ref(coord
);
4450 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4452 body
.emit(ret(tex
));
4457 ir_function_signature
*
4458 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4460 ir_variable
*s
= in_var(sampler_type
, "sampler");
4461 const glsl_type
*return_type
= glsl_type::int_type
;
4462 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4464 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4465 tex
->set_sampler(var_ref(s
), return_type
);
4467 body
.emit(ret(tex
));
4472 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4473 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4474 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4475 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4476 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4477 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4479 ir_function_signature
*
4480 builtin_builder::_fwidth(const glsl_type
*type
)
4482 ir_variable
*p
= in_var(type
, "p");
4483 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4485 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4490 ir_function_signature
*
4491 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4493 ir_variable
*p
= in_var(type
, "p");
4494 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4496 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4497 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4502 ir_function_signature
*
4503 builtin_builder::_fwidthFine(const glsl_type
*type
)
4505 ir_variable
*p
= in_var(type
, "p");
4506 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4508 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4509 abs(expr(ir_unop_dFdy_fine
, p
)))));
4514 ir_function_signature
*
4515 builtin_builder::_noise1(const glsl_type
*type
)
4517 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4520 ir_function_signature
*
4521 builtin_builder::_noise2(const glsl_type
*type
)
4523 ir_variable
*p
= in_var(type
, "p");
4524 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4526 ir_constant_data b_offset
;
4527 b_offset
.f
[0] = 601.0f
;
4528 b_offset
.f
[1] = 313.0f
;
4529 b_offset
.f
[2] = 29.0f
;
4530 b_offset
.f
[3] = 277.0f
;
4532 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4533 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4534 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4535 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4536 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4537 body
.emit(assign(t
, a
, WRITEMASK_X
));
4538 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4544 ir_function_signature
*
4545 builtin_builder::_noise3(const glsl_type
*type
)
4547 ir_variable
*p
= in_var(type
, "p");
4548 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4550 ir_constant_data b_offset
;
4551 b_offset
.f
[0] = 601.0f
;
4552 b_offset
.f
[1] = 313.0f
;
4553 b_offset
.f
[2] = 29.0f
;
4554 b_offset
.f
[3] = 277.0f
;
4556 ir_constant_data c_offset
;
4557 c_offset
.f
[0] = 1559.0f
;
4558 c_offset
.f
[1] = 113.0f
;
4559 c_offset
.f
[2] = 1861.0f
;
4560 c_offset
.f
[3] = 797.0f
;
4562 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4563 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4564 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4565 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4566 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4567 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4568 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4569 body
.emit(assign(t
, a
, WRITEMASK_X
));
4570 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4571 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4577 ir_function_signature
*
4578 builtin_builder::_noise4(const glsl_type
*type
)
4580 ir_variable
*p
= in_var(type
, "p");
4581 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4583 ir_variable
*_p
= body
.make_temp(type
, "_p");
4585 ir_constant_data p_offset
;
4586 p_offset
.f
[0] = 1559.0f
;
4587 p_offset
.f
[1] = 113.0f
;
4588 p_offset
.f
[2] = 1861.0f
;
4589 p_offset
.f
[3] = 797.0f
;
4591 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4593 ir_constant_data offset
;
4594 offset
.f
[0] = 601.0f
;
4595 offset
.f
[1] = 313.0f
;
4596 offset
.f
[2] = 29.0f
;
4597 offset
.f
[3] = 277.0f
;
4599 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4600 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4601 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4602 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4603 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4604 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4605 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4606 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4607 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4608 body
.emit(assign(t
, a
, WRITEMASK_X
));
4609 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4610 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4611 body
.emit(assign(t
, d
, WRITEMASK_W
));
4617 ir_function_signature
*
4618 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4620 ir_variable
*value
= in_var(type
, "value");
4621 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4622 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4623 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4625 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
4630 ir_function_signature
*
4631 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4633 ir_variable
*base
= in_var(type
, "base");
4634 ir_variable
*insert
= in_var(type
, "insert");
4635 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4636 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4637 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
4639 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
4644 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
4646 ir_function_signature
*
4647 builtin_builder::_bitCount(const glsl_type
*type
)
4649 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
4650 glsl_type::ivec(type
->vector_elements
), type
);
4653 ir_function_signature
*
4654 builtin_builder::_findLSB(const glsl_type
*type
)
4656 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
4657 glsl_type::ivec(type
->vector_elements
), type
);
4660 ir_function_signature
*
4661 builtin_builder::_findMSB(const glsl_type
*type
)
4663 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
4664 glsl_type::ivec(type
->vector_elements
), type
);
4667 ir_function_signature
*
4668 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
4670 ir_variable
*a
= in_var(type
, "a");
4671 ir_variable
*b
= in_var(type
, "b");
4672 ir_variable
*c
= in_var(type
, "c");
4673 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
4675 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
4680 ir_function_signature
*
4681 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4683 return binop(ir_binop_ldexp
, x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
, x_type
, x_type
, exp_type
);
4686 ir_function_signature
*
4687 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4689 ir_variable
*x
= in_var(x_type
, "x");
4690 ir_variable
*exponent
= out_var(exp_type
, "exp");
4691 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
4693 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
4695 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
4699 ir_function_signature
*
4700 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
4702 ir_variable
*x
= in_var(x_type
, "x");
4703 ir_variable
*exponent
= out_var(exp_type
, "exp");
4704 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
4706 const unsigned vec_elem
= x_type
->vector_elements
;
4707 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
4708 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
4710 /* Single-precision floating-point values are stored as
4715 * An exponent shift of 23 will shift the mantissa out, leaving only the
4716 * exponent and sign bit (which itself may be zero, if the absolute value
4717 * was taken before the bitcast and shift.
4719 ir_constant
*exponent_shift
= imm(23);
4720 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
4722 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
4724 /* Exponent of floating-point values in the range [0.5, 1.0). */
4725 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
4727 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
4728 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
4730 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
4731 * to unsigned integers to ensure that 1 bits aren't shifted in.
4733 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
4734 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
4735 imm(0, vec_elem
)))));
4737 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
4738 body
.emit(assign(bits
, bitcast_f2u(x
)));
4739 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
4740 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
4741 imm(0u, vec_elem
)))));
4742 body
.emit(ret(bitcast_u2f(bits
)));
4747 ir_function_signature
*
4748 builtin_builder::_uaddCarry(const glsl_type
*type
)
4750 ir_variable
*x
= in_var(type
, "x");
4751 ir_variable
*y
= in_var(type
, "y");
4752 ir_variable
*carry
= out_var(type
, "carry");
4753 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
4755 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
4756 body
.emit(ret(add(x
, y
)));
4761 ir_function_signature
*
4762 builtin_builder::_usubBorrow(const glsl_type
*type
)
4764 ir_variable
*x
= in_var(type
, "x");
4765 ir_variable
*y
= in_var(type
, "y");
4766 ir_variable
*borrow
= out_var(type
, "borrow");
4767 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
4769 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
4770 body
.emit(ret(sub(x
, y
)));
4776 * For both imulExtended() and umulExtended() built-ins.
4778 ir_function_signature
*
4779 builtin_builder::_mulExtended(const glsl_type
*type
)
4781 ir_variable
*x
= in_var(type
, "x");
4782 ir_variable
*y
= in_var(type
, "y");
4783 ir_variable
*msb
= out_var(type
, "msb");
4784 ir_variable
*lsb
= out_var(type
, "lsb");
4785 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
4787 body
.emit(assign(msb
, imul_high(x
, y
)));
4788 body
.emit(assign(lsb
, mul(x
, y
)));
4793 ir_function_signature
*
4794 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
4796 ir_variable
*interpolant
= in_var(type
, "interpolant");
4797 interpolant
->data
.must_be_shader_input
= 1;
4798 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
4800 body
.emit(ret(interpolate_at_centroid(interpolant
)));
4805 ir_function_signature
*
4806 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
4808 ir_variable
*interpolant
= in_var(type
, "interpolant");
4809 interpolant
->data
.must_be_shader_input
= 1;
4810 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
4811 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
4813 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
4818 ir_function_signature
*
4819 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
4821 ir_variable
*interpolant
= in_var(type
, "interpolant");
4822 interpolant
->data
.must_be_shader_input
= 1;
4823 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
4824 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
4826 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
4831 ir_function_signature
*
4832 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail
)
4834 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
4835 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
4839 ir_function_signature
*
4840 builtin_builder::_atomic_op(const char *intrinsic
,
4841 builtin_available_predicate avail
)
4843 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
4844 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
4846 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
4847 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
4849 body
.emit(ret(retval
));
4853 ir_function_signature
*
4854 builtin_builder::_min3(const glsl_type
*type
)
4856 ir_variable
*x
= in_var(type
, "x");
4857 ir_variable
*y
= in_var(type
, "y");
4858 ir_variable
*z
= in_var(type
, "z");
4859 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4861 ir_expression
*min3
= min2(x
, min2(y
,z
));
4862 body
.emit(ret(min3
));
4867 ir_function_signature
*
4868 builtin_builder::_max3(const glsl_type
*type
)
4870 ir_variable
*x
= in_var(type
, "x");
4871 ir_variable
*y
= in_var(type
, "y");
4872 ir_variable
*z
= in_var(type
, "z");
4873 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4875 ir_expression
*max3
= max2(x
, max2(y
,z
));
4876 body
.emit(ret(max3
));
4881 ir_function_signature
*
4882 builtin_builder::_mid3(const glsl_type
*type
)
4884 ir_variable
*x
= in_var(type
, "x");
4885 ir_variable
*y
= in_var(type
, "y");
4886 ir_variable
*z
= in_var(type
, "z");
4887 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
4889 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
4890 body
.emit(ret(mid3
));
4895 ir_function_signature
*
4896 builtin_builder::_image_prototype(const glsl_type
*image_type
,
4897 unsigned num_arguments
,
4900 const glsl_type
*data_type
= glsl_type::get_instance(
4901 image_type
->sampler_type
,
4902 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
4904 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
4905 glsl_type::void_type
: data_type
);
4907 /* Addressing arguments that are always present. */
4908 ir_variable
*image
= in_var(image_type
, "image");
4909 ir_variable
*coord
= in_var(
4910 glsl_type::ivec(image_type
->coordinate_components()), "coord");
4912 const builtin_available_predicate avail
=
4913 (flags
& IMAGE_FUNCTION_AVAIL_ATOMIC
? shader_image_atomic
:
4914 shader_image_load_store
);
4915 ir_function_signature
*sig
= new_sig(ret_type
, avail
, 2, image
, coord
);
4917 /* Sample index for multisample images. */
4918 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
4919 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
4921 /* Data arguments. */
4922 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
4923 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
4924 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
4925 ralloc_free(arg_name
);
4928 /* Set the maximal set of qualifiers allowed for this image
4929 * built-in. Function calls with arguments having fewer
4930 * qualifiers than present in the prototype are allowed by the
4931 * spec, but not with more, i.e. this will make the compiler
4932 * accept everything that needs to be accepted, and reject cases
4933 * like loads from write-only or stores to read-only images.
4935 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
4936 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
4937 image
->data
.image_coherent
= true;
4938 image
->data
.image_volatile
= true;
4939 image
->data
.image_restrict
= true;
4944 ir_function_signature
*
4945 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
4946 unsigned /* num_arguments */,
4947 unsigned /* flags */)
4949 const glsl_type
*ret_type
;
4950 unsigned num_components
= image_type
->coordinate_components();
4952 /* From the ARB_shader_image_size extension:
4953 * "Cube images return the dimensions of one face."
4955 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
4956 !image_type
->sampler_array
) {
4960 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
4961 * supported by mesa.
4963 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
4965 ir_variable
*image
= in_var(image_type
, "image");
4966 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
4968 /* Set the maximal set of qualifiers allowed for this image
4969 * built-in. Function calls with arguments having fewer
4970 * qualifiers than present in the prototype are allowed by the
4971 * spec, but not with more, i.e. this will make the compiler
4972 * accept everything that needs to be accepted, and reject cases
4973 * like loads from write-only or stores to read-only images.
4975 image
->data
.image_read_only
= true;
4976 image
->data
.image_write_only
= true;
4977 image
->data
.image_coherent
= true;
4978 image
->data
.image_volatile
= true;
4979 image
->data
.image_restrict
= true;
4984 ir_function_signature
*
4985 builtin_builder::_image(image_prototype_ctr prototype
,
4986 const glsl_type
*image_type
,
4987 const char *intrinsic_name
,
4988 unsigned num_arguments
,
4991 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
4992 num_arguments
, flags
);
4994 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
4995 ir_factory
body(&sig
->body
, mem_ctx
);
4996 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
4998 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
4999 body
.emit(call(f
, NULL
, sig
->parameters
));
5001 ir_variable
*ret_val
=
5002 body
.make_temp(sig
->return_type
, "_ret_val");
5003 body
.emit(call(f
, ret_val
, sig
->parameters
));
5004 body
.emit(ret(ret_val
));
5007 sig
->is_defined
= true;
5010 sig
->is_intrinsic
= true;
5016 ir_function_signature
*
5017 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5019 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5023 ir_function_signature
*
5024 builtin_builder::_memory_barrier(builtin_available_predicate avail
)
5026 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5027 body
.emit(call(shader
->symbols
->get_function("__intrinsic_memory_barrier"),
5028 NULL
, sig
->parameters
));
5034 /******************************************************************************/
5036 /* The singleton instance of builtin_builder. */
5037 static builtin_builder builtins
;
5038 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5041 * External API (exposing the built-in module to the rest of the compiler):
5045 _mesa_glsl_initialize_builtin_functions()
5047 mtx_lock(&builtins_lock
);
5048 builtins
.initialize();
5049 mtx_unlock(&builtins_lock
);
5053 _mesa_glsl_release_builtin_functions()
5055 mtx_lock(&builtins_lock
);
5057 mtx_unlock(&builtins_lock
);
5060 ir_function_signature
*
5061 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5062 const char *name
, exec_list
*actual_parameters
)
5064 ir_function_signature
* s
;
5065 mtx_lock(&builtins_lock
);
5066 s
= builtins
.find(state
, name
, actual_parameters
);
5067 mtx_unlock(&builtins_lock
);
5072 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5075 mtx_lock(&builtins_lock
);
5076 f
= builtins
.shader
->symbols
->get_function(name
);
5077 mtx_unlock(&builtins_lock
);
5082 _mesa_glsl_get_builtin_function_shader()
5084 return builtins
.shader
;