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_or_es3(const _mesa_glsl_parse_state
*state
)
135 return state
->is_version(140, 300);
139 v400_fs_only(const _mesa_glsl_parse_state
*state
)
141 return state
->is_version(400, 0) &&
142 state
->stage
== MESA_SHADER_FRAGMENT
;
146 texture_rectangle(const _mesa_glsl_parse_state
*state
)
148 return state
->ARB_texture_rectangle_enable
;
152 texture_external(const _mesa_glsl_parse_state
*state
)
154 return state
->OES_EGL_image_external_enable
;
157 /** True if texturing functions with explicit LOD are allowed. */
159 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
161 /* Texturing functions with "Lod" in their name exist:
162 * - In the vertex shader stage (for all languages)
163 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
164 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
166 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
167 * don't need to explicitly check state->es_shader.
169 return state
->stage
== MESA_SHADER_VERTEX
||
170 state
->is_version(130, 300) ||
171 state
->ARB_shader_texture_lod_enable
;
175 v110_lod(const _mesa_glsl_parse_state
*state
)
177 return !state
->es_shader
&& lod_exists_in_stage(state
);
181 texture_buffer(const _mesa_glsl_parse_state
*state
)
183 return state
->is_version(140, 320) ||
184 state
->EXT_texture_buffer_enable
||
185 state
->OES_texture_buffer_enable
;
189 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
191 return state
->ARB_shader_texture_lod_enable
;
195 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
197 return state
->ARB_shader_texture_lod_enable
&&
198 state
->ARB_texture_rectangle_enable
;
202 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
204 return state
->is_version(330, 300) ||
205 state
->ARB_shader_bit_encoding_enable
||
206 state
->ARB_gpu_shader5_enable
;
210 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
212 return state
->is_version(450, 310) ||
213 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
217 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
219 return state
->ARB_shading_language_packing_enable
||
220 state
->is_version(420, 300);
224 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
226 return state
->ARB_shading_language_packing_enable
||
227 state
->ARB_gpu_shader5_enable
||
228 state
->is_version(400, 300);
232 gpu_shader5(const _mesa_glsl_parse_state
*state
)
234 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
238 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
240 return state
->is_version(400, 320) ||
241 state
->ARB_gpu_shader5_enable
||
242 state
->EXT_gpu_shader5_enable
||
243 state
->OES_gpu_shader5_enable
;
247 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
249 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
253 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
255 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
259 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
261 return state
->ARB_shading_language_packing_enable
||
262 state
->ARB_gpu_shader5_enable
||
263 state
->is_version(400, 310);
267 fs_gpu_shader5(const _mesa_glsl_parse_state
*state
)
269 return state
->stage
== MESA_SHADER_FRAGMENT
&&
270 (state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
);
275 texture_array_lod(const _mesa_glsl_parse_state
*state
)
277 return lod_exists_in_stage(state
) &&
278 state
->EXT_texture_array_enable
;
282 fs_texture_array(const _mesa_glsl_parse_state
*state
)
284 return state
->stage
== MESA_SHADER_FRAGMENT
&&
285 state
->EXT_texture_array_enable
;
289 texture_array(const _mesa_glsl_parse_state
*state
)
291 return state
->EXT_texture_array_enable
;
295 texture_multisample(const _mesa_glsl_parse_state
*state
)
297 return state
->is_version(150, 310) ||
298 state
->ARB_texture_multisample_enable
;
302 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
304 return state
->is_version(150, 320) ||
305 state
->ARB_texture_multisample_enable
||
306 state
->OES_texture_storage_multisample_2d_array_enable
;
310 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
312 return texture_multisample(state
) &&
313 state
->EXT_shader_samples_identical_enable
;
317 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
319 return texture_multisample_array(state
) &&
320 state
->EXT_shader_samples_identical_enable
;
324 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
326 return state
->stage
== MESA_SHADER_FRAGMENT
&&
327 (state
->is_version(400, 0) ||
328 state
->ARB_texture_cube_map_array_enable
);
332 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
334 return state
->is_version(400, 0) ||
335 state
->ARB_texture_cube_map_array_enable
;
339 texture_query_levels(const _mesa_glsl_parse_state
*state
)
341 return state
->is_version(430, 0) ||
342 state
->ARB_texture_query_levels_enable
;
346 texture_query_lod(const _mesa_glsl_parse_state
*state
)
348 return state
->stage
== MESA_SHADER_FRAGMENT
&&
349 state
->ARB_texture_query_lod_enable
;
353 texture_gather(const _mesa_glsl_parse_state
*state
)
355 return state
->is_version(400, 0) ||
356 state
->ARB_texture_gather_enable
||
357 state
->ARB_gpu_shader5_enable
;
361 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
363 return state
->is_version(400, 310) ||
364 state
->ARB_texture_gather_enable
||
365 state
->ARB_gpu_shader5_enable
;
368 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
369 * used for relaxation of const offset requirements.
372 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
374 return !state
->is_version(400, 320) &&
375 !state
->ARB_gpu_shader5_enable
&&
376 !state
->EXT_gpu_shader5_enable
&&
377 !state
->OES_gpu_shader5_enable
&&
378 (state
->ARB_texture_gather_enable
||
379 state
->is_version(0, 310));
382 /* Desktop GL or OES_standard_derivatives + fragment shader only */
384 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
386 return state
->stage
== MESA_SHADER_FRAGMENT
&&
387 (state
->is_version(110, 300) ||
388 state
->OES_standard_derivatives_enable
);
392 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
394 return state
->stage
== MESA_SHADER_FRAGMENT
&&
395 (state
->is_version(450, 0) ||
396 state
->ARB_derivative_control_enable
);
400 tex1d_lod(const _mesa_glsl_parse_state
*state
)
402 return !state
->es_shader
&& lod_exists_in_stage(state
);
405 /** True if sampler3D exists */
407 tex3d(const _mesa_glsl_parse_state
*state
)
409 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
410 * OES_texture_3D extension, and in GLSL ES 3.00.
412 return !state
->es_shader
||
413 state
->OES_texture_3D_enable
||
414 state
->language_version
>= 300;
418 fs_tex3d(const _mesa_glsl_parse_state
*state
)
420 return state
->stage
== MESA_SHADER_FRAGMENT
&&
421 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
425 tex3d_lod(const _mesa_glsl_parse_state
*state
)
427 return tex3d(state
) && lod_exists_in_stage(state
);
431 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
433 return state
->has_atomic_counters();
437 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
439 return state
->ARB_shader_atomic_counter_ops_enable
;
443 shader_clock(const _mesa_glsl_parse_state
*state
)
445 return state
->ARB_shader_clock_enable
;
449 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
451 return state
->has_shader_storage_buffer_objects();
455 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
457 return state
->AMD_shader_trinary_minmax_enable
;
461 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
463 return (state
->is_version(420, 310) ||
464 state
->ARB_shader_image_load_store_enable
);
468 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
470 return (state
->is_version(420, 320) ||
471 state
->ARB_shader_image_load_store_enable
||
472 state
->OES_shader_image_atomic_enable
);
476 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
478 return (state
->is_version(450, 320) ||
479 state
->OES_shader_image_atomic_enable
);
483 shader_image_size(const _mesa_glsl_parse_state
*state
)
485 return state
->is_version(430, 310) ||
486 state
->ARB_shader_image_size_enable
;
490 shader_samples(const _mesa_glsl_parse_state
*state
)
492 return state
->is_version(450, 0) ||
493 state
->ARB_shader_texture_image_samples_enable
;
497 gs_streams(const _mesa_glsl_parse_state
*state
)
499 return gpu_shader5(state
) && gs_only(state
);
503 fp64(const _mesa_glsl_parse_state
*state
)
505 return state
->has_double();
509 compute_shader(const _mesa_glsl_parse_state
*state
)
511 return state
->stage
== MESA_SHADER_COMPUTE
;
515 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
517 return compute_shader(state
) || shader_storage_buffer_object(state
);
521 barrier_supported(const _mesa_glsl_parse_state
*state
)
523 return compute_shader(state
) ||
524 state
->stage
== MESA_SHADER_TESS_CTRL
;
529 /******************************************************************************/
534 * builtin_builder: A singleton object representing the core of the built-in
537 * It generates IR for every built-in function signature, and organizes them
540 class builtin_builder
{
547 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
548 const char *name
, exec_list
*actual_parameters
);
551 * A shader to hold all the built-in signatures; created by this module.
553 * This includes signatures for every built-in, regardless of version or
554 * enabled extensions. The availability predicate associated with each
555 * signature allows matching_signature() to filter out the irrelevant ones.
562 /** Global variables used by built-in functions. */
563 ir_variable
*gl_ModelViewProjectionMatrix
;
564 ir_variable
*gl_Vertex
;
566 void create_shader();
567 void create_intrinsics();
568 void create_builtins();
571 * IR builder helpers:
573 * These convenience functions assist in emitting IR, but don't necessarily
574 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
577 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
578 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
579 ir_constant
*imm(float f
, unsigned vector_elements
=1);
580 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
581 ir_constant
*imm(int i
, unsigned vector_elements
=1);
582 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
583 ir_constant
*imm(double d
, unsigned vector_elements
=1);
584 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
585 ir_dereference_variable
*var_ref(ir_variable
*var
);
586 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
587 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
589 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
590 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
593 * Call function \param f with parameters specified as the linked
594 * list \param params of \c ir_variable objects. \param ret should
595 * point to the ir_variable that will hold the function return
596 * value, or be \c NULL if the function has void return type.
598 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
600 /** Create a new function and add the given signatures. */
601 void add_function(const char *name
, ...);
603 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
604 unsigned num_arguments
,
608 * Create a new image built-in function for all known image types.
609 * \p flags is a bitfield of \c image_function_flags flags.
611 void add_image_function(const char *name
,
612 const char *intrinsic_name
,
613 image_prototype_ctr prototype
,
614 unsigned num_arguments
,
618 * Create new functions for all known image built-ins and types.
619 * If \p glsl is \c true, use the GLSL built-in names and emit code
620 * to call into the actual compiler intrinsic. If \p glsl is
621 * false, emit a function prototype with no body for each image
624 void add_image_functions(bool glsl
);
626 ir_function_signature
*new_sig(const glsl_type
*return_type
,
627 builtin_available_predicate avail
,
628 int num_params
, ...);
631 * Function signature generators:
634 ir_function_signature
*unop(builtin_available_predicate avail
,
635 ir_expression_operation opcode
,
636 const glsl_type
*return_type
,
637 const glsl_type
*param_type
);
638 ir_function_signature
*binop(builtin_available_predicate avail
,
639 ir_expression_operation opcode
,
640 const glsl_type
*return_type
,
641 const glsl_type
*param0_type
,
642 const glsl_type
*param1_type
);
644 #define B0(X) ir_function_signature *_##X();
645 #define B1(X) ir_function_signature *_##X(const glsl_type *);
646 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
647 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
648 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
649 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
686 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
687 const glsl_type
*val_type
,
688 const glsl_type
*blend_type
);
697 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
698 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
699 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
700 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
701 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
702 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
703 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
704 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
705 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
706 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
707 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
708 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
721 BA1(determinant_mat2
);
722 BA1(determinant_mat3
);
723 BA1(determinant_mat4
);
731 BA1(greaterThanEqual
);
740 /** Flags to _texture() */
741 #define TEX_PROJECT 1
743 #define TEX_COMPONENT 4
744 #define TEX_OFFSET_NONCONST 8
745 #define TEX_OFFSET_ARRAY 16
747 ir_function_signature
*_texture(ir_texture_opcode opcode
,
748 builtin_available_predicate avail
,
749 const glsl_type
*return_type
,
750 const glsl_type
*sampler_type
,
751 const glsl_type
*coord_type
,
753 B0(textureCubeArrayShadow
);
754 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
755 const glsl_type
*return_type
,
756 const glsl_type
*sampler_type
,
757 const glsl_type
*coord_type
,
758 const glsl_type
*offset_type
= NULL
);
762 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
763 const glsl_type
*stream_type
);
764 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
765 const glsl_type
*stream_type
);
768 BA2(textureQueryLod
);
769 B1(textureQueryLevels
);
770 BA2(textureSamplesIdentical
);
798 B1(interpolateAtCentroid
)
799 B1(interpolateAtOffset
)
800 B1(interpolateAtSample
)
802 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
803 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
);
804 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
);
805 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
806 builtin_available_predicate avail
);
807 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
808 builtin_available_predicate avail
);
809 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
810 builtin_available_predicate avail
);
812 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
813 const glsl_type
*type
);
814 ir_function_signature
*_atomic_op2(const char *intrinsic
,
815 builtin_available_predicate avail
,
816 const glsl_type
*type
);
817 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
818 const glsl_type
*type
);
819 ir_function_signature
*_atomic_op3(const char *intrinsic
,
820 builtin_available_predicate avail
,
821 const glsl_type
*type
);
827 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
828 unsigned num_arguments
,
830 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
831 unsigned num_arguments
,
833 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
834 unsigned num_arguments
,
836 ir_function_signature
*_image(image_prototype_ctr prototype
,
837 const glsl_type
*image_type
,
838 const char *intrinsic_name
,
839 unsigned num_arguments
,
842 ir_function_signature
*_memory_barrier_intrinsic(
843 builtin_available_predicate avail
);
844 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
845 builtin_available_predicate avail
);
847 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
848 const glsl_type
*type
);
849 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
850 const glsl_type
*type
);
861 enum image_function_flags
{
862 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
863 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
864 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
865 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
866 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
867 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
868 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
869 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
870 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
873 } /* anonymous namespace */
876 * Core builtin_builder functionality:
879 builtin_builder::builtin_builder()
881 gl_ModelViewProjectionMatrix(NULL
),
887 builtin_builder::~builtin_builder()
889 ralloc_free(mem_ctx
);
892 ir_function_signature
*
893 builtin_builder::find(_mesa_glsl_parse_state
*state
,
894 const char *name
, exec_list
*actual_parameters
)
896 /* The shader currently being compiled requested a built-in function;
897 * it needs to link against builtin_builder::shader in order to get them.
899 * Even if we don't find a matching signature, we still need to do this so
900 * that the "no matching signature" error will list potential candidates
901 * from the available built-ins.
903 state
->uses_builtin_functions
= true;
905 ir_function
*f
= shader
->symbols
->get_function(name
);
909 ir_function_signature
*sig
=
910 f
->matching_signature(state
, actual_parameters
, true);
918 builtin_builder::initialize()
920 /* If already initialized, don't do it again. */
924 mem_ctx
= ralloc_context(NULL
);
931 builtin_builder::release()
933 ralloc_free(mem_ctx
);
941 builtin_builder::create_shader()
943 /* The target doesn't actually matter. There's no target for generic
944 * GLSL utility code that could be linked against any stage, so just
945 * arbitrarily pick GL_VERTEX_SHADER.
947 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
948 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
950 gl_ModelViewProjectionMatrix
=
951 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
952 "gl_ModelViewProjectionMatrix",
955 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
957 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
958 shader
->symbols
->add_variable(gl_Vertex
);
964 * Create ir_function and ir_function_signature objects for each
968 builtin_builder::create_intrinsics()
970 add_function("__intrinsic_atomic_read",
971 _atomic_counter_intrinsic(shader_atomic_counters
),
973 add_function("__intrinsic_atomic_increment",
974 _atomic_counter_intrinsic(shader_atomic_counters
),
976 add_function("__intrinsic_atomic_predecrement",
977 _atomic_counter_intrinsic(shader_atomic_counters
),
980 add_function("__intrinsic_atomic_add",
981 _atomic_intrinsic2(buffer_atomics_supported
,
982 glsl_type::uint_type
),
983 _atomic_intrinsic2(buffer_atomics_supported
,
984 glsl_type::int_type
),
985 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
987 add_function("__intrinsic_atomic_sub",
988 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
990 add_function("__intrinsic_atomic_min",
991 _atomic_intrinsic2(buffer_atomics_supported
,
992 glsl_type::uint_type
),
993 _atomic_intrinsic2(buffer_atomics_supported
,
994 glsl_type::int_type
),
995 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
997 add_function("__intrinsic_atomic_max",
998 _atomic_intrinsic2(buffer_atomics_supported
,
999 glsl_type::uint_type
),
1000 _atomic_intrinsic2(buffer_atomics_supported
,
1001 glsl_type::int_type
),
1002 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1004 add_function("__intrinsic_atomic_and",
1005 _atomic_intrinsic2(buffer_atomics_supported
,
1006 glsl_type::uint_type
),
1007 _atomic_intrinsic2(buffer_atomics_supported
,
1008 glsl_type::int_type
),
1009 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1011 add_function("__intrinsic_atomic_or",
1012 _atomic_intrinsic2(buffer_atomics_supported
,
1013 glsl_type::uint_type
),
1014 _atomic_intrinsic2(buffer_atomics_supported
,
1015 glsl_type::int_type
),
1016 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1018 add_function("__intrinsic_atomic_xor",
1019 _atomic_intrinsic2(buffer_atomics_supported
,
1020 glsl_type::uint_type
),
1021 _atomic_intrinsic2(buffer_atomics_supported
,
1022 glsl_type::int_type
),
1023 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1025 add_function("__intrinsic_atomic_exchange",
1026 _atomic_intrinsic2(buffer_atomics_supported
,
1027 glsl_type::uint_type
),
1028 _atomic_intrinsic2(buffer_atomics_supported
,
1029 glsl_type::int_type
),
1030 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1032 add_function("__intrinsic_atomic_comp_swap",
1033 _atomic_intrinsic3(buffer_atomics_supported
,
1034 glsl_type::uint_type
),
1035 _atomic_intrinsic3(buffer_atomics_supported
,
1036 glsl_type::int_type
),
1037 _atomic_counter_intrinsic2(shader_atomic_counter_ops
),
1040 add_image_functions(false);
1042 add_function("__intrinsic_memory_barrier",
1043 _memory_barrier_intrinsic(shader_image_load_store
),
1045 add_function("__intrinsic_group_memory_barrier",
1046 _memory_barrier_intrinsic(compute_shader
),
1048 add_function("__intrinsic_memory_barrier_atomic_counter",
1049 _memory_barrier_intrinsic(compute_shader
),
1051 add_function("__intrinsic_memory_barrier_buffer",
1052 _memory_barrier_intrinsic(compute_shader
),
1054 add_function("__intrinsic_memory_barrier_image",
1055 _memory_barrier_intrinsic(compute_shader
),
1057 add_function("__intrinsic_memory_barrier_shared",
1058 _memory_barrier_intrinsic(compute_shader
),
1061 add_function("__intrinsic_shader_clock",
1062 _shader_clock_intrinsic(shader_clock
,
1063 glsl_type::uvec2_type
),
1068 * Create ir_function and ir_function_signature objects for each built-in.
1070 * Contains a list of every available built-in.
1073 builtin_builder::create_builtins()
1076 add_function(#NAME, \
1077 _##NAME(glsl_type::float_type), \
1078 _##NAME(glsl_type::vec2_type), \
1079 _##NAME(glsl_type::vec3_type), \
1080 _##NAME(glsl_type::vec4_type), \
1084 add_function(#NAME, \
1085 _##NAME(always_available, glsl_type::float_type), \
1086 _##NAME(always_available, glsl_type::vec2_type), \
1087 _##NAME(always_available, glsl_type::vec3_type), \
1088 _##NAME(always_available, glsl_type::vec4_type), \
1089 _##NAME(fp64, glsl_type::double_type), \
1090 _##NAME(fp64, glsl_type::dvec2_type), \
1091 _##NAME(fp64, glsl_type::dvec3_type), \
1092 _##NAME(fp64, glsl_type::dvec4_type), \
1095 #define FD130(NAME) \
1096 add_function(#NAME, \
1097 _##NAME(v130, glsl_type::float_type), \
1098 _##NAME(v130, glsl_type::vec2_type), \
1099 _##NAME(v130, glsl_type::vec3_type), \
1100 _##NAME(v130, glsl_type::vec4_type), \
1101 _##NAME(fp64, glsl_type::double_type), \
1102 _##NAME(fp64, glsl_type::dvec2_type), \
1103 _##NAME(fp64, glsl_type::dvec3_type), \
1104 _##NAME(fp64, glsl_type::dvec4_type), \
1107 #define FDGS5(NAME) \
1108 add_function(#NAME, \
1109 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1110 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1111 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1112 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1113 _##NAME(fp64, glsl_type::double_type), \
1114 _##NAME(fp64, glsl_type::dvec2_type), \
1115 _##NAME(fp64, glsl_type::dvec3_type), \
1116 _##NAME(fp64, glsl_type::dvec4_type), \
1120 add_function(#NAME, \
1121 _##NAME(glsl_type::float_type), \
1122 _##NAME(glsl_type::vec2_type), \
1123 _##NAME(glsl_type::vec3_type), \
1124 _##NAME(glsl_type::vec4_type), \
1125 _##NAME(glsl_type::int_type), \
1126 _##NAME(glsl_type::ivec2_type), \
1127 _##NAME(glsl_type::ivec3_type), \
1128 _##NAME(glsl_type::ivec4_type), \
1132 add_function(#NAME, \
1133 _##NAME(always_available, glsl_type::float_type), \
1134 _##NAME(always_available, glsl_type::vec2_type), \
1135 _##NAME(always_available, glsl_type::vec3_type), \
1136 _##NAME(always_available, glsl_type::vec4_type), \
1137 _##NAME(always_available, glsl_type::int_type), \
1138 _##NAME(always_available, glsl_type::ivec2_type), \
1139 _##NAME(always_available, glsl_type::ivec3_type), \
1140 _##NAME(always_available, glsl_type::ivec4_type), \
1141 _##NAME(fp64, glsl_type::double_type), \
1142 _##NAME(fp64, glsl_type::dvec2_type), \
1143 _##NAME(fp64, glsl_type::dvec3_type), \
1144 _##NAME(fp64, glsl_type::dvec4_type), \
1147 #define FIUD(NAME) \
1148 add_function(#NAME, \
1149 _##NAME(always_available, glsl_type::float_type), \
1150 _##NAME(always_available, glsl_type::vec2_type), \
1151 _##NAME(always_available, glsl_type::vec3_type), \
1152 _##NAME(always_available, glsl_type::vec4_type), \
1154 _##NAME(always_available, glsl_type::int_type), \
1155 _##NAME(always_available, glsl_type::ivec2_type), \
1156 _##NAME(always_available, glsl_type::ivec3_type), \
1157 _##NAME(always_available, glsl_type::ivec4_type), \
1159 _##NAME(v130, glsl_type::uint_type), \
1160 _##NAME(v130, glsl_type::uvec2_type), \
1161 _##NAME(v130, glsl_type::uvec3_type), \
1162 _##NAME(v130, glsl_type::uvec4_type), \
1163 _##NAME(fp64, glsl_type::double_type), \
1164 _##NAME(fp64, glsl_type::dvec2_type), \
1165 _##NAME(fp64, glsl_type::dvec3_type), \
1166 _##NAME(fp64, glsl_type::dvec4_type), \
1170 add_function(#NAME, \
1171 _##NAME(glsl_type::int_type), \
1172 _##NAME(glsl_type::ivec2_type), \
1173 _##NAME(glsl_type::ivec3_type), \
1174 _##NAME(glsl_type::ivec4_type), \
1176 _##NAME(glsl_type::uint_type), \
1177 _##NAME(glsl_type::uvec2_type), \
1178 _##NAME(glsl_type::uvec3_type), \
1179 _##NAME(glsl_type::uvec4_type), \
1182 #define FIUBD(NAME) \
1183 add_function(#NAME, \
1184 _##NAME(always_available, glsl_type::float_type), \
1185 _##NAME(always_available, glsl_type::vec2_type), \
1186 _##NAME(always_available, glsl_type::vec3_type), \
1187 _##NAME(always_available, glsl_type::vec4_type), \
1189 _##NAME(always_available, glsl_type::int_type), \
1190 _##NAME(always_available, glsl_type::ivec2_type), \
1191 _##NAME(always_available, glsl_type::ivec3_type), \
1192 _##NAME(always_available, glsl_type::ivec4_type), \
1194 _##NAME(v130, glsl_type::uint_type), \
1195 _##NAME(v130, glsl_type::uvec2_type), \
1196 _##NAME(v130, glsl_type::uvec3_type), \
1197 _##NAME(v130, glsl_type::uvec4_type), \
1199 _##NAME(always_available, glsl_type::bool_type), \
1200 _##NAME(always_available, glsl_type::bvec2_type), \
1201 _##NAME(always_available, glsl_type::bvec3_type), \
1202 _##NAME(always_available, glsl_type::bvec4_type), \
1204 _##NAME(fp64, glsl_type::double_type), \
1205 _##NAME(fp64, glsl_type::dvec2_type), \
1206 _##NAME(fp64, glsl_type::dvec3_type), \
1207 _##NAME(fp64, glsl_type::dvec4_type), \
1210 #define FIUD2_MIXED(NAME) \
1211 add_function(#NAME, \
1212 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1213 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1214 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1215 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1217 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1218 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1219 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1221 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1222 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1223 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1224 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1226 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1227 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1228 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1230 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1231 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1232 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1233 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1235 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1236 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1237 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1239 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1240 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1241 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1242 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1243 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1244 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1245 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1256 add_function("atan",
1257 _atan(glsl_type::float_type
),
1258 _atan(glsl_type::vec2_type
),
1259 _atan(glsl_type::vec3_type
),
1260 _atan(glsl_type::vec4_type
),
1261 _atan2(glsl_type::float_type
),
1262 _atan2(glsl_type::vec2_type
),
1263 _atan2(glsl_type::vec3_type
),
1264 _atan2(glsl_type::vec4_type
),
1290 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1291 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1292 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1293 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1295 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1296 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1297 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1299 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1300 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1301 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1302 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1304 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1305 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1306 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1316 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1317 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1318 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1319 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1321 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1322 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1323 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1325 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1326 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1327 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1328 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1330 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1331 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1332 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1334 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1335 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1336 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1337 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1339 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1340 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1341 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1342 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1344 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1345 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1346 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1347 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1349 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1350 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1351 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1352 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1354 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1355 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1356 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1357 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1360 add_function("step",
1361 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1362 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1363 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1364 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1366 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1367 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1368 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1369 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1370 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1371 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1372 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1374 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1375 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1376 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1379 add_function("smoothstep",
1380 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1381 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1382 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1383 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1385 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1386 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1387 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1388 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1389 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1390 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1391 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1393 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1394 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1395 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1403 add_function("intBitsToFloat",
1404 _intBitsToFloat(glsl_type::int_type
),
1405 _intBitsToFloat(glsl_type::ivec2_type
),
1406 _intBitsToFloat(glsl_type::ivec3_type
),
1407 _intBitsToFloat(glsl_type::ivec4_type
),
1409 add_function("uintBitsToFloat",
1410 _uintBitsToFloat(glsl_type::uint_type
),
1411 _uintBitsToFloat(glsl_type::uvec2_type
),
1412 _uintBitsToFloat(glsl_type::uvec3_type
),
1413 _uintBitsToFloat(glsl_type::uvec4_type
),
1416 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1417 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1418 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1419 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1420 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1421 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1422 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1423 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1424 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1425 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1426 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1427 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1434 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1435 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1438 add_function("ftransform", _ftransform(), NULL
);
1443 add_function("matrixCompMult",
1444 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1445 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1446 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1447 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1448 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1449 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1450 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1451 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1452 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1453 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1454 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1455 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1456 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1457 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1458 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1459 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1460 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1461 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1463 add_function("outerProduct",
1464 _outerProduct(v120
, glsl_type::mat2_type
),
1465 _outerProduct(v120
, glsl_type::mat3_type
),
1466 _outerProduct(v120
, glsl_type::mat4_type
),
1467 _outerProduct(v120
, glsl_type::mat2x3_type
),
1468 _outerProduct(v120
, glsl_type::mat2x4_type
),
1469 _outerProduct(v120
, glsl_type::mat3x2_type
),
1470 _outerProduct(v120
, glsl_type::mat3x4_type
),
1471 _outerProduct(v120
, glsl_type::mat4x2_type
),
1472 _outerProduct(v120
, glsl_type::mat4x3_type
),
1473 _outerProduct(fp64
, glsl_type::dmat2_type
),
1474 _outerProduct(fp64
, glsl_type::dmat3_type
),
1475 _outerProduct(fp64
, glsl_type::dmat4_type
),
1476 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1477 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1478 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1479 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1480 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1481 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1483 add_function("determinant",
1484 _determinant_mat2(v120
, glsl_type::mat2_type
),
1485 _determinant_mat3(v120
, glsl_type::mat3_type
),
1486 _determinant_mat4(v120
, glsl_type::mat4_type
),
1487 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1488 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1489 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1492 add_function("inverse",
1493 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1494 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1495 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1496 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1497 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1498 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1500 add_function("transpose",
1501 _transpose(v120
, glsl_type::mat2_type
),
1502 _transpose(v120
, glsl_type::mat3_type
),
1503 _transpose(v120
, glsl_type::mat4_type
),
1504 _transpose(v120
, glsl_type::mat2x3_type
),
1505 _transpose(v120
, glsl_type::mat2x4_type
),
1506 _transpose(v120
, glsl_type::mat3x2_type
),
1507 _transpose(v120
, glsl_type::mat3x4_type
),
1508 _transpose(v120
, glsl_type::mat4x2_type
),
1509 _transpose(v120
, glsl_type::mat4x3_type
),
1510 _transpose(fp64
, glsl_type::dmat2_type
),
1511 _transpose(fp64
, glsl_type::dmat3_type
),
1512 _transpose(fp64
, glsl_type::dmat4_type
),
1513 _transpose(fp64
, glsl_type::dmat2x3_type
),
1514 _transpose(fp64
, glsl_type::dmat2x4_type
),
1515 _transpose(fp64
, glsl_type::dmat3x2_type
),
1516 _transpose(fp64
, glsl_type::dmat3x4_type
),
1517 _transpose(fp64
, glsl_type::dmat4x2_type
),
1518 _transpose(fp64
, glsl_type::dmat4x3_type
),
1523 FIUD(greaterThanEqual
)
1528 _any(glsl_type::bvec2_type
),
1529 _any(glsl_type::bvec3_type
),
1530 _any(glsl_type::bvec4_type
),
1534 _all(glsl_type::bvec2_type
),
1535 _all(glsl_type::bvec3_type
),
1536 _all(glsl_type::bvec4_type
),
1540 _not(glsl_type::bvec2_type
),
1541 _not(glsl_type::bvec3_type
),
1542 _not(glsl_type::bvec4_type
),
1545 add_function("textureSize",
1546 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1547 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1548 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1550 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1551 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1552 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1554 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1555 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1556 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1558 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1559 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1560 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1562 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1563 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1564 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1566 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1567 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1568 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1569 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1570 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1571 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1573 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1574 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1576 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1577 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1578 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1579 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1581 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1582 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1583 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1584 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1586 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1587 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1588 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1589 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1590 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1591 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1593 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1594 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1595 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1598 add_function("textureSamples",
1599 _textureSamples(glsl_type::sampler2DMS_type
),
1600 _textureSamples(glsl_type::isampler2DMS_type
),
1601 _textureSamples(glsl_type::usampler2DMS_type
),
1603 _textureSamples(glsl_type::sampler2DMSArray_type
),
1604 _textureSamples(glsl_type::isampler2DMSArray_type
),
1605 _textureSamples(glsl_type::usampler2DMSArray_type
),
1608 add_function("texture",
1609 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1610 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1611 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1613 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1614 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1615 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1617 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1618 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1619 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1621 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1622 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1623 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1625 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1626 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1627 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1629 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1630 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1631 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1633 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1634 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1635 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1637 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1638 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1639 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1641 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1642 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1643 /* samplerCubeArrayShadow is special; it has an extra parameter
1644 * for the shadow comparitor since there is no vec5 type.
1646 _textureCubeArrayShadow(),
1648 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1649 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1650 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1652 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1654 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1655 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1656 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1658 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1659 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1660 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1662 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1663 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1664 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1666 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1667 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1668 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1670 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1671 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1672 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1674 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1675 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1676 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1678 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1679 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1680 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1682 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1683 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1684 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1686 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1689 add_function("textureLod",
1690 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1691 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1692 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1694 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1695 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1696 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1698 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1699 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1700 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1702 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1703 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1704 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1706 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1707 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1709 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1710 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1711 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1713 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1714 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1715 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1717 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1718 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1719 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1721 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1724 add_function("textureOffset",
1725 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1726 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1727 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1729 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1730 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1731 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1733 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1734 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1735 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1737 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1738 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1739 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1741 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1743 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1744 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1746 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1747 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1748 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1750 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1751 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1752 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1754 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1756 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1757 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1758 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1760 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1761 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1762 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1764 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1765 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1766 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1768 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1769 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1771 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1772 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1773 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1775 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1776 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1777 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1779 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1782 add_function("textureProj",
1783 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1784 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1785 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1786 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1787 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1788 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1790 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1791 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1792 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1793 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1794 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1795 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1797 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1798 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1799 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1801 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1802 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1804 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1805 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1806 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1807 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1808 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1809 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1811 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1813 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1814 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1815 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1816 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1817 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1818 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1820 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1821 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1822 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1823 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1824 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1825 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1827 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1828 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1829 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1831 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1832 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1835 add_function("texelFetch",
1836 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1837 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1838 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1840 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1841 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1842 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1844 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1845 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1846 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1848 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1849 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1850 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1852 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1853 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1854 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1856 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1857 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1858 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1860 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1861 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1862 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1864 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1865 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1866 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1868 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1869 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1870 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1873 add_function("texelFetchOffset",
1874 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1875 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1876 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1878 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1879 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1880 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1882 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1883 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1884 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1886 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1887 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1888 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1890 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1891 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1892 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1894 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1895 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1896 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1900 add_function("textureProjOffset",
1901 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1902 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1903 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1904 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1905 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1906 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1908 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1909 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1910 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1911 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1912 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1915 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1916 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1919 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1920 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1922 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1923 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1924 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1925 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1926 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1927 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1929 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1931 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1932 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1933 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1934 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1935 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1936 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1938 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1939 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1940 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1941 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1942 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1943 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1945 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1946 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1947 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1949 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1950 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1953 add_function("textureLodOffset",
1954 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1955 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1956 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1958 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1959 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1960 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1962 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1963 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1964 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1966 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1967 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1969 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1970 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1971 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1973 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1974 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1975 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1977 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1980 add_function("textureProjLod",
1981 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1982 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1983 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1984 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1985 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1986 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1988 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1989 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1990 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1991 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1992 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1993 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1995 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1996 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1997 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1999 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2000 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2003 add_function("textureProjLodOffset",
2004 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2005 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2006 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2007 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2008 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2009 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2011 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2012 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2013 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2014 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2015 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2016 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2018 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2019 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2020 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2022 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2023 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2026 add_function("textureGrad",
2027 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2028 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2029 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2031 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2032 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2033 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2035 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2036 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2037 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2039 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2040 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2041 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2043 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2044 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2045 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2047 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2049 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2050 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2051 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2053 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2054 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2055 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2057 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2058 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2059 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2061 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2062 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2063 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2065 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2066 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2069 add_function("textureGradOffset",
2070 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2071 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2072 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2074 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2075 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2076 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2078 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2079 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2080 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2082 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2083 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2084 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2086 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2088 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2089 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2091 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2092 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2093 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2095 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2096 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2097 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2099 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2100 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2103 add_function("textureProjGrad",
2104 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2105 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2106 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2107 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2108 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2109 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2111 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2112 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2113 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2114 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2115 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2116 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2118 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2119 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2120 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2122 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2123 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2124 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2125 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2126 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2127 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2129 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2131 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2132 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2135 add_function("textureProjGradOffset",
2136 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2137 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2138 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2139 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2140 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2141 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2143 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2144 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2145 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2146 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2147 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2148 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2150 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2151 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2152 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2154 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2155 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2156 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2157 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2158 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2159 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2161 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2163 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2164 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2167 add_function("EmitVertex", _EmitVertex(), NULL
);
2168 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2169 add_function("EmitStreamVertex",
2170 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2171 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2173 add_function("EndStreamPrimitive",
2174 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2175 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2177 add_function("barrier", _barrier(), NULL
);
2179 add_function("textureQueryLOD",
2180 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2181 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2182 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2184 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2185 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2186 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2188 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2189 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2190 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2192 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2193 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2194 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2196 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2197 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2198 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2200 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2201 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2202 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2204 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2205 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2206 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2208 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2209 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2210 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2211 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2212 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2213 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2216 add_function("textureQueryLod",
2217 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2218 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2219 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2221 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2222 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2223 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2225 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2226 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2227 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2229 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2230 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2231 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2233 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2234 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2235 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2237 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2238 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2239 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2241 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2242 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2243 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2245 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2246 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2247 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2248 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2249 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2250 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2253 add_function("textureQueryLevels",
2254 _textureQueryLevels(glsl_type::sampler1D_type
),
2255 _textureQueryLevels(glsl_type::sampler2D_type
),
2256 _textureQueryLevels(glsl_type::sampler3D_type
),
2257 _textureQueryLevels(glsl_type::samplerCube_type
),
2258 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2259 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2260 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2261 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2262 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2263 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2264 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2265 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2266 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2268 _textureQueryLevels(glsl_type::isampler1D_type
),
2269 _textureQueryLevels(glsl_type::isampler2D_type
),
2270 _textureQueryLevels(glsl_type::isampler3D_type
),
2271 _textureQueryLevels(glsl_type::isamplerCube_type
),
2272 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2273 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2274 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2276 _textureQueryLevels(glsl_type::usampler1D_type
),
2277 _textureQueryLevels(glsl_type::usampler2D_type
),
2278 _textureQueryLevels(glsl_type::usampler3D_type
),
2279 _textureQueryLevels(glsl_type::usamplerCube_type
),
2280 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2281 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2282 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2286 add_function("textureSamplesIdenticalEXT",
2287 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2288 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2289 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2291 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2292 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2293 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2296 add_function("texture1D",
2297 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2298 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2301 add_function("texture1DArray",
2302 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2303 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2306 add_function("texture1DProj",
2307 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2308 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2309 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2310 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2313 add_function("texture1DLod",
2314 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2317 add_function("texture1DArrayLod",
2318 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2321 add_function("texture1DProjLod",
2322 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2323 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2326 add_function("texture2D",
2327 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2328 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2329 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2332 add_function("texture2DArray",
2333 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2334 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2337 add_function("texture2DProj",
2338 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2339 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2340 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2341 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2342 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2343 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2346 add_function("texture2DLod",
2347 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2350 add_function("texture2DArrayLod",
2351 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2354 add_function("texture2DProjLod",
2355 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2356 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2359 add_function("texture3D",
2360 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2361 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2364 add_function("texture3DProj",
2365 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2366 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2369 add_function("texture3DLod",
2370 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2373 add_function("texture3DProjLod",
2374 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2377 add_function("textureCube",
2378 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2379 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2382 add_function("textureCubeLod",
2383 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2386 add_function("texture2DRect",
2387 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2390 add_function("texture2DRectProj",
2391 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2392 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2395 add_function("shadow1D",
2396 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2397 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2400 add_function("shadow1DArray",
2401 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2402 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2405 add_function("shadow2D",
2406 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2407 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2410 add_function("shadow2DArray",
2411 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2412 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2415 add_function("shadow1DProj",
2416 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2417 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2420 add_function("shadow2DProj",
2421 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2422 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2425 add_function("shadow1DLod",
2426 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2429 add_function("shadow2DLod",
2430 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2433 add_function("shadow1DArrayLod",
2434 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2437 add_function("shadow1DProjLod",
2438 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2441 add_function("shadow2DProjLod",
2442 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2445 add_function("shadow2DRect",
2446 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2449 add_function("shadow2DRectProj",
2450 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2453 add_function("texture1DGradARB",
2454 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2457 add_function("texture1DProjGradARB",
2458 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2459 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2462 add_function("texture2DGradARB",
2463 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2466 add_function("texture2DProjGradARB",
2467 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2468 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2471 add_function("texture3DGradARB",
2472 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2475 add_function("texture3DProjGradARB",
2476 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2479 add_function("textureCubeGradARB",
2480 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2483 add_function("shadow1DGradARB",
2484 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2487 add_function("shadow1DProjGradARB",
2488 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2491 add_function("shadow2DGradARB",
2492 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2495 add_function("shadow2DProjGradARB",
2496 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2499 add_function("texture2DRectGradARB",
2500 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2503 add_function("texture2DRectProjGradARB",
2504 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2505 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2508 add_function("shadow2DRectGradARB",
2509 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2512 add_function("shadow2DRectProjGradARB",
2513 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2516 add_function("textureGather",
2517 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2518 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2519 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2521 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2522 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2523 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2525 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2526 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2527 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2529 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2530 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2531 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2533 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2534 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2535 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2537 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2538 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2539 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2541 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2542 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2543 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2545 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2546 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2547 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2549 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2550 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2551 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2553 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2554 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2555 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2557 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2558 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2559 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2560 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2561 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2564 add_function("textureGatherOffset",
2565 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2566 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2567 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2569 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2570 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2571 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2573 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2574 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2575 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2577 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2578 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2579 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2581 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2582 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2583 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2585 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2586 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2587 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2589 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2590 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2591 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2593 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2594 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2595 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2597 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2598 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2599 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2601 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2602 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2603 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2605 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2606 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2607 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2609 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2610 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2613 add_function("textureGatherOffsets",
2614 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2615 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2616 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2618 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2619 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2620 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2622 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2623 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2624 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2626 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2627 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2628 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2630 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2631 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2632 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2634 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2635 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2636 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2638 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2639 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2640 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2665 add_function("ldexp",
2666 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2667 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2668 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2669 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2670 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2671 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2672 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2673 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2676 add_function("frexp",
2677 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2678 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2679 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2680 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2681 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2682 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2683 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2684 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2686 add_function("uaddCarry",
2687 _uaddCarry(glsl_type::uint_type
),
2688 _uaddCarry(glsl_type::uvec2_type
),
2689 _uaddCarry(glsl_type::uvec3_type
),
2690 _uaddCarry(glsl_type::uvec4_type
),
2692 add_function("usubBorrow",
2693 _usubBorrow(glsl_type::uint_type
),
2694 _usubBorrow(glsl_type::uvec2_type
),
2695 _usubBorrow(glsl_type::uvec3_type
),
2696 _usubBorrow(glsl_type::uvec4_type
),
2698 add_function("imulExtended",
2699 _mulExtended(glsl_type::int_type
),
2700 _mulExtended(glsl_type::ivec2_type
),
2701 _mulExtended(glsl_type::ivec3_type
),
2702 _mulExtended(glsl_type::ivec4_type
),
2704 add_function("umulExtended",
2705 _mulExtended(glsl_type::uint_type
),
2706 _mulExtended(glsl_type::uvec2_type
),
2707 _mulExtended(glsl_type::uvec3_type
),
2708 _mulExtended(glsl_type::uvec4_type
),
2710 add_function("interpolateAtCentroid",
2711 _interpolateAtCentroid(glsl_type::float_type
),
2712 _interpolateAtCentroid(glsl_type::vec2_type
),
2713 _interpolateAtCentroid(glsl_type::vec3_type
),
2714 _interpolateAtCentroid(glsl_type::vec4_type
),
2716 add_function("interpolateAtOffset",
2717 _interpolateAtOffset(glsl_type::float_type
),
2718 _interpolateAtOffset(glsl_type::vec2_type
),
2719 _interpolateAtOffset(glsl_type::vec3_type
),
2720 _interpolateAtOffset(glsl_type::vec4_type
),
2722 add_function("interpolateAtSample",
2723 _interpolateAtSample(glsl_type::float_type
),
2724 _interpolateAtSample(glsl_type::vec2_type
),
2725 _interpolateAtSample(glsl_type::vec3_type
),
2726 _interpolateAtSample(glsl_type::vec4_type
),
2729 add_function("atomicCounter",
2730 _atomic_counter_op("__intrinsic_atomic_read",
2731 shader_atomic_counters
),
2733 add_function("atomicCounterIncrement",
2734 _atomic_counter_op("__intrinsic_atomic_increment",
2735 shader_atomic_counters
),
2737 add_function("atomicCounterDecrement",
2738 _atomic_counter_op("__intrinsic_atomic_predecrement",
2739 shader_atomic_counters
),
2742 add_function("atomicCounterAddARB",
2743 _atomic_counter_op1("__intrinsic_atomic_add",
2744 shader_atomic_counter_ops
),
2746 add_function("atomicCounterSubtractARB",
2747 _atomic_counter_op1("__intrinsic_atomic_sub",
2748 shader_atomic_counter_ops
),
2750 add_function("atomicCounterMinARB",
2751 _atomic_counter_op1("__intrinsic_atomic_min",
2752 shader_atomic_counter_ops
),
2754 add_function("atomicCounterMaxARB",
2755 _atomic_counter_op1("__intrinsic_atomic_max",
2756 shader_atomic_counter_ops
),
2758 add_function("atomicCounterAndARB",
2759 _atomic_counter_op1("__intrinsic_atomic_and",
2760 shader_atomic_counter_ops
),
2762 add_function("atomicCounterOrARB",
2763 _atomic_counter_op1("__intrinsic_atomic_or",
2764 shader_atomic_counter_ops
),
2766 add_function("atomicCounterXorARB",
2767 _atomic_counter_op1("__intrinsic_atomic_xor",
2768 shader_atomic_counter_ops
),
2770 add_function("atomicCounterExchangeARB",
2771 _atomic_counter_op1("__intrinsic_atomic_exchange",
2772 shader_atomic_counter_ops
),
2774 add_function("atomicCounterCompSwapARB",
2775 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
2776 shader_atomic_counter_ops
),
2779 add_function("atomicAdd",
2780 _atomic_op2("__intrinsic_atomic_add",
2781 buffer_atomics_supported
,
2782 glsl_type::uint_type
),
2783 _atomic_op2("__intrinsic_atomic_add",
2784 buffer_atomics_supported
,
2785 glsl_type::int_type
),
2787 add_function("atomicMin",
2788 _atomic_op2("__intrinsic_atomic_min",
2789 buffer_atomics_supported
,
2790 glsl_type::uint_type
),
2791 _atomic_op2("__intrinsic_atomic_min",
2792 buffer_atomics_supported
,
2793 glsl_type::int_type
),
2795 add_function("atomicMax",
2796 _atomic_op2("__intrinsic_atomic_max",
2797 buffer_atomics_supported
,
2798 glsl_type::uint_type
),
2799 _atomic_op2("__intrinsic_atomic_max",
2800 buffer_atomics_supported
,
2801 glsl_type::int_type
),
2803 add_function("atomicAnd",
2804 _atomic_op2("__intrinsic_atomic_and",
2805 buffer_atomics_supported
,
2806 glsl_type::uint_type
),
2807 _atomic_op2("__intrinsic_atomic_and",
2808 buffer_atomics_supported
,
2809 glsl_type::int_type
),
2811 add_function("atomicOr",
2812 _atomic_op2("__intrinsic_atomic_or",
2813 buffer_atomics_supported
,
2814 glsl_type::uint_type
),
2815 _atomic_op2("__intrinsic_atomic_or",
2816 buffer_atomics_supported
,
2817 glsl_type::int_type
),
2819 add_function("atomicXor",
2820 _atomic_op2("__intrinsic_atomic_xor",
2821 buffer_atomics_supported
,
2822 glsl_type::uint_type
),
2823 _atomic_op2("__intrinsic_atomic_xor",
2824 buffer_atomics_supported
,
2825 glsl_type::int_type
),
2827 add_function("atomicExchange",
2828 _atomic_op2("__intrinsic_atomic_exchange",
2829 buffer_atomics_supported
,
2830 glsl_type::uint_type
),
2831 _atomic_op2("__intrinsic_atomic_exchange",
2832 buffer_atomics_supported
,
2833 glsl_type::int_type
),
2835 add_function("atomicCompSwap",
2836 _atomic_op3("__intrinsic_atomic_comp_swap",
2837 buffer_atomics_supported
,
2838 glsl_type::uint_type
),
2839 _atomic_op3("__intrinsic_atomic_comp_swap",
2840 buffer_atomics_supported
,
2841 glsl_type::int_type
),
2844 add_function("min3",
2845 _min3(glsl_type::float_type
),
2846 _min3(glsl_type::vec2_type
),
2847 _min3(glsl_type::vec3_type
),
2848 _min3(glsl_type::vec4_type
),
2850 _min3(glsl_type::int_type
),
2851 _min3(glsl_type::ivec2_type
),
2852 _min3(glsl_type::ivec3_type
),
2853 _min3(glsl_type::ivec4_type
),
2855 _min3(glsl_type::uint_type
),
2856 _min3(glsl_type::uvec2_type
),
2857 _min3(glsl_type::uvec3_type
),
2858 _min3(glsl_type::uvec4_type
),
2861 add_function("max3",
2862 _max3(glsl_type::float_type
),
2863 _max3(glsl_type::vec2_type
),
2864 _max3(glsl_type::vec3_type
),
2865 _max3(glsl_type::vec4_type
),
2867 _max3(glsl_type::int_type
),
2868 _max3(glsl_type::ivec2_type
),
2869 _max3(glsl_type::ivec3_type
),
2870 _max3(glsl_type::ivec4_type
),
2872 _max3(glsl_type::uint_type
),
2873 _max3(glsl_type::uvec2_type
),
2874 _max3(glsl_type::uvec3_type
),
2875 _max3(glsl_type::uvec4_type
),
2878 add_function("mid3",
2879 _mid3(glsl_type::float_type
),
2880 _mid3(glsl_type::vec2_type
),
2881 _mid3(glsl_type::vec3_type
),
2882 _mid3(glsl_type::vec4_type
),
2884 _mid3(glsl_type::int_type
),
2885 _mid3(glsl_type::ivec2_type
),
2886 _mid3(glsl_type::ivec3_type
),
2887 _mid3(glsl_type::ivec4_type
),
2889 _mid3(glsl_type::uint_type
),
2890 _mid3(glsl_type::uvec2_type
),
2891 _mid3(glsl_type::uvec3_type
),
2892 _mid3(glsl_type::uvec4_type
),
2895 add_image_functions(true);
2897 add_function("memoryBarrier",
2898 _memory_barrier("__intrinsic_memory_barrier",
2899 shader_image_load_store
),
2901 add_function("groupMemoryBarrier",
2902 _memory_barrier("__intrinsic_group_memory_barrier",
2905 add_function("memoryBarrierAtomicCounter",
2906 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2909 add_function("memoryBarrierBuffer",
2910 _memory_barrier("__intrinsic_memory_barrier_buffer",
2913 add_function("memoryBarrierImage",
2914 _memory_barrier("__intrinsic_memory_barrier_image",
2917 add_function("memoryBarrierShared",
2918 _memory_barrier("__intrinsic_memory_barrier_shared",
2922 add_function("clock2x32ARB",
2923 _shader_clock(shader_clock
,
2924 glsl_type::uvec2_type
),
2935 builtin_builder::add_function(const char *name
, ...)
2939 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2943 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2949 stuff
.push_tail(sig
);
2950 validate_ir_tree(&stuff
);
2953 f
->add_signature(sig
);
2957 shader
->symbols
->add_function(f
);
2961 builtin_builder::add_image_function(const char *name
,
2962 const char *intrinsic_name
,
2963 image_prototype_ctr prototype
,
2964 unsigned num_arguments
,
2967 static const glsl_type
*const types
[] = {
2968 glsl_type::image1D_type
,
2969 glsl_type::image2D_type
,
2970 glsl_type::image3D_type
,
2971 glsl_type::image2DRect_type
,
2972 glsl_type::imageCube_type
,
2973 glsl_type::imageBuffer_type
,
2974 glsl_type::image1DArray_type
,
2975 glsl_type::image2DArray_type
,
2976 glsl_type::imageCubeArray_type
,
2977 glsl_type::image2DMS_type
,
2978 glsl_type::image2DMSArray_type
,
2979 glsl_type::iimage1D_type
,
2980 glsl_type::iimage2D_type
,
2981 glsl_type::iimage3D_type
,
2982 glsl_type::iimage2DRect_type
,
2983 glsl_type::iimageCube_type
,
2984 glsl_type::iimageBuffer_type
,
2985 glsl_type::iimage1DArray_type
,
2986 glsl_type::iimage2DArray_type
,
2987 glsl_type::iimageCubeArray_type
,
2988 glsl_type::iimage2DMS_type
,
2989 glsl_type::iimage2DMSArray_type
,
2990 glsl_type::uimage1D_type
,
2991 glsl_type::uimage2D_type
,
2992 glsl_type::uimage3D_type
,
2993 glsl_type::uimage2DRect_type
,
2994 glsl_type::uimageCube_type
,
2995 glsl_type::uimageBuffer_type
,
2996 glsl_type::uimage1DArray_type
,
2997 glsl_type::uimage2DArray_type
,
2998 glsl_type::uimageCubeArray_type
,
2999 glsl_type::uimage2DMS_type
,
3000 glsl_type::uimage2DMSArray_type
3003 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3005 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3006 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3007 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3008 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3009 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3010 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3011 num_arguments
, flags
));
3014 shader
->symbols
->add_function(f
);
3018 builtin_builder::add_image_functions(bool glsl
)
3020 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3022 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3023 "__intrinsic_image_load",
3024 &builtin_builder::_image_prototype
, 0,
3025 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3026 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3027 IMAGE_FUNCTION_READ_ONLY
));
3029 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3030 "__intrinsic_image_store",
3031 &builtin_builder::_image_prototype
, 1,
3032 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3033 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3034 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3035 IMAGE_FUNCTION_WRITE_ONLY
));
3037 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3039 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3040 "__intrinsic_image_atomic_add",
3041 &builtin_builder::_image_prototype
, 1, atom_flags
);
3043 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3044 "__intrinsic_image_atomic_min",
3045 &builtin_builder::_image_prototype
, 1, atom_flags
);
3047 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3048 "__intrinsic_image_atomic_max",
3049 &builtin_builder::_image_prototype
, 1, atom_flags
);
3051 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3052 "__intrinsic_image_atomic_and",
3053 &builtin_builder::_image_prototype
, 1, atom_flags
);
3055 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3056 "__intrinsic_image_atomic_or",
3057 &builtin_builder::_image_prototype
, 1, atom_flags
);
3059 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3060 "__intrinsic_image_atomic_xor",
3061 &builtin_builder::_image_prototype
, 1, atom_flags
);
3063 add_image_function((glsl
? "imageAtomicExchange" :
3064 "__intrinsic_image_atomic_exchange"),
3065 "__intrinsic_image_atomic_exchange",
3066 &builtin_builder::_image_prototype
, 1,
3067 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3068 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
));
3070 add_image_function((glsl
? "imageAtomicCompSwap" :
3071 "__intrinsic_image_atomic_comp_swap"),
3072 "__intrinsic_image_atomic_comp_swap",
3073 &builtin_builder::_image_prototype
, 2, atom_flags
);
3075 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3076 "__intrinsic_image_size",
3077 &builtin_builder::_image_size_prototype
, 1,
3078 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
3080 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3081 "__intrinsic_image_samples",
3082 &builtin_builder::_image_samples_prototype
, 1,
3083 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3084 IMAGE_FUNCTION_MS_ONLY
);
3088 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3090 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3094 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3096 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3100 builtin_builder::imm(bool b
, unsigned vector_elements
)
3102 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3106 builtin_builder::imm(float f
, unsigned vector_elements
)
3108 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3112 builtin_builder::imm(int i
, unsigned vector_elements
)
3114 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3118 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3120 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3124 builtin_builder::imm(double d
, unsigned vector_elements
)
3126 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3130 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3132 return new(mem_ctx
) ir_constant(type
, &data
);
3135 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3137 ir_dereference_variable
*
3138 builtin_builder::var_ref(ir_variable
*var
)
3140 return new(mem_ctx
) ir_dereference_variable(var
);
3143 ir_dereference_array
*
3144 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3146 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3149 /** Return an element of a matrix */
3151 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3153 return swizzle(array_ref(var
, column
), row
, 1);
3157 * Implementations of built-in functions:
3160 ir_function_signature
*
3161 builtin_builder::new_sig(const glsl_type
*return_type
,
3162 builtin_available_predicate avail
,
3168 ir_function_signature
*sig
=
3169 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3172 va_start(ap
, num_params
);
3173 for (int i
= 0; i
< num_params
; i
++) {
3174 plist
.push_tail(va_arg(ap
, ir_variable
*));
3178 sig
->replace_parameters(&plist
);
3182 #define MAKE_SIG(return_type, avail, ...) \
3183 ir_function_signature *sig = \
3184 new_sig(return_type, avail, __VA_ARGS__); \
3185 ir_factory body(&sig->body, mem_ctx); \
3186 sig->is_defined = true;
3188 #define MAKE_INTRINSIC(return_type, avail, ...) \
3189 ir_function_signature *sig = \
3190 new_sig(return_type, avail, __VA_ARGS__); \
3191 sig->is_intrinsic = true;
3193 ir_function_signature
*
3194 builtin_builder::unop(builtin_available_predicate avail
,
3195 ir_expression_operation opcode
,
3196 const glsl_type
*return_type
,
3197 const glsl_type
*param_type
)
3199 ir_variable
*x
= in_var(param_type
, "x");
3200 MAKE_SIG(return_type
, avail
, 1, x
);
3201 body
.emit(ret(expr(opcode
, x
)));
3205 #define UNOP(NAME, OPCODE, AVAIL) \
3206 ir_function_signature * \
3207 builtin_builder::_##NAME(const glsl_type *type) \
3209 return unop(&AVAIL, OPCODE, type, type); \
3212 #define UNOPA(NAME, OPCODE) \
3213 ir_function_signature * \
3214 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3216 return unop(avail, OPCODE, type, type); \
3219 ir_function_signature
*
3220 builtin_builder::binop(builtin_available_predicate avail
,
3221 ir_expression_operation opcode
,
3222 const glsl_type
*return_type
,
3223 const glsl_type
*param0_type
,
3224 const glsl_type
*param1_type
)
3226 ir_variable
*x
= in_var(param0_type
, "x");
3227 ir_variable
*y
= in_var(param1_type
, "y");
3228 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3229 body
.emit(ret(expr(opcode
, x
, y
)));
3233 #define BINOP(NAME, OPCODE, AVAIL) \
3234 ir_function_signature * \
3235 builtin_builder::_##NAME(const glsl_type *return_type, \
3236 const glsl_type *param0_type, \
3237 const glsl_type *param1_type) \
3239 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3243 * Angle and Trigonometry Functions @{
3246 ir_function_signature
*
3247 builtin_builder::_radians(const glsl_type
*type
)
3249 ir_variable
*degrees
= in_var(type
, "degrees");
3250 MAKE_SIG(type
, always_available
, 1, degrees
);
3251 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3255 ir_function_signature
*
3256 builtin_builder::_degrees(const glsl_type
*type
)
3258 ir_variable
*radians
= in_var(type
, "radians");
3259 MAKE_SIG(type
, always_available
, 1, radians
);
3260 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3264 UNOP(sin
, ir_unop_sin
, always_available
)
3265 UNOP(cos
, ir_unop_cos
, always_available
)
3267 ir_function_signature
*
3268 builtin_builder::_tan(const glsl_type
*type
)
3270 ir_variable
*theta
= in_var(type
, "theta");
3271 MAKE_SIG(type
, always_available
, 1, theta
);
3272 body
.emit(ret(div(sin(theta
), cos(theta
))));
3277 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3281 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3284 add(imm(M_PI_4f
- 1.0f
),
3287 mul(abs(x
), imm(p1
))))))))));
3291 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3293 exec_list actual_params
;
3295 foreach_in_list(ir_variable
, var
, ¶ms
) {
3296 actual_params
.push_tail(var_ref(var
));
3299 ir_function_signature
*sig
=
3300 f
->exact_matching_signature(NULL
, &actual_params
);
3304 ir_dereference_variable
*deref
=
3305 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3307 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3310 ir_function_signature
*
3311 builtin_builder::_asin(const glsl_type
*type
)
3313 ir_variable
*x
= in_var(type
, "x");
3314 MAKE_SIG(type
, always_available
, 1, x
);
3316 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3321 ir_function_signature
*
3322 builtin_builder::_acos(const glsl_type
*type
)
3324 ir_variable
*x
= in_var(type
, "x");
3325 MAKE_SIG(type
, always_available
, 1, x
);
3327 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3332 ir_function_signature
*
3333 builtin_builder::_atan2(const glsl_type
*type
)
3335 ir_variable
*vec_y
= in_var(type
, "vec_y");
3336 ir_variable
*vec_x
= in_var(type
, "vec_x");
3337 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3339 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3340 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3341 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3342 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3343 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3344 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3345 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3347 /* If |x| >= 1.0e-8 * |y|: */
3349 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3351 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3353 /* Then...call atan(y/x) */
3354 do_atan(outer_then
, glsl_type::float_type
, r
, div(y
, x
));
3356 /* ...and fix it up: */
3357 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3358 inner_if
->then_instructions
.push_tail(
3359 if_tree(gequal(y
, imm(0.0f
)),
3360 assign(r
, add(r
, imm(M_PIf
))),
3361 assign(r
, sub(r
, imm(M_PIf
)))));
3362 outer_then
.emit(inner_if
);
3365 outer_if
->else_instructions
.push_tail(
3366 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3368 body
.emit(outer_if
);
3370 body
.emit(assign(vec_result
, r
, 1 << i
));
3372 body
.emit(ret(vec_result
));
3378 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3381 * range-reduction, first step:
3383 * / y_over_x if |y_over_x| <= 1.0;
3385 * \ 1.0 / y_over_x otherwise
3387 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3388 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3394 * approximate atan by evaluating polynomial:
3396 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3397 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3398 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3400 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3401 body
.emit(assign(tmp
, mul(x
, x
)));
3402 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3404 imm(0.0536813784310406f
)),
3406 imm(0.1173503194786851f
)),
3408 imm(0.1938924977115610f
)),
3410 imm(0.3326756418091246f
)),
3412 imm(0.9999793128310355f
)),
3415 /* range-reduction fixup */
3416 body
.emit(assign(tmp
, add(tmp
,
3417 mul(b2f(greater(abs(y_over_x
),
3418 imm(1.0f
, type
->components()))),
3424 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3427 ir_function_signature
*
3428 builtin_builder::_atan(const glsl_type
*type
)
3430 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3431 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3433 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3434 do_atan(body
, type
, tmp
, y_over_x
);
3435 body
.emit(ret(tmp
));
3440 ir_function_signature
*
3441 builtin_builder::_sinh(const glsl_type
*type
)
3443 ir_variable
*x
= in_var(type
, "x");
3444 MAKE_SIG(type
, v130
, 1, x
);
3446 /* 0.5 * (e^x - e^(-x)) */
3447 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3452 ir_function_signature
*
3453 builtin_builder::_cosh(const glsl_type
*type
)
3455 ir_variable
*x
= in_var(type
, "x");
3456 MAKE_SIG(type
, v130
, 1, x
);
3458 /* 0.5 * (e^x + e^(-x)) */
3459 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3464 ir_function_signature
*
3465 builtin_builder::_tanh(const glsl_type
*type
)
3467 ir_variable
*x
= in_var(type
, "x");
3468 MAKE_SIG(type
, v130
, 1, x
);
3470 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3471 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3472 add(exp(x
), exp(neg(x
))))));
3477 ir_function_signature
*
3478 builtin_builder::_asinh(const glsl_type
*type
)
3480 ir_variable
*x
= in_var(type
, "x");
3481 MAKE_SIG(type
, v130
, 1, x
);
3483 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3488 ir_function_signature
*
3489 builtin_builder::_acosh(const glsl_type
*type
)
3491 ir_variable
*x
= in_var(type
, "x");
3492 MAKE_SIG(type
, v130
, 1, x
);
3494 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3498 ir_function_signature
*
3499 builtin_builder::_atanh(const glsl_type
*type
)
3501 ir_variable
*x
= in_var(type
, "x");
3502 MAKE_SIG(type
, v130
, 1, x
);
3504 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3505 sub(imm(1.0f
), x
))))));
3511 * Exponential Functions @{
3514 ir_function_signature
*
3515 builtin_builder::_pow(const glsl_type
*type
)
3517 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3520 UNOP(exp
, ir_unop_exp
, always_available
)
3521 UNOP(log
, ir_unop_log
, always_available
)
3522 UNOP(exp2
, ir_unop_exp2
, always_available
)
3523 UNOP(log2
, ir_unop_log2
, always_available
)
3524 UNOPA(sqrt
, ir_unop_sqrt
)
3525 UNOPA(inversesqrt
, ir_unop_rsq
)
3529 UNOPA(abs
, ir_unop_abs
)
3530 UNOPA(sign
, ir_unop_sign
)
3531 UNOPA(floor
, ir_unop_floor
)
3532 UNOPA(trunc
, ir_unop_trunc
)
3533 UNOPA(round
, ir_unop_round_even
)
3534 UNOPA(roundEven
, ir_unop_round_even
)
3535 UNOPA(ceil
, ir_unop_ceil
)
3536 UNOPA(fract
, ir_unop_fract
)
3538 ir_function_signature
*
3539 builtin_builder::_mod(builtin_available_predicate avail
,
3540 const glsl_type
*x_type
, const glsl_type
*y_type
)
3542 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3545 ir_function_signature
*
3546 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3548 ir_variable
*x
= in_var(type
, "x");
3549 ir_variable
*i
= out_var(type
, "i");
3550 MAKE_SIG(type
, avail
, 2, x
, i
);
3552 ir_variable
*t
= body
.make_temp(type
, "t");
3553 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3554 body
.emit(assign(i
, t
));
3555 body
.emit(ret(sub(x
, t
)));
3560 ir_function_signature
*
3561 builtin_builder::_min(builtin_available_predicate avail
,
3562 const glsl_type
*x_type
, const glsl_type
*y_type
)
3564 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3567 ir_function_signature
*
3568 builtin_builder::_max(builtin_available_predicate avail
,
3569 const glsl_type
*x_type
, const glsl_type
*y_type
)
3571 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3574 ir_function_signature
*
3575 builtin_builder::_clamp(builtin_available_predicate avail
,
3576 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3578 ir_variable
*x
= in_var(val_type
, "x");
3579 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3580 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3581 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3583 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3588 ir_function_signature
*
3589 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3591 ir_variable
*x
= in_var(val_type
, "x");
3592 ir_variable
*y
= in_var(val_type
, "y");
3593 ir_variable
*a
= in_var(blend_type
, "a");
3594 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3596 body
.emit(ret(lrp(x
, y
, a
)));
3601 ir_function_signature
*
3602 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3603 const glsl_type
*val_type
,
3604 const glsl_type
*blend_type
)
3606 ir_variable
*x
= in_var(val_type
, "x");
3607 ir_variable
*y
= in_var(val_type
, "y");
3608 ir_variable
*a
= in_var(blend_type
, "a");
3609 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3611 /* csel matches the ternary operator in that a selector of true choses the
3612 * first argument. This differs from mix(x, y, false) which choses the
3613 * second argument (to remain consistent with the interpolating version of
3614 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3616 * To handle the behavior mismatch, reverse the x and y arguments.
3618 body
.emit(ret(csel(a
, y
, x
)));
3623 ir_function_signature
*
3624 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3626 ir_variable
*edge
= in_var(edge_type
, "edge");
3627 ir_variable
*x
= in_var(x_type
, "x");
3628 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3630 ir_variable
*t
= body
.make_temp(x_type
, "t");
3631 if (x_type
->vector_elements
== 1) {
3632 /* Both are floats */
3633 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3634 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3636 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3637 } else if (edge_type
->vector_elements
== 1) {
3638 /* x is a vector but edge is a float */
3639 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3640 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3641 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3643 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3646 /* Both are vectors */
3647 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3648 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3649 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3652 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3662 ir_function_signature
*
3663 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3665 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3666 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3667 ir_variable
*x
= in_var(x_type
, "x");
3668 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3670 /* From the GLSL 1.10 specification:
3673 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3674 * return t * t * (3 - 2 * t);
3677 ir_variable
*t
= body
.make_temp(x_type
, "t");
3678 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3679 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3681 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3686 ir_function_signature
*
3687 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3689 ir_variable
*x
= in_var(type
, "x");
3690 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3692 body
.emit(ret(nequal(x
, x
)));
3697 ir_function_signature
*
3698 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3700 ir_variable
*x
= in_var(type
, "x");
3701 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3703 ir_constant_data infinities
;
3704 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3705 switch (type
->base_type
) {
3706 case GLSL_TYPE_FLOAT
:
3707 infinities
.f
[i
] = INFINITY
;
3709 case GLSL_TYPE_DOUBLE
:
3710 infinities
.d
[i
] = INFINITY
;
3713 unreachable("unknown type");
3717 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3722 ir_function_signature
*
3723 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3725 ir_variable
*x
= in_var(type
, "x");
3726 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3727 body
.emit(ret(bitcast_f2i(x
)));
3731 ir_function_signature
*
3732 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3734 ir_variable
*x
= in_var(type
, "x");
3735 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3736 body
.emit(ret(bitcast_f2u(x
)));
3740 ir_function_signature
*
3741 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3743 ir_variable
*x
= in_var(type
, "x");
3744 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3745 body
.emit(ret(bitcast_i2f(x
)));
3749 ir_function_signature
*
3750 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3752 ir_variable
*x
= in_var(type
, "x");
3753 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3754 body
.emit(ret(bitcast_u2f(x
)));
3758 ir_function_signature
*
3759 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3761 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3762 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3763 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3767 ir_function_signature
*
3768 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3770 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3771 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3772 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3776 ir_function_signature
*
3777 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3779 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3780 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3781 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3785 ir_function_signature
*
3786 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3788 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3789 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3790 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3794 ir_function_signature
*
3795 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3797 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3798 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3799 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3803 ir_function_signature
*
3804 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3806 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3807 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3808 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3813 ir_function_signature
*
3814 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3816 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3817 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3818 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3822 ir_function_signature
*
3823 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3825 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3826 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3827 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3831 ir_function_signature
*
3832 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3834 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3835 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3836 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3840 ir_function_signature
*
3841 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3843 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3844 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3845 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3849 ir_function_signature
*
3850 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3852 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3853 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3854 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3858 ir_function_signature
*
3859 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3861 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3862 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3863 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3867 ir_function_signature
*
3868 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3870 ir_variable
*x
= in_var(type
, "x");
3871 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3873 body
.emit(ret(sqrt(dot(x
, x
))));
3878 ir_function_signature
*
3879 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3881 ir_variable
*p0
= in_var(type
, "p0");
3882 ir_variable
*p1
= in_var(type
, "p1");
3883 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3885 if (type
->vector_elements
== 1) {
3886 body
.emit(ret(abs(sub(p0
, p1
))));
3888 ir_variable
*p
= body
.make_temp(type
, "p");
3889 body
.emit(assign(p
, sub(p0
, p1
)));
3890 body
.emit(ret(sqrt(dot(p
, p
))));
3896 ir_function_signature
*
3897 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3899 if (type
->vector_elements
== 1)
3900 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3902 return binop(avail
, ir_binop_dot
,
3903 type
->get_base_type(), type
, type
);
3906 ir_function_signature
*
3907 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3909 ir_variable
*a
= in_var(type
, "a");
3910 ir_variable
*b
= in_var(type
, "b");
3911 MAKE_SIG(type
, avail
, 2, a
, b
);
3913 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3914 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3916 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3917 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3922 ir_function_signature
*
3923 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3925 ir_variable
*x
= in_var(type
, "x");
3926 MAKE_SIG(type
, avail
, 1, x
);
3928 if (type
->vector_elements
== 1) {
3929 body
.emit(ret(sign(x
)));
3931 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3937 ir_function_signature
*
3938 builtin_builder::_ftransform()
3940 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3942 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3943 glsl_type::vec4_type
,
3944 var_ref(gl_ModelViewProjectionMatrix
),
3945 var_ref(gl_Vertex
))));
3947 /* FINISHME: Once the ir_expression() constructor handles type inference
3948 * for matrix operations, we can simplify this to:
3950 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3955 ir_function_signature
*
3956 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3958 ir_variable
*N
= in_var(type
, "N");
3959 ir_variable
*I
= in_var(type
, "I");
3960 ir_variable
*Nref
= in_var(type
, "Nref");
3961 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3963 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3964 ret(N
), ret(neg(N
))));
3969 ir_function_signature
*
3970 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3972 ir_variable
*I
= in_var(type
, "I");
3973 ir_variable
*N
= in_var(type
, "N");
3974 MAKE_SIG(type
, avail
, 2, I
, N
);
3976 /* I - 2 * dot(N, I) * N */
3977 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3982 ir_function_signature
*
3983 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3985 ir_variable
*I
= in_var(type
, "I");
3986 ir_variable
*N
= in_var(type
, "N");
3987 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3988 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
3990 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
3991 body
.emit(assign(n_dot_i
, dot(N
, I
)));
3993 /* From the GLSL 1.10 specification:
3994 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
3996 * return genType(0.0)
3998 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4000 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4001 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4002 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4003 mul(n_dot_i
, n_dot_i
)))))));
4004 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4005 ret(ir_constant::zero(mem_ctx
, type
)),
4006 ret(sub(mul(eta
, I
),
4007 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4012 ir_function_signature
*
4013 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4015 ir_variable
*x
= in_var(type
, "x");
4016 ir_variable
*y
= in_var(type
, "y");
4017 MAKE_SIG(type
, avail
, 2, x
, y
);
4019 ir_variable
*z
= body
.make_temp(type
, "z");
4020 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4021 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4028 ir_function_signature
*
4029 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4034 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
4035 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4036 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4038 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4039 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4041 MAKE_SIG(type
, avail
, 2, c
, r
);
4043 ir_variable
*m
= body
.make_temp(type
, "m");
4044 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4045 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4052 ir_function_signature
*
4053 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4055 const glsl_type
*transpose_type
=
4056 glsl_type::get_instance(orig_type
->base_type
,
4057 orig_type
->matrix_columns
,
4058 orig_type
->vector_elements
);
4060 ir_variable
*m
= in_var(orig_type
, "m");
4061 MAKE_SIG(transpose_type
, avail
, 1, m
);
4063 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4064 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4065 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4066 body
.emit(assign(array_ref(t
, j
),
4067 matrix_elt(m
, i
, j
),
4076 ir_function_signature
*
4077 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4079 ir_variable
*m
= in_var(type
, "m");
4080 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4082 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4083 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4088 ir_function_signature
*
4089 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4091 ir_variable
*m
= in_var(type
, "m");
4092 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4095 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4096 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4099 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4100 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4103 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4104 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4106 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4107 mul(matrix_elt(m
, 0, 1), f2
)),
4108 mul(matrix_elt(m
, 0, 2), f3
))));
4113 ir_function_signature
*
4114 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4116 ir_variable
*m
= in_var(type
, "m");
4117 const glsl_type
*btype
= type
->get_base_type();
4118 MAKE_SIG(btype
, avail
, 1, m
);
4120 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4121 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4122 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4123 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4124 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4125 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4126 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4127 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4128 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4129 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4130 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4131 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4132 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4133 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4134 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4135 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4136 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4137 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4138 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4140 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)))));
4141 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)))));
4142 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)))));
4143 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)))));
4144 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)))));
4145 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)))));
4146 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)))));
4147 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)))));
4148 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)))));
4149 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)))));
4150 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)))));
4151 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)))));
4152 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)))));
4153 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)))));
4154 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)))));
4155 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)))));
4156 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)))));
4157 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)))));
4158 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)))));
4160 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4162 body
.emit(assign(adj_0
,
4163 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4164 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4165 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4167 body
.emit(assign(adj_0
, neg(
4168 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4169 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4170 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4172 body
.emit(assign(adj_0
,
4173 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4174 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4175 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4177 body
.emit(assign(adj_0
, neg(
4178 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4179 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4180 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4183 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4188 ir_function_signature
*
4189 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4191 ir_variable
*m
= in_var(type
, "m");
4192 MAKE_SIG(type
, avail
, 1, m
);
4194 ir_variable
*adj
= body
.make_temp(type
, "adj");
4195 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4196 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4197 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4198 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4200 ir_expression
*det
=
4201 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4202 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4204 body
.emit(ret(div(adj
, det
)));
4208 ir_function_signature
*
4209 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4211 ir_variable
*m
= in_var(type
, "m");
4212 const glsl_type
*btype
= type
->get_base_type();
4213 MAKE_SIG(type
, avail
, 1, m
);
4215 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4216 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4217 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4219 body
.emit(assign(f11_22_21_12
,
4220 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4221 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4222 body
.emit(assign(f10_22_20_12
,
4223 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4224 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4225 body
.emit(assign(f10_21_20_11
,
4226 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4227 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4229 ir_variable
*adj
= body
.make_temp(type
, "adj");
4230 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4231 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4232 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4234 body
.emit(assign(array_ref(adj
, 0), neg(
4235 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4236 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4238 body
.emit(assign(array_ref(adj
, 1),
4239 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4240 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4242 body
.emit(assign(array_ref(adj
, 2), neg(
4243 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4244 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4247 body
.emit(assign(array_ref(adj
, 0),
4248 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4249 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4251 body
.emit(assign(array_ref(adj
, 1), neg(
4252 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4253 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4255 body
.emit(assign(array_ref(adj
, 2),
4256 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4257 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4260 ir_expression
*det
=
4261 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4262 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4263 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4265 body
.emit(ret(div(adj
, det
)));
4270 ir_function_signature
*
4271 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4273 ir_variable
*m
= in_var(type
, "m");
4274 const glsl_type
*btype
= type
->get_base_type();
4275 MAKE_SIG(type
, avail
, 1, m
);
4277 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4278 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4279 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4280 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4281 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4282 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4283 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4284 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4285 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4286 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4287 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4288 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4289 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4290 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4291 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4292 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4293 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4294 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4295 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4297 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)))));
4298 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)))));
4299 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)))));
4300 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)))));
4301 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)))));
4302 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)))));
4303 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)))));
4304 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)))));
4305 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)))));
4306 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)))));
4307 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)))));
4308 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)))));
4309 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)))));
4310 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)))));
4311 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)))));
4312 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)))));
4313 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)))));
4314 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)))));
4315 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)))));
4317 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4318 body
.emit(assign(array_ref(adj
, 0),
4319 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4320 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4321 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4323 body
.emit(assign(array_ref(adj
, 1), neg(
4324 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4325 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4326 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4328 body
.emit(assign(array_ref(adj
, 2),
4329 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4330 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4331 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4333 body
.emit(assign(array_ref(adj
, 3), neg(
4334 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4335 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4336 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4339 body
.emit(assign(array_ref(adj
, 0), neg(
4340 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4341 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4342 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4344 body
.emit(assign(array_ref(adj
, 1),
4345 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4346 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4347 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4349 body
.emit(assign(array_ref(adj
, 2), neg(
4350 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4351 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4352 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4354 body
.emit(assign(array_ref(adj
, 3),
4355 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4356 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4357 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4360 body
.emit(assign(array_ref(adj
, 0),
4361 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4362 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4363 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4365 body
.emit(assign(array_ref(adj
, 1), neg(
4366 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4367 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4368 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4370 body
.emit(assign(array_ref(adj
, 2),
4371 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4372 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4373 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4375 body
.emit(assign(array_ref(adj
, 3), neg(
4376 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4377 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4378 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4381 body
.emit(assign(array_ref(adj
, 0), neg(
4382 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4383 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4384 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4386 body
.emit(assign(array_ref(adj
, 1),
4387 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4388 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4389 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4391 body
.emit(assign(array_ref(adj
, 2), neg(
4392 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4393 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4394 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4396 body
.emit(assign(array_ref(adj
, 3),
4397 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4398 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4399 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4402 ir_expression
*det
=
4403 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4404 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4405 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4406 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4408 body
.emit(ret(div(adj
, det
)));
4414 ir_function_signature
*
4415 builtin_builder::_lessThan(builtin_available_predicate avail
,
4416 const glsl_type
*type
)
4418 return binop(avail
, ir_binop_less
,
4419 glsl_type::bvec(type
->vector_elements
), type
, type
);
4422 ir_function_signature
*
4423 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4424 const glsl_type
*type
)
4426 return binop(avail
, ir_binop_lequal
,
4427 glsl_type::bvec(type
->vector_elements
), type
, type
);
4430 ir_function_signature
*
4431 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4432 const glsl_type
*type
)
4434 return binop(avail
, ir_binop_greater
,
4435 glsl_type::bvec(type
->vector_elements
), type
, type
);
4438 ir_function_signature
*
4439 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4440 const glsl_type
*type
)
4442 return binop(avail
, ir_binop_gequal
,
4443 glsl_type::bvec(type
->vector_elements
), type
, type
);
4446 ir_function_signature
*
4447 builtin_builder::_equal(builtin_available_predicate avail
,
4448 const glsl_type
*type
)
4450 return binop(avail
, ir_binop_equal
,
4451 glsl_type::bvec(type
->vector_elements
), type
, type
);
4454 ir_function_signature
*
4455 builtin_builder::_notEqual(builtin_available_predicate avail
,
4456 const glsl_type
*type
)
4458 return binop(avail
, ir_binop_nequal
,
4459 glsl_type::bvec(type
->vector_elements
), type
, type
);
4462 ir_function_signature
*
4463 builtin_builder::_any(const glsl_type
*type
)
4465 ir_variable
*v
= in_var(type
, "v");
4466 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4468 const unsigned vec_elem
= v
->type
->vector_elements
;
4469 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4474 ir_function_signature
*
4475 builtin_builder::_all(const glsl_type
*type
)
4477 ir_variable
*v
= in_var(type
, "v");
4478 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4480 const unsigned vec_elem
= v
->type
->vector_elements
;
4481 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4486 UNOP(not, ir_unop_logic_not
, always_available
)
4489 has_lod(const glsl_type
*sampler_type
)
4491 assert(sampler_type
->is_sampler());
4493 switch (sampler_type
->sampler_dimensionality
) {
4494 case GLSL_SAMPLER_DIM_RECT
:
4495 case GLSL_SAMPLER_DIM_BUF
:
4496 case GLSL_SAMPLER_DIM_MS
:
4503 ir_function_signature
*
4504 builtin_builder::_textureSize(builtin_available_predicate avail
,
4505 const glsl_type
*return_type
,
4506 const glsl_type
*sampler_type
)
4508 ir_variable
*s
= in_var(sampler_type
, "sampler");
4509 /* The sampler always exists; add optional lod later. */
4510 MAKE_SIG(return_type
, avail
, 1, s
);
4512 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4513 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4515 if (has_lod(sampler_type
)) {
4516 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4517 sig
->parameters
.push_tail(lod
);
4518 tex
->lod_info
.lod
= var_ref(lod
);
4520 tex
->lod_info
.lod
= imm(0u);
4523 body
.emit(ret(tex
));
4528 ir_function_signature
*
4529 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4531 ir_variable
*s
= in_var(sampler_type
, "sampler");
4532 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4534 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4535 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4536 body
.emit(ret(tex
));
4541 ir_function_signature
*
4542 builtin_builder::_texture(ir_texture_opcode opcode
,
4543 builtin_available_predicate avail
,
4544 const glsl_type
*return_type
,
4545 const glsl_type
*sampler_type
,
4546 const glsl_type
*coord_type
,
4549 ir_variable
*s
= in_var(sampler_type
, "sampler");
4550 ir_variable
*P
= in_var(coord_type
, "P");
4551 /* The sampler and coordinate always exist; add optional parameters later. */
4552 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4554 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4555 tex
->set_sampler(var_ref(s
), return_type
);
4557 const int coord_size
= sampler_type
->coordinate_components();
4559 if (coord_size
== coord_type
->vector_elements
) {
4560 tex
->coordinate
= var_ref(P
);
4562 /* The incoming coordinate also has the projector or shadow comparitor,
4563 * so we need to swizzle those away.
4565 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4568 /* The projector is always in the last component. */
4569 if (flags
& TEX_PROJECT
)
4570 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4572 if (sampler_type
->sampler_shadow
) {
4573 if (opcode
== ir_tg4
) {
4574 /* gather has refz as a separate parameter, immediately after the
4577 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4578 sig
->parameters
.push_tail(refz
);
4579 tex
->shadow_comparitor
= var_ref(refz
);
4581 /* The shadow comparitor is normally in the Z component, but a few types
4582 * have sufficiently large coordinates that it's in W.
4584 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4588 if (opcode
== ir_txl
) {
4589 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4590 sig
->parameters
.push_tail(lod
);
4591 tex
->lod_info
.lod
= var_ref(lod
);
4592 } else if (opcode
== ir_txd
) {
4593 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4594 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4595 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4596 sig
->parameters
.push_tail(dPdx
);
4597 sig
->parameters
.push_tail(dPdy
);
4598 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4599 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4602 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4603 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4604 ir_variable
*offset
=
4605 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4606 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4607 sig
->parameters
.push_tail(offset
);
4608 tex
->offset
= var_ref(offset
);
4611 if (flags
& TEX_OFFSET_ARRAY
) {
4612 ir_variable
*offsets
=
4613 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4614 "offsets", ir_var_const_in
);
4615 sig
->parameters
.push_tail(offsets
);
4616 tex
->offset
= var_ref(offsets
);
4619 if (opcode
== ir_tg4
) {
4620 if (flags
& TEX_COMPONENT
) {
4621 ir_variable
*component
=
4622 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4623 sig
->parameters
.push_tail(component
);
4624 tex
->lod_info
.component
= var_ref(component
);
4627 tex
->lod_info
.component
= imm(0);
4631 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4632 * inconsistent with both textureLodOffset and textureGradOffset.
4634 if (opcode
== ir_txb
) {
4635 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4636 sig
->parameters
.push_tail(bias
);
4637 tex
->lod_info
.bias
= var_ref(bias
);
4640 body
.emit(ret(tex
));
4645 ir_function_signature
*
4646 builtin_builder::_textureCubeArrayShadow()
4648 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4649 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4650 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4651 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4653 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4654 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4656 tex
->coordinate
= var_ref(P
);
4657 tex
->shadow_comparitor
= var_ref(compare
);
4659 body
.emit(ret(tex
));
4664 ir_function_signature
*
4665 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4666 const glsl_type
*return_type
,
4667 const glsl_type
*sampler_type
,
4668 const glsl_type
*coord_type
,
4669 const glsl_type
*offset_type
)
4671 ir_variable
*s
= in_var(sampler_type
, "sampler");
4672 ir_variable
*P
= in_var(coord_type
, "P");
4673 /* The sampler and coordinate always exist; add optional parameters later. */
4674 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4676 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4677 tex
->coordinate
= var_ref(P
);
4678 tex
->set_sampler(var_ref(s
), return_type
);
4680 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4681 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4682 sig
->parameters
.push_tail(sample
);
4683 tex
->lod_info
.sample_index
= var_ref(sample
);
4684 tex
->op
= ir_txf_ms
;
4685 } else if (has_lod(sampler_type
)) {
4686 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4687 sig
->parameters
.push_tail(lod
);
4688 tex
->lod_info
.lod
= var_ref(lod
);
4690 tex
->lod_info
.lod
= imm(0u);
4693 if (offset_type
!= NULL
) {
4694 ir_variable
*offset
=
4695 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4696 sig
->parameters
.push_tail(offset
);
4697 tex
->offset
= var_ref(offset
);
4700 body
.emit(ret(tex
));
4705 ir_function_signature
*
4706 builtin_builder::_EmitVertex()
4708 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4710 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4711 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4716 ir_function_signature
*
4717 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4718 const glsl_type
*stream_type
)
4720 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4722 * "Emit the current values of output variables to the current output
4723 * primitive on stream stream. The argument to stream must be a constant
4724 * integral expression."
4726 ir_variable
*stream
=
4727 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4729 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4731 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4736 ir_function_signature
*
4737 builtin_builder::_EndPrimitive()
4739 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4741 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4742 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4747 ir_function_signature
*
4748 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4749 const glsl_type
*stream_type
)
4751 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4753 * "Completes the current output primitive on stream stream and starts
4754 * a new one. The argument to stream must be a constant integral
4757 ir_variable
*stream
=
4758 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4760 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4762 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4767 ir_function_signature
*
4768 builtin_builder::_barrier()
4770 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4772 body
.emit(new(mem_ctx
) ir_barrier());
4776 ir_function_signature
*
4777 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4778 const glsl_type
*sampler_type
,
4779 const glsl_type
*coord_type
)
4781 ir_variable
*s
= in_var(sampler_type
, "sampler");
4782 ir_variable
*coord
= in_var(coord_type
, "coord");
4783 /* The sampler and coordinate always exist; add optional parameters later. */
4784 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4786 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4787 tex
->coordinate
= var_ref(coord
);
4788 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4790 body
.emit(ret(tex
));
4795 ir_function_signature
*
4796 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4798 ir_variable
*s
= in_var(sampler_type
, "sampler");
4799 const glsl_type
*return_type
= glsl_type::int_type
;
4800 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4802 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4803 tex
->set_sampler(var_ref(s
), return_type
);
4805 body
.emit(ret(tex
));
4810 ir_function_signature
*
4811 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4812 const glsl_type
*sampler_type
,
4813 const glsl_type
*coord_type
)
4815 ir_variable
*s
= in_var(sampler_type
, "sampler");
4816 ir_variable
*P
= in_var(coord_type
, "P");
4817 const glsl_type
*return_type
= glsl_type::bool_type
;
4818 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4820 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4821 tex
->coordinate
= var_ref(P
);
4822 tex
->set_sampler(var_ref(s
), return_type
);
4824 body
.emit(ret(tex
));
4829 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4830 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4831 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4832 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4833 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4834 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4836 ir_function_signature
*
4837 builtin_builder::_fwidth(const glsl_type
*type
)
4839 ir_variable
*p
= in_var(type
, "p");
4840 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4842 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4847 ir_function_signature
*
4848 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4850 ir_variable
*p
= in_var(type
, "p");
4851 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4853 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4854 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4859 ir_function_signature
*
4860 builtin_builder::_fwidthFine(const glsl_type
*type
)
4862 ir_variable
*p
= in_var(type
, "p");
4863 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4865 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4866 abs(expr(ir_unop_dFdy_fine
, p
)))));
4871 ir_function_signature
*
4872 builtin_builder::_noise1(const glsl_type
*type
)
4874 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4877 ir_function_signature
*
4878 builtin_builder::_noise2(const glsl_type
*type
)
4880 ir_variable
*p
= in_var(type
, "p");
4881 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4883 ir_constant_data b_offset
;
4884 b_offset
.f
[0] = 601.0f
;
4885 b_offset
.f
[1] = 313.0f
;
4886 b_offset
.f
[2] = 29.0f
;
4887 b_offset
.f
[3] = 277.0f
;
4889 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4890 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4891 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4892 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4893 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4894 body
.emit(assign(t
, a
, WRITEMASK_X
));
4895 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4901 ir_function_signature
*
4902 builtin_builder::_noise3(const glsl_type
*type
)
4904 ir_variable
*p
= in_var(type
, "p");
4905 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4907 ir_constant_data b_offset
;
4908 b_offset
.f
[0] = 601.0f
;
4909 b_offset
.f
[1] = 313.0f
;
4910 b_offset
.f
[2] = 29.0f
;
4911 b_offset
.f
[3] = 277.0f
;
4913 ir_constant_data c_offset
;
4914 c_offset
.f
[0] = 1559.0f
;
4915 c_offset
.f
[1] = 113.0f
;
4916 c_offset
.f
[2] = 1861.0f
;
4917 c_offset
.f
[3] = 797.0f
;
4919 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4920 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4921 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4922 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4923 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4924 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4925 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4926 body
.emit(assign(t
, a
, WRITEMASK_X
));
4927 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4928 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4934 ir_function_signature
*
4935 builtin_builder::_noise4(const glsl_type
*type
)
4937 ir_variable
*p
= in_var(type
, "p");
4938 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4940 ir_variable
*_p
= body
.make_temp(type
, "_p");
4942 ir_constant_data p_offset
;
4943 p_offset
.f
[0] = 1559.0f
;
4944 p_offset
.f
[1] = 113.0f
;
4945 p_offset
.f
[2] = 1861.0f
;
4946 p_offset
.f
[3] = 797.0f
;
4948 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4950 ir_constant_data offset
;
4951 offset
.f
[0] = 601.0f
;
4952 offset
.f
[1] = 313.0f
;
4953 offset
.f
[2] = 29.0f
;
4954 offset
.f
[3] = 277.0f
;
4956 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4957 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4958 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4959 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4960 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4961 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4962 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4963 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4964 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4965 body
.emit(assign(t
, a
, WRITEMASK_X
));
4966 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4967 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4968 body
.emit(assign(t
, d
, WRITEMASK_W
));
4974 ir_function_signature
*
4975 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4977 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4978 ir_variable
*value
= in_var(type
, "value");
4979 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4980 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4981 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4983 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
4984 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
4986 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
4987 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
4988 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
4993 ir_function_signature
*
4994 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
4996 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4997 ir_variable
*base
= in_var(type
, "base");
4998 ir_variable
*insert
= in_var(type
, "insert");
4999 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5000 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5001 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
5003 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5004 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5006 body
.emit(ret(bitfield_insert(base
, insert
,
5007 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5008 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5013 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
5015 ir_function_signature
*
5016 builtin_builder::_bitCount(const glsl_type
*type
)
5018 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
5019 glsl_type::ivec(type
->vector_elements
), type
);
5022 ir_function_signature
*
5023 builtin_builder::_findLSB(const glsl_type
*type
)
5025 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
5026 glsl_type::ivec(type
->vector_elements
), type
);
5029 ir_function_signature
*
5030 builtin_builder::_findMSB(const glsl_type
*type
)
5032 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
5033 glsl_type::ivec(type
->vector_elements
), type
);
5036 ir_function_signature
*
5037 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5039 ir_variable
*a
= in_var(type
, "a");
5040 ir_variable
*b
= in_var(type
, "b");
5041 ir_variable
*c
= in_var(type
, "c");
5042 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5044 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5049 ir_function_signature
*
5050 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5052 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
,
5053 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5056 ir_function_signature
*
5057 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5059 ir_variable
*x
= in_var(x_type
, "x");
5060 ir_variable
*exponent
= out_var(exp_type
, "exp");
5061 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5063 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5065 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5069 ir_function_signature
*
5070 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5072 ir_variable
*x
= in_var(x_type
, "x");
5073 ir_variable
*exponent
= out_var(exp_type
, "exp");
5074 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
5076 const unsigned vec_elem
= x_type
->vector_elements
;
5077 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5078 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5080 /* Single-precision floating-point values are stored as
5085 * An exponent shift of 23 will shift the mantissa out, leaving only the
5086 * exponent and sign bit (which itself may be zero, if the absolute value
5087 * was taken before the bitcast and shift.
5089 ir_constant
*exponent_shift
= imm(23);
5090 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5092 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5094 /* Exponent of floating-point values in the range [0.5, 1.0). */
5095 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5097 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5098 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5100 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5101 * to unsigned integers to ensure that 1 bits aren't shifted in.
5103 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5104 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5105 imm(0, vec_elem
)))));
5107 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5108 body
.emit(assign(bits
, bitcast_f2u(x
)));
5109 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5110 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5111 imm(0u, vec_elem
)))));
5112 body
.emit(ret(bitcast_u2f(bits
)));
5117 ir_function_signature
*
5118 builtin_builder::_uaddCarry(const glsl_type
*type
)
5120 ir_variable
*x
= in_var(type
, "x");
5121 ir_variable
*y
= in_var(type
, "y");
5122 ir_variable
*carry
= out_var(type
, "carry");
5123 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
5125 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5126 body
.emit(ret(add(x
, y
)));
5131 ir_function_signature
*
5132 builtin_builder::_usubBorrow(const glsl_type
*type
)
5134 ir_variable
*x
= in_var(type
, "x");
5135 ir_variable
*y
= in_var(type
, "y");
5136 ir_variable
*borrow
= out_var(type
, "borrow");
5137 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
5139 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5140 body
.emit(ret(sub(x
, y
)));
5146 * For both imulExtended() and umulExtended() built-ins.
5148 ir_function_signature
*
5149 builtin_builder::_mulExtended(const glsl_type
*type
)
5151 ir_variable
*x
= in_var(type
, "x");
5152 ir_variable
*y
= in_var(type
, "y");
5153 ir_variable
*msb
= out_var(type
, "msb");
5154 ir_variable
*lsb
= out_var(type
, "lsb");
5155 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5157 body
.emit(assign(msb
, imul_high(x
, y
)));
5158 body
.emit(assign(lsb
, mul(x
, y
)));
5163 ir_function_signature
*
5164 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5166 ir_variable
*interpolant
= in_var(type
, "interpolant");
5167 interpolant
->data
.must_be_shader_input
= 1;
5168 MAKE_SIG(type
, fs_gpu_shader5
, 1, interpolant
);
5170 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5175 ir_function_signature
*
5176 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5178 ir_variable
*interpolant
= in_var(type
, "interpolant");
5179 interpolant
->data
.must_be_shader_input
= 1;
5180 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5181 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, offset
);
5183 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5188 ir_function_signature
*
5189 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5191 ir_variable
*interpolant
= in_var(type
, "interpolant");
5192 interpolant
->data
.must_be_shader_input
= 1;
5193 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5194 MAKE_SIG(type
, fs_gpu_shader5
, 2, interpolant
, sample_num
);
5196 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5201 ir_function_signature
*
5202 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5204 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5205 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5209 ir_function_signature
*
5210 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
)
5212 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5213 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5214 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 2, counter
, data
);
5218 ir_function_signature
*
5219 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
)
5221 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5222 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5223 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5224 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5228 ir_function_signature
*
5229 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5230 const glsl_type
*type
)
5232 ir_variable
*atomic
= in_var(type
, "atomic");
5233 ir_variable
*data
= in_var(type
, "data");
5234 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5238 ir_function_signature
*
5239 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5240 const glsl_type
*type
)
5242 ir_variable
*atomic
= in_var(type
, "atomic");
5243 ir_variable
*data1
= in_var(type
, "data1");
5244 ir_variable
*data2
= in_var(type
, "data2");
5245 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5249 ir_function_signature
*
5250 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5251 builtin_available_predicate avail
)
5253 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5254 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5256 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5257 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5259 body
.emit(ret(retval
));
5263 ir_function_signature
*
5264 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5265 builtin_available_predicate avail
)
5267 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5268 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5269 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5271 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5272 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5274 body
.emit(ret(retval
));
5278 ir_function_signature
*
5279 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5280 builtin_available_predicate avail
)
5282 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5283 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5284 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5285 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5287 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5288 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5290 body
.emit(ret(retval
));
5294 ir_function_signature
*
5295 builtin_builder::_atomic_op2(const char *intrinsic
,
5296 builtin_available_predicate avail
,
5297 const glsl_type
*type
)
5299 ir_variable
*atomic
= in_var(type
, "atomic_var");
5300 ir_variable
*data
= in_var(type
, "atomic_data");
5301 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5303 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5304 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5306 body
.emit(ret(retval
));
5310 ir_function_signature
*
5311 builtin_builder::_atomic_op3(const char *intrinsic
,
5312 builtin_available_predicate avail
,
5313 const glsl_type
*type
)
5315 ir_variable
*atomic
= in_var(type
, "atomic_var");
5316 ir_variable
*data1
= in_var(type
, "atomic_data1");
5317 ir_variable
*data2
= in_var(type
, "atomic_data2");
5318 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5320 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5321 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5323 body
.emit(ret(retval
));
5327 ir_function_signature
*
5328 builtin_builder::_min3(const glsl_type
*type
)
5330 ir_variable
*x
= in_var(type
, "x");
5331 ir_variable
*y
= in_var(type
, "y");
5332 ir_variable
*z
= in_var(type
, "z");
5333 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5335 ir_expression
*min3
= min2(x
, min2(y
,z
));
5336 body
.emit(ret(min3
));
5341 ir_function_signature
*
5342 builtin_builder::_max3(const glsl_type
*type
)
5344 ir_variable
*x
= in_var(type
, "x");
5345 ir_variable
*y
= in_var(type
, "y");
5346 ir_variable
*z
= in_var(type
, "z");
5347 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5349 ir_expression
*max3
= max2(x
, max2(y
,z
));
5350 body
.emit(ret(max3
));
5355 ir_function_signature
*
5356 builtin_builder::_mid3(const glsl_type
*type
)
5358 ir_variable
*x
= in_var(type
, "x");
5359 ir_variable
*y
= in_var(type
, "y");
5360 ir_variable
*z
= in_var(type
, "z");
5361 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5363 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5364 body
.emit(ret(mid3
));
5369 static builtin_available_predicate
5370 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5372 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5373 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5374 return shader_image_atomic_exchange_float
;
5376 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5377 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5378 return shader_image_atomic
;
5381 return shader_image_load_store
;
5384 ir_function_signature
*
5385 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5386 unsigned num_arguments
,
5389 const glsl_type
*data_type
= glsl_type::get_instance(
5390 image_type
->sampled_type
,
5391 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5393 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5394 glsl_type::void_type
: data_type
);
5396 /* Addressing arguments that are always present. */
5397 ir_variable
*image
= in_var(image_type
, "image");
5398 ir_variable
*coord
= in_var(
5399 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5401 ir_function_signature
*sig
= new_sig(
5402 ret_type
, get_image_available_predicate(image_type
, flags
),
5405 /* Sample index for multisample images. */
5406 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5407 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5409 /* Data arguments. */
5410 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5411 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5412 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5413 ralloc_free(arg_name
);
5416 /* Set the maximal set of qualifiers allowed for this image
5417 * built-in. Function calls with arguments having fewer
5418 * qualifiers than present in the prototype are allowed by the
5419 * spec, but not with more, i.e. this will make the compiler
5420 * accept everything that needs to be accepted, and reject cases
5421 * like loads from write-only or stores to read-only images.
5423 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5424 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5425 image
->data
.image_coherent
= true;
5426 image
->data
.image_volatile
= true;
5427 image
->data
.image_restrict
= true;
5432 ir_function_signature
*
5433 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5434 unsigned /* num_arguments */,
5435 unsigned /* flags */)
5437 const glsl_type
*ret_type
;
5438 unsigned num_components
= image_type
->coordinate_components();
5440 /* From the ARB_shader_image_size extension:
5441 * "Cube images return the dimensions of one face."
5443 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5444 !image_type
->sampler_array
) {
5448 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5449 * supported by mesa.
5451 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5453 ir_variable
*image
= in_var(image_type
, "image");
5454 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5456 /* Set the maximal set of qualifiers allowed for this image
5457 * built-in. Function calls with arguments having fewer
5458 * qualifiers than present in the prototype are allowed by the
5459 * spec, but not with more, i.e. this will make the compiler
5460 * accept everything that needs to be accepted, and reject cases
5461 * like loads from write-only or stores to read-only images.
5463 image
->data
.image_read_only
= true;
5464 image
->data
.image_write_only
= true;
5465 image
->data
.image_coherent
= true;
5466 image
->data
.image_volatile
= true;
5467 image
->data
.image_restrict
= true;
5472 ir_function_signature
*
5473 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5474 unsigned /* num_arguments */,
5475 unsigned /* flags */)
5477 ir_variable
*image
= in_var(image_type
, "image");
5478 ir_function_signature
*sig
=
5479 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5481 /* Set the maximal set of qualifiers allowed for this image
5482 * built-in. Function calls with arguments having fewer
5483 * qualifiers than present in the prototype are allowed by the
5484 * spec, but not with more, i.e. this will make the compiler
5485 * accept everything that needs to be accepted, and reject cases
5486 * like loads from write-only or stores to read-only images.
5488 image
->data
.image_read_only
= true;
5489 image
->data
.image_write_only
= true;
5490 image
->data
.image_coherent
= true;
5491 image
->data
.image_volatile
= true;
5492 image
->data
.image_restrict
= true;
5497 ir_function_signature
*
5498 builtin_builder::_image(image_prototype_ctr prototype
,
5499 const glsl_type
*image_type
,
5500 const char *intrinsic_name
,
5501 unsigned num_arguments
,
5504 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5505 num_arguments
, flags
);
5507 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5508 ir_factory
body(&sig
->body
, mem_ctx
);
5509 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5511 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5512 body
.emit(call(f
, NULL
, sig
->parameters
));
5514 ir_variable
*ret_val
=
5515 body
.make_temp(sig
->return_type
, "_ret_val");
5516 body
.emit(call(f
, ret_val
, sig
->parameters
));
5517 body
.emit(ret(ret_val
));
5520 sig
->is_defined
= true;
5523 sig
->is_intrinsic
= true;
5529 ir_function_signature
*
5530 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5532 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5536 ir_function_signature
*
5537 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5538 builtin_available_predicate avail
)
5540 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5541 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5542 NULL
, sig
->parameters
));
5546 ir_function_signature
*
5547 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5548 const glsl_type
*type
)
5550 MAKE_INTRINSIC(type
, avail
, 0);
5554 ir_function_signature
*
5555 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5556 const glsl_type
*type
)
5558 MAKE_SIG(type
, avail
, 0);
5560 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5562 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5563 retval
, sig
->parameters
));
5564 body
.emit(ret(retval
));
5570 /******************************************************************************/
5572 /* The singleton instance of builtin_builder. */
5573 static builtin_builder builtins
;
5574 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5577 * External API (exposing the built-in module to the rest of the compiler):
5581 _mesa_glsl_initialize_builtin_functions()
5583 mtx_lock(&builtins_lock
);
5584 builtins
.initialize();
5585 mtx_unlock(&builtins_lock
);
5589 _mesa_glsl_release_builtin_functions()
5591 mtx_lock(&builtins_lock
);
5593 mtx_unlock(&builtins_lock
);
5596 ir_function_signature
*
5597 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5598 const char *name
, exec_list
*actual_parameters
)
5600 ir_function_signature
* s
;
5601 mtx_lock(&builtins_lock
);
5602 s
= builtins
.find(state
, name
, actual_parameters
);
5603 mtx_unlock(&builtins_lock
);
5608 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5611 mtx_lock(&builtins_lock
);
5612 f
= builtins
.shader
->symbols
->get_function(name
);
5613 mtx_unlock(&builtins_lock
);
5618 _mesa_glsl_get_builtin_function_shader()
5620 return builtins
.shader
;
5625 * Get the function signature for main from a shader
5627 ir_function_signature
*
5628 _mesa_get_main_function_signature(gl_shader
*sh
)
5630 ir_function
*const f
= sh
->symbols
->get_function("main");
5632 exec_list void_parameters
;
5634 /* Look for the 'void main()' signature and ensure that it's defined.
5635 * This keeps the linker from accidentally pick a shader that just
5636 * contains a prototype for main.
5638 * We don't have to check for multiple definitions of main (in multiple
5639 * shaders) because that would have already been caught above.
5641 ir_function_signature
*sig
=
5642 f
->matching_signature(NULL
, &void_parameters
, false);
5643 if ((sig
!= NULL
) && sig
->is_defined
) {