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 state
->ARB_ES3_1_compatibility_enable
||
214 (v130(state
) && state
->EXT_shader_integer_mix_enable
);
218 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
220 return state
->ARB_shading_language_packing_enable
||
221 state
->is_version(420, 300);
225 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
227 return state
->ARB_shading_language_packing_enable
||
228 state
->ARB_gpu_shader5_enable
||
229 state
->is_version(400, 300);
233 gpu_shader5(const _mesa_glsl_parse_state
*state
)
235 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
239 gpu_shader5_es(const _mesa_glsl_parse_state
*state
)
241 return state
->is_version(400, 320) ||
242 state
->ARB_gpu_shader5_enable
||
243 state
->EXT_gpu_shader5_enable
||
244 state
->OES_gpu_shader5_enable
;
248 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
250 return state
->is_version(400, 320) ||
251 state
->ARB_gpu_shader5_enable
||
252 state
->EXT_texture_cube_map_array_enable
||
253 state
->OES_texture_cube_map_array_enable
;
257 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
259 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
263 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
265 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
269 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
271 return state
->ARB_shading_language_packing_enable
||
272 state
->ARB_gpu_shader5_enable
||
273 state
->is_version(400, 310);
277 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state
*state
)
279 return gpu_shader5_or_es31(state
) ||
280 state
->MESA_shader_integer_functions_enable
;
284 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
286 return state
->stage
== MESA_SHADER_FRAGMENT
&&
287 (state
->is_version(400, 320) ||
288 state
->ARB_gpu_shader5_enable
||
289 state
->OES_shader_multisample_interpolation_enable
);
294 texture_array_lod(const _mesa_glsl_parse_state
*state
)
296 return lod_exists_in_stage(state
) &&
297 state
->EXT_texture_array_enable
;
301 fs_texture_array(const _mesa_glsl_parse_state
*state
)
303 return state
->stage
== MESA_SHADER_FRAGMENT
&&
304 state
->EXT_texture_array_enable
;
308 texture_array(const _mesa_glsl_parse_state
*state
)
310 return state
->EXT_texture_array_enable
;
314 texture_multisample(const _mesa_glsl_parse_state
*state
)
316 return state
->is_version(150, 310) ||
317 state
->ARB_texture_multisample_enable
;
321 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
323 return state
->is_version(150, 320) ||
324 state
->ARB_texture_multisample_enable
||
325 state
->OES_texture_storage_multisample_2d_array_enable
;
329 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
331 return texture_multisample(state
) &&
332 state
->EXT_shader_samples_identical_enable
;
336 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
338 return texture_multisample_array(state
) &&
339 state
->EXT_shader_samples_identical_enable
;
343 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
345 return state
->stage
== MESA_SHADER_FRAGMENT
&&
346 state
->has_texture_cube_map_array();
350 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
352 return state
->has_texture_cube_map_array();
356 texture_query_levels(const _mesa_glsl_parse_state
*state
)
358 return state
->is_version(430, 0) ||
359 state
->ARB_texture_query_levels_enable
;
363 texture_query_lod(const _mesa_glsl_parse_state
*state
)
365 return state
->stage
== MESA_SHADER_FRAGMENT
&&
366 state
->ARB_texture_query_lod_enable
;
370 texture_gather_cube_map_array(const _mesa_glsl_parse_state
*state
)
372 return state
->is_version(400, 320) ||
373 state
->ARB_texture_gather_enable
||
374 state
->ARB_gpu_shader5_enable
||
375 state
->EXT_texture_cube_map_array_enable
||
376 state
->OES_texture_cube_map_array_enable
;
380 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
382 return state
->is_version(400, 310) ||
383 state
->ARB_texture_gather_enable
||
384 state
->ARB_gpu_shader5_enable
;
387 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
388 * used for relaxation of const offset requirements.
391 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
393 return !state
->is_version(400, 320) &&
394 !state
->ARB_gpu_shader5_enable
&&
395 !state
->EXT_gpu_shader5_enable
&&
396 !state
->OES_gpu_shader5_enable
&&
397 (state
->ARB_texture_gather_enable
||
398 state
->is_version(0, 310));
401 /* Desktop GL or OES_standard_derivatives + fragment shader only */
403 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
405 return state
->stage
== MESA_SHADER_FRAGMENT
&&
406 (state
->is_version(110, 300) ||
407 state
->OES_standard_derivatives_enable
);
411 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
413 return state
->stage
== MESA_SHADER_FRAGMENT
&&
414 (state
->is_version(450, 0) ||
415 state
->ARB_derivative_control_enable
);
419 tex1d_lod(const _mesa_glsl_parse_state
*state
)
421 return !state
->es_shader
&& lod_exists_in_stage(state
);
424 /** True if sampler3D exists */
426 tex3d(const _mesa_glsl_parse_state
*state
)
428 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
429 * OES_texture_3D extension, and in GLSL ES 3.00.
431 return !state
->es_shader
||
432 state
->OES_texture_3D_enable
||
433 state
->language_version
>= 300;
437 fs_tex3d(const _mesa_glsl_parse_state
*state
)
439 return state
->stage
== MESA_SHADER_FRAGMENT
&&
440 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
444 tex3d_lod(const _mesa_glsl_parse_state
*state
)
446 return tex3d(state
) && lod_exists_in_stage(state
);
450 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
452 return state
->has_atomic_counters();
456 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
458 return state
->ARB_shader_atomic_counter_ops_enable
;
462 shader_clock(const _mesa_glsl_parse_state
*state
)
464 return state
->ARB_shader_clock_enable
;
468 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
470 return state
->has_shader_storage_buffer_objects();
474 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
476 return state
->AMD_shader_trinary_minmax_enable
;
480 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
482 return (state
->is_version(420, 310) ||
483 state
->ARB_shader_image_load_store_enable
);
487 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
489 return (state
->is_version(420, 320) ||
490 state
->ARB_shader_image_load_store_enable
||
491 state
->OES_shader_image_atomic_enable
);
495 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
497 return (state
->is_version(450, 320) ||
498 state
->ARB_ES3_1_compatibility_enable
||
499 state
->OES_shader_image_atomic_enable
);
503 shader_image_size(const _mesa_glsl_parse_state
*state
)
505 return state
->is_version(430, 310) ||
506 state
->ARB_shader_image_size_enable
;
510 shader_samples(const _mesa_glsl_parse_state
*state
)
512 return state
->is_version(450, 0) ||
513 state
->ARB_shader_texture_image_samples_enable
;
517 gs_streams(const _mesa_glsl_parse_state
*state
)
519 return gpu_shader5(state
) && gs_only(state
);
523 fp64(const _mesa_glsl_parse_state
*state
)
525 return state
->has_double();
529 compute_shader(const _mesa_glsl_parse_state
*state
)
531 return state
->stage
== MESA_SHADER_COMPUTE
;
535 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
537 return compute_shader(state
) || shader_storage_buffer_object(state
);
541 barrier_supported(const _mesa_glsl_parse_state
*state
)
543 return compute_shader(state
) ||
544 state
->stage
== MESA_SHADER_TESS_CTRL
;
548 vote(const _mesa_glsl_parse_state
*state
)
550 return state
->ARB_shader_group_vote_enable
;
555 /******************************************************************************/
560 * builtin_builder: A singleton object representing the core of the built-in
563 * It generates IR for every built-in function signature, and organizes them
566 class builtin_builder
{
573 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
574 const char *name
, exec_list
*actual_parameters
);
577 * A shader to hold all the built-in signatures; created by this module.
579 * This includes signatures for every built-in, regardless of version or
580 * enabled extensions. The availability predicate associated with each
581 * signature allows matching_signature() to filter out the irrelevant ones.
588 /** Global variables used by built-in functions. */
589 ir_variable
*gl_ModelViewProjectionMatrix
;
590 ir_variable
*gl_Vertex
;
592 void create_shader();
593 void create_intrinsics();
594 void create_builtins();
597 * IR builder helpers:
599 * These convenience functions assist in emitting IR, but don't necessarily
600 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
603 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
604 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
605 ir_constant
*imm(float f
, unsigned vector_elements
=1);
606 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
607 ir_constant
*imm(int i
, unsigned vector_elements
=1);
608 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
609 ir_constant
*imm(double d
, unsigned vector_elements
=1);
610 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
611 ir_dereference_variable
*var_ref(ir_variable
*var
);
612 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
613 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
615 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
616 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
619 * Call function \param f with parameters specified as the linked
620 * list \param params of \c ir_variable objects. \param ret should
621 * point to the ir_variable that will hold the function return
622 * value, or be \c NULL if the function has void return type.
624 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
626 /** Create a new function and add the given signatures. */
627 void add_function(const char *name
, ...);
629 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
630 unsigned num_arguments
,
634 * Create a new image built-in function for all known image types.
635 * \p flags is a bitfield of \c image_function_flags flags.
637 void add_image_function(const char *name
,
638 const char *intrinsic_name
,
639 image_prototype_ctr prototype
,
640 unsigned num_arguments
,
644 * Create new functions for all known image built-ins and types.
645 * If \p glsl is \c true, use the GLSL built-in names and emit code
646 * to call into the actual compiler intrinsic. If \p glsl is
647 * false, emit a function prototype with no body for each image
650 void add_image_functions(bool glsl
);
652 ir_function_signature
*new_sig(const glsl_type
*return_type
,
653 builtin_available_predicate avail
,
654 int num_params
, ...);
657 * Function signature generators:
660 ir_function_signature
*unop(builtin_available_predicate avail
,
661 ir_expression_operation opcode
,
662 const glsl_type
*return_type
,
663 const glsl_type
*param_type
);
664 ir_function_signature
*binop(builtin_available_predicate avail
,
665 ir_expression_operation opcode
,
666 const glsl_type
*return_type
,
667 const glsl_type
*param0_type
,
668 const glsl_type
*param1_type
);
670 #define B0(X) ir_function_signature *_##X();
671 #define B1(X) ir_function_signature *_##X(const glsl_type *);
672 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
673 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
674 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
675 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
712 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
713 const glsl_type
*val_type
,
714 const glsl_type
*blend_type
);
723 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
724 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
725 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
726 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
727 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
728 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
729 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
730 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
731 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
732 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
733 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
734 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
747 BA1(determinant_mat2
);
748 BA1(determinant_mat3
);
749 BA1(determinant_mat4
);
757 BA1(greaterThanEqual
);
766 /** Flags to _texture() */
767 #define TEX_PROJECT 1
769 #define TEX_COMPONENT 4
770 #define TEX_OFFSET_NONCONST 8
771 #define TEX_OFFSET_ARRAY 16
773 ir_function_signature
*_texture(ir_texture_opcode opcode
,
774 builtin_available_predicate avail
,
775 const glsl_type
*return_type
,
776 const glsl_type
*sampler_type
,
777 const glsl_type
*coord_type
,
779 B0(textureCubeArrayShadow
);
780 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
781 const glsl_type
*return_type
,
782 const glsl_type
*sampler_type
,
783 const glsl_type
*coord_type
,
784 const glsl_type
*offset_type
= NULL
);
788 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
789 const glsl_type
*stream_type
);
790 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
791 const glsl_type
*stream_type
);
794 BA2(textureQueryLod
);
795 B1(textureQueryLevels
);
796 BA2(textureSamplesIdentical
);
824 B1(interpolateAtCentroid
)
825 B1(interpolateAtOffset
)
826 B1(interpolateAtSample
)
828 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
829 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
);
830 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
);
831 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
832 builtin_available_predicate avail
);
833 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
834 builtin_available_predicate avail
);
835 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
836 builtin_available_predicate avail
);
838 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
839 const glsl_type
*type
);
840 ir_function_signature
*_atomic_op2(const char *intrinsic
,
841 builtin_available_predicate avail
,
842 const glsl_type
*type
);
843 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
844 const glsl_type
*type
);
845 ir_function_signature
*_atomic_op3(const char *intrinsic
,
846 builtin_available_predicate avail
,
847 const glsl_type
*type
);
853 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
854 unsigned num_arguments
,
856 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
857 unsigned num_arguments
,
859 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
860 unsigned num_arguments
,
862 ir_function_signature
*_image(image_prototype_ctr prototype
,
863 const glsl_type
*image_type
,
864 const char *intrinsic_name
,
865 unsigned num_arguments
,
868 ir_function_signature
*_memory_barrier_intrinsic(
869 builtin_available_predicate avail
);
870 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
871 builtin_available_predicate avail
);
873 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
874 const glsl_type
*type
);
875 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
876 const glsl_type
*type
);
878 ir_function_signature
*_vote(enum ir_expression_operation opcode
);
889 enum image_function_flags
{
890 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
891 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
892 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
893 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
894 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
895 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
896 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
897 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
898 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
901 } /* anonymous namespace */
904 * Core builtin_builder functionality:
907 builtin_builder::builtin_builder()
909 gl_ModelViewProjectionMatrix(NULL
),
915 builtin_builder::~builtin_builder()
917 ralloc_free(mem_ctx
);
920 ir_function_signature
*
921 builtin_builder::find(_mesa_glsl_parse_state
*state
,
922 const char *name
, exec_list
*actual_parameters
)
924 /* The shader currently being compiled requested a built-in function;
925 * it needs to link against builtin_builder::shader in order to get them.
927 * Even if we don't find a matching signature, we still need to do this so
928 * that the "no matching signature" error will list potential candidates
929 * from the available built-ins.
931 state
->uses_builtin_functions
= true;
933 ir_function
*f
= shader
->symbols
->get_function(name
);
937 ir_function_signature
*sig
=
938 f
->matching_signature(state
, actual_parameters
, true);
946 builtin_builder::initialize()
948 /* If already initialized, don't do it again. */
952 mem_ctx
= ralloc_context(NULL
);
959 builtin_builder::release()
961 ralloc_free(mem_ctx
);
969 builtin_builder::create_shader()
971 /* The target doesn't actually matter. There's no target for generic
972 * GLSL utility code that could be linked against any stage, so just
973 * arbitrarily pick GL_VERTEX_SHADER.
975 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
976 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
978 gl_ModelViewProjectionMatrix
=
979 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
980 "gl_ModelViewProjectionMatrix",
983 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
985 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
986 shader
->symbols
->add_variable(gl_Vertex
);
992 * Create ir_function and ir_function_signature objects for each
996 builtin_builder::create_intrinsics()
998 add_function("__intrinsic_atomic_read",
999 _atomic_counter_intrinsic(shader_atomic_counters
),
1001 add_function("__intrinsic_atomic_increment",
1002 _atomic_counter_intrinsic(shader_atomic_counters
),
1004 add_function("__intrinsic_atomic_predecrement",
1005 _atomic_counter_intrinsic(shader_atomic_counters
),
1008 add_function("__intrinsic_atomic_add",
1009 _atomic_intrinsic2(buffer_atomics_supported
,
1010 glsl_type::uint_type
),
1011 _atomic_intrinsic2(buffer_atomics_supported
,
1012 glsl_type::int_type
),
1013 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1015 add_function("__intrinsic_atomic_sub",
1016 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1018 add_function("__intrinsic_atomic_min",
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_max",
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_and",
1033 _atomic_intrinsic2(buffer_atomics_supported
,
1034 glsl_type::uint_type
),
1035 _atomic_intrinsic2(buffer_atomics_supported
,
1036 glsl_type::int_type
),
1037 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1039 add_function("__intrinsic_atomic_or",
1040 _atomic_intrinsic2(buffer_atomics_supported
,
1041 glsl_type::uint_type
),
1042 _atomic_intrinsic2(buffer_atomics_supported
,
1043 glsl_type::int_type
),
1044 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1046 add_function("__intrinsic_atomic_xor",
1047 _atomic_intrinsic2(buffer_atomics_supported
,
1048 glsl_type::uint_type
),
1049 _atomic_intrinsic2(buffer_atomics_supported
,
1050 glsl_type::int_type
),
1051 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1053 add_function("__intrinsic_atomic_exchange",
1054 _atomic_intrinsic2(buffer_atomics_supported
,
1055 glsl_type::uint_type
),
1056 _atomic_intrinsic2(buffer_atomics_supported
,
1057 glsl_type::int_type
),
1058 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1060 add_function("__intrinsic_atomic_comp_swap",
1061 _atomic_intrinsic3(buffer_atomics_supported
,
1062 glsl_type::uint_type
),
1063 _atomic_intrinsic3(buffer_atomics_supported
,
1064 glsl_type::int_type
),
1065 _atomic_counter_intrinsic2(shader_atomic_counter_ops
),
1068 add_image_functions(false);
1070 add_function("__intrinsic_memory_barrier",
1071 _memory_barrier_intrinsic(shader_image_load_store
),
1073 add_function("__intrinsic_group_memory_barrier",
1074 _memory_barrier_intrinsic(compute_shader
),
1076 add_function("__intrinsic_memory_barrier_atomic_counter",
1077 _memory_barrier_intrinsic(compute_shader
),
1079 add_function("__intrinsic_memory_barrier_buffer",
1080 _memory_barrier_intrinsic(compute_shader
),
1082 add_function("__intrinsic_memory_barrier_image",
1083 _memory_barrier_intrinsic(compute_shader
),
1085 add_function("__intrinsic_memory_barrier_shared",
1086 _memory_barrier_intrinsic(compute_shader
),
1089 add_function("__intrinsic_shader_clock",
1090 _shader_clock_intrinsic(shader_clock
,
1091 glsl_type::uvec2_type
),
1096 * Create ir_function and ir_function_signature objects for each built-in.
1098 * Contains a list of every available built-in.
1101 builtin_builder::create_builtins()
1104 add_function(#NAME, \
1105 _##NAME(glsl_type::float_type), \
1106 _##NAME(glsl_type::vec2_type), \
1107 _##NAME(glsl_type::vec3_type), \
1108 _##NAME(glsl_type::vec4_type), \
1112 add_function(#NAME, \
1113 _##NAME(always_available, glsl_type::float_type), \
1114 _##NAME(always_available, glsl_type::vec2_type), \
1115 _##NAME(always_available, glsl_type::vec3_type), \
1116 _##NAME(always_available, glsl_type::vec4_type), \
1117 _##NAME(fp64, glsl_type::double_type), \
1118 _##NAME(fp64, glsl_type::dvec2_type), \
1119 _##NAME(fp64, glsl_type::dvec3_type), \
1120 _##NAME(fp64, glsl_type::dvec4_type), \
1123 #define FD130(NAME) \
1124 add_function(#NAME, \
1125 _##NAME(v130, glsl_type::float_type), \
1126 _##NAME(v130, glsl_type::vec2_type), \
1127 _##NAME(v130, glsl_type::vec3_type), \
1128 _##NAME(v130, glsl_type::vec4_type), \
1129 _##NAME(fp64, glsl_type::double_type), \
1130 _##NAME(fp64, glsl_type::dvec2_type), \
1131 _##NAME(fp64, glsl_type::dvec3_type), \
1132 _##NAME(fp64, glsl_type::dvec4_type), \
1135 #define FDGS5(NAME) \
1136 add_function(#NAME, \
1137 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1138 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1139 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1140 _##NAME(gpu_shader5_es, glsl_type::vec4_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), \
1148 add_function(#NAME, \
1149 _##NAME(glsl_type::float_type), \
1150 _##NAME(glsl_type::vec2_type), \
1151 _##NAME(glsl_type::vec3_type), \
1152 _##NAME(glsl_type::vec4_type), \
1153 _##NAME(glsl_type::int_type), \
1154 _##NAME(glsl_type::ivec2_type), \
1155 _##NAME(glsl_type::ivec3_type), \
1156 _##NAME(glsl_type::ivec4_type), \
1160 add_function(#NAME, \
1161 _##NAME(always_available, glsl_type::float_type), \
1162 _##NAME(always_available, glsl_type::vec2_type), \
1163 _##NAME(always_available, glsl_type::vec3_type), \
1164 _##NAME(always_available, glsl_type::vec4_type), \
1165 _##NAME(always_available, glsl_type::int_type), \
1166 _##NAME(always_available, glsl_type::ivec2_type), \
1167 _##NAME(always_available, glsl_type::ivec3_type), \
1168 _##NAME(always_available, glsl_type::ivec4_type), \
1169 _##NAME(fp64, glsl_type::double_type), \
1170 _##NAME(fp64, glsl_type::dvec2_type), \
1171 _##NAME(fp64, glsl_type::dvec3_type), \
1172 _##NAME(fp64, glsl_type::dvec4_type), \
1175 #define FIUD(NAME) \
1176 add_function(#NAME, \
1177 _##NAME(always_available, glsl_type::float_type), \
1178 _##NAME(always_available, glsl_type::vec2_type), \
1179 _##NAME(always_available, glsl_type::vec3_type), \
1180 _##NAME(always_available, glsl_type::vec4_type), \
1182 _##NAME(always_available, glsl_type::int_type), \
1183 _##NAME(always_available, glsl_type::ivec2_type), \
1184 _##NAME(always_available, glsl_type::ivec3_type), \
1185 _##NAME(always_available, glsl_type::ivec4_type), \
1187 _##NAME(v130, glsl_type::uint_type), \
1188 _##NAME(v130, glsl_type::uvec2_type), \
1189 _##NAME(v130, glsl_type::uvec3_type), \
1190 _##NAME(v130, glsl_type::uvec4_type), \
1191 _##NAME(fp64, glsl_type::double_type), \
1192 _##NAME(fp64, glsl_type::dvec2_type), \
1193 _##NAME(fp64, glsl_type::dvec3_type), \
1194 _##NAME(fp64, glsl_type::dvec4_type), \
1198 add_function(#NAME, \
1199 _##NAME(glsl_type::int_type), \
1200 _##NAME(glsl_type::ivec2_type), \
1201 _##NAME(glsl_type::ivec3_type), \
1202 _##NAME(glsl_type::ivec4_type), \
1204 _##NAME(glsl_type::uint_type), \
1205 _##NAME(glsl_type::uvec2_type), \
1206 _##NAME(glsl_type::uvec3_type), \
1207 _##NAME(glsl_type::uvec4_type), \
1210 #define FIUBD(NAME) \
1211 add_function(#NAME, \
1212 _##NAME(always_available, glsl_type::float_type), \
1213 _##NAME(always_available, glsl_type::vec2_type), \
1214 _##NAME(always_available, glsl_type::vec3_type), \
1215 _##NAME(always_available, glsl_type::vec4_type), \
1217 _##NAME(always_available, glsl_type::int_type), \
1218 _##NAME(always_available, glsl_type::ivec2_type), \
1219 _##NAME(always_available, glsl_type::ivec3_type), \
1220 _##NAME(always_available, glsl_type::ivec4_type), \
1222 _##NAME(v130, glsl_type::uint_type), \
1223 _##NAME(v130, glsl_type::uvec2_type), \
1224 _##NAME(v130, glsl_type::uvec3_type), \
1225 _##NAME(v130, glsl_type::uvec4_type), \
1227 _##NAME(always_available, glsl_type::bool_type), \
1228 _##NAME(always_available, glsl_type::bvec2_type), \
1229 _##NAME(always_available, glsl_type::bvec3_type), \
1230 _##NAME(always_available, glsl_type::bvec4_type), \
1232 _##NAME(fp64, glsl_type::double_type), \
1233 _##NAME(fp64, glsl_type::dvec2_type), \
1234 _##NAME(fp64, glsl_type::dvec3_type), \
1235 _##NAME(fp64, glsl_type::dvec4_type), \
1238 #define FIUD2_MIXED(NAME) \
1239 add_function(#NAME, \
1240 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1241 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1242 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1243 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1245 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1246 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1247 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1249 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1250 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1251 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1252 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1254 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1255 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1256 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1258 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1259 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1260 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1261 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1263 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1264 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1265 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1267 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1268 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1269 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1270 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1271 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1272 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1273 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1284 add_function("atan",
1285 _atan(glsl_type::float_type
),
1286 _atan(glsl_type::vec2_type
),
1287 _atan(glsl_type::vec3_type
),
1288 _atan(glsl_type::vec4_type
),
1289 _atan2(glsl_type::float_type
),
1290 _atan2(glsl_type::vec2_type
),
1291 _atan2(glsl_type::vec3_type
),
1292 _atan2(glsl_type::vec4_type
),
1318 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1319 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1320 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1321 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1323 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1324 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1325 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1327 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1328 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1329 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1330 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1332 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1333 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1334 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1344 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1345 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1346 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1347 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1349 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1350 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1351 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1353 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1354 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1355 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1356 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1358 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1359 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1360 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1362 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1363 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1364 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1365 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1367 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1368 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1369 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1370 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1372 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1373 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1374 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1375 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1377 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1378 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1379 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1380 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1382 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1383 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1384 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1385 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1388 add_function("step",
1389 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1390 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1391 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1392 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1394 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1395 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1396 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1397 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1398 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1399 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1400 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1402 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1403 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1404 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1407 add_function("smoothstep",
1408 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1409 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1410 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1411 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1413 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1414 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1415 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1416 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1417 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1418 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1419 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1421 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1422 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1423 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1431 add_function("intBitsToFloat",
1432 _intBitsToFloat(glsl_type::int_type
),
1433 _intBitsToFloat(glsl_type::ivec2_type
),
1434 _intBitsToFloat(glsl_type::ivec3_type
),
1435 _intBitsToFloat(glsl_type::ivec4_type
),
1437 add_function("uintBitsToFloat",
1438 _uintBitsToFloat(glsl_type::uint_type
),
1439 _uintBitsToFloat(glsl_type::uvec2_type
),
1440 _uintBitsToFloat(glsl_type::uvec3_type
),
1441 _uintBitsToFloat(glsl_type::uvec4_type
),
1444 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1445 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1446 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1447 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1448 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1449 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1450 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1451 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1452 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1453 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1454 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1455 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1462 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1463 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1466 add_function("ftransform", _ftransform(), NULL
);
1471 add_function("matrixCompMult",
1472 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1473 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1474 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1475 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1476 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1477 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1478 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1479 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1480 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1481 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1482 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1483 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1484 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1485 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1486 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1487 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1488 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1489 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1491 add_function("outerProduct",
1492 _outerProduct(v120
, glsl_type::mat2_type
),
1493 _outerProduct(v120
, glsl_type::mat3_type
),
1494 _outerProduct(v120
, glsl_type::mat4_type
),
1495 _outerProduct(v120
, glsl_type::mat2x3_type
),
1496 _outerProduct(v120
, glsl_type::mat2x4_type
),
1497 _outerProduct(v120
, glsl_type::mat3x2_type
),
1498 _outerProduct(v120
, glsl_type::mat3x4_type
),
1499 _outerProduct(v120
, glsl_type::mat4x2_type
),
1500 _outerProduct(v120
, glsl_type::mat4x3_type
),
1501 _outerProduct(fp64
, glsl_type::dmat2_type
),
1502 _outerProduct(fp64
, glsl_type::dmat3_type
),
1503 _outerProduct(fp64
, glsl_type::dmat4_type
),
1504 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1505 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1506 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1507 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1508 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1509 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1511 add_function("determinant",
1512 _determinant_mat2(v120
, glsl_type::mat2_type
),
1513 _determinant_mat3(v120
, glsl_type::mat3_type
),
1514 _determinant_mat4(v120
, glsl_type::mat4_type
),
1515 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1516 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1517 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1520 add_function("inverse",
1521 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1522 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1523 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1524 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1525 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1526 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1528 add_function("transpose",
1529 _transpose(v120
, glsl_type::mat2_type
),
1530 _transpose(v120
, glsl_type::mat3_type
),
1531 _transpose(v120
, glsl_type::mat4_type
),
1532 _transpose(v120
, glsl_type::mat2x3_type
),
1533 _transpose(v120
, glsl_type::mat2x4_type
),
1534 _transpose(v120
, glsl_type::mat3x2_type
),
1535 _transpose(v120
, glsl_type::mat3x4_type
),
1536 _transpose(v120
, glsl_type::mat4x2_type
),
1537 _transpose(v120
, glsl_type::mat4x3_type
),
1538 _transpose(fp64
, glsl_type::dmat2_type
),
1539 _transpose(fp64
, glsl_type::dmat3_type
),
1540 _transpose(fp64
, glsl_type::dmat4_type
),
1541 _transpose(fp64
, glsl_type::dmat2x3_type
),
1542 _transpose(fp64
, glsl_type::dmat2x4_type
),
1543 _transpose(fp64
, glsl_type::dmat3x2_type
),
1544 _transpose(fp64
, glsl_type::dmat3x4_type
),
1545 _transpose(fp64
, glsl_type::dmat4x2_type
),
1546 _transpose(fp64
, glsl_type::dmat4x3_type
),
1551 FIUD(greaterThanEqual
)
1556 _any(glsl_type::bvec2_type
),
1557 _any(glsl_type::bvec3_type
),
1558 _any(glsl_type::bvec4_type
),
1562 _all(glsl_type::bvec2_type
),
1563 _all(glsl_type::bvec3_type
),
1564 _all(glsl_type::bvec4_type
),
1568 _not(glsl_type::bvec2_type
),
1569 _not(glsl_type::bvec3_type
),
1570 _not(glsl_type::bvec4_type
),
1573 add_function("textureSize",
1574 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1575 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1576 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1578 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1579 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1580 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1582 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1583 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1584 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1586 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1587 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1588 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1590 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1591 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1592 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1594 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1595 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1596 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1597 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1598 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1599 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1601 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1602 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1604 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1605 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1606 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1607 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1609 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1610 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1611 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1612 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1614 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1615 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1616 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1617 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1618 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1619 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1621 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1622 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1623 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1626 add_function("textureSamples",
1627 _textureSamples(glsl_type::sampler2DMS_type
),
1628 _textureSamples(glsl_type::isampler2DMS_type
),
1629 _textureSamples(glsl_type::usampler2DMS_type
),
1631 _textureSamples(glsl_type::sampler2DMSArray_type
),
1632 _textureSamples(glsl_type::isampler2DMSArray_type
),
1633 _textureSamples(glsl_type::usampler2DMSArray_type
),
1636 add_function("texture",
1637 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1638 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1639 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1641 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1642 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1643 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1645 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1646 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1647 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1649 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1650 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1651 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1653 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1654 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1655 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1657 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1658 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1659 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1661 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1662 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1663 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1665 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1666 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1667 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1669 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1670 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1671 /* samplerCubeArrayShadow is special; it has an extra parameter
1672 * for the shadow comparitor since there is no vec5 type.
1674 _textureCubeArrayShadow(),
1676 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1677 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1678 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1680 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1682 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1683 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1684 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1686 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1687 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1688 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1690 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1691 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1692 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1694 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1695 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1696 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1698 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1699 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1700 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1702 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1703 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1704 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1706 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1707 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1708 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1710 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1711 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1712 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1714 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1717 add_function("textureLod",
1718 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1719 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1720 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1722 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1723 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1724 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1726 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1727 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1728 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1730 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1731 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1732 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1734 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1735 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1737 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1738 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1739 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1741 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1742 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1743 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1745 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1746 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1747 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1749 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1752 add_function("textureOffset",
1753 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1754 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1755 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1757 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1758 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1759 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1761 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1762 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1763 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1765 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1766 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1767 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1769 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1771 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1772 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1774 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1775 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1776 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1778 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1779 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1780 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1782 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1783 /* The next one was forgotten in GLSL 1.30 spec. It's from
1784 * EXT_gpu_shader4 originally. It was added in 4.30 with the
1785 * wrong syntax. This was corrected in 4.40. 4.30 indicates
1786 * that it was intended to be included previously, so allow it
1789 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1791 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1792 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1793 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1795 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1796 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1797 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1799 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1800 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1801 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1803 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1804 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1806 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1807 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1808 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1810 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1811 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1812 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1814 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1817 add_function("textureProj",
1818 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1819 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1820 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1821 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1822 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1823 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1825 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1826 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1827 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1828 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1829 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1830 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1832 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1833 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1834 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1836 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1837 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1839 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1840 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1841 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1842 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1843 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1844 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1846 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1848 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1849 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1850 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1851 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1852 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1853 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1855 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1856 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1857 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1858 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1859 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1860 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1862 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1863 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1864 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1866 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1867 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1870 add_function("texelFetch",
1871 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1872 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1873 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1875 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1876 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1877 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1879 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1880 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1881 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1883 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1884 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1885 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1887 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1888 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1889 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1891 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1892 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1893 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1895 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1896 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1897 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1899 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1900 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1901 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1903 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1904 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1905 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1908 add_function("texelFetchOffset",
1909 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1910 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1911 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1913 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1914 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1915 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1917 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1918 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1919 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1921 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1922 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1923 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1925 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1926 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1927 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1929 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1930 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1931 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1935 add_function("textureProjOffset",
1936 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1937 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1938 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1939 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1940 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1941 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1943 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1944 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1945 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1946 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1947 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1948 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1950 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1951 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1952 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1954 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1955 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1957 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1958 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1959 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1960 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1962 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1966 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1967 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1969 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1971 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1973 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1974 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1975 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1976 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1977 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1978 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1980 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1981 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1982 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1984 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1985 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1988 add_function("textureLodOffset",
1989 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1990 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1991 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1993 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1994 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1995 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1997 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1998 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1999 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2001 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2002 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2004 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2005 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2006 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2008 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2009 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2010 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2012 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2015 add_function("textureProjLod",
2016 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2017 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2018 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2019 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2020 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2021 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2023 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2024 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2025 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2026 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2027 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2028 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2030 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2031 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2032 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2034 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2035 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2038 add_function("textureProjLodOffset",
2039 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2040 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2041 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2042 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2043 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2044 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2046 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2047 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2048 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2049 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2050 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2051 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2053 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2054 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2055 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2057 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2058 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2061 add_function("textureGrad",
2062 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2063 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2064 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2066 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2067 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2068 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2070 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2071 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2072 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2074 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2075 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2076 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2078 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2079 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2080 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2082 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2084 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2085 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2086 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2088 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2089 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2090 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2092 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2093 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2094 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2096 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2097 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2098 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2100 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2101 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2104 add_function("textureGradOffset",
2105 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2106 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2107 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2109 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2110 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2111 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2113 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2114 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2115 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2117 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2118 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2119 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2121 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2123 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2124 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2126 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2127 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2128 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2130 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2131 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2132 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2134 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2135 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2138 add_function("textureProjGrad",
2139 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2140 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2141 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2142 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2143 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2144 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2146 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2147 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2148 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2149 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2150 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2151 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2153 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2154 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2155 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2157 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2158 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2159 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2160 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2161 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2162 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2164 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2166 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2167 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2170 add_function("textureProjGradOffset",
2171 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2172 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2173 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2174 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2175 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2176 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2178 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2179 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2180 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2181 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2182 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2183 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2185 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2186 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2187 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2189 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2190 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2191 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2192 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2193 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2194 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2196 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2198 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2199 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2202 add_function("EmitVertex", _EmitVertex(), NULL
);
2203 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2204 add_function("EmitStreamVertex",
2205 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2206 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2208 add_function("EndStreamPrimitive",
2209 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2210 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2212 add_function("barrier", _barrier(), NULL
);
2214 add_function("textureQueryLOD",
2215 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2216 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2217 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2219 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2220 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2221 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2223 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2224 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2225 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2227 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2228 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2229 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2231 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2232 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2233 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2235 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2236 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2237 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2239 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2240 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2241 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2243 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2244 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2245 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2246 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2247 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2248 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2251 add_function("textureQueryLod",
2252 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2253 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2254 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2256 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2257 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2258 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2260 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2261 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2262 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2264 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2265 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2266 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2268 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2269 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2270 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2272 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2273 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2274 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2276 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2277 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2278 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2280 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2281 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2282 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2283 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2284 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2285 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2288 add_function("textureQueryLevels",
2289 _textureQueryLevels(glsl_type::sampler1D_type
),
2290 _textureQueryLevels(glsl_type::sampler2D_type
),
2291 _textureQueryLevels(glsl_type::sampler3D_type
),
2292 _textureQueryLevels(glsl_type::samplerCube_type
),
2293 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2294 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2295 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2296 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2297 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2298 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2299 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2300 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2301 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2303 _textureQueryLevels(glsl_type::isampler1D_type
),
2304 _textureQueryLevels(glsl_type::isampler2D_type
),
2305 _textureQueryLevels(glsl_type::isampler3D_type
),
2306 _textureQueryLevels(glsl_type::isamplerCube_type
),
2307 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2308 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2309 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2311 _textureQueryLevels(glsl_type::usampler1D_type
),
2312 _textureQueryLevels(glsl_type::usampler2D_type
),
2313 _textureQueryLevels(glsl_type::usampler3D_type
),
2314 _textureQueryLevels(glsl_type::usamplerCube_type
),
2315 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2316 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2317 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2321 add_function("textureSamplesIdenticalEXT",
2322 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2323 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2324 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2326 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2327 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2328 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2331 add_function("texture1D",
2332 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2333 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2336 add_function("texture1DArray",
2337 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2338 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2341 add_function("texture1DProj",
2342 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2343 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2344 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2345 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2348 add_function("texture1DLod",
2349 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2352 add_function("texture1DArrayLod",
2353 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2356 add_function("texture1DProjLod",
2357 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2358 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2361 add_function("texture2D",
2362 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2363 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2364 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2367 add_function("texture2DArray",
2368 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2369 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2372 add_function("texture2DProj",
2373 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2374 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2375 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2376 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2377 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2378 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2381 add_function("texture2DLod",
2382 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2385 add_function("texture2DArrayLod",
2386 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2389 add_function("texture2DProjLod",
2390 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2391 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2394 add_function("texture3D",
2395 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2396 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2399 add_function("texture3DProj",
2400 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2401 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2404 add_function("texture3DLod",
2405 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2408 add_function("texture3DProjLod",
2409 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2412 add_function("textureCube",
2413 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2414 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2417 add_function("textureCubeLod",
2418 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2421 add_function("texture2DRect",
2422 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2425 add_function("texture2DRectProj",
2426 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2427 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2430 add_function("shadow1D",
2431 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2432 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2435 add_function("shadow1DArray",
2436 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2437 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2440 add_function("shadow2D",
2441 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2442 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2445 add_function("shadow2DArray",
2446 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2447 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2450 add_function("shadow1DProj",
2451 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2452 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2455 add_function("shadow2DProj",
2456 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2457 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2460 add_function("shadow1DLod",
2461 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2464 add_function("shadow2DLod",
2465 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2468 add_function("shadow1DArrayLod",
2469 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2472 add_function("shadow1DProjLod",
2473 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2476 add_function("shadow2DProjLod",
2477 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2480 add_function("shadow2DRect",
2481 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2484 add_function("shadow2DRectProj",
2485 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2488 add_function("texture1DGradARB",
2489 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2492 add_function("texture1DProjGradARB",
2493 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2494 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2497 add_function("texture2DGradARB",
2498 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2501 add_function("texture2DProjGradARB",
2502 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2503 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2506 add_function("texture3DGradARB",
2507 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2510 add_function("texture3DProjGradARB",
2511 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2514 add_function("textureCubeGradARB",
2515 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2518 add_function("shadow1DGradARB",
2519 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2522 add_function("shadow1DProjGradARB",
2523 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2526 add_function("shadow2DGradARB",
2527 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2530 add_function("shadow2DProjGradARB",
2531 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2534 add_function("texture2DRectGradARB",
2535 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2538 add_function("texture2DRectProjGradARB",
2539 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2540 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2543 add_function("shadow2DRectGradARB",
2544 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2547 add_function("shadow2DRectProjGradARB",
2548 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2551 add_function("textureGather",
2552 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2553 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2554 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2556 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2557 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2558 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2560 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2561 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2562 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2564 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2565 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2566 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2568 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2569 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2570 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2572 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2573 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2574 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2576 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2577 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2578 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2580 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2581 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2582 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2584 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2585 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2586 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2588 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2589 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2590 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2592 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2593 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2594 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2595 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2596 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2599 add_function("textureGatherOffset",
2600 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2601 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2602 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2604 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2605 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2606 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2608 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2609 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2610 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2612 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2613 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2614 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2616 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2617 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2618 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2620 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2621 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2622 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2624 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2625 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2626 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2628 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2629 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2630 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2632 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2633 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2634 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2636 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2637 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2638 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2640 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2641 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2642 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2644 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2645 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2648 add_function("textureGatherOffsets",
2649 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2650 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2651 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2653 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2654 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2655 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2657 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2658 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2659 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2661 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2662 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2663 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2665 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2666 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2667 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2669 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2670 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2671 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2673 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2674 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2675 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2700 add_function("ldexp",
2701 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2702 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2703 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2704 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2705 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2706 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2707 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2708 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2711 add_function("frexp",
2712 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2713 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2714 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2715 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2716 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2717 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2718 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2719 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2721 add_function("uaddCarry",
2722 _uaddCarry(glsl_type::uint_type
),
2723 _uaddCarry(glsl_type::uvec2_type
),
2724 _uaddCarry(glsl_type::uvec3_type
),
2725 _uaddCarry(glsl_type::uvec4_type
),
2727 add_function("usubBorrow",
2728 _usubBorrow(glsl_type::uint_type
),
2729 _usubBorrow(glsl_type::uvec2_type
),
2730 _usubBorrow(glsl_type::uvec3_type
),
2731 _usubBorrow(glsl_type::uvec4_type
),
2733 add_function("imulExtended",
2734 _mulExtended(glsl_type::int_type
),
2735 _mulExtended(glsl_type::ivec2_type
),
2736 _mulExtended(glsl_type::ivec3_type
),
2737 _mulExtended(glsl_type::ivec4_type
),
2739 add_function("umulExtended",
2740 _mulExtended(glsl_type::uint_type
),
2741 _mulExtended(glsl_type::uvec2_type
),
2742 _mulExtended(glsl_type::uvec3_type
),
2743 _mulExtended(glsl_type::uvec4_type
),
2745 add_function("interpolateAtCentroid",
2746 _interpolateAtCentroid(glsl_type::float_type
),
2747 _interpolateAtCentroid(glsl_type::vec2_type
),
2748 _interpolateAtCentroid(glsl_type::vec3_type
),
2749 _interpolateAtCentroid(glsl_type::vec4_type
),
2751 add_function("interpolateAtOffset",
2752 _interpolateAtOffset(glsl_type::float_type
),
2753 _interpolateAtOffset(glsl_type::vec2_type
),
2754 _interpolateAtOffset(glsl_type::vec3_type
),
2755 _interpolateAtOffset(glsl_type::vec4_type
),
2757 add_function("interpolateAtSample",
2758 _interpolateAtSample(glsl_type::float_type
),
2759 _interpolateAtSample(glsl_type::vec2_type
),
2760 _interpolateAtSample(glsl_type::vec3_type
),
2761 _interpolateAtSample(glsl_type::vec4_type
),
2764 add_function("atomicCounter",
2765 _atomic_counter_op("__intrinsic_atomic_read",
2766 shader_atomic_counters
),
2768 add_function("atomicCounterIncrement",
2769 _atomic_counter_op("__intrinsic_atomic_increment",
2770 shader_atomic_counters
),
2772 add_function("atomicCounterDecrement",
2773 _atomic_counter_op("__intrinsic_atomic_predecrement",
2774 shader_atomic_counters
),
2777 add_function("atomicCounterAddARB",
2778 _atomic_counter_op1("__intrinsic_atomic_add",
2779 shader_atomic_counter_ops
),
2781 add_function("atomicCounterSubtractARB",
2782 _atomic_counter_op1("__intrinsic_atomic_sub",
2783 shader_atomic_counter_ops
),
2785 add_function("atomicCounterMinARB",
2786 _atomic_counter_op1("__intrinsic_atomic_min",
2787 shader_atomic_counter_ops
),
2789 add_function("atomicCounterMaxARB",
2790 _atomic_counter_op1("__intrinsic_atomic_max",
2791 shader_atomic_counter_ops
),
2793 add_function("atomicCounterAndARB",
2794 _atomic_counter_op1("__intrinsic_atomic_and",
2795 shader_atomic_counter_ops
),
2797 add_function("atomicCounterOrARB",
2798 _atomic_counter_op1("__intrinsic_atomic_or",
2799 shader_atomic_counter_ops
),
2801 add_function("atomicCounterXorARB",
2802 _atomic_counter_op1("__intrinsic_atomic_xor",
2803 shader_atomic_counter_ops
),
2805 add_function("atomicCounterExchangeARB",
2806 _atomic_counter_op1("__intrinsic_atomic_exchange",
2807 shader_atomic_counter_ops
),
2809 add_function("atomicCounterCompSwapARB",
2810 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
2811 shader_atomic_counter_ops
),
2814 add_function("atomicAdd",
2815 _atomic_op2("__intrinsic_atomic_add",
2816 buffer_atomics_supported
,
2817 glsl_type::uint_type
),
2818 _atomic_op2("__intrinsic_atomic_add",
2819 buffer_atomics_supported
,
2820 glsl_type::int_type
),
2822 add_function("atomicMin",
2823 _atomic_op2("__intrinsic_atomic_min",
2824 buffer_atomics_supported
,
2825 glsl_type::uint_type
),
2826 _atomic_op2("__intrinsic_atomic_min",
2827 buffer_atomics_supported
,
2828 glsl_type::int_type
),
2830 add_function("atomicMax",
2831 _atomic_op2("__intrinsic_atomic_max",
2832 buffer_atomics_supported
,
2833 glsl_type::uint_type
),
2834 _atomic_op2("__intrinsic_atomic_max",
2835 buffer_atomics_supported
,
2836 glsl_type::int_type
),
2838 add_function("atomicAnd",
2839 _atomic_op2("__intrinsic_atomic_and",
2840 buffer_atomics_supported
,
2841 glsl_type::uint_type
),
2842 _atomic_op2("__intrinsic_atomic_and",
2843 buffer_atomics_supported
,
2844 glsl_type::int_type
),
2846 add_function("atomicOr",
2847 _atomic_op2("__intrinsic_atomic_or",
2848 buffer_atomics_supported
,
2849 glsl_type::uint_type
),
2850 _atomic_op2("__intrinsic_atomic_or",
2851 buffer_atomics_supported
,
2852 glsl_type::int_type
),
2854 add_function("atomicXor",
2855 _atomic_op2("__intrinsic_atomic_xor",
2856 buffer_atomics_supported
,
2857 glsl_type::uint_type
),
2858 _atomic_op2("__intrinsic_atomic_xor",
2859 buffer_atomics_supported
,
2860 glsl_type::int_type
),
2862 add_function("atomicExchange",
2863 _atomic_op2("__intrinsic_atomic_exchange",
2864 buffer_atomics_supported
,
2865 glsl_type::uint_type
),
2866 _atomic_op2("__intrinsic_atomic_exchange",
2867 buffer_atomics_supported
,
2868 glsl_type::int_type
),
2870 add_function("atomicCompSwap",
2871 _atomic_op3("__intrinsic_atomic_comp_swap",
2872 buffer_atomics_supported
,
2873 glsl_type::uint_type
),
2874 _atomic_op3("__intrinsic_atomic_comp_swap",
2875 buffer_atomics_supported
,
2876 glsl_type::int_type
),
2879 add_function("min3",
2880 _min3(glsl_type::float_type
),
2881 _min3(glsl_type::vec2_type
),
2882 _min3(glsl_type::vec3_type
),
2883 _min3(glsl_type::vec4_type
),
2885 _min3(glsl_type::int_type
),
2886 _min3(glsl_type::ivec2_type
),
2887 _min3(glsl_type::ivec3_type
),
2888 _min3(glsl_type::ivec4_type
),
2890 _min3(glsl_type::uint_type
),
2891 _min3(glsl_type::uvec2_type
),
2892 _min3(glsl_type::uvec3_type
),
2893 _min3(glsl_type::uvec4_type
),
2896 add_function("max3",
2897 _max3(glsl_type::float_type
),
2898 _max3(glsl_type::vec2_type
),
2899 _max3(glsl_type::vec3_type
),
2900 _max3(glsl_type::vec4_type
),
2902 _max3(glsl_type::int_type
),
2903 _max3(glsl_type::ivec2_type
),
2904 _max3(glsl_type::ivec3_type
),
2905 _max3(glsl_type::ivec4_type
),
2907 _max3(glsl_type::uint_type
),
2908 _max3(glsl_type::uvec2_type
),
2909 _max3(glsl_type::uvec3_type
),
2910 _max3(glsl_type::uvec4_type
),
2913 add_function("mid3",
2914 _mid3(glsl_type::float_type
),
2915 _mid3(glsl_type::vec2_type
),
2916 _mid3(glsl_type::vec3_type
),
2917 _mid3(glsl_type::vec4_type
),
2919 _mid3(glsl_type::int_type
),
2920 _mid3(glsl_type::ivec2_type
),
2921 _mid3(glsl_type::ivec3_type
),
2922 _mid3(glsl_type::ivec4_type
),
2924 _mid3(glsl_type::uint_type
),
2925 _mid3(glsl_type::uvec2_type
),
2926 _mid3(glsl_type::uvec3_type
),
2927 _mid3(glsl_type::uvec4_type
),
2930 add_image_functions(true);
2932 add_function("memoryBarrier",
2933 _memory_barrier("__intrinsic_memory_barrier",
2934 shader_image_load_store
),
2936 add_function("groupMemoryBarrier",
2937 _memory_barrier("__intrinsic_group_memory_barrier",
2940 add_function("memoryBarrierAtomicCounter",
2941 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2944 add_function("memoryBarrierBuffer",
2945 _memory_barrier("__intrinsic_memory_barrier_buffer",
2948 add_function("memoryBarrierImage",
2949 _memory_barrier("__intrinsic_memory_barrier_image",
2952 add_function("memoryBarrierShared",
2953 _memory_barrier("__intrinsic_memory_barrier_shared",
2957 add_function("clock2x32ARB",
2958 _shader_clock(shader_clock
,
2959 glsl_type::uvec2_type
),
2962 add_function("anyInvocationARB", _vote(ir_unop_vote_any
), NULL
);
2963 add_function("allInvocationsARB", _vote(ir_unop_vote_all
), NULL
);
2964 add_function("allInvocationsEqualARB", _vote(ir_unop_vote_eq
), NULL
);
2974 builtin_builder::add_function(const char *name
, ...)
2978 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2982 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2988 stuff
.push_tail(sig
);
2989 validate_ir_tree(&stuff
);
2992 f
->add_signature(sig
);
2996 shader
->symbols
->add_function(f
);
3000 builtin_builder::add_image_function(const char *name
,
3001 const char *intrinsic_name
,
3002 image_prototype_ctr prototype
,
3003 unsigned num_arguments
,
3006 static const glsl_type
*const types
[] = {
3007 glsl_type::image1D_type
,
3008 glsl_type::image2D_type
,
3009 glsl_type::image3D_type
,
3010 glsl_type::image2DRect_type
,
3011 glsl_type::imageCube_type
,
3012 glsl_type::imageBuffer_type
,
3013 glsl_type::image1DArray_type
,
3014 glsl_type::image2DArray_type
,
3015 glsl_type::imageCubeArray_type
,
3016 glsl_type::image2DMS_type
,
3017 glsl_type::image2DMSArray_type
,
3018 glsl_type::iimage1D_type
,
3019 glsl_type::iimage2D_type
,
3020 glsl_type::iimage3D_type
,
3021 glsl_type::iimage2DRect_type
,
3022 glsl_type::iimageCube_type
,
3023 glsl_type::iimageBuffer_type
,
3024 glsl_type::iimage1DArray_type
,
3025 glsl_type::iimage2DArray_type
,
3026 glsl_type::iimageCubeArray_type
,
3027 glsl_type::iimage2DMS_type
,
3028 glsl_type::iimage2DMSArray_type
,
3029 glsl_type::uimage1D_type
,
3030 glsl_type::uimage2D_type
,
3031 glsl_type::uimage3D_type
,
3032 glsl_type::uimage2DRect_type
,
3033 glsl_type::uimageCube_type
,
3034 glsl_type::uimageBuffer_type
,
3035 glsl_type::uimage1DArray_type
,
3036 glsl_type::uimage2DArray_type
,
3037 glsl_type::uimageCubeArray_type
,
3038 glsl_type::uimage2DMS_type
,
3039 glsl_type::uimage2DMSArray_type
3042 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3044 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3045 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3046 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3047 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3048 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3049 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3050 num_arguments
, flags
));
3053 shader
->symbols
->add_function(f
);
3057 builtin_builder::add_image_functions(bool glsl
)
3059 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3061 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3062 "__intrinsic_image_load",
3063 &builtin_builder::_image_prototype
, 0,
3064 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3065 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3066 IMAGE_FUNCTION_READ_ONLY
));
3068 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3069 "__intrinsic_image_store",
3070 &builtin_builder::_image_prototype
, 1,
3071 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3072 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3073 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3074 IMAGE_FUNCTION_WRITE_ONLY
));
3076 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3078 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3079 "__intrinsic_image_atomic_add",
3080 &builtin_builder::_image_prototype
, 1, atom_flags
);
3082 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3083 "__intrinsic_image_atomic_min",
3084 &builtin_builder::_image_prototype
, 1, atom_flags
);
3086 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3087 "__intrinsic_image_atomic_max",
3088 &builtin_builder::_image_prototype
, 1, atom_flags
);
3090 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3091 "__intrinsic_image_atomic_and",
3092 &builtin_builder::_image_prototype
, 1, atom_flags
);
3094 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3095 "__intrinsic_image_atomic_or",
3096 &builtin_builder::_image_prototype
, 1, atom_flags
);
3098 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3099 "__intrinsic_image_atomic_xor",
3100 &builtin_builder::_image_prototype
, 1, atom_flags
);
3102 add_image_function((glsl
? "imageAtomicExchange" :
3103 "__intrinsic_image_atomic_exchange"),
3104 "__intrinsic_image_atomic_exchange",
3105 &builtin_builder::_image_prototype
, 1,
3106 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3107 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
));
3109 add_image_function((glsl
? "imageAtomicCompSwap" :
3110 "__intrinsic_image_atomic_comp_swap"),
3111 "__intrinsic_image_atomic_comp_swap",
3112 &builtin_builder::_image_prototype
, 2, atom_flags
);
3114 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3115 "__intrinsic_image_size",
3116 &builtin_builder::_image_size_prototype
, 1,
3117 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
3119 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3120 "__intrinsic_image_samples",
3121 &builtin_builder::_image_samples_prototype
, 1,
3122 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3123 IMAGE_FUNCTION_MS_ONLY
);
3127 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3129 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3133 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3135 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3139 builtin_builder::imm(bool b
, unsigned vector_elements
)
3141 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3145 builtin_builder::imm(float f
, unsigned vector_elements
)
3147 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3151 builtin_builder::imm(int i
, unsigned vector_elements
)
3153 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3157 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3159 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3163 builtin_builder::imm(double d
, unsigned vector_elements
)
3165 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3169 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3171 return new(mem_ctx
) ir_constant(type
, &data
);
3174 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3176 ir_dereference_variable
*
3177 builtin_builder::var_ref(ir_variable
*var
)
3179 return new(mem_ctx
) ir_dereference_variable(var
);
3182 ir_dereference_array
*
3183 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3185 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3188 /** Return an element of a matrix */
3190 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3192 return swizzle(array_ref(var
, column
), row
, 1);
3196 * Implementations of built-in functions:
3199 ir_function_signature
*
3200 builtin_builder::new_sig(const glsl_type
*return_type
,
3201 builtin_available_predicate avail
,
3207 ir_function_signature
*sig
=
3208 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3211 va_start(ap
, num_params
);
3212 for (int i
= 0; i
< num_params
; i
++) {
3213 plist
.push_tail(va_arg(ap
, ir_variable
*));
3217 sig
->replace_parameters(&plist
);
3221 #define MAKE_SIG(return_type, avail, ...) \
3222 ir_function_signature *sig = \
3223 new_sig(return_type, avail, __VA_ARGS__); \
3224 ir_factory body(&sig->body, mem_ctx); \
3225 sig->is_defined = true;
3227 #define MAKE_INTRINSIC(return_type, avail, ...) \
3228 ir_function_signature *sig = \
3229 new_sig(return_type, avail, __VA_ARGS__); \
3230 sig->is_intrinsic = true;
3232 ir_function_signature
*
3233 builtin_builder::unop(builtin_available_predicate avail
,
3234 ir_expression_operation opcode
,
3235 const glsl_type
*return_type
,
3236 const glsl_type
*param_type
)
3238 ir_variable
*x
= in_var(param_type
, "x");
3239 MAKE_SIG(return_type
, avail
, 1, x
);
3240 body
.emit(ret(expr(opcode
, x
)));
3244 #define UNOP(NAME, OPCODE, AVAIL) \
3245 ir_function_signature * \
3246 builtin_builder::_##NAME(const glsl_type *type) \
3248 return unop(&AVAIL, OPCODE, type, type); \
3251 #define UNOPA(NAME, OPCODE) \
3252 ir_function_signature * \
3253 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3255 return unop(avail, OPCODE, type, type); \
3258 ir_function_signature
*
3259 builtin_builder::binop(builtin_available_predicate avail
,
3260 ir_expression_operation opcode
,
3261 const glsl_type
*return_type
,
3262 const glsl_type
*param0_type
,
3263 const glsl_type
*param1_type
)
3265 ir_variable
*x
= in_var(param0_type
, "x");
3266 ir_variable
*y
= in_var(param1_type
, "y");
3267 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3268 body
.emit(ret(expr(opcode
, x
, y
)));
3272 #define BINOP(NAME, OPCODE, AVAIL) \
3273 ir_function_signature * \
3274 builtin_builder::_##NAME(const glsl_type *return_type, \
3275 const glsl_type *param0_type, \
3276 const glsl_type *param1_type) \
3278 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3282 * Angle and Trigonometry Functions @{
3285 ir_function_signature
*
3286 builtin_builder::_radians(const glsl_type
*type
)
3288 ir_variable
*degrees
= in_var(type
, "degrees");
3289 MAKE_SIG(type
, always_available
, 1, degrees
);
3290 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3294 ir_function_signature
*
3295 builtin_builder::_degrees(const glsl_type
*type
)
3297 ir_variable
*radians
= in_var(type
, "radians");
3298 MAKE_SIG(type
, always_available
, 1, radians
);
3299 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3303 UNOP(sin
, ir_unop_sin
, always_available
)
3304 UNOP(cos
, ir_unop_cos
, always_available
)
3306 ir_function_signature
*
3307 builtin_builder::_tan(const glsl_type
*type
)
3309 ir_variable
*theta
= in_var(type
, "theta");
3310 MAKE_SIG(type
, always_available
, 1, theta
);
3311 body
.emit(ret(div(sin(theta
), cos(theta
))));
3316 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3320 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3323 add(imm(M_PI_4f
- 1.0f
),
3326 mul(abs(x
), imm(p1
))))))))));
3330 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3332 exec_list actual_params
;
3334 foreach_in_list(ir_variable
, var
, ¶ms
) {
3335 actual_params
.push_tail(var_ref(var
));
3338 ir_function_signature
*sig
=
3339 f
->exact_matching_signature(NULL
, &actual_params
);
3343 ir_dereference_variable
*deref
=
3344 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3346 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3349 ir_function_signature
*
3350 builtin_builder::_asin(const glsl_type
*type
)
3352 ir_variable
*x
= in_var(type
, "x");
3353 MAKE_SIG(type
, always_available
, 1, x
);
3355 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3360 ir_function_signature
*
3361 builtin_builder::_acos(const glsl_type
*type
)
3363 ir_variable
*x
= in_var(type
, "x");
3364 MAKE_SIG(type
, always_available
, 1, x
);
3366 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3371 ir_function_signature
*
3372 builtin_builder::_atan2(const glsl_type
*type
)
3374 ir_variable
*vec_y
= in_var(type
, "vec_y");
3375 ir_variable
*vec_x
= in_var(type
, "vec_x");
3376 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3378 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3379 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3380 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3381 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3382 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3383 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3384 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3386 /* If |x| >= 1.0e-8 * |y|: */
3388 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3390 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3392 /* Then...call atan(y/x) */
3393 do_atan(outer_then
, glsl_type::float_type
, r
, div(y
, x
));
3395 /* ...and fix it up: */
3396 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3397 inner_if
->then_instructions
.push_tail(
3398 if_tree(gequal(y
, imm(0.0f
)),
3399 assign(r
, add(r
, imm(M_PIf
))),
3400 assign(r
, sub(r
, imm(M_PIf
)))));
3401 outer_then
.emit(inner_if
);
3404 outer_if
->else_instructions
.push_tail(
3405 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3407 body
.emit(outer_if
);
3409 body
.emit(assign(vec_result
, r
, 1 << i
));
3411 body
.emit(ret(vec_result
));
3417 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3420 * range-reduction, first step:
3422 * / y_over_x if |y_over_x| <= 1.0;
3424 * \ 1.0 / y_over_x otherwise
3426 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3427 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3433 * approximate atan by evaluating polynomial:
3435 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3436 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3437 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3439 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3440 body
.emit(assign(tmp
, mul(x
, x
)));
3441 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3443 imm(0.0536813784310406f
)),
3445 imm(0.1173503194786851f
)),
3447 imm(0.1938924977115610f
)),
3449 imm(0.3326756418091246f
)),
3451 imm(0.9999793128310355f
)),
3454 /* range-reduction fixup */
3455 body
.emit(assign(tmp
, add(tmp
,
3456 mul(b2f(greater(abs(y_over_x
),
3457 imm(1.0f
, type
->components()))),
3463 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3466 ir_function_signature
*
3467 builtin_builder::_atan(const glsl_type
*type
)
3469 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3470 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3472 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3473 do_atan(body
, type
, tmp
, y_over_x
);
3474 body
.emit(ret(tmp
));
3479 ir_function_signature
*
3480 builtin_builder::_sinh(const glsl_type
*type
)
3482 ir_variable
*x
= in_var(type
, "x");
3483 MAKE_SIG(type
, v130
, 1, x
);
3485 /* 0.5 * (e^x - e^(-x)) */
3486 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3491 ir_function_signature
*
3492 builtin_builder::_cosh(const glsl_type
*type
)
3494 ir_variable
*x
= in_var(type
, "x");
3495 MAKE_SIG(type
, v130
, 1, x
);
3497 /* 0.5 * (e^x + e^(-x)) */
3498 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3503 ir_function_signature
*
3504 builtin_builder::_tanh(const glsl_type
*type
)
3506 ir_variable
*x
= in_var(type
, "x");
3507 MAKE_SIG(type
, v130
, 1, x
);
3509 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3510 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3511 add(exp(x
), exp(neg(x
))))));
3516 ir_function_signature
*
3517 builtin_builder::_asinh(const glsl_type
*type
)
3519 ir_variable
*x
= in_var(type
, "x");
3520 MAKE_SIG(type
, v130
, 1, x
);
3522 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3527 ir_function_signature
*
3528 builtin_builder::_acosh(const glsl_type
*type
)
3530 ir_variable
*x
= in_var(type
, "x");
3531 MAKE_SIG(type
, v130
, 1, x
);
3533 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3537 ir_function_signature
*
3538 builtin_builder::_atanh(const glsl_type
*type
)
3540 ir_variable
*x
= in_var(type
, "x");
3541 MAKE_SIG(type
, v130
, 1, x
);
3543 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3544 sub(imm(1.0f
), x
))))));
3550 * Exponential Functions @{
3553 ir_function_signature
*
3554 builtin_builder::_pow(const glsl_type
*type
)
3556 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3559 UNOP(exp
, ir_unop_exp
, always_available
)
3560 UNOP(log
, ir_unop_log
, always_available
)
3561 UNOP(exp2
, ir_unop_exp2
, always_available
)
3562 UNOP(log2
, ir_unop_log2
, always_available
)
3563 UNOPA(sqrt
, ir_unop_sqrt
)
3564 UNOPA(inversesqrt
, ir_unop_rsq
)
3568 UNOPA(abs
, ir_unop_abs
)
3569 UNOPA(sign
, ir_unop_sign
)
3570 UNOPA(floor
, ir_unop_floor
)
3571 UNOPA(trunc
, ir_unop_trunc
)
3572 UNOPA(round
, ir_unop_round_even
)
3573 UNOPA(roundEven
, ir_unop_round_even
)
3574 UNOPA(ceil
, ir_unop_ceil
)
3575 UNOPA(fract
, ir_unop_fract
)
3577 ir_function_signature
*
3578 builtin_builder::_mod(builtin_available_predicate avail
,
3579 const glsl_type
*x_type
, const glsl_type
*y_type
)
3581 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3584 ir_function_signature
*
3585 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3587 ir_variable
*x
= in_var(type
, "x");
3588 ir_variable
*i
= out_var(type
, "i");
3589 MAKE_SIG(type
, avail
, 2, x
, i
);
3591 ir_variable
*t
= body
.make_temp(type
, "t");
3592 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3593 body
.emit(assign(i
, t
));
3594 body
.emit(ret(sub(x
, t
)));
3599 ir_function_signature
*
3600 builtin_builder::_min(builtin_available_predicate avail
,
3601 const glsl_type
*x_type
, const glsl_type
*y_type
)
3603 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3606 ir_function_signature
*
3607 builtin_builder::_max(builtin_available_predicate avail
,
3608 const glsl_type
*x_type
, const glsl_type
*y_type
)
3610 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3613 ir_function_signature
*
3614 builtin_builder::_clamp(builtin_available_predicate avail
,
3615 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3617 ir_variable
*x
= in_var(val_type
, "x");
3618 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3619 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3620 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3622 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3627 ir_function_signature
*
3628 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3630 ir_variable
*x
= in_var(val_type
, "x");
3631 ir_variable
*y
= in_var(val_type
, "y");
3632 ir_variable
*a
= in_var(blend_type
, "a");
3633 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3635 body
.emit(ret(lrp(x
, y
, a
)));
3640 ir_function_signature
*
3641 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3642 const glsl_type
*val_type
,
3643 const glsl_type
*blend_type
)
3645 ir_variable
*x
= in_var(val_type
, "x");
3646 ir_variable
*y
= in_var(val_type
, "y");
3647 ir_variable
*a
= in_var(blend_type
, "a");
3648 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3650 /* csel matches the ternary operator in that a selector of true choses the
3651 * first argument. This differs from mix(x, y, false) which choses the
3652 * second argument (to remain consistent with the interpolating version of
3653 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3655 * To handle the behavior mismatch, reverse the x and y arguments.
3657 body
.emit(ret(csel(a
, y
, x
)));
3662 ir_function_signature
*
3663 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3665 ir_variable
*edge
= in_var(edge_type
, "edge");
3666 ir_variable
*x
= in_var(x_type
, "x");
3667 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3669 ir_variable
*t
= body
.make_temp(x_type
, "t");
3670 if (x_type
->vector_elements
== 1) {
3671 /* Both are floats */
3672 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3673 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3675 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3676 } else if (edge_type
->vector_elements
== 1) {
3677 /* x is a vector but edge is a float */
3678 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3679 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3680 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3682 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3685 /* Both are vectors */
3686 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3687 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3688 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3691 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3701 ir_function_signature
*
3702 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3704 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3705 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3706 ir_variable
*x
= in_var(x_type
, "x");
3707 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3709 /* From the GLSL 1.10 specification:
3712 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3713 * return t * t * (3 - 2 * t);
3716 ir_variable
*t
= body
.make_temp(x_type
, "t");
3717 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3718 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3720 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3725 ir_function_signature
*
3726 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3728 ir_variable
*x
= in_var(type
, "x");
3729 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3731 body
.emit(ret(nequal(x
, x
)));
3736 ir_function_signature
*
3737 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3739 ir_variable
*x
= in_var(type
, "x");
3740 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3742 ir_constant_data infinities
;
3743 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3744 switch (type
->base_type
) {
3745 case GLSL_TYPE_FLOAT
:
3746 infinities
.f
[i
] = INFINITY
;
3748 case GLSL_TYPE_DOUBLE
:
3749 infinities
.d
[i
] = INFINITY
;
3752 unreachable("unknown type");
3756 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3761 ir_function_signature
*
3762 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3764 ir_variable
*x
= in_var(type
, "x");
3765 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3766 body
.emit(ret(bitcast_f2i(x
)));
3770 ir_function_signature
*
3771 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3773 ir_variable
*x
= in_var(type
, "x");
3774 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3775 body
.emit(ret(bitcast_f2u(x
)));
3779 ir_function_signature
*
3780 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3782 ir_variable
*x
= in_var(type
, "x");
3783 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3784 body
.emit(ret(bitcast_i2f(x
)));
3788 ir_function_signature
*
3789 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3791 ir_variable
*x
= in_var(type
, "x");
3792 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3793 body
.emit(ret(bitcast_u2f(x
)));
3797 ir_function_signature
*
3798 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3800 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3801 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3802 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3806 ir_function_signature
*
3807 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3809 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3810 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3811 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3815 ir_function_signature
*
3816 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3818 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3819 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3820 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3824 ir_function_signature
*
3825 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3827 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3828 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3829 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3833 ir_function_signature
*
3834 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3836 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3837 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3838 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3842 ir_function_signature
*
3843 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3845 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3846 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3847 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3852 ir_function_signature
*
3853 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3855 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3856 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3857 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3861 ir_function_signature
*
3862 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3864 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3865 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3866 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3870 ir_function_signature
*
3871 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3873 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3874 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3875 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3879 ir_function_signature
*
3880 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3882 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3883 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3884 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3888 ir_function_signature
*
3889 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3891 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3892 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3893 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3897 ir_function_signature
*
3898 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3900 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3901 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3902 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3906 ir_function_signature
*
3907 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3909 ir_variable
*x
= in_var(type
, "x");
3910 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3912 body
.emit(ret(sqrt(dot(x
, x
))));
3917 ir_function_signature
*
3918 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3920 ir_variable
*p0
= in_var(type
, "p0");
3921 ir_variable
*p1
= in_var(type
, "p1");
3922 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3924 if (type
->vector_elements
== 1) {
3925 body
.emit(ret(abs(sub(p0
, p1
))));
3927 ir_variable
*p
= body
.make_temp(type
, "p");
3928 body
.emit(assign(p
, sub(p0
, p1
)));
3929 body
.emit(ret(sqrt(dot(p
, p
))));
3935 ir_function_signature
*
3936 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3938 if (type
->vector_elements
== 1)
3939 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3941 return binop(avail
, ir_binop_dot
,
3942 type
->get_base_type(), type
, type
);
3945 ir_function_signature
*
3946 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3948 ir_variable
*a
= in_var(type
, "a");
3949 ir_variable
*b
= in_var(type
, "b");
3950 MAKE_SIG(type
, avail
, 2, a
, b
);
3952 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3953 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3955 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3956 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3961 ir_function_signature
*
3962 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3964 ir_variable
*x
= in_var(type
, "x");
3965 MAKE_SIG(type
, avail
, 1, x
);
3967 if (type
->vector_elements
== 1) {
3968 body
.emit(ret(sign(x
)));
3970 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3976 ir_function_signature
*
3977 builtin_builder::_ftransform()
3979 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3981 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3982 glsl_type::vec4_type
,
3983 var_ref(gl_ModelViewProjectionMatrix
),
3984 var_ref(gl_Vertex
))));
3986 /* FINISHME: Once the ir_expression() constructor handles type inference
3987 * for matrix operations, we can simplify this to:
3989 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3994 ir_function_signature
*
3995 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3997 ir_variable
*N
= in_var(type
, "N");
3998 ir_variable
*I
= in_var(type
, "I");
3999 ir_variable
*Nref
= in_var(type
, "Nref");
4000 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4002 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4003 ret(N
), ret(neg(N
))));
4008 ir_function_signature
*
4009 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4011 ir_variable
*I
= in_var(type
, "I");
4012 ir_variable
*N
= in_var(type
, "N");
4013 MAKE_SIG(type
, avail
, 2, I
, N
);
4015 /* I - 2 * dot(N, I) * N */
4016 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4021 ir_function_signature
*
4022 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4024 ir_variable
*I
= in_var(type
, "I");
4025 ir_variable
*N
= in_var(type
, "N");
4026 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4027 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4029 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4030 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4032 /* From the GLSL 1.10 specification:
4033 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4035 * return genType(0.0)
4037 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4039 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4040 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4041 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4042 mul(n_dot_i
, n_dot_i
)))))));
4043 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4044 ret(ir_constant::zero(mem_ctx
, type
)),
4045 ret(sub(mul(eta
, I
),
4046 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4051 ir_function_signature
*
4052 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4054 ir_variable
*x
= in_var(type
, "x");
4055 ir_variable
*y
= in_var(type
, "y");
4056 MAKE_SIG(type
, avail
, 2, x
, y
);
4058 ir_variable
*z
= body
.make_temp(type
, "z");
4059 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4060 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4067 ir_function_signature
*
4068 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4073 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
4074 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4075 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4077 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4078 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4080 MAKE_SIG(type
, avail
, 2, c
, r
);
4082 ir_variable
*m
= body
.make_temp(type
, "m");
4083 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4084 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4091 ir_function_signature
*
4092 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4094 const glsl_type
*transpose_type
=
4095 glsl_type::get_instance(orig_type
->base_type
,
4096 orig_type
->matrix_columns
,
4097 orig_type
->vector_elements
);
4099 ir_variable
*m
= in_var(orig_type
, "m");
4100 MAKE_SIG(transpose_type
, avail
, 1, m
);
4102 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4103 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4104 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4105 body
.emit(assign(array_ref(t
, j
),
4106 matrix_elt(m
, i
, j
),
4115 ir_function_signature
*
4116 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4118 ir_variable
*m
= in_var(type
, "m");
4119 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4121 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4122 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4127 ir_function_signature
*
4128 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4130 ir_variable
*m
= in_var(type
, "m");
4131 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4134 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4135 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4138 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4139 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4142 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4143 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4145 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4146 mul(matrix_elt(m
, 0, 1), f2
)),
4147 mul(matrix_elt(m
, 0, 2), f3
))));
4152 ir_function_signature
*
4153 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4155 ir_variable
*m
= in_var(type
, "m");
4156 const glsl_type
*btype
= type
->get_base_type();
4157 MAKE_SIG(btype
, avail
, 1, m
);
4159 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4160 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4161 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4162 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4163 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4164 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4165 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4166 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4167 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4168 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4169 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4170 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4171 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4172 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4173 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4174 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4175 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4176 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4177 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4179 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)))));
4180 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)))));
4181 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)))));
4182 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)))));
4183 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)))));
4184 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)))));
4185 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)))));
4186 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)))));
4187 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)))));
4188 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)))));
4189 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)))));
4190 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)))));
4191 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)))));
4192 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)))));
4193 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)))));
4194 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)))));
4195 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)))));
4196 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)))));
4197 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)))));
4199 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4201 body
.emit(assign(adj_0
,
4202 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4203 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4204 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4206 body
.emit(assign(adj_0
, neg(
4207 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4208 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4209 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4211 body
.emit(assign(adj_0
,
4212 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4213 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4214 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4216 body
.emit(assign(adj_0
, neg(
4217 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4218 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4219 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4222 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4227 ir_function_signature
*
4228 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4230 ir_variable
*m
= in_var(type
, "m");
4231 MAKE_SIG(type
, avail
, 1, m
);
4233 ir_variable
*adj
= body
.make_temp(type
, "adj");
4234 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4235 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4236 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4237 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4239 ir_expression
*det
=
4240 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4241 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4243 body
.emit(ret(div(adj
, det
)));
4247 ir_function_signature
*
4248 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4250 ir_variable
*m
= in_var(type
, "m");
4251 const glsl_type
*btype
= type
->get_base_type();
4252 MAKE_SIG(type
, avail
, 1, m
);
4254 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4255 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4256 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4258 body
.emit(assign(f11_22_21_12
,
4259 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4260 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4261 body
.emit(assign(f10_22_20_12
,
4262 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4263 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4264 body
.emit(assign(f10_21_20_11
,
4265 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4266 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4268 ir_variable
*adj
= body
.make_temp(type
, "adj");
4269 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4270 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4271 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4273 body
.emit(assign(array_ref(adj
, 0), neg(
4274 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4275 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4277 body
.emit(assign(array_ref(adj
, 1),
4278 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4279 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4281 body
.emit(assign(array_ref(adj
, 2), neg(
4282 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4283 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4286 body
.emit(assign(array_ref(adj
, 0),
4287 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4288 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4290 body
.emit(assign(array_ref(adj
, 1), neg(
4291 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4292 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4294 body
.emit(assign(array_ref(adj
, 2),
4295 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4296 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4299 ir_expression
*det
=
4300 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4301 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4302 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4304 body
.emit(ret(div(adj
, det
)));
4309 ir_function_signature
*
4310 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4312 ir_variable
*m
= in_var(type
, "m");
4313 const glsl_type
*btype
= type
->get_base_type();
4314 MAKE_SIG(type
, avail
, 1, m
);
4316 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4317 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4318 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4319 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4320 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4321 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4322 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4323 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4324 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4325 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4326 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4327 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4328 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4329 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4330 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4331 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4332 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4333 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4334 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4336 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)))));
4337 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)))));
4338 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)))));
4339 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)))));
4340 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)))));
4341 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)))));
4342 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)))));
4343 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)))));
4344 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)))));
4345 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)))));
4346 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)))));
4347 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)))));
4348 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)))));
4349 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)))));
4350 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)))));
4351 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)))));
4352 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)))));
4353 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)))));
4354 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)))));
4356 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4357 body
.emit(assign(array_ref(adj
, 0),
4358 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4359 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4360 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4362 body
.emit(assign(array_ref(adj
, 1), neg(
4363 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4364 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4365 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4367 body
.emit(assign(array_ref(adj
, 2),
4368 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4369 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4370 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4372 body
.emit(assign(array_ref(adj
, 3), neg(
4373 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4374 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4375 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4378 body
.emit(assign(array_ref(adj
, 0), neg(
4379 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4380 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4381 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4383 body
.emit(assign(array_ref(adj
, 1),
4384 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4385 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4386 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4388 body
.emit(assign(array_ref(adj
, 2), neg(
4389 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4390 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4391 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4393 body
.emit(assign(array_ref(adj
, 3),
4394 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4395 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4396 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4399 body
.emit(assign(array_ref(adj
, 0),
4400 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4401 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4402 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4404 body
.emit(assign(array_ref(adj
, 1), neg(
4405 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4406 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4407 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4409 body
.emit(assign(array_ref(adj
, 2),
4410 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4411 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4412 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4414 body
.emit(assign(array_ref(adj
, 3), neg(
4415 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4416 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4417 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4420 body
.emit(assign(array_ref(adj
, 0), neg(
4421 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4422 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4423 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4425 body
.emit(assign(array_ref(adj
, 1),
4426 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4427 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4428 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4430 body
.emit(assign(array_ref(adj
, 2), neg(
4431 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4432 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4433 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4435 body
.emit(assign(array_ref(adj
, 3),
4436 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4437 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4438 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4441 ir_expression
*det
=
4442 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4443 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4444 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4445 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4447 body
.emit(ret(div(adj
, det
)));
4453 ir_function_signature
*
4454 builtin_builder::_lessThan(builtin_available_predicate avail
,
4455 const glsl_type
*type
)
4457 return binop(avail
, ir_binop_less
,
4458 glsl_type::bvec(type
->vector_elements
), type
, type
);
4461 ir_function_signature
*
4462 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4463 const glsl_type
*type
)
4465 return binop(avail
, ir_binop_lequal
,
4466 glsl_type::bvec(type
->vector_elements
), type
, type
);
4469 ir_function_signature
*
4470 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4471 const glsl_type
*type
)
4473 return binop(avail
, ir_binop_greater
,
4474 glsl_type::bvec(type
->vector_elements
), type
, type
);
4477 ir_function_signature
*
4478 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4479 const glsl_type
*type
)
4481 return binop(avail
, ir_binop_gequal
,
4482 glsl_type::bvec(type
->vector_elements
), type
, type
);
4485 ir_function_signature
*
4486 builtin_builder::_equal(builtin_available_predicate avail
,
4487 const glsl_type
*type
)
4489 return binop(avail
, ir_binop_equal
,
4490 glsl_type::bvec(type
->vector_elements
), type
, type
);
4493 ir_function_signature
*
4494 builtin_builder::_notEqual(builtin_available_predicate avail
,
4495 const glsl_type
*type
)
4497 return binop(avail
, ir_binop_nequal
,
4498 glsl_type::bvec(type
->vector_elements
), type
, type
);
4501 ir_function_signature
*
4502 builtin_builder::_any(const glsl_type
*type
)
4504 ir_variable
*v
= in_var(type
, "v");
4505 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4507 const unsigned vec_elem
= v
->type
->vector_elements
;
4508 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4513 ir_function_signature
*
4514 builtin_builder::_all(const glsl_type
*type
)
4516 ir_variable
*v
= in_var(type
, "v");
4517 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4519 const unsigned vec_elem
= v
->type
->vector_elements
;
4520 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4525 UNOP(not, ir_unop_logic_not
, always_available
)
4528 has_lod(const glsl_type
*sampler_type
)
4530 assert(sampler_type
->is_sampler());
4532 switch (sampler_type
->sampler_dimensionality
) {
4533 case GLSL_SAMPLER_DIM_RECT
:
4534 case GLSL_SAMPLER_DIM_BUF
:
4535 case GLSL_SAMPLER_DIM_MS
:
4542 ir_function_signature
*
4543 builtin_builder::_textureSize(builtin_available_predicate avail
,
4544 const glsl_type
*return_type
,
4545 const glsl_type
*sampler_type
)
4547 ir_variable
*s
= in_var(sampler_type
, "sampler");
4548 /* The sampler always exists; add optional lod later. */
4549 MAKE_SIG(return_type
, avail
, 1, s
);
4551 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4552 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4554 if (has_lod(sampler_type
)) {
4555 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4556 sig
->parameters
.push_tail(lod
);
4557 tex
->lod_info
.lod
= var_ref(lod
);
4559 tex
->lod_info
.lod
= imm(0u);
4562 body
.emit(ret(tex
));
4567 ir_function_signature
*
4568 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4570 ir_variable
*s
= in_var(sampler_type
, "sampler");
4571 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4573 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4574 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4575 body
.emit(ret(tex
));
4580 ir_function_signature
*
4581 builtin_builder::_texture(ir_texture_opcode opcode
,
4582 builtin_available_predicate avail
,
4583 const glsl_type
*return_type
,
4584 const glsl_type
*sampler_type
,
4585 const glsl_type
*coord_type
,
4588 ir_variable
*s
= in_var(sampler_type
, "sampler");
4589 ir_variable
*P
= in_var(coord_type
, "P");
4590 /* The sampler and coordinate always exist; add optional parameters later. */
4591 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4593 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4594 tex
->set_sampler(var_ref(s
), return_type
);
4596 const int coord_size
= sampler_type
->coordinate_components();
4598 if (coord_size
== coord_type
->vector_elements
) {
4599 tex
->coordinate
= var_ref(P
);
4601 /* The incoming coordinate also has the projector or shadow comparitor,
4602 * so we need to swizzle those away.
4604 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4607 /* The projector is always in the last component. */
4608 if (flags
& TEX_PROJECT
)
4609 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4611 if (sampler_type
->sampler_shadow
) {
4612 if (opcode
== ir_tg4
) {
4613 /* gather has refz as a separate parameter, immediately after the
4616 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4617 sig
->parameters
.push_tail(refz
);
4618 tex
->shadow_comparitor
= var_ref(refz
);
4620 /* The shadow comparitor is normally in the Z component, but a few types
4621 * have sufficiently large coordinates that it's in W.
4623 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4627 if (opcode
== ir_txl
) {
4628 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4629 sig
->parameters
.push_tail(lod
);
4630 tex
->lod_info
.lod
= var_ref(lod
);
4631 } else if (opcode
== ir_txd
) {
4632 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4633 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4634 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4635 sig
->parameters
.push_tail(dPdx
);
4636 sig
->parameters
.push_tail(dPdy
);
4637 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4638 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4641 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4642 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4643 ir_variable
*offset
=
4644 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4645 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4646 sig
->parameters
.push_tail(offset
);
4647 tex
->offset
= var_ref(offset
);
4650 if (flags
& TEX_OFFSET_ARRAY
) {
4651 ir_variable
*offsets
=
4652 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4653 "offsets", ir_var_const_in
);
4654 sig
->parameters
.push_tail(offsets
);
4655 tex
->offset
= var_ref(offsets
);
4658 if (opcode
== ir_tg4
) {
4659 if (flags
& TEX_COMPONENT
) {
4660 ir_variable
*component
=
4661 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4662 sig
->parameters
.push_tail(component
);
4663 tex
->lod_info
.component
= var_ref(component
);
4666 tex
->lod_info
.component
= imm(0);
4670 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4671 * inconsistent with both textureLodOffset and textureGradOffset.
4673 if (opcode
== ir_txb
) {
4674 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4675 sig
->parameters
.push_tail(bias
);
4676 tex
->lod_info
.bias
= var_ref(bias
);
4679 body
.emit(ret(tex
));
4684 ir_function_signature
*
4685 builtin_builder::_textureCubeArrayShadow()
4687 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4688 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4689 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4690 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4692 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4693 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4695 tex
->coordinate
= var_ref(P
);
4696 tex
->shadow_comparitor
= var_ref(compare
);
4698 body
.emit(ret(tex
));
4703 ir_function_signature
*
4704 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4705 const glsl_type
*return_type
,
4706 const glsl_type
*sampler_type
,
4707 const glsl_type
*coord_type
,
4708 const glsl_type
*offset_type
)
4710 ir_variable
*s
= in_var(sampler_type
, "sampler");
4711 ir_variable
*P
= in_var(coord_type
, "P");
4712 /* The sampler and coordinate always exist; add optional parameters later. */
4713 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4715 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4716 tex
->coordinate
= var_ref(P
);
4717 tex
->set_sampler(var_ref(s
), return_type
);
4719 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4720 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4721 sig
->parameters
.push_tail(sample
);
4722 tex
->lod_info
.sample_index
= var_ref(sample
);
4723 tex
->op
= ir_txf_ms
;
4724 } else if (has_lod(sampler_type
)) {
4725 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4726 sig
->parameters
.push_tail(lod
);
4727 tex
->lod_info
.lod
= var_ref(lod
);
4729 tex
->lod_info
.lod
= imm(0u);
4732 if (offset_type
!= NULL
) {
4733 ir_variable
*offset
=
4734 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4735 sig
->parameters
.push_tail(offset
);
4736 tex
->offset
= var_ref(offset
);
4739 body
.emit(ret(tex
));
4744 ir_function_signature
*
4745 builtin_builder::_EmitVertex()
4747 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4749 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4750 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4755 ir_function_signature
*
4756 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4757 const glsl_type
*stream_type
)
4759 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4761 * "Emit the current values of output variables to the current output
4762 * primitive on stream stream. The argument to stream must be a constant
4763 * integral expression."
4765 ir_variable
*stream
=
4766 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4768 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4770 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4775 ir_function_signature
*
4776 builtin_builder::_EndPrimitive()
4778 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4780 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4781 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4786 ir_function_signature
*
4787 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4788 const glsl_type
*stream_type
)
4790 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4792 * "Completes the current output primitive on stream stream and starts
4793 * a new one. The argument to stream must be a constant integral
4796 ir_variable
*stream
=
4797 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4799 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4801 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4806 ir_function_signature
*
4807 builtin_builder::_barrier()
4809 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4811 body
.emit(new(mem_ctx
) ir_barrier());
4815 ir_function_signature
*
4816 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4817 const glsl_type
*sampler_type
,
4818 const glsl_type
*coord_type
)
4820 ir_variable
*s
= in_var(sampler_type
, "sampler");
4821 ir_variable
*coord
= in_var(coord_type
, "coord");
4822 /* The sampler and coordinate always exist; add optional parameters later. */
4823 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4825 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4826 tex
->coordinate
= var_ref(coord
);
4827 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4829 body
.emit(ret(tex
));
4834 ir_function_signature
*
4835 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4837 ir_variable
*s
= in_var(sampler_type
, "sampler");
4838 const glsl_type
*return_type
= glsl_type::int_type
;
4839 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4841 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4842 tex
->set_sampler(var_ref(s
), return_type
);
4844 body
.emit(ret(tex
));
4849 ir_function_signature
*
4850 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4851 const glsl_type
*sampler_type
,
4852 const glsl_type
*coord_type
)
4854 ir_variable
*s
= in_var(sampler_type
, "sampler");
4855 ir_variable
*P
= in_var(coord_type
, "P");
4856 const glsl_type
*return_type
= glsl_type::bool_type
;
4857 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4859 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4860 tex
->coordinate
= var_ref(P
);
4861 tex
->set_sampler(var_ref(s
), return_type
);
4863 body
.emit(ret(tex
));
4868 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4869 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4870 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4871 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4872 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4873 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4875 ir_function_signature
*
4876 builtin_builder::_fwidth(const glsl_type
*type
)
4878 ir_variable
*p
= in_var(type
, "p");
4879 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4881 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4886 ir_function_signature
*
4887 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4889 ir_variable
*p
= in_var(type
, "p");
4890 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4892 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4893 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4898 ir_function_signature
*
4899 builtin_builder::_fwidthFine(const glsl_type
*type
)
4901 ir_variable
*p
= in_var(type
, "p");
4902 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4904 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4905 abs(expr(ir_unop_dFdy_fine
, p
)))));
4910 ir_function_signature
*
4911 builtin_builder::_noise1(const glsl_type
*type
)
4913 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4916 ir_function_signature
*
4917 builtin_builder::_noise2(const glsl_type
*type
)
4919 ir_variable
*p
= in_var(type
, "p");
4920 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4922 ir_constant_data b_offset
;
4923 b_offset
.f
[0] = 601.0f
;
4924 b_offset
.f
[1] = 313.0f
;
4925 b_offset
.f
[2] = 29.0f
;
4926 b_offset
.f
[3] = 277.0f
;
4928 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4929 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4930 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4931 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4932 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4933 body
.emit(assign(t
, a
, WRITEMASK_X
));
4934 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4940 ir_function_signature
*
4941 builtin_builder::_noise3(const glsl_type
*type
)
4943 ir_variable
*p
= in_var(type
, "p");
4944 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4946 ir_constant_data b_offset
;
4947 b_offset
.f
[0] = 601.0f
;
4948 b_offset
.f
[1] = 313.0f
;
4949 b_offset
.f
[2] = 29.0f
;
4950 b_offset
.f
[3] = 277.0f
;
4952 ir_constant_data c_offset
;
4953 c_offset
.f
[0] = 1559.0f
;
4954 c_offset
.f
[1] = 113.0f
;
4955 c_offset
.f
[2] = 1861.0f
;
4956 c_offset
.f
[3] = 797.0f
;
4958 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4959 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4960 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4961 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4962 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4963 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4964 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_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
));
4973 ir_function_signature
*
4974 builtin_builder::_noise4(const glsl_type
*type
)
4976 ir_variable
*p
= in_var(type
, "p");
4977 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4979 ir_variable
*_p
= body
.make_temp(type
, "_p");
4981 ir_constant_data p_offset
;
4982 p_offset
.f
[0] = 1559.0f
;
4983 p_offset
.f
[1] = 113.0f
;
4984 p_offset
.f
[2] = 1861.0f
;
4985 p_offset
.f
[3] = 797.0f
;
4987 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4989 ir_constant_data offset
;
4990 offset
.f
[0] = 601.0f
;
4991 offset
.f
[1] = 313.0f
;
4992 offset
.f
[2] = 29.0f
;
4993 offset
.f
[3] = 277.0f
;
4995 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4996 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4997 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4998 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4999 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5000 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5001 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5002 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5003 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5004 body
.emit(assign(t
, a
, WRITEMASK_X
));
5005 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5006 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5007 body
.emit(assign(t
, d
, WRITEMASK_W
));
5013 ir_function_signature
*
5014 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5016 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5017 ir_variable
*value
= in_var(type
, "value");
5018 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5019 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5020 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5023 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5024 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5026 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5027 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5028 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5033 ir_function_signature
*
5034 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5036 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5037 ir_variable
*base
= in_var(type
, "base");
5038 ir_variable
*insert
= in_var(type
, "insert");
5039 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5040 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5041 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5044 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5045 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5047 body
.emit(ret(bitfield_insert(base
, insert
,
5048 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5049 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5054 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5056 ir_function_signature
*
5057 builtin_builder::_bitCount(const glsl_type
*type
)
5059 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5060 glsl_type::ivec(type
->vector_elements
), type
);
5063 ir_function_signature
*
5064 builtin_builder::_findLSB(const glsl_type
*type
)
5066 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5067 glsl_type::ivec(type
->vector_elements
), type
);
5070 ir_function_signature
*
5071 builtin_builder::_findMSB(const glsl_type
*type
)
5073 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5074 glsl_type::ivec(type
->vector_elements
), type
);
5077 ir_function_signature
*
5078 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5080 ir_variable
*a
= in_var(type
, "a");
5081 ir_variable
*b
= in_var(type
, "b");
5082 ir_variable
*c
= in_var(type
, "c");
5083 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5085 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5090 ir_function_signature
*
5091 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5093 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5094 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5097 ir_function_signature
*
5098 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5100 ir_variable
*x
= in_var(x_type
, "x");
5101 ir_variable
*exponent
= out_var(exp_type
, "exp");
5102 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5104 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5106 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5110 ir_function_signature
*
5111 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5113 ir_variable
*x
= in_var(x_type
, "x");
5114 ir_variable
*exponent
= out_var(exp_type
, "exp");
5115 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5117 const unsigned vec_elem
= x_type
->vector_elements
;
5118 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5119 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5121 /* Single-precision floating-point values are stored as
5126 * An exponent shift of 23 will shift the mantissa out, leaving only the
5127 * exponent and sign bit (which itself may be zero, if the absolute value
5128 * was taken before the bitcast and shift.
5130 ir_constant
*exponent_shift
= imm(23);
5131 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5133 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5135 /* Exponent of floating-point values in the range [0.5, 1.0). */
5136 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5138 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5139 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5141 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5142 * to unsigned integers to ensure that 1 bits aren't shifted in.
5144 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5145 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5146 imm(0, vec_elem
)))));
5148 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5149 body
.emit(assign(bits
, bitcast_f2u(x
)));
5150 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5151 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5152 imm(0u, vec_elem
)))));
5153 body
.emit(ret(bitcast_u2f(bits
)));
5158 ir_function_signature
*
5159 builtin_builder::_uaddCarry(const glsl_type
*type
)
5161 ir_variable
*x
= in_var(type
, "x");
5162 ir_variable
*y
= in_var(type
, "y");
5163 ir_variable
*carry
= out_var(type
, "carry");
5164 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5166 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5167 body
.emit(ret(add(x
, y
)));
5172 ir_function_signature
*
5173 builtin_builder::_usubBorrow(const glsl_type
*type
)
5175 ir_variable
*x
= in_var(type
, "x");
5176 ir_variable
*y
= in_var(type
, "y");
5177 ir_variable
*borrow
= out_var(type
, "borrow");
5178 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5180 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5181 body
.emit(ret(sub(x
, y
)));
5187 * For both imulExtended() and umulExtended() built-ins.
5189 ir_function_signature
*
5190 builtin_builder::_mulExtended(const glsl_type
*type
)
5192 ir_variable
*x
= in_var(type
, "x");
5193 ir_variable
*y
= in_var(type
, "y");
5194 ir_variable
*msb
= out_var(type
, "msb");
5195 ir_variable
*lsb
= out_var(type
, "lsb");
5196 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5198 body
.emit(assign(msb
, imul_high(x
, y
)));
5199 body
.emit(assign(lsb
, mul(x
, y
)));
5204 ir_function_signature
*
5205 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5207 ir_variable
*interpolant
= in_var(type
, "interpolant");
5208 interpolant
->data
.must_be_shader_input
= 1;
5209 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5211 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5216 ir_function_signature
*
5217 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5219 ir_variable
*interpolant
= in_var(type
, "interpolant");
5220 interpolant
->data
.must_be_shader_input
= 1;
5221 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5222 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5224 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5229 ir_function_signature
*
5230 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5232 ir_variable
*interpolant
= in_var(type
, "interpolant");
5233 interpolant
->data
.must_be_shader_input
= 1;
5234 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5235 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5237 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5242 ir_function_signature
*
5243 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5245 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5246 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5250 ir_function_signature
*
5251 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
)
5253 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5254 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5255 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 2, counter
, data
);
5259 ir_function_signature
*
5260 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
)
5262 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5263 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5264 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5265 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5269 ir_function_signature
*
5270 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5271 const glsl_type
*type
)
5273 ir_variable
*atomic
= in_var(type
, "atomic");
5274 ir_variable
*data
= in_var(type
, "data");
5275 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5279 ir_function_signature
*
5280 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5281 const glsl_type
*type
)
5283 ir_variable
*atomic
= in_var(type
, "atomic");
5284 ir_variable
*data1
= in_var(type
, "data1");
5285 ir_variable
*data2
= in_var(type
, "data2");
5286 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5290 ir_function_signature
*
5291 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5292 builtin_available_predicate avail
)
5294 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5295 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5297 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5298 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5300 body
.emit(ret(retval
));
5304 ir_function_signature
*
5305 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5306 builtin_available_predicate avail
)
5308 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5309 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5310 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5312 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5313 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5315 body
.emit(ret(retval
));
5319 ir_function_signature
*
5320 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5321 builtin_available_predicate avail
)
5323 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5324 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5325 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5326 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5328 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5329 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5331 body
.emit(ret(retval
));
5335 ir_function_signature
*
5336 builtin_builder::_atomic_op2(const char *intrinsic
,
5337 builtin_available_predicate avail
,
5338 const glsl_type
*type
)
5340 ir_variable
*atomic
= in_var(type
, "atomic_var");
5341 ir_variable
*data
= in_var(type
, "atomic_data");
5342 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5344 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5345 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5347 body
.emit(ret(retval
));
5351 ir_function_signature
*
5352 builtin_builder::_atomic_op3(const char *intrinsic
,
5353 builtin_available_predicate avail
,
5354 const glsl_type
*type
)
5356 ir_variable
*atomic
= in_var(type
, "atomic_var");
5357 ir_variable
*data1
= in_var(type
, "atomic_data1");
5358 ir_variable
*data2
= in_var(type
, "atomic_data2");
5359 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5361 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5362 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5364 body
.emit(ret(retval
));
5368 ir_function_signature
*
5369 builtin_builder::_min3(const glsl_type
*type
)
5371 ir_variable
*x
= in_var(type
, "x");
5372 ir_variable
*y
= in_var(type
, "y");
5373 ir_variable
*z
= in_var(type
, "z");
5374 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5376 ir_expression
*min3
= min2(x
, min2(y
,z
));
5377 body
.emit(ret(min3
));
5382 ir_function_signature
*
5383 builtin_builder::_max3(const glsl_type
*type
)
5385 ir_variable
*x
= in_var(type
, "x");
5386 ir_variable
*y
= in_var(type
, "y");
5387 ir_variable
*z
= in_var(type
, "z");
5388 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5390 ir_expression
*max3
= max2(x
, max2(y
,z
));
5391 body
.emit(ret(max3
));
5396 ir_function_signature
*
5397 builtin_builder::_mid3(const glsl_type
*type
)
5399 ir_variable
*x
= in_var(type
, "x");
5400 ir_variable
*y
= in_var(type
, "y");
5401 ir_variable
*z
= in_var(type
, "z");
5402 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5404 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5405 body
.emit(ret(mid3
));
5410 static builtin_available_predicate
5411 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5413 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5414 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5415 return shader_image_atomic_exchange_float
;
5417 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5418 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5419 return shader_image_atomic
;
5422 return shader_image_load_store
;
5425 ir_function_signature
*
5426 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5427 unsigned num_arguments
,
5430 const glsl_type
*data_type
= glsl_type::get_instance(
5431 image_type
->sampled_type
,
5432 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5434 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5435 glsl_type::void_type
: data_type
);
5437 /* Addressing arguments that are always present. */
5438 ir_variable
*image
= in_var(image_type
, "image");
5439 ir_variable
*coord
= in_var(
5440 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5442 ir_function_signature
*sig
= new_sig(
5443 ret_type
, get_image_available_predicate(image_type
, flags
),
5446 /* Sample index for multisample images. */
5447 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5448 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5450 /* Data arguments. */
5451 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5452 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5453 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5454 ralloc_free(arg_name
);
5457 /* Set the maximal set of qualifiers allowed for this image
5458 * built-in. Function calls with arguments having fewer
5459 * qualifiers than present in the prototype are allowed by the
5460 * spec, but not with more, i.e. this will make the compiler
5461 * accept everything that needs to be accepted, and reject cases
5462 * like loads from write-only or stores to read-only images.
5464 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5465 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5466 image
->data
.image_coherent
= true;
5467 image
->data
.image_volatile
= true;
5468 image
->data
.image_restrict
= true;
5473 ir_function_signature
*
5474 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5475 unsigned /* num_arguments */,
5476 unsigned /* flags */)
5478 const glsl_type
*ret_type
;
5479 unsigned num_components
= image_type
->coordinate_components();
5481 /* From the ARB_shader_image_size extension:
5482 * "Cube images return the dimensions of one face."
5484 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5485 !image_type
->sampler_array
) {
5489 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5490 * supported by mesa.
5492 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5494 ir_variable
*image
= in_var(image_type
, "image");
5495 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5497 /* Set the maximal set of qualifiers allowed for this image
5498 * built-in. Function calls with arguments having fewer
5499 * qualifiers than present in the prototype are allowed by the
5500 * spec, but not with more, i.e. this will make the compiler
5501 * accept everything that needs to be accepted, and reject cases
5502 * like loads from write-only or stores to read-only images.
5504 image
->data
.image_read_only
= true;
5505 image
->data
.image_write_only
= true;
5506 image
->data
.image_coherent
= true;
5507 image
->data
.image_volatile
= true;
5508 image
->data
.image_restrict
= true;
5513 ir_function_signature
*
5514 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5515 unsigned /* num_arguments */,
5516 unsigned /* flags */)
5518 ir_variable
*image
= in_var(image_type
, "image");
5519 ir_function_signature
*sig
=
5520 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5522 /* Set the maximal set of qualifiers allowed for this image
5523 * built-in. Function calls with arguments having fewer
5524 * qualifiers than present in the prototype are allowed by the
5525 * spec, but not with more, i.e. this will make the compiler
5526 * accept everything that needs to be accepted, and reject cases
5527 * like loads from write-only or stores to read-only images.
5529 image
->data
.image_read_only
= true;
5530 image
->data
.image_write_only
= true;
5531 image
->data
.image_coherent
= true;
5532 image
->data
.image_volatile
= true;
5533 image
->data
.image_restrict
= true;
5538 ir_function_signature
*
5539 builtin_builder::_image(image_prototype_ctr prototype
,
5540 const glsl_type
*image_type
,
5541 const char *intrinsic_name
,
5542 unsigned num_arguments
,
5545 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5546 num_arguments
, flags
);
5548 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5549 ir_factory
body(&sig
->body
, mem_ctx
);
5550 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5552 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5553 body
.emit(call(f
, NULL
, sig
->parameters
));
5555 ir_variable
*ret_val
=
5556 body
.make_temp(sig
->return_type
, "_ret_val");
5557 body
.emit(call(f
, ret_val
, sig
->parameters
));
5558 body
.emit(ret(ret_val
));
5561 sig
->is_defined
= true;
5564 sig
->is_intrinsic
= true;
5570 ir_function_signature
*
5571 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5573 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5577 ir_function_signature
*
5578 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5579 builtin_available_predicate avail
)
5581 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5582 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5583 NULL
, sig
->parameters
));
5587 ir_function_signature
*
5588 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5589 const glsl_type
*type
)
5591 MAKE_INTRINSIC(type
, avail
, 0);
5595 ir_function_signature
*
5596 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5597 const glsl_type
*type
)
5599 MAKE_SIG(type
, avail
, 0);
5601 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5603 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5604 retval
, sig
->parameters
));
5605 body
.emit(ret(retval
));
5609 ir_function_signature
*
5610 builtin_builder::_vote(enum ir_expression_operation opcode
)
5612 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
5614 MAKE_SIG(glsl_type::bool_type
, vote
, 1, value
);
5615 body
.emit(ret(expr(opcode
, value
)));
5621 /******************************************************************************/
5623 /* The singleton instance of builtin_builder. */
5624 static builtin_builder builtins
;
5625 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5628 * External API (exposing the built-in module to the rest of the compiler):
5632 _mesa_glsl_initialize_builtin_functions()
5634 mtx_lock(&builtins_lock
);
5635 builtins
.initialize();
5636 mtx_unlock(&builtins_lock
);
5640 _mesa_glsl_release_builtin_functions()
5642 mtx_lock(&builtins_lock
);
5644 mtx_unlock(&builtins_lock
);
5647 ir_function_signature
*
5648 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5649 const char *name
, exec_list
*actual_parameters
)
5651 ir_function_signature
* s
;
5652 mtx_lock(&builtins_lock
);
5653 s
= builtins
.find(state
, name
, actual_parameters
);
5654 mtx_unlock(&builtins_lock
);
5659 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5662 mtx_lock(&builtins_lock
);
5663 f
= builtins
.shader
->symbols
->get_function(name
);
5664 mtx_unlock(&builtins_lock
);
5669 _mesa_glsl_get_builtin_function_shader()
5671 return builtins
.shader
;
5676 * Get the function signature for main from a shader
5678 ir_function_signature
*
5679 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
5681 ir_function
*const f
= symbols
->get_function("main");
5683 exec_list void_parameters
;
5685 /* Look for the 'void main()' signature and ensure that it's defined.
5686 * This keeps the linker from accidentally pick a shader that just
5687 * contains a prototype for main.
5689 * We don't have to check for multiple definitions of main (in multiple
5690 * shaders) because that would have already been caught above.
5692 ir_function_signature
*sig
=
5693 f
->matching_signature(NULL
, &void_parameters
, false);
5694 if ((sig
!= NULL
) && sig
->is_defined
) {