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 void create_shader();
589 void create_intrinsics();
590 void create_builtins();
593 * IR builder helpers:
595 * These convenience functions assist in emitting IR, but don't necessarily
596 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
599 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
600 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
601 ir_constant
*imm(float f
, unsigned vector_elements
=1);
602 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
603 ir_constant
*imm(int i
, unsigned vector_elements
=1);
604 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
605 ir_constant
*imm(double d
, unsigned vector_elements
=1);
606 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
607 ir_dereference_variable
*var_ref(ir_variable
*var
);
608 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
609 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
611 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
612 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
615 * Call function \param f with parameters specified as the linked
616 * list \param params of \c ir_variable objects. \param ret should
617 * point to the ir_variable that will hold the function return
618 * value, or be \c NULL if the function has void return type.
620 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
622 /** Create a new function and add the given signatures. */
623 void add_function(const char *name
, ...);
625 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
626 unsigned num_arguments
,
630 * Create a new image built-in function for all known image types.
631 * \p flags is a bitfield of \c image_function_flags flags.
633 void add_image_function(const char *name
,
634 const char *intrinsic_name
,
635 image_prototype_ctr prototype
,
636 unsigned num_arguments
,
638 enum ir_intrinsic_id id
);
641 * Create new functions for all known image built-ins and types.
642 * If \p glsl is \c true, use the GLSL built-in names and emit code
643 * to call into the actual compiler intrinsic. If \p glsl is
644 * false, emit a function prototype with no body for each image
647 void add_image_functions(bool glsl
);
649 ir_function_signature
*new_sig(const glsl_type
*return_type
,
650 builtin_available_predicate avail
,
651 int num_params
, ...);
654 * Function signature generators:
657 ir_function_signature
*unop(builtin_available_predicate avail
,
658 ir_expression_operation opcode
,
659 const glsl_type
*return_type
,
660 const glsl_type
*param_type
);
661 ir_function_signature
*binop(builtin_available_predicate avail
,
662 ir_expression_operation opcode
,
663 const glsl_type
*return_type
,
664 const glsl_type
*param0_type
,
665 const glsl_type
*param1_type
);
667 #define B0(X) ir_function_signature *_##X();
668 #define B1(X) ir_function_signature *_##X(const glsl_type *);
669 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
670 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
671 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
672 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
709 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
710 const glsl_type
*val_type
,
711 const glsl_type
*blend_type
);
720 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
721 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
722 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
723 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
724 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
725 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
726 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
727 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
728 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
729 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
730 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
731 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
744 BA1(determinant_mat2
);
745 BA1(determinant_mat3
);
746 BA1(determinant_mat4
);
754 BA1(greaterThanEqual
);
763 /** Flags to _texture() */
764 #define TEX_PROJECT 1
766 #define TEX_COMPONENT 4
767 #define TEX_OFFSET_NONCONST 8
768 #define TEX_OFFSET_ARRAY 16
770 ir_function_signature
*_texture(ir_texture_opcode opcode
,
771 builtin_available_predicate avail
,
772 const glsl_type
*return_type
,
773 const glsl_type
*sampler_type
,
774 const glsl_type
*coord_type
,
776 B0(textureCubeArrayShadow
);
777 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
778 const glsl_type
*return_type
,
779 const glsl_type
*sampler_type
,
780 const glsl_type
*coord_type
,
781 const glsl_type
*offset_type
= NULL
);
785 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
786 const glsl_type
*stream_type
);
787 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
788 const glsl_type
*stream_type
);
791 BA2(textureQueryLod
);
792 B1(textureQueryLevels
);
793 BA2(textureSamplesIdentical
);
821 B1(interpolateAtCentroid
)
822 B1(interpolateAtOffset
)
823 B1(interpolateAtSample
)
825 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
,
826 enum ir_intrinsic_id id
);
827 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
,
828 enum ir_intrinsic_id id
);
829 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
,
830 enum ir_intrinsic_id id
);
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 enum ir_intrinsic_id id
);
841 ir_function_signature
*_atomic_op2(const char *intrinsic
,
842 builtin_available_predicate avail
,
843 const glsl_type
*type
);
844 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
845 const glsl_type
*type
,
846 enum ir_intrinsic_id id
);
847 ir_function_signature
*_atomic_op3(const char *intrinsic
,
848 builtin_available_predicate avail
,
849 const glsl_type
*type
);
855 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
856 unsigned num_arguments
,
858 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
859 unsigned num_arguments
,
861 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
862 unsigned num_arguments
,
864 ir_function_signature
*_image(image_prototype_ctr prototype
,
865 const glsl_type
*image_type
,
866 const char *intrinsic_name
,
867 unsigned num_arguments
,
869 enum ir_intrinsic_id id
);
871 ir_function_signature
*_memory_barrier_intrinsic(
872 builtin_available_predicate avail
,
873 enum ir_intrinsic_id id
);
874 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
875 builtin_available_predicate avail
);
877 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
878 const glsl_type
*type
);
879 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
880 const glsl_type
*type
);
882 ir_function_signature
*_vote(enum ir_expression_operation opcode
);
893 enum image_function_flags
{
894 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
895 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
896 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
897 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
898 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
899 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
900 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
901 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
902 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
905 } /* anonymous namespace */
908 * Core builtin_builder functionality:
911 builtin_builder::builtin_builder()
917 builtin_builder::~builtin_builder()
919 ralloc_free(mem_ctx
);
922 ir_function_signature
*
923 builtin_builder::find(_mesa_glsl_parse_state
*state
,
924 const char *name
, exec_list
*actual_parameters
)
926 /* The shader currently being compiled requested a built-in function;
927 * it needs to link against builtin_builder::shader in order to get them.
929 * Even if we don't find a matching signature, we still need to do this so
930 * that the "no matching signature" error will list potential candidates
931 * from the available built-ins.
933 state
->uses_builtin_functions
= true;
935 ir_function
*f
= shader
->symbols
->get_function(name
);
939 ir_function_signature
*sig
=
940 f
->matching_signature(state
, actual_parameters
, true);
948 builtin_builder::initialize()
950 /* If already initialized, don't do it again. */
954 mem_ctx
= ralloc_context(NULL
);
961 builtin_builder::release()
963 ralloc_free(mem_ctx
);
971 builtin_builder::create_shader()
973 /* The target doesn't actually matter. There's no target for generic
974 * GLSL utility code that could be linked against any stage, so just
975 * arbitrarily pick GL_VERTEX_SHADER.
977 shader
= _mesa_new_shader(0, MESA_SHADER_VERTEX
);
978 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
984 * Create ir_function and ir_function_signature objects for each
988 builtin_builder::create_intrinsics()
990 add_function("__intrinsic_atomic_read",
991 _atomic_counter_intrinsic(shader_atomic_counters
,
992 ir_intrinsic_atomic_counter_read
),
994 add_function("__intrinsic_atomic_increment",
995 _atomic_counter_intrinsic(shader_atomic_counters
,
996 ir_intrinsic_atomic_counter_increment
),
998 add_function("__intrinsic_atomic_predecrement",
999 _atomic_counter_intrinsic(shader_atomic_counters
,
1000 ir_intrinsic_atomic_counter_predecrement
),
1003 add_function("__intrinsic_atomic_add",
1004 _atomic_intrinsic2(buffer_atomics_supported
,
1005 glsl_type::uint_type
,
1006 ir_intrinsic_generic_atomic_add
),
1007 _atomic_intrinsic2(buffer_atomics_supported
,
1008 glsl_type::int_type
,
1009 ir_intrinsic_generic_atomic_add
),
1010 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1011 ir_intrinsic_atomic_counter_add
),
1013 add_function("__intrinsic_atomic_min",
1014 _atomic_intrinsic2(buffer_atomics_supported
,
1015 glsl_type::uint_type
,
1016 ir_intrinsic_generic_atomic_min
),
1017 _atomic_intrinsic2(buffer_atomics_supported
,
1018 glsl_type::int_type
,
1019 ir_intrinsic_generic_atomic_min
),
1020 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1021 ir_intrinsic_atomic_counter_min
),
1023 add_function("__intrinsic_atomic_max",
1024 _atomic_intrinsic2(buffer_atomics_supported
,
1025 glsl_type::uint_type
,
1026 ir_intrinsic_generic_atomic_max
),
1027 _atomic_intrinsic2(buffer_atomics_supported
,
1028 glsl_type::int_type
,
1029 ir_intrinsic_generic_atomic_max
),
1030 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1031 ir_intrinsic_atomic_counter_max
),
1033 add_function("__intrinsic_atomic_and",
1034 _atomic_intrinsic2(buffer_atomics_supported
,
1035 glsl_type::uint_type
,
1036 ir_intrinsic_generic_atomic_and
),
1037 _atomic_intrinsic2(buffer_atomics_supported
,
1038 glsl_type::int_type
,
1039 ir_intrinsic_generic_atomic_and
),
1040 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1041 ir_intrinsic_atomic_counter_and
),
1043 add_function("__intrinsic_atomic_or",
1044 _atomic_intrinsic2(buffer_atomics_supported
,
1045 glsl_type::uint_type
,
1046 ir_intrinsic_generic_atomic_or
),
1047 _atomic_intrinsic2(buffer_atomics_supported
,
1048 glsl_type::int_type
,
1049 ir_intrinsic_generic_atomic_or
),
1050 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1051 ir_intrinsic_atomic_counter_or
),
1053 add_function("__intrinsic_atomic_xor",
1054 _atomic_intrinsic2(buffer_atomics_supported
,
1055 glsl_type::uint_type
,
1056 ir_intrinsic_generic_atomic_xor
),
1057 _atomic_intrinsic2(buffer_atomics_supported
,
1058 glsl_type::int_type
,
1059 ir_intrinsic_generic_atomic_xor
),
1060 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1061 ir_intrinsic_atomic_counter_xor
),
1063 add_function("__intrinsic_atomic_exchange",
1064 _atomic_intrinsic2(buffer_atomics_supported
,
1065 glsl_type::uint_type
,
1066 ir_intrinsic_generic_atomic_exchange
),
1067 _atomic_intrinsic2(buffer_atomics_supported
,
1068 glsl_type::int_type
,
1069 ir_intrinsic_generic_atomic_exchange
),
1070 _atomic_counter_intrinsic1(shader_atomic_counter_ops
,
1071 ir_intrinsic_atomic_counter_exchange
),
1073 add_function("__intrinsic_atomic_comp_swap",
1074 _atomic_intrinsic3(buffer_atomics_supported
,
1075 glsl_type::uint_type
,
1076 ir_intrinsic_generic_atomic_comp_swap
),
1077 _atomic_intrinsic3(buffer_atomics_supported
,
1078 glsl_type::int_type
,
1079 ir_intrinsic_generic_atomic_comp_swap
),
1080 _atomic_counter_intrinsic2(shader_atomic_counter_ops
,
1081 ir_intrinsic_atomic_counter_comp_swap
),
1084 add_image_functions(false);
1086 add_function("__intrinsic_memory_barrier",
1087 _memory_barrier_intrinsic(shader_image_load_store
,
1088 ir_intrinsic_memory_barrier
),
1090 add_function("__intrinsic_group_memory_barrier",
1091 _memory_barrier_intrinsic(compute_shader
,
1092 ir_intrinsic_group_memory_barrier
),
1094 add_function("__intrinsic_memory_barrier_atomic_counter",
1095 _memory_barrier_intrinsic(compute_shader
,
1096 ir_intrinsic_memory_barrier_atomic_counter
),
1098 add_function("__intrinsic_memory_barrier_buffer",
1099 _memory_barrier_intrinsic(compute_shader
,
1100 ir_intrinsic_memory_barrier_buffer
),
1102 add_function("__intrinsic_memory_barrier_image",
1103 _memory_barrier_intrinsic(compute_shader
,
1104 ir_intrinsic_memory_barrier_image
),
1106 add_function("__intrinsic_memory_barrier_shared",
1107 _memory_barrier_intrinsic(compute_shader
,
1108 ir_intrinsic_memory_barrier_shared
),
1111 add_function("__intrinsic_shader_clock",
1112 _shader_clock_intrinsic(shader_clock
,
1113 glsl_type::uvec2_type
),
1118 * Create ir_function and ir_function_signature objects for each built-in.
1120 * Contains a list of every available built-in.
1123 builtin_builder::create_builtins()
1126 add_function(#NAME, \
1127 _##NAME(glsl_type::float_type), \
1128 _##NAME(glsl_type::vec2_type), \
1129 _##NAME(glsl_type::vec3_type), \
1130 _##NAME(glsl_type::vec4_type), \
1134 add_function(#NAME, \
1135 _##NAME(always_available, glsl_type::float_type), \
1136 _##NAME(always_available, glsl_type::vec2_type), \
1137 _##NAME(always_available, glsl_type::vec3_type), \
1138 _##NAME(always_available, glsl_type::vec4_type), \
1139 _##NAME(fp64, glsl_type::double_type), \
1140 _##NAME(fp64, glsl_type::dvec2_type), \
1141 _##NAME(fp64, glsl_type::dvec3_type), \
1142 _##NAME(fp64, glsl_type::dvec4_type), \
1145 #define FD130(NAME) \
1146 add_function(#NAME, \
1147 _##NAME(v130, glsl_type::float_type), \
1148 _##NAME(v130, glsl_type::vec2_type), \
1149 _##NAME(v130, glsl_type::vec3_type), \
1150 _##NAME(v130, glsl_type::vec4_type), \
1151 _##NAME(fp64, glsl_type::double_type), \
1152 _##NAME(fp64, glsl_type::dvec2_type), \
1153 _##NAME(fp64, glsl_type::dvec3_type), \
1154 _##NAME(fp64, glsl_type::dvec4_type), \
1157 #define FDGS5(NAME) \
1158 add_function(#NAME, \
1159 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1160 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1161 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1162 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1163 _##NAME(fp64, glsl_type::double_type), \
1164 _##NAME(fp64, glsl_type::dvec2_type), \
1165 _##NAME(fp64, glsl_type::dvec3_type), \
1166 _##NAME(fp64, glsl_type::dvec4_type), \
1170 add_function(#NAME, \
1171 _##NAME(glsl_type::float_type), \
1172 _##NAME(glsl_type::vec2_type), \
1173 _##NAME(glsl_type::vec3_type), \
1174 _##NAME(glsl_type::vec4_type), \
1175 _##NAME(glsl_type::int_type), \
1176 _##NAME(glsl_type::ivec2_type), \
1177 _##NAME(glsl_type::ivec3_type), \
1178 _##NAME(glsl_type::ivec4_type), \
1182 add_function(#NAME, \
1183 _##NAME(always_available, glsl_type::float_type), \
1184 _##NAME(always_available, glsl_type::vec2_type), \
1185 _##NAME(always_available, glsl_type::vec3_type), \
1186 _##NAME(always_available, glsl_type::vec4_type), \
1187 _##NAME(always_available, glsl_type::int_type), \
1188 _##NAME(always_available, glsl_type::ivec2_type), \
1189 _##NAME(always_available, glsl_type::ivec3_type), \
1190 _##NAME(always_available, glsl_type::ivec4_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), \
1197 #define FIUD(NAME) \
1198 add_function(#NAME, \
1199 _##NAME(always_available, glsl_type::float_type), \
1200 _##NAME(always_available, glsl_type::vec2_type), \
1201 _##NAME(always_available, glsl_type::vec3_type), \
1202 _##NAME(always_available, glsl_type::vec4_type), \
1204 _##NAME(always_available, glsl_type::int_type), \
1205 _##NAME(always_available, glsl_type::ivec2_type), \
1206 _##NAME(always_available, glsl_type::ivec3_type), \
1207 _##NAME(always_available, glsl_type::ivec4_type), \
1209 _##NAME(v130, glsl_type::uint_type), \
1210 _##NAME(v130, glsl_type::uvec2_type), \
1211 _##NAME(v130, glsl_type::uvec3_type), \
1212 _##NAME(v130, glsl_type::uvec4_type), \
1213 _##NAME(fp64, glsl_type::double_type), \
1214 _##NAME(fp64, glsl_type::dvec2_type), \
1215 _##NAME(fp64, glsl_type::dvec3_type), \
1216 _##NAME(fp64, glsl_type::dvec4_type), \
1220 add_function(#NAME, \
1221 _##NAME(glsl_type::int_type), \
1222 _##NAME(glsl_type::ivec2_type), \
1223 _##NAME(glsl_type::ivec3_type), \
1224 _##NAME(glsl_type::ivec4_type), \
1226 _##NAME(glsl_type::uint_type), \
1227 _##NAME(glsl_type::uvec2_type), \
1228 _##NAME(glsl_type::uvec3_type), \
1229 _##NAME(glsl_type::uvec4_type), \
1232 #define FIUBD(NAME) \
1233 add_function(#NAME, \
1234 _##NAME(always_available, glsl_type::float_type), \
1235 _##NAME(always_available, glsl_type::vec2_type), \
1236 _##NAME(always_available, glsl_type::vec3_type), \
1237 _##NAME(always_available, glsl_type::vec4_type), \
1239 _##NAME(always_available, glsl_type::int_type), \
1240 _##NAME(always_available, glsl_type::ivec2_type), \
1241 _##NAME(always_available, glsl_type::ivec3_type), \
1242 _##NAME(always_available, glsl_type::ivec4_type), \
1244 _##NAME(v130, glsl_type::uint_type), \
1245 _##NAME(v130, glsl_type::uvec2_type), \
1246 _##NAME(v130, glsl_type::uvec3_type), \
1247 _##NAME(v130, glsl_type::uvec4_type), \
1249 _##NAME(always_available, glsl_type::bool_type), \
1250 _##NAME(always_available, glsl_type::bvec2_type), \
1251 _##NAME(always_available, glsl_type::bvec3_type), \
1252 _##NAME(always_available, glsl_type::bvec4_type), \
1254 _##NAME(fp64, glsl_type::double_type), \
1255 _##NAME(fp64, glsl_type::dvec2_type), \
1256 _##NAME(fp64, glsl_type::dvec3_type), \
1257 _##NAME(fp64, glsl_type::dvec4_type), \
1260 #define FIUD2_MIXED(NAME) \
1261 add_function(#NAME, \
1262 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1263 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1264 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1265 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1267 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1268 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1269 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1271 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1272 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1273 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1274 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1276 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1277 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1278 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1280 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1281 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1282 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1283 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1285 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1286 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1287 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1289 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1290 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1291 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1292 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1293 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1294 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1295 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1306 add_function("atan",
1307 _atan(glsl_type::float_type
),
1308 _atan(glsl_type::vec2_type
),
1309 _atan(glsl_type::vec3_type
),
1310 _atan(glsl_type::vec4_type
),
1311 _atan2(glsl_type::float_type
),
1312 _atan2(glsl_type::vec2_type
),
1313 _atan2(glsl_type::vec3_type
),
1314 _atan2(glsl_type::vec4_type
),
1340 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1341 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1342 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1343 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1345 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1346 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1347 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1349 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1350 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1351 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1352 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1354 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1355 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1356 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1366 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1367 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1368 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1369 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1371 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1372 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1373 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1375 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1376 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1377 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1378 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1380 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1381 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1382 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1384 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1385 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1386 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1387 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1389 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1390 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1391 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1392 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1394 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1395 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1396 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1397 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1399 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1400 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1401 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1402 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1404 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1405 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1406 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1407 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1410 add_function("step",
1411 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1412 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1413 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1414 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1416 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1417 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1418 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1419 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1420 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1421 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1422 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1424 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1425 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1426 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1429 add_function("smoothstep",
1430 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1431 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1432 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1433 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1435 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1436 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1437 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1438 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1439 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1440 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1441 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1443 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1444 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1445 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1453 add_function("intBitsToFloat",
1454 _intBitsToFloat(glsl_type::int_type
),
1455 _intBitsToFloat(glsl_type::ivec2_type
),
1456 _intBitsToFloat(glsl_type::ivec3_type
),
1457 _intBitsToFloat(glsl_type::ivec4_type
),
1459 add_function("uintBitsToFloat",
1460 _uintBitsToFloat(glsl_type::uint_type
),
1461 _uintBitsToFloat(glsl_type::uvec2_type
),
1462 _uintBitsToFloat(glsl_type::uvec3_type
),
1463 _uintBitsToFloat(glsl_type::uvec4_type
),
1466 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1467 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1468 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1469 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1470 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1471 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1472 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1473 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1474 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1475 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1476 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1477 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1484 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1485 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1488 add_function("ftransform", _ftransform(), NULL
);
1493 add_function("matrixCompMult",
1494 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1495 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1496 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1497 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1498 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1499 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1500 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1501 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1502 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1503 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1504 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1505 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1506 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1507 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1508 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1509 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1510 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1511 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1513 add_function("outerProduct",
1514 _outerProduct(v120
, glsl_type::mat2_type
),
1515 _outerProduct(v120
, glsl_type::mat3_type
),
1516 _outerProduct(v120
, glsl_type::mat4_type
),
1517 _outerProduct(v120
, glsl_type::mat2x3_type
),
1518 _outerProduct(v120
, glsl_type::mat2x4_type
),
1519 _outerProduct(v120
, glsl_type::mat3x2_type
),
1520 _outerProduct(v120
, glsl_type::mat3x4_type
),
1521 _outerProduct(v120
, glsl_type::mat4x2_type
),
1522 _outerProduct(v120
, glsl_type::mat4x3_type
),
1523 _outerProduct(fp64
, glsl_type::dmat2_type
),
1524 _outerProduct(fp64
, glsl_type::dmat3_type
),
1525 _outerProduct(fp64
, glsl_type::dmat4_type
),
1526 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1527 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1528 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1529 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1530 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1531 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1533 add_function("determinant",
1534 _determinant_mat2(v120
, glsl_type::mat2_type
),
1535 _determinant_mat3(v120
, glsl_type::mat3_type
),
1536 _determinant_mat4(v120
, glsl_type::mat4_type
),
1537 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1538 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1539 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1542 add_function("inverse",
1543 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1544 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1545 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1546 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1547 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1548 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1550 add_function("transpose",
1551 _transpose(v120
, glsl_type::mat2_type
),
1552 _transpose(v120
, glsl_type::mat3_type
),
1553 _transpose(v120
, glsl_type::mat4_type
),
1554 _transpose(v120
, glsl_type::mat2x3_type
),
1555 _transpose(v120
, glsl_type::mat2x4_type
),
1556 _transpose(v120
, glsl_type::mat3x2_type
),
1557 _transpose(v120
, glsl_type::mat3x4_type
),
1558 _transpose(v120
, glsl_type::mat4x2_type
),
1559 _transpose(v120
, glsl_type::mat4x3_type
),
1560 _transpose(fp64
, glsl_type::dmat2_type
),
1561 _transpose(fp64
, glsl_type::dmat3_type
),
1562 _transpose(fp64
, glsl_type::dmat4_type
),
1563 _transpose(fp64
, glsl_type::dmat2x3_type
),
1564 _transpose(fp64
, glsl_type::dmat2x4_type
),
1565 _transpose(fp64
, glsl_type::dmat3x2_type
),
1566 _transpose(fp64
, glsl_type::dmat3x4_type
),
1567 _transpose(fp64
, glsl_type::dmat4x2_type
),
1568 _transpose(fp64
, glsl_type::dmat4x3_type
),
1573 FIUD(greaterThanEqual
)
1578 _any(glsl_type::bvec2_type
),
1579 _any(glsl_type::bvec3_type
),
1580 _any(glsl_type::bvec4_type
),
1584 _all(glsl_type::bvec2_type
),
1585 _all(glsl_type::bvec3_type
),
1586 _all(glsl_type::bvec4_type
),
1590 _not(glsl_type::bvec2_type
),
1591 _not(glsl_type::bvec3_type
),
1592 _not(glsl_type::bvec4_type
),
1595 add_function("textureSize",
1596 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1597 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1598 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1600 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1601 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1602 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1604 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1605 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1606 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1608 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1609 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1610 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1612 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1613 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1614 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1616 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1617 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1618 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1619 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1620 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1621 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1623 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1624 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1626 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1627 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1628 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1629 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1631 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1632 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1633 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1634 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1636 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1637 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1638 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1639 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1640 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1641 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1643 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1644 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1645 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1648 add_function("textureSamples",
1649 _textureSamples(glsl_type::sampler2DMS_type
),
1650 _textureSamples(glsl_type::isampler2DMS_type
),
1651 _textureSamples(glsl_type::usampler2DMS_type
),
1653 _textureSamples(glsl_type::sampler2DMSArray_type
),
1654 _textureSamples(glsl_type::isampler2DMSArray_type
),
1655 _textureSamples(glsl_type::usampler2DMSArray_type
),
1658 add_function("texture",
1659 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1660 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1661 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1663 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1664 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1665 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1667 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1668 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1669 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1671 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1672 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1673 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1675 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1676 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1677 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1679 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1680 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1681 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1683 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1684 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1685 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1687 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1688 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1689 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1691 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1692 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1693 /* samplerCubeArrayShadow is special; it has an extra parameter
1694 * for the shadow comparitor since there is no vec5 type.
1696 _textureCubeArrayShadow(),
1698 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1699 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1700 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1702 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1704 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1705 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1706 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1708 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1709 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1710 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1712 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1713 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1714 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1716 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1717 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1718 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1720 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1721 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1722 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1724 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1725 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1726 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1728 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1729 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1730 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1732 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1733 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1734 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1736 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1739 add_function("textureLod",
1740 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1741 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1742 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1744 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1745 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1746 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1748 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1749 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1750 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1752 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1753 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1754 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1756 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1757 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1759 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1760 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1761 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1763 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1764 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1765 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1767 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1768 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1769 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1771 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1774 add_function("textureOffset",
1775 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1776 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1777 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1779 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1780 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1781 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1783 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1784 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1785 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1787 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1788 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1789 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1791 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1793 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1794 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1796 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1797 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1798 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1800 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1801 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1802 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1804 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1805 /* The next one was forgotten in GLSL 1.30 spec. It's from
1806 * EXT_gpu_shader4 originally. It was added in 4.30 with the
1807 * wrong syntax. This was corrected in 4.40. 4.30 indicates
1808 * that it was intended to be included previously, so allow it
1811 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1813 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1814 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1815 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1817 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1818 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1819 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1821 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1822 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1823 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1825 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1826 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1828 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1829 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1830 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1832 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1833 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1834 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1836 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1839 add_function("textureProj",
1840 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1841 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1842 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1843 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1844 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1845 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1847 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1848 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1849 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1850 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1851 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1852 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1854 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1855 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1856 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1858 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1859 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1861 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1862 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1863 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1864 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1865 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1866 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1868 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1870 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1871 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1872 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1873 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1874 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1875 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1877 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1878 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1879 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1880 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1881 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1882 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1884 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1885 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1886 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1888 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1889 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1892 add_function("texelFetch",
1893 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1894 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1895 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1897 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1898 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1899 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1901 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1902 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1903 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1905 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1906 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1907 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1909 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1910 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1911 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1913 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1914 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1915 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1917 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1918 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1919 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1921 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1922 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1923 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1925 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1926 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1927 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1930 add_function("texelFetchOffset",
1931 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1932 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1933 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1935 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1936 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1937 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1939 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1940 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1941 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1943 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1944 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1945 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1947 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1948 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1949 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1951 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1952 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1953 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1957 add_function("textureProjOffset",
1958 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1959 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1960 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1962 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1963 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1965 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1966 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1967 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1968 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1969 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1970 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1972 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1973 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1974 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1976 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1977 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1979 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1980 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1981 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1982 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1983 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1984 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1986 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1988 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1989 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1990 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1991 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1992 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1993 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1995 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1996 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1997 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1998 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1999 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2000 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2002 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2003 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2004 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2006 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2007 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2010 add_function("textureLodOffset",
2011 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2012 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2013 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2015 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2016 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2017 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2019 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2020 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2021 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2023 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2024 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2026 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2027 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2028 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2030 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2031 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2032 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2034 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2037 add_function("textureProjLod",
2038 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2039 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2040 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2041 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2042 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2043 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2045 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2046 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2047 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2048 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2049 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2050 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2052 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2053 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2054 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2056 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2057 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2060 add_function("textureProjLodOffset",
2061 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2062 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2063 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2064 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2065 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2066 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2068 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2069 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2070 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2071 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2072 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2073 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2075 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2076 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2077 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2079 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2080 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2083 add_function("textureGrad",
2084 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2085 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2086 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2088 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2089 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2090 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2092 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2093 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2094 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2096 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2097 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2098 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2100 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2101 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2102 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2104 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2106 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2107 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2108 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2110 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2111 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2112 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2114 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2115 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2116 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2118 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2119 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2120 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2122 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2123 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2126 add_function("textureGradOffset",
2127 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2128 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2129 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2131 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2132 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2133 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2135 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2136 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2137 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2139 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2140 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2141 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2143 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2145 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2146 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2148 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2149 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2150 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2152 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2153 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2154 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2156 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2157 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2160 add_function("textureProjGrad",
2161 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2162 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2163 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2164 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2165 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2166 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2168 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2169 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2170 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2171 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2172 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2173 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2175 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2176 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2177 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2179 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2180 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2181 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2182 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2183 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2184 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2186 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2188 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2189 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2192 add_function("textureProjGradOffset",
2193 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2194 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2195 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2196 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2197 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2198 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2200 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2201 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2202 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2203 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2204 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2205 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2207 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2208 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2209 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2211 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2212 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2213 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2214 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2215 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2216 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2218 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2220 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2221 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2224 add_function("EmitVertex", _EmitVertex(), NULL
);
2225 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2226 add_function("EmitStreamVertex",
2227 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2228 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2230 add_function("EndStreamPrimitive",
2231 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2232 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2234 add_function("barrier", _barrier(), NULL
);
2236 add_function("textureQueryLOD",
2237 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2238 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2239 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2241 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2242 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2243 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2245 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2246 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2247 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2249 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2250 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2251 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2253 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2254 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2255 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2257 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2258 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2259 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2261 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2262 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2263 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2265 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2266 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2267 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2268 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2269 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2270 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2273 add_function("textureQueryLod",
2274 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2275 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2276 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2278 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2279 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2280 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2282 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2283 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2284 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2286 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2287 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2288 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2290 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2291 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2292 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2294 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2295 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2296 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2298 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2299 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2300 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2302 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2303 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2304 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2305 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2306 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2307 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2310 add_function("textureQueryLevels",
2311 _textureQueryLevels(glsl_type::sampler1D_type
),
2312 _textureQueryLevels(glsl_type::sampler2D_type
),
2313 _textureQueryLevels(glsl_type::sampler3D_type
),
2314 _textureQueryLevels(glsl_type::samplerCube_type
),
2315 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2316 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2317 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2318 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2319 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2320 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2321 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2322 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2323 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2325 _textureQueryLevels(glsl_type::isampler1D_type
),
2326 _textureQueryLevels(glsl_type::isampler2D_type
),
2327 _textureQueryLevels(glsl_type::isampler3D_type
),
2328 _textureQueryLevels(glsl_type::isamplerCube_type
),
2329 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2330 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2331 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2333 _textureQueryLevels(glsl_type::usampler1D_type
),
2334 _textureQueryLevels(glsl_type::usampler2D_type
),
2335 _textureQueryLevels(glsl_type::usampler3D_type
),
2336 _textureQueryLevels(glsl_type::usamplerCube_type
),
2337 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2338 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2339 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2343 add_function("textureSamplesIdenticalEXT",
2344 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2345 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2346 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2348 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2349 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2350 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2353 add_function("texture1D",
2354 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2355 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2358 add_function("texture1DArray",
2359 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2360 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2363 add_function("texture1DProj",
2364 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2365 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2366 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2367 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 add_function("texture1DLod",
2371 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2374 add_function("texture1DArrayLod",
2375 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2378 add_function("texture1DProjLod",
2379 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2380 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2383 add_function("texture2D",
2384 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2385 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2386 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2389 add_function("texture2DArray",
2390 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2391 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2394 add_function("texture2DProj",
2395 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2396 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2397 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2398 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2399 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2400 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2403 add_function("texture2DLod",
2404 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2407 add_function("texture2DArrayLod",
2408 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2411 add_function("texture2DProjLod",
2412 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2413 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2416 add_function("texture3D",
2417 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2418 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2421 add_function("texture3DProj",
2422 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2423 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2426 add_function("texture3DLod",
2427 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2430 add_function("texture3DProjLod",
2431 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2434 add_function("textureCube",
2435 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2436 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2439 add_function("textureCubeLod",
2440 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2443 add_function("texture2DRect",
2444 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2447 add_function("texture2DRectProj",
2448 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2449 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2452 add_function("shadow1D",
2453 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2454 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2457 add_function("shadow1DArray",
2458 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2459 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2462 add_function("shadow2D",
2463 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2464 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2467 add_function("shadow2DArray",
2468 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2469 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2472 add_function("shadow1DProj",
2473 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2474 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2477 add_function("shadow2DProj",
2478 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2479 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2482 add_function("shadow1DLod",
2483 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2486 add_function("shadow2DLod",
2487 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2490 add_function("shadow1DArrayLod",
2491 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2494 add_function("shadow1DProjLod",
2495 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2498 add_function("shadow2DProjLod",
2499 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2502 add_function("shadow2DRect",
2503 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2506 add_function("shadow2DRectProj",
2507 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2510 add_function("texture1DGradARB",
2511 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2514 add_function("texture1DProjGradARB",
2515 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2516 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2519 add_function("texture2DGradARB",
2520 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2523 add_function("texture2DProjGradARB",
2524 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2525 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2528 add_function("texture3DGradARB",
2529 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2532 add_function("texture3DProjGradARB",
2533 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2536 add_function("textureCubeGradARB",
2537 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2540 add_function("shadow1DGradARB",
2541 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2544 add_function("shadow1DProjGradARB",
2545 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2548 add_function("shadow2DGradARB",
2549 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2552 add_function("shadow2DProjGradARB",
2553 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2556 add_function("texture2DRectGradARB",
2557 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2560 add_function("texture2DRectProjGradARB",
2561 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2562 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2565 add_function("shadow2DRectGradARB",
2566 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2569 add_function("shadow2DRectProjGradARB",
2570 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2573 add_function("textureGather",
2574 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2575 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2576 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2578 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2579 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2580 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2582 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2583 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2584 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2586 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2587 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2588 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2590 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2591 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2592 _texture(ir_tg4
, texture_gather_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2594 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2595 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2596 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2598 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2599 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2600 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2602 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2603 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2604 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2606 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2607 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2608 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2610 _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
),
2611 _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
),
2612 _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
),
2614 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2615 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2616 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2617 _texture(ir_tg4
, gpu_shader5_or_OES_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2618 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2621 add_function("textureGatherOffset",
2622 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2623 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2624 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2626 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2627 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2628 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2630 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2631 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2632 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2634 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2635 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2636 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2638 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2639 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2640 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2642 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2643 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2644 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2646 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2647 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2648 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2650 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2651 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2652 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2654 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2655 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2656 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2658 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2659 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2660 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2662 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2663 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2664 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2666 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2667 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2670 add_function("textureGatherOffsets",
2671 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2672 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2673 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2675 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2676 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2677 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2679 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2680 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2681 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2683 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2684 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2685 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2687 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2688 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2689 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2691 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2692 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2693 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2695 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2696 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2697 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2722 add_function("ldexp",
2723 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2724 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2725 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2726 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2727 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2728 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2729 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2730 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2733 add_function("frexp",
2734 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2735 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2736 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2737 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2738 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2739 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2740 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2741 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2743 add_function("uaddCarry",
2744 _uaddCarry(glsl_type::uint_type
),
2745 _uaddCarry(glsl_type::uvec2_type
),
2746 _uaddCarry(glsl_type::uvec3_type
),
2747 _uaddCarry(glsl_type::uvec4_type
),
2749 add_function("usubBorrow",
2750 _usubBorrow(glsl_type::uint_type
),
2751 _usubBorrow(glsl_type::uvec2_type
),
2752 _usubBorrow(glsl_type::uvec3_type
),
2753 _usubBorrow(glsl_type::uvec4_type
),
2755 add_function("imulExtended",
2756 _mulExtended(glsl_type::int_type
),
2757 _mulExtended(glsl_type::ivec2_type
),
2758 _mulExtended(glsl_type::ivec3_type
),
2759 _mulExtended(glsl_type::ivec4_type
),
2761 add_function("umulExtended",
2762 _mulExtended(glsl_type::uint_type
),
2763 _mulExtended(glsl_type::uvec2_type
),
2764 _mulExtended(glsl_type::uvec3_type
),
2765 _mulExtended(glsl_type::uvec4_type
),
2767 add_function("interpolateAtCentroid",
2768 _interpolateAtCentroid(glsl_type::float_type
),
2769 _interpolateAtCentroid(glsl_type::vec2_type
),
2770 _interpolateAtCentroid(glsl_type::vec3_type
),
2771 _interpolateAtCentroid(glsl_type::vec4_type
),
2773 add_function("interpolateAtOffset",
2774 _interpolateAtOffset(glsl_type::float_type
),
2775 _interpolateAtOffset(glsl_type::vec2_type
),
2776 _interpolateAtOffset(glsl_type::vec3_type
),
2777 _interpolateAtOffset(glsl_type::vec4_type
),
2779 add_function("interpolateAtSample",
2780 _interpolateAtSample(glsl_type::float_type
),
2781 _interpolateAtSample(glsl_type::vec2_type
),
2782 _interpolateAtSample(glsl_type::vec3_type
),
2783 _interpolateAtSample(glsl_type::vec4_type
),
2786 add_function("atomicCounter",
2787 _atomic_counter_op("__intrinsic_atomic_read",
2788 shader_atomic_counters
),
2790 add_function("atomicCounterIncrement",
2791 _atomic_counter_op("__intrinsic_atomic_increment",
2792 shader_atomic_counters
),
2794 add_function("atomicCounterDecrement",
2795 _atomic_counter_op("__intrinsic_atomic_predecrement",
2796 shader_atomic_counters
),
2799 add_function("atomicCounterAddARB",
2800 _atomic_counter_op1("__intrinsic_atomic_add",
2801 shader_atomic_counter_ops
),
2803 add_function("atomicCounterSubtractARB",
2804 _atomic_counter_op1("__intrinsic_atomic_sub",
2805 shader_atomic_counter_ops
),
2807 add_function("atomicCounterMinARB",
2808 _atomic_counter_op1("__intrinsic_atomic_min",
2809 shader_atomic_counter_ops
),
2811 add_function("atomicCounterMaxARB",
2812 _atomic_counter_op1("__intrinsic_atomic_max",
2813 shader_atomic_counter_ops
),
2815 add_function("atomicCounterAndARB",
2816 _atomic_counter_op1("__intrinsic_atomic_and",
2817 shader_atomic_counter_ops
),
2819 add_function("atomicCounterOrARB",
2820 _atomic_counter_op1("__intrinsic_atomic_or",
2821 shader_atomic_counter_ops
),
2823 add_function("atomicCounterXorARB",
2824 _atomic_counter_op1("__intrinsic_atomic_xor",
2825 shader_atomic_counter_ops
),
2827 add_function("atomicCounterExchangeARB",
2828 _atomic_counter_op1("__intrinsic_atomic_exchange",
2829 shader_atomic_counter_ops
),
2831 add_function("atomicCounterCompSwapARB",
2832 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
2833 shader_atomic_counter_ops
),
2836 add_function("atomicAdd",
2837 _atomic_op2("__intrinsic_atomic_add",
2838 buffer_atomics_supported
,
2839 glsl_type::uint_type
),
2840 _atomic_op2("__intrinsic_atomic_add",
2841 buffer_atomics_supported
,
2842 glsl_type::int_type
),
2844 add_function("atomicMin",
2845 _atomic_op2("__intrinsic_atomic_min",
2846 buffer_atomics_supported
,
2847 glsl_type::uint_type
),
2848 _atomic_op2("__intrinsic_atomic_min",
2849 buffer_atomics_supported
,
2850 glsl_type::int_type
),
2852 add_function("atomicMax",
2853 _atomic_op2("__intrinsic_atomic_max",
2854 buffer_atomics_supported
,
2855 glsl_type::uint_type
),
2856 _atomic_op2("__intrinsic_atomic_max",
2857 buffer_atomics_supported
,
2858 glsl_type::int_type
),
2860 add_function("atomicAnd",
2861 _atomic_op2("__intrinsic_atomic_and",
2862 buffer_atomics_supported
,
2863 glsl_type::uint_type
),
2864 _atomic_op2("__intrinsic_atomic_and",
2865 buffer_atomics_supported
,
2866 glsl_type::int_type
),
2868 add_function("atomicOr",
2869 _atomic_op2("__intrinsic_atomic_or",
2870 buffer_atomics_supported
,
2871 glsl_type::uint_type
),
2872 _atomic_op2("__intrinsic_atomic_or",
2873 buffer_atomics_supported
,
2874 glsl_type::int_type
),
2876 add_function("atomicXor",
2877 _atomic_op2("__intrinsic_atomic_xor",
2878 buffer_atomics_supported
,
2879 glsl_type::uint_type
),
2880 _atomic_op2("__intrinsic_atomic_xor",
2881 buffer_atomics_supported
,
2882 glsl_type::int_type
),
2884 add_function("atomicExchange",
2885 _atomic_op2("__intrinsic_atomic_exchange",
2886 buffer_atomics_supported
,
2887 glsl_type::uint_type
),
2888 _atomic_op2("__intrinsic_atomic_exchange",
2889 buffer_atomics_supported
,
2890 glsl_type::int_type
),
2892 add_function("atomicCompSwap",
2893 _atomic_op3("__intrinsic_atomic_comp_swap",
2894 buffer_atomics_supported
,
2895 glsl_type::uint_type
),
2896 _atomic_op3("__intrinsic_atomic_comp_swap",
2897 buffer_atomics_supported
,
2898 glsl_type::int_type
),
2901 add_function("min3",
2902 _min3(glsl_type::float_type
),
2903 _min3(glsl_type::vec2_type
),
2904 _min3(glsl_type::vec3_type
),
2905 _min3(glsl_type::vec4_type
),
2907 _min3(glsl_type::int_type
),
2908 _min3(glsl_type::ivec2_type
),
2909 _min3(glsl_type::ivec3_type
),
2910 _min3(glsl_type::ivec4_type
),
2912 _min3(glsl_type::uint_type
),
2913 _min3(glsl_type::uvec2_type
),
2914 _min3(glsl_type::uvec3_type
),
2915 _min3(glsl_type::uvec4_type
),
2918 add_function("max3",
2919 _max3(glsl_type::float_type
),
2920 _max3(glsl_type::vec2_type
),
2921 _max3(glsl_type::vec3_type
),
2922 _max3(glsl_type::vec4_type
),
2924 _max3(glsl_type::int_type
),
2925 _max3(glsl_type::ivec2_type
),
2926 _max3(glsl_type::ivec3_type
),
2927 _max3(glsl_type::ivec4_type
),
2929 _max3(glsl_type::uint_type
),
2930 _max3(glsl_type::uvec2_type
),
2931 _max3(glsl_type::uvec3_type
),
2932 _max3(glsl_type::uvec4_type
),
2935 add_function("mid3",
2936 _mid3(glsl_type::float_type
),
2937 _mid3(glsl_type::vec2_type
),
2938 _mid3(glsl_type::vec3_type
),
2939 _mid3(glsl_type::vec4_type
),
2941 _mid3(glsl_type::int_type
),
2942 _mid3(glsl_type::ivec2_type
),
2943 _mid3(glsl_type::ivec3_type
),
2944 _mid3(glsl_type::ivec4_type
),
2946 _mid3(glsl_type::uint_type
),
2947 _mid3(glsl_type::uvec2_type
),
2948 _mid3(glsl_type::uvec3_type
),
2949 _mid3(glsl_type::uvec4_type
),
2952 add_image_functions(true);
2954 add_function("memoryBarrier",
2955 _memory_barrier("__intrinsic_memory_barrier",
2956 shader_image_load_store
),
2958 add_function("groupMemoryBarrier",
2959 _memory_barrier("__intrinsic_group_memory_barrier",
2962 add_function("memoryBarrierAtomicCounter",
2963 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2966 add_function("memoryBarrierBuffer",
2967 _memory_barrier("__intrinsic_memory_barrier_buffer",
2970 add_function("memoryBarrierImage",
2971 _memory_barrier("__intrinsic_memory_barrier_image",
2974 add_function("memoryBarrierShared",
2975 _memory_barrier("__intrinsic_memory_barrier_shared",
2979 add_function("clock2x32ARB",
2980 _shader_clock(shader_clock
,
2981 glsl_type::uvec2_type
),
2984 add_function("anyInvocationARB", _vote(ir_unop_vote_any
), NULL
);
2985 add_function("allInvocationsARB", _vote(ir_unop_vote_all
), NULL
);
2986 add_function("allInvocationsEqualARB", _vote(ir_unop_vote_eq
), NULL
);
2996 builtin_builder::add_function(const char *name
, ...)
3000 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3004 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
3010 stuff
.push_tail(sig
);
3011 validate_ir_tree(&stuff
);
3014 f
->add_signature(sig
);
3018 shader
->symbols
->add_function(f
);
3022 builtin_builder::add_image_function(const char *name
,
3023 const char *intrinsic_name
,
3024 image_prototype_ctr prototype
,
3025 unsigned num_arguments
,
3027 enum ir_intrinsic_id intrinsic_id
)
3029 static const glsl_type
*const types
[] = {
3030 glsl_type::image1D_type
,
3031 glsl_type::image2D_type
,
3032 glsl_type::image3D_type
,
3033 glsl_type::image2DRect_type
,
3034 glsl_type::imageCube_type
,
3035 glsl_type::imageBuffer_type
,
3036 glsl_type::image1DArray_type
,
3037 glsl_type::image2DArray_type
,
3038 glsl_type::imageCubeArray_type
,
3039 glsl_type::image2DMS_type
,
3040 glsl_type::image2DMSArray_type
,
3041 glsl_type::iimage1D_type
,
3042 glsl_type::iimage2D_type
,
3043 glsl_type::iimage3D_type
,
3044 glsl_type::iimage2DRect_type
,
3045 glsl_type::iimageCube_type
,
3046 glsl_type::iimageBuffer_type
,
3047 glsl_type::iimage1DArray_type
,
3048 glsl_type::iimage2DArray_type
,
3049 glsl_type::iimageCubeArray_type
,
3050 glsl_type::iimage2DMS_type
,
3051 glsl_type::iimage2DMSArray_type
,
3052 glsl_type::uimage1D_type
,
3053 glsl_type::uimage2D_type
,
3054 glsl_type::uimage3D_type
,
3055 glsl_type::uimage2DRect_type
,
3056 glsl_type::uimageCube_type
,
3057 glsl_type::uimageBuffer_type
,
3058 glsl_type::uimage1DArray_type
,
3059 glsl_type::uimage2DArray_type
,
3060 glsl_type::uimageCubeArray_type
,
3061 glsl_type::uimage2DMS_type
,
3062 glsl_type::uimage2DMSArray_type
3065 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3067 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3068 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3069 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3070 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3071 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3072 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3073 num_arguments
, flags
, intrinsic_id
));
3076 shader
->symbols
->add_function(f
);
3080 builtin_builder::add_image_functions(bool glsl
)
3082 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3084 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3085 "__intrinsic_image_load",
3086 &builtin_builder::_image_prototype
, 0,
3087 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3088 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3089 IMAGE_FUNCTION_READ_ONLY
),
3090 ir_intrinsic_image_load
);
3092 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3093 "__intrinsic_image_store",
3094 &builtin_builder::_image_prototype
, 1,
3095 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3096 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3097 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3098 IMAGE_FUNCTION_WRITE_ONLY
),
3099 ir_intrinsic_image_store
);
3101 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3103 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3104 "__intrinsic_image_atomic_add",
3105 &builtin_builder::_image_prototype
, 1, atom_flags
,
3106 ir_intrinsic_image_atomic_add
);
3108 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3109 "__intrinsic_image_atomic_min",
3110 &builtin_builder::_image_prototype
, 1, atom_flags
,
3111 ir_intrinsic_image_atomic_min
);
3113 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3114 "__intrinsic_image_atomic_max",
3115 &builtin_builder::_image_prototype
, 1, atom_flags
,
3116 ir_intrinsic_image_atomic_max
);
3118 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3119 "__intrinsic_image_atomic_and",
3120 &builtin_builder::_image_prototype
, 1, atom_flags
,
3121 ir_intrinsic_image_atomic_and
);
3123 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3124 "__intrinsic_image_atomic_or",
3125 &builtin_builder::_image_prototype
, 1, atom_flags
,
3126 ir_intrinsic_image_atomic_or
);
3128 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3129 "__intrinsic_image_atomic_xor",
3130 &builtin_builder::_image_prototype
, 1, atom_flags
,
3131 ir_intrinsic_image_atomic_xor
);
3133 add_image_function((glsl
? "imageAtomicExchange" :
3134 "__intrinsic_image_atomic_exchange"),
3135 "__intrinsic_image_atomic_exchange",
3136 &builtin_builder::_image_prototype
, 1,
3137 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3138 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
),
3139 ir_intrinsic_image_atomic_exchange
);
3141 add_image_function((glsl
? "imageAtomicCompSwap" :
3142 "__intrinsic_image_atomic_comp_swap"),
3143 "__intrinsic_image_atomic_comp_swap",
3144 &builtin_builder::_image_prototype
, 2, atom_flags
,
3145 ir_intrinsic_image_atomic_comp_swap
);
3147 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3148 "__intrinsic_image_size",
3149 &builtin_builder::_image_size_prototype
, 1,
3150 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
,
3151 ir_intrinsic_image_size
);
3153 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3154 "__intrinsic_image_samples",
3155 &builtin_builder::_image_samples_prototype
, 1,
3156 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3157 IMAGE_FUNCTION_MS_ONLY
,
3158 ir_intrinsic_image_samples
);
3162 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3164 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3168 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3170 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3174 builtin_builder::imm(bool b
, unsigned vector_elements
)
3176 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3180 builtin_builder::imm(float f
, unsigned vector_elements
)
3182 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3186 builtin_builder::imm(int i
, unsigned vector_elements
)
3188 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3192 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3194 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3198 builtin_builder::imm(double d
, unsigned vector_elements
)
3200 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3204 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3206 return new(mem_ctx
) ir_constant(type
, &data
);
3209 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3211 ir_dereference_variable
*
3212 builtin_builder::var_ref(ir_variable
*var
)
3214 return new(mem_ctx
) ir_dereference_variable(var
);
3217 ir_dereference_array
*
3218 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3220 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3223 /** Return an element of a matrix */
3225 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3227 return swizzle(array_ref(var
, column
), row
, 1);
3231 * Implementations of built-in functions:
3234 ir_function_signature
*
3235 builtin_builder::new_sig(const glsl_type
*return_type
,
3236 builtin_available_predicate avail
,
3242 ir_function_signature
*sig
=
3243 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3246 va_start(ap
, num_params
);
3247 for (int i
= 0; i
< num_params
; i
++) {
3248 plist
.push_tail(va_arg(ap
, ir_variable
*));
3252 sig
->replace_parameters(&plist
);
3256 #define MAKE_SIG(return_type, avail, ...) \
3257 ir_function_signature *sig = \
3258 new_sig(return_type, avail, __VA_ARGS__); \
3259 ir_factory body(&sig->body, mem_ctx); \
3260 sig->is_defined = true;
3262 #define MAKE_INTRINSIC(return_type, id, avail, ...) \
3263 ir_function_signature *sig = \
3264 new_sig(return_type, avail, __VA_ARGS__); \
3265 sig->intrinsic_id = id;
3267 ir_function_signature
*
3268 builtin_builder::unop(builtin_available_predicate avail
,
3269 ir_expression_operation opcode
,
3270 const glsl_type
*return_type
,
3271 const glsl_type
*param_type
)
3273 ir_variable
*x
= in_var(param_type
, "x");
3274 MAKE_SIG(return_type
, avail
, 1, x
);
3275 body
.emit(ret(expr(opcode
, x
)));
3279 #define UNOP(NAME, OPCODE, AVAIL) \
3280 ir_function_signature * \
3281 builtin_builder::_##NAME(const glsl_type *type) \
3283 return unop(&AVAIL, OPCODE, type, type); \
3286 #define UNOPA(NAME, OPCODE) \
3287 ir_function_signature * \
3288 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3290 return unop(avail, OPCODE, type, type); \
3293 ir_function_signature
*
3294 builtin_builder::binop(builtin_available_predicate avail
,
3295 ir_expression_operation opcode
,
3296 const glsl_type
*return_type
,
3297 const glsl_type
*param0_type
,
3298 const glsl_type
*param1_type
)
3300 ir_variable
*x
= in_var(param0_type
, "x");
3301 ir_variable
*y
= in_var(param1_type
, "y");
3302 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3303 body
.emit(ret(expr(opcode
, x
, y
)));
3307 #define BINOP(NAME, OPCODE, AVAIL) \
3308 ir_function_signature * \
3309 builtin_builder::_##NAME(const glsl_type *return_type, \
3310 const glsl_type *param0_type, \
3311 const glsl_type *param1_type) \
3313 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3317 * Angle and Trigonometry Functions @{
3320 ir_function_signature
*
3321 builtin_builder::_radians(const glsl_type
*type
)
3323 ir_variable
*degrees
= in_var(type
, "degrees");
3324 MAKE_SIG(type
, always_available
, 1, degrees
);
3325 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3329 ir_function_signature
*
3330 builtin_builder::_degrees(const glsl_type
*type
)
3332 ir_variable
*radians
= in_var(type
, "radians");
3333 MAKE_SIG(type
, always_available
, 1, radians
);
3334 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3338 UNOP(sin
, ir_unop_sin
, always_available
)
3339 UNOP(cos
, ir_unop_cos
, always_available
)
3341 ir_function_signature
*
3342 builtin_builder::_tan(const glsl_type
*type
)
3344 ir_variable
*theta
= in_var(type
, "theta");
3345 MAKE_SIG(type
, always_available
, 1, theta
);
3346 body
.emit(ret(div(sin(theta
), cos(theta
))));
3351 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3355 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3358 add(imm(M_PI_4f
- 1.0f
),
3361 mul(abs(x
), imm(p1
))))))))));
3365 * Generate a ir_call to a function with a set of parameters
3367 * The input \c params can either be a list of \c ir_variable or a list of
3368 * \c ir_dereference_variable. In the latter case, all nodes will be removed
3369 * from \c params and used directly as the parameters to the generated
3373 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3375 exec_list actual_params
;
3377 foreach_in_list_safe(ir_instruction
, ir
, ¶ms
) {
3378 ir_dereference_variable
*d
= ir
->as_dereference_variable();
3381 actual_params
.push_tail(d
);
3383 ir_variable
*var
= ir
->as_variable();
3384 assert(var
!= NULL
);
3385 actual_params
.push_tail(var_ref(var
));
3389 ir_function_signature
*sig
=
3390 f
->exact_matching_signature(NULL
, &actual_params
);
3394 ir_dereference_variable
*deref
=
3395 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3397 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3400 ir_function_signature
*
3401 builtin_builder::_asin(const glsl_type
*type
)
3403 ir_variable
*x
= in_var(type
, "x");
3404 MAKE_SIG(type
, always_available
, 1, x
);
3406 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3411 ir_function_signature
*
3412 builtin_builder::_acos(const glsl_type
*type
)
3414 ir_variable
*x
= in_var(type
, "x");
3415 MAKE_SIG(type
, always_available
, 1, x
);
3417 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3422 ir_function_signature
*
3423 builtin_builder::_atan2(const glsl_type
*type
)
3425 ir_variable
*vec_y
= in_var(type
, "vec_y");
3426 ir_variable
*vec_x
= in_var(type
, "vec_x");
3427 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3429 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3430 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3431 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3432 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3433 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3434 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3435 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3437 /* If |x| >= 1.0e-8 * |y|: */
3439 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3441 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3443 /* Then...call atan(y/x) */
3444 do_atan(outer_then
, glsl_type::float_type
, r
, div(y
, x
));
3446 /* ...and fix it up: */
3447 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3448 inner_if
->then_instructions
.push_tail(
3449 if_tree(gequal(y
, imm(0.0f
)),
3450 assign(r
, add(r
, imm(M_PIf
))),
3451 assign(r
, sub(r
, imm(M_PIf
)))));
3452 outer_then
.emit(inner_if
);
3455 outer_if
->else_instructions
.push_tail(
3456 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3458 body
.emit(outer_if
);
3460 body
.emit(assign(vec_result
, r
, 1 << i
));
3462 body
.emit(ret(vec_result
));
3468 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3471 * range-reduction, first step:
3473 * / y_over_x if |y_over_x| <= 1.0;
3475 * \ 1.0 / y_over_x otherwise
3477 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3478 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3484 * approximate atan by evaluating polynomial:
3486 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3487 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3488 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3490 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3491 body
.emit(assign(tmp
, mul(x
, x
)));
3492 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3494 imm(0.0536813784310406f
)),
3496 imm(0.1173503194786851f
)),
3498 imm(0.1938924977115610f
)),
3500 imm(0.3326756418091246f
)),
3502 imm(0.9999793128310355f
)),
3505 /* range-reduction fixup */
3506 body
.emit(assign(tmp
, add(tmp
,
3507 mul(b2f(greater(abs(y_over_x
),
3508 imm(1.0f
, type
->components()))),
3514 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3517 ir_function_signature
*
3518 builtin_builder::_atan(const glsl_type
*type
)
3520 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3521 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3523 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3524 do_atan(body
, type
, tmp
, y_over_x
);
3525 body
.emit(ret(tmp
));
3530 ir_function_signature
*
3531 builtin_builder::_sinh(const glsl_type
*type
)
3533 ir_variable
*x
= in_var(type
, "x");
3534 MAKE_SIG(type
, v130
, 1, x
);
3536 /* 0.5 * (e^x - e^(-x)) */
3537 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3542 ir_function_signature
*
3543 builtin_builder::_cosh(const glsl_type
*type
)
3545 ir_variable
*x
= in_var(type
, "x");
3546 MAKE_SIG(type
, v130
, 1, x
);
3548 /* 0.5 * (e^x + e^(-x)) */
3549 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3554 ir_function_signature
*
3555 builtin_builder::_tanh(const glsl_type
*type
)
3557 ir_variable
*x
= in_var(type
, "x");
3558 MAKE_SIG(type
, v130
, 1, x
);
3560 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3561 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3562 add(exp(x
), exp(neg(x
))))));
3567 ir_function_signature
*
3568 builtin_builder::_asinh(const glsl_type
*type
)
3570 ir_variable
*x
= in_var(type
, "x");
3571 MAKE_SIG(type
, v130
, 1, x
);
3573 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3578 ir_function_signature
*
3579 builtin_builder::_acosh(const glsl_type
*type
)
3581 ir_variable
*x
= in_var(type
, "x");
3582 MAKE_SIG(type
, v130
, 1, x
);
3584 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3588 ir_function_signature
*
3589 builtin_builder::_atanh(const glsl_type
*type
)
3591 ir_variable
*x
= in_var(type
, "x");
3592 MAKE_SIG(type
, v130
, 1, x
);
3594 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3595 sub(imm(1.0f
), x
))))));
3601 * Exponential Functions @{
3604 ir_function_signature
*
3605 builtin_builder::_pow(const glsl_type
*type
)
3607 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3610 UNOP(exp
, ir_unop_exp
, always_available
)
3611 UNOP(log
, ir_unop_log
, always_available
)
3612 UNOP(exp2
, ir_unop_exp2
, always_available
)
3613 UNOP(log2
, ir_unop_log2
, always_available
)
3614 UNOPA(sqrt
, ir_unop_sqrt
)
3615 UNOPA(inversesqrt
, ir_unop_rsq
)
3619 UNOPA(abs
, ir_unop_abs
)
3620 UNOPA(sign
, ir_unop_sign
)
3621 UNOPA(floor
, ir_unop_floor
)
3622 UNOPA(trunc
, ir_unop_trunc
)
3623 UNOPA(round
, ir_unop_round_even
)
3624 UNOPA(roundEven
, ir_unop_round_even
)
3625 UNOPA(ceil
, ir_unop_ceil
)
3626 UNOPA(fract
, ir_unop_fract
)
3628 ir_function_signature
*
3629 builtin_builder::_mod(builtin_available_predicate avail
,
3630 const glsl_type
*x_type
, const glsl_type
*y_type
)
3632 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3635 ir_function_signature
*
3636 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3638 ir_variable
*x
= in_var(type
, "x");
3639 ir_variable
*i
= out_var(type
, "i");
3640 MAKE_SIG(type
, avail
, 2, x
, i
);
3642 ir_variable
*t
= body
.make_temp(type
, "t");
3643 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3644 body
.emit(assign(i
, t
));
3645 body
.emit(ret(sub(x
, t
)));
3650 ir_function_signature
*
3651 builtin_builder::_min(builtin_available_predicate avail
,
3652 const glsl_type
*x_type
, const glsl_type
*y_type
)
3654 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3657 ir_function_signature
*
3658 builtin_builder::_max(builtin_available_predicate avail
,
3659 const glsl_type
*x_type
, const glsl_type
*y_type
)
3661 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3664 ir_function_signature
*
3665 builtin_builder::_clamp(builtin_available_predicate avail
,
3666 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3668 ir_variable
*x
= in_var(val_type
, "x");
3669 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3670 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3671 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3673 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3678 ir_function_signature
*
3679 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3681 ir_variable
*x
= in_var(val_type
, "x");
3682 ir_variable
*y
= in_var(val_type
, "y");
3683 ir_variable
*a
= in_var(blend_type
, "a");
3684 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3686 body
.emit(ret(lrp(x
, y
, a
)));
3691 ir_function_signature
*
3692 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3693 const glsl_type
*val_type
,
3694 const glsl_type
*blend_type
)
3696 ir_variable
*x
= in_var(val_type
, "x");
3697 ir_variable
*y
= in_var(val_type
, "y");
3698 ir_variable
*a
= in_var(blend_type
, "a");
3699 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3701 /* csel matches the ternary operator in that a selector of true choses the
3702 * first argument. This differs from mix(x, y, false) which choses the
3703 * second argument (to remain consistent with the interpolating version of
3704 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3706 * To handle the behavior mismatch, reverse the x and y arguments.
3708 body
.emit(ret(csel(a
, y
, x
)));
3713 ir_function_signature
*
3714 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3716 ir_variable
*edge
= in_var(edge_type
, "edge");
3717 ir_variable
*x
= in_var(x_type
, "x");
3718 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3720 ir_variable
*t
= body
.make_temp(x_type
, "t");
3721 if (x_type
->vector_elements
== 1) {
3722 /* Both are floats */
3723 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3724 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3726 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3727 } else if (edge_type
->vector_elements
== 1) {
3728 /* x is a vector but edge is a float */
3729 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3730 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3731 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3733 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3736 /* Both are vectors */
3737 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3738 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3739 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3742 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3752 ir_function_signature
*
3753 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3755 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3756 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3757 ir_variable
*x
= in_var(x_type
, "x");
3758 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3760 /* From the GLSL 1.10 specification:
3763 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3764 * return t * t * (3 - 2 * t);
3767 ir_variable
*t
= body
.make_temp(x_type
, "t");
3768 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3769 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3771 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3776 ir_function_signature
*
3777 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3779 ir_variable
*x
= in_var(type
, "x");
3780 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3782 body
.emit(ret(nequal(x
, x
)));
3787 ir_function_signature
*
3788 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3790 ir_variable
*x
= in_var(type
, "x");
3791 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3793 ir_constant_data infinities
;
3794 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3795 switch (type
->base_type
) {
3796 case GLSL_TYPE_FLOAT
:
3797 infinities
.f
[i
] = INFINITY
;
3799 case GLSL_TYPE_DOUBLE
:
3800 infinities
.d
[i
] = INFINITY
;
3803 unreachable("unknown type");
3807 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3812 ir_function_signature
*
3813 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3815 ir_variable
*x
= in_var(type
, "x");
3816 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3817 body
.emit(ret(bitcast_f2i(x
)));
3821 ir_function_signature
*
3822 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3824 ir_variable
*x
= in_var(type
, "x");
3825 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3826 body
.emit(ret(bitcast_f2u(x
)));
3830 ir_function_signature
*
3831 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3833 ir_variable
*x
= in_var(type
, "x");
3834 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3835 body
.emit(ret(bitcast_i2f(x
)));
3839 ir_function_signature
*
3840 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3842 ir_variable
*x
= in_var(type
, "x");
3843 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3844 body
.emit(ret(bitcast_u2f(x
)));
3848 ir_function_signature
*
3849 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3851 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3852 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3853 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3857 ir_function_signature
*
3858 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3860 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3861 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3862 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3866 ir_function_signature
*
3867 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3869 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3870 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3871 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3875 ir_function_signature
*
3876 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3878 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3879 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3880 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3884 ir_function_signature
*
3885 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3887 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3888 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3889 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3893 ir_function_signature
*
3894 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3896 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3897 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3898 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3903 ir_function_signature
*
3904 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3906 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3907 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3908 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3912 ir_function_signature
*
3913 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3915 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3916 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3917 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3921 ir_function_signature
*
3922 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3924 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3925 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3926 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3930 ir_function_signature
*
3931 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3933 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3934 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3935 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3939 ir_function_signature
*
3940 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3942 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3943 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3944 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3948 ir_function_signature
*
3949 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3951 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3952 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3953 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3957 ir_function_signature
*
3958 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3960 ir_variable
*x
= in_var(type
, "x");
3961 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3963 body
.emit(ret(sqrt(dot(x
, x
))));
3968 ir_function_signature
*
3969 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3971 ir_variable
*p0
= in_var(type
, "p0");
3972 ir_variable
*p1
= in_var(type
, "p1");
3973 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3975 if (type
->vector_elements
== 1) {
3976 body
.emit(ret(abs(sub(p0
, p1
))));
3978 ir_variable
*p
= body
.make_temp(type
, "p");
3979 body
.emit(assign(p
, sub(p0
, p1
)));
3980 body
.emit(ret(sqrt(dot(p
, p
))));
3986 ir_function_signature
*
3987 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3989 if (type
->vector_elements
== 1)
3990 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3992 return binop(avail
, ir_binop_dot
,
3993 type
->get_base_type(), type
, type
);
3996 ir_function_signature
*
3997 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3999 ir_variable
*a
= in_var(type
, "a");
4000 ir_variable
*b
= in_var(type
, "b");
4001 MAKE_SIG(type
, avail
, 2, a
, b
);
4003 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
4004 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
4006 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
4007 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
4012 ir_function_signature
*
4013 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
4015 ir_variable
*x
= in_var(type
, "x");
4016 MAKE_SIG(type
, avail
, 1, x
);
4018 if (type
->vector_elements
== 1) {
4019 body
.emit(ret(sign(x
)));
4021 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
4027 ir_function_signature
*
4028 builtin_builder::_ftransform()
4030 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
4032 /* ftransform() refers to global variables, and is always emitted
4033 * directly by ast_function.cpp. Just emit a prototype here so we
4034 * can recognize calls to it.
4039 ir_function_signature
*
4040 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
4042 ir_variable
*N
= in_var(type
, "N");
4043 ir_variable
*I
= in_var(type
, "I");
4044 ir_variable
*Nref
= in_var(type
, "Nref");
4045 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
4047 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
4048 ret(N
), ret(neg(N
))));
4053 ir_function_signature
*
4054 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
4056 ir_variable
*I
= in_var(type
, "I");
4057 ir_variable
*N
= in_var(type
, "N");
4058 MAKE_SIG(type
, avail
, 2, I
, N
);
4060 /* I - 2 * dot(N, I) * N */
4061 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
4066 ir_function_signature
*
4067 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
4069 ir_variable
*I
= in_var(type
, "I");
4070 ir_variable
*N
= in_var(type
, "N");
4071 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
4072 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4074 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4075 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4077 /* From the GLSL 1.10 specification:
4078 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4080 * return genType(0.0)
4082 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4084 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4085 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4086 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4087 mul(n_dot_i
, n_dot_i
)))))));
4088 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4089 ret(ir_constant::zero(mem_ctx
, type
)),
4090 ret(sub(mul(eta
, I
),
4091 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4096 ir_function_signature
*
4097 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4099 ir_variable
*x
= in_var(type
, "x");
4100 ir_variable
*y
= in_var(type
, "y");
4101 MAKE_SIG(type
, avail
, 2, x
, y
);
4103 ir_variable
*z
= body
.make_temp(type
, "z");
4104 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4105 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4112 ir_function_signature
*
4113 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4118 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
4119 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4120 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4122 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4123 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4125 MAKE_SIG(type
, avail
, 2, c
, r
);
4127 ir_variable
*m
= body
.make_temp(type
, "m");
4128 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4129 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4136 ir_function_signature
*
4137 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4139 const glsl_type
*transpose_type
=
4140 glsl_type::get_instance(orig_type
->base_type
,
4141 orig_type
->matrix_columns
,
4142 orig_type
->vector_elements
);
4144 ir_variable
*m
= in_var(orig_type
, "m");
4145 MAKE_SIG(transpose_type
, avail
, 1, m
);
4147 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4148 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4149 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4150 body
.emit(assign(array_ref(t
, j
),
4151 matrix_elt(m
, i
, j
),
4160 ir_function_signature
*
4161 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4163 ir_variable
*m
= in_var(type
, "m");
4164 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4166 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4167 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4172 ir_function_signature
*
4173 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4175 ir_variable
*m
= in_var(type
, "m");
4176 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4179 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4180 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4183 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4184 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4187 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4188 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4190 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4191 mul(matrix_elt(m
, 0, 1), f2
)),
4192 mul(matrix_elt(m
, 0, 2), f3
))));
4197 ir_function_signature
*
4198 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4200 ir_variable
*m
= in_var(type
, "m");
4201 const glsl_type
*btype
= type
->get_base_type();
4202 MAKE_SIG(btype
, avail
, 1, m
);
4204 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4205 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4206 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4207 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4208 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4209 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4210 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4211 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4212 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4213 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4214 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4215 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4216 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4217 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4218 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4219 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4220 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4221 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4222 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4224 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)))));
4225 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)))));
4226 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)))));
4227 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)))));
4228 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)))));
4229 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)))));
4230 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)))));
4231 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)))));
4232 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)))));
4233 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)))));
4234 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)))));
4235 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)))));
4236 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)))));
4237 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)))));
4238 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)))));
4239 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)))));
4240 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)))));
4241 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)))));
4242 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)))));
4244 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4246 body
.emit(assign(adj_0
,
4247 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4248 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4249 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4251 body
.emit(assign(adj_0
, neg(
4252 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4253 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4254 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4256 body
.emit(assign(adj_0
,
4257 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4258 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4259 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4261 body
.emit(assign(adj_0
, neg(
4262 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4263 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4264 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4267 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4272 ir_function_signature
*
4273 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4275 ir_variable
*m
= in_var(type
, "m");
4276 MAKE_SIG(type
, avail
, 1, m
);
4278 ir_variable
*adj
= body
.make_temp(type
, "adj");
4279 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4280 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4281 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4282 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4284 ir_expression
*det
=
4285 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4286 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4288 body
.emit(ret(div(adj
, det
)));
4292 ir_function_signature
*
4293 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4295 ir_variable
*m
= in_var(type
, "m");
4296 const glsl_type
*btype
= type
->get_base_type();
4297 MAKE_SIG(type
, avail
, 1, m
);
4299 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4300 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4301 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4303 body
.emit(assign(f11_22_21_12
,
4304 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4305 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4306 body
.emit(assign(f10_22_20_12
,
4307 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4308 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4309 body
.emit(assign(f10_21_20_11
,
4310 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4311 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4313 ir_variable
*adj
= body
.make_temp(type
, "adj");
4314 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4315 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4316 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4318 body
.emit(assign(array_ref(adj
, 0), neg(
4319 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4320 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4322 body
.emit(assign(array_ref(adj
, 1),
4323 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4324 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4326 body
.emit(assign(array_ref(adj
, 2), neg(
4327 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4328 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4331 body
.emit(assign(array_ref(adj
, 0),
4332 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4333 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4335 body
.emit(assign(array_ref(adj
, 1), neg(
4336 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4337 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4339 body
.emit(assign(array_ref(adj
, 2),
4340 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4341 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4344 ir_expression
*det
=
4345 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4346 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4347 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4349 body
.emit(ret(div(adj
, det
)));
4354 ir_function_signature
*
4355 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4357 ir_variable
*m
= in_var(type
, "m");
4358 const glsl_type
*btype
= type
->get_base_type();
4359 MAKE_SIG(type
, avail
, 1, m
);
4361 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4362 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4363 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4364 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4365 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4366 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4367 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4368 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4369 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4370 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4371 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4372 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4373 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4374 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4375 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4376 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4377 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4378 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4379 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4381 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)))));
4382 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)))));
4383 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)))));
4384 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)))));
4385 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)))));
4386 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)))));
4387 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)))));
4388 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)))));
4389 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)))));
4390 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)))));
4391 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)))));
4392 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)))));
4393 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)))));
4394 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)))));
4395 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)))));
4396 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)))));
4397 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)))));
4398 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)))));
4399 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)))));
4401 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4402 body
.emit(assign(array_ref(adj
, 0),
4403 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4404 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4405 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4407 body
.emit(assign(array_ref(adj
, 1), neg(
4408 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4409 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4410 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4412 body
.emit(assign(array_ref(adj
, 2),
4413 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4414 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4415 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4417 body
.emit(assign(array_ref(adj
, 3), neg(
4418 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4419 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4420 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4423 body
.emit(assign(array_ref(adj
, 0), neg(
4424 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4425 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4426 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4428 body
.emit(assign(array_ref(adj
, 1),
4429 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4430 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4431 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4433 body
.emit(assign(array_ref(adj
, 2), neg(
4434 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4435 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4436 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4438 body
.emit(assign(array_ref(adj
, 3),
4439 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4440 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4441 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4444 body
.emit(assign(array_ref(adj
, 0),
4445 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4446 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4447 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4449 body
.emit(assign(array_ref(adj
, 1), neg(
4450 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4451 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4452 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4454 body
.emit(assign(array_ref(adj
, 2),
4455 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4456 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4457 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4459 body
.emit(assign(array_ref(adj
, 3), neg(
4460 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4461 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4462 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4465 body
.emit(assign(array_ref(adj
, 0), neg(
4466 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4467 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4468 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4470 body
.emit(assign(array_ref(adj
, 1),
4471 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4472 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4473 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4475 body
.emit(assign(array_ref(adj
, 2), neg(
4476 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4477 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4478 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4480 body
.emit(assign(array_ref(adj
, 3),
4481 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4482 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4483 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4486 ir_expression
*det
=
4487 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4488 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4489 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4490 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4492 body
.emit(ret(div(adj
, det
)));
4498 ir_function_signature
*
4499 builtin_builder::_lessThan(builtin_available_predicate avail
,
4500 const glsl_type
*type
)
4502 return binop(avail
, ir_binop_less
,
4503 glsl_type::bvec(type
->vector_elements
), type
, type
);
4506 ir_function_signature
*
4507 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4508 const glsl_type
*type
)
4510 return binop(avail
, ir_binop_lequal
,
4511 glsl_type::bvec(type
->vector_elements
), type
, type
);
4514 ir_function_signature
*
4515 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4516 const glsl_type
*type
)
4518 return binop(avail
, ir_binop_greater
,
4519 glsl_type::bvec(type
->vector_elements
), type
, type
);
4522 ir_function_signature
*
4523 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4524 const glsl_type
*type
)
4526 return binop(avail
, ir_binop_gequal
,
4527 glsl_type::bvec(type
->vector_elements
), type
, type
);
4530 ir_function_signature
*
4531 builtin_builder::_equal(builtin_available_predicate avail
,
4532 const glsl_type
*type
)
4534 return binop(avail
, ir_binop_equal
,
4535 glsl_type::bvec(type
->vector_elements
), type
, type
);
4538 ir_function_signature
*
4539 builtin_builder::_notEqual(builtin_available_predicate avail
,
4540 const glsl_type
*type
)
4542 return binop(avail
, ir_binop_nequal
,
4543 glsl_type::bvec(type
->vector_elements
), type
, type
);
4546 ir_function_signature
*
4547 builtin_builder::_any(const glsl_type
*type
)
4549 ir_variable
*v
= in_var(type
, "v");
4550 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4552 const unsigned vec_elem
= v
->type
->vector_elements
;
4553 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4558 ir_function_signature
*
4559 builtin_builder::_all(const glsl_type
*type
)
4561 ir_variable
*v
= in_var(type
, "v");
4562 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4564 const unsigned vec_elem
= v
->type
->vector_elements
;
4565 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4570 UNOP(not, ir_unop_logic_not
, always_available
)
4573 has_lod(const glsl_type
*sampler_type
)
4575 assert(sampler_type
->is_sampler());
4577 switch (sampler_type
->sampler_dimensionality
) {
4578 case GLSL_SAMPLER_DIM_RECT
:
4579 case GLSL_SAMPLER_DIM_BUF
:
4580 case GLSL_SAMPLER_DIM_MS
:
4587 ir_function_signature
*
4588 builtin_builder::_textureSize(builtin_available_predicate avail
,
4589 const glsl_type
*return_type
,
4590 const glsl_type
*sampler_type
)
4592 ir_variable
*s
= in_var(sampler_type
, "sampler");
4593 /* The sampler always exists; add optional lod later. */
4594 MAKE_SIG(return_type
, avail
, 1, s
);
4596 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4597 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4599 if (has_lod(sampler_type
)) {
4600 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4601 sig
->parameters
.push_tail(lod
);
4602 tex
->lod_info
.lod
= var_ref(lod
);
4604 tex
->lod_info
.lod
= imm(0u);
4607 body
.emit(ret(tex
));
4612 ir_function_signature
*
4613 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4615 ir_variable
*s
= in_var(sampler_type
, "sampler");
4616 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4618 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4619 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4620 body
.emit(ret(tex
));
4625 ir_function_signature
*
4626 builtin_builder::_texture(ir_texture_opcode opcode
,
4627 builtin_available_predicate avail
,
4628 const glsl_type
*return_type
,
4629 const glsl_type
*sampler_type
,
4630 const glsl_type
*coord_type
,
4633 ir_variable
*s
= in_var(sampler_type
, "sampler");
4634 ir_variable
*P
= in_var(coord_type
, "P");
4635 /* The sampler and coordinate always exist; add optional parameters later. */
4636 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4638 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4639 tex
->set_sampler(var_ref(s
), return_type
);
4641 const int coord_size
= sampler_type
->coordinate_components();
4643 if (coord_size
== coord_type
->vector_elements
) {
4644 tex
->coordinate
= var_ref(P
);
4646 /* The incoming coordinate also has the projector or shadow comparitor,
4647 * so we need to swizzle those away.
4649 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4652 /* The projector is always in the last component. */
4653 if (flags
& TEX_PROJECT
)
4654 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4656 if (sampler_type
->sampler_shadow
) {
4657 if (opcode
== ir_tg4
) {
4658 /* gather has refz as a separate parameter, immediately after the
4661 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4662 sig
->parameters
.push_tail(refz
);
4663 tex
->shadow_comparitor
= var_ref(refz
);
4665 /* The shadow comparitor is normally in the Z component, but a few types
4666 * have sufficiently large coordinates that it's in W.
4668 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4672 if (opcode
== ir_txl
) {
4673 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4674 sig
->parameters
.push_tail(lod
);
4675 tex
->lod_info
.lod
= var_ref(lod
);
4676 } else if (opcode
== ir_txd
) {
4677 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4678 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4679 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4680 sig
->parameters
.push_tail(dPdx
);
4681 sig
->parameters
.push_tail(dPdy
);
4682 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4683 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4686 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4687 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4688 ir_variable
*offset
=
4689 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4690 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4691 sig
->parameters
.push_tail(offset
);
4692 tex
->offset
= var_ref(offset
);
4695 if (flags
& TEX_OFFSET_ARRAY
) {
4696 ir_variable
*offsets
=
4697 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4698 "offsets", ir_var_const_in
);
4699 sig
->parameters
.push_tail(offsets
);
4700 tex
->offset
= var_ref(offsets
);
4703 if (opcode
== ir_tg4
) {
4704 if (flags
& TEX_COMPONENT
) {
4705 ir_variable
*component
=
4706 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4707 sig
->parameters
.push_tail(component
);
4708 tex
->lod_info
.component
= var_ref(component
);
4711 tex
->lod_info
.component
= imm(0);
4715 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4716 * inconsistent with both textureLodOffset and textureGradOffset.
4718 if (opcode
== ir_txb
) {
4719 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4720 sig
->parameters
.push_tail(bias
);
4721 tex
->lod_info
.bias
= var_ref(bias
);
4724 body
.emit(ret(tex
));
4729 ir_function_signature
*
4730 builtin_builder::_textureCubeArrayShadow()
4732 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4733 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4734 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4735 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4737 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4738 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4740 tex
->coordinate
= var_ref(P
);
4741 tex
->shadow_comparitor
= var_ref(compare
);
4743 body
.emit(ret(tex
));
4748 ir_function_signature
*
4749 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4750 const glsl_type
*return_type
,
4751 const glsl_type
*sampler_type
,
4752 const glsl_type
*coord_type
,
4753 const glsl_type
*offset_type
)
4755 ir_variable
*s
= in_var(sampler_type
, "sampler");
4756 ir_variable
*P
= in_var(coord_type
, "P");
4757 /* The sampler and coordinate always exist; add optional parameters later. */
4758 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4760 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4761 tex
->coordinate
= var_ref(P
);
4762 tex
->set_sampler(var_ref(s
), return_type
);
4764 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4765 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4766 sig
->parameters
.push_tail(sample
);
4767 tex
->lod_info
.sample_index
= var_ref(sample
);
4768 tex
->op
= ir_txf_ms
;
4769 } else if (has_lod(sampler_type
)) {
4770 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4771 sig
->parameters
.push_tail(lod
);
4772 tex
->lod_info
.lod
= var_ref(lod
);
4774 tex
->lod_info
.lod
= imm(0u);
4777 if (offset_type
!= NULL
) {
4778 ir_variable
*offset
=
4779 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4780 sig
->parameters
.push_tail(offset
);
4781 tex
->offset
= var_ref(offset
);
4784 body
.emit(ret(tex
));
4789 ir_function_signature
*
4790 builtin_builder::_EmitVertex()
4792 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4794 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4795 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4800 ir_function_signature
*
4801 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4802 const glsl_type
*stream_type
)
4804 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4806 * "Emit the current values of output variables to the current output
4807 * primitive on stream stream. The argument to stream must be a constant
4808 * integral expression."
4810 ir_variable
*stream
=
4811 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4813 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4815 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4820 ir_function_signature
*
4821 builtin_builder::_EndPrimitive()
4823 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4825 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4826 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4831 ir_function_signature
*
4832 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4833 const glsl_type
*stream_type
)
4835 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4837 * "Completes the current output primitive on stream stream and starts
4838 * a new one. The argument to stream must be a constant integral
4841 ir_variable
*stream
=
4842 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4844 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4846 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4851 ir_function_signature
*
4852 builtin_builder::_barrier()
4854 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4856 body
.emit(new(mem_ctx
) ir_barrier());
4860 ir_function_signature
*
4861 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4862 const glsl_type
*sampler_type
,
4863 const glsl_type
*coord_type
)
4865 ir_variable
*s
= in_var(sampler_type
, "sampler");
4866 ir_variable
*coord
= in_var(coord_type
, "coord");
4867 /* The sampler and coordinate always exist; add optional parameters later. */
4868 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4870 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4871 tex
->coordinate
= var_ref(coord
);
4872 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4874 body
.emit(ret(tex
));
4879 ir_function_signature
*
4880 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4882 ir_variable
*s
= in_var(sampler_type
, "sampler");
4883 const glsl_type
*return_type
= glsl_type::int_type
;
4884 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4886 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4887 tex
->set_sampler(var_ref(s
), return_type
);
4889 body
.emit(ret(tex
));
4894 ir_function_signature
*
4895 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4896 const glsl_type
*sampler_type
,
4897 const glsl_type
*coord_type
)
4899 ir_variable
*s
= in_var(sampler_type
, "sampler");
4900 ir_variable
*P
= in_var(coord_type
, "P");
4901 const glsl_type
*return_type
= glsl_type::bool_type
;
4902 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4904 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4905 tex
->coordinate
= var_ref(P
);
4906 tex
->set_sampler(var_ref(s
), return_type
);
4908 body
.emit(ret(tex
));
4913 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4914 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4915 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4916 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4917 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4918 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4920 ir_function_signature
*
4921 builtin_builder::_fwidth(const glsl_type
*type
)
4923 ir_variable
*p
= in_var(type
, "p");
4924 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4926 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4931 ir_function_signature
*
4932 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4934 ir_variable
*p
= in_var(type
, "p");
4935 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4937 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4938 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4943 ir_function_signature
*
4944 builtin_builder::_fwidthFine(const glsl_type
*type
)
4946 ir_variable
*p
= in_var(type
, "p");
4947 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4949 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4950 abs(expr(ir_unop_dFdy_fine
, p
)))));
4955 ir_function_signature
*
4956 builtin_builder::_noise1(const glsl_type
*type
)
4958 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4961 ir_function_signature
*
4962 builtin_builder::_noise2(const glsl_type
*type
)
4964 ir_variable
*p
= in_var(type
, "p");
4965 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4967 ir_constant_data b_offset
;
4968 b_offset
.f
[0] = 601.0f
;
4969 b_offset
.f
[1] = 313.0f
;
4970 b_offset
.f
[2] = 29.0f
;
4971 b_offset
.f
[3] = 277.0f
;
4973 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4974 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4975 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4976 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4977 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4978 body
.emit(assign(t
, a
, WRITEMASK_X
));
4979 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4985 ir_function_signature
*
4986 builtin_builder::_noise3(const glsl_type
*type
)
4988 ir_variable
*p
= in_var(type
, "p");
4989 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4991 ir_constant_data b_offset
;
4992 b_offset
.f
[0] = 601.0f
;
4993 b_offset
.f
[1] = 313.0f
;
4994 b_offset
.f
[2] = 29.0f
;
4995 b_offset
.f
[3] = 277.0f
;
4997 ir_constant_data c_offset
;
4998 c_offset
.f
[0] = 1559.0f
;
4999 c_offset
.f
[1] = 113.0f
;
5000 c_offset
.f
[2] = 1861.0f
;
5001 c_offset
.f
[3] = 797.0f
;
5003 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5004 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5005 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5006 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
5007 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5008 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
5009 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
5010 body
.emit(assign(t
, a
, WRITEMASK_X
));
5011 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5012 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5018 ir_function_signature
*
5019 builtin_builder::_noise4(const glsl_type
*type
)
5021 ir_variable
*p
= in_var(type
, "p");
5022 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
5024 ir_variable
*_p
= body
.make_temp(type
, "_p");
5026 ir_constant_data p_offset
;
5027 p_offset
.f
[0] = 1559.0f
;
5028 p_offset
.f
[1] = 113.0f
;
5029 p_offset
.f
[2] = 1861.0f
;
5030 p_offset
.f
[3] = 797.0f
;
5032 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
5034 ir_constant_data offset
;
5035 offset
.f
[0] = 601.0f
;
5036 offset
.f
[1] = 313.0f
;
5037 offset
.f
[2] = 29.0f
;
5038 offset
.f
[3] = 277.0f
;
5040 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
5041 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
5042 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
5043 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
5044 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
5045 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
5046 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
5047 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
5048 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
5049 body
.emit(assign(t
, a
, WRITEMASK_X
));
5050 body
.emit(assign(t
, b
, WRITEMASK_Y
));
5051 body
.emit(assign(t
, c
, WRITEMASK_Z
));
5052 body
.emit(assign(t
, d
, WRITEMASK_W
));
5058 ir_function_signature
*
5059 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
5061 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5062 ir_variable
*value
= in_var(type
, "value");
5063 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5064 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5065 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, value
, offset
,
5068 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5069 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5071 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
5072 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5073 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5078 ir_function_signature
*
5079 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5081 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5082 ir_variable
*base
= in_var(type
, "base");
5083 ir_variable
*insert
= in_var(type
, "insert");
5084 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5085 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5086 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 4, base
, insert
,
5089 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5090 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5092 body
.emit(ret(bitfield_insert(base
, insert
,
5093 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5094 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5099 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31_or_integer_functions
)
5101 ir_function_signature
*
5102 builtin_builder::_bitCount(const glsl_type
*type
)
5104 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_bit_count
,
5105 glsl_type::ivec(type
->vector_elements
), type
);
5108 ir_function_signature
*
5109 builtin_builder::_findLSB(const glsl_type
*type
)
5111 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_lsb
,
5112 glsl_type::ivec(type
->vector_elements
), type
);
5115 ir_function_signature
*
5116 builtin_builder::_findMSB(const glsl_type
*type
)
5118 return unop(gpu_shader5_or_es31_or_integer_functions
, ir_unop_find_msb
,
5119 glsl_type::ivec(type
->vector_elements
), type
);
5122 ir_function_signature
*
5123 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5125 ir_variable
*a
= in_var(type
, "a");
5126 ir_variable
*b
= in_var(type
, "b");
5127 ir_variable
*c
= in_var(type
, "c");
5128 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5130 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5135 ir_function_signature
*
5136 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5138 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31_or_integer_functions
,
5139 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5142 ir_function_signature
*
5143 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5145 ir_variable
*x
= in_var(x_type
, "x");
5146 ir_variable
*exponent
= out_var(exp_type
, "exp");
5147 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5149 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5151 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5155 ir_function_signature
*
5156 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5158 ir_variable
*x
= in_var(x_type
, "x");
5159 ir_variable
*exponent
= out_var(exp_type
, "exp");
5160 MAKE_SIG(x_type
, gpu_shader5_or_es31_or_integer_functions
, 2, x
, exponent
);
5162 const unsigned vec_elem
= x_type
->vector_elements
;
5163 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5164 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5166 /* Single-precision floating-point values are stored as
5171 * An exponent shift of 23 will shift the mantissa out, leaving only the
5172 * exponent and sign bit (which itself may be zero, if the absolute value
5173 * was taken before the bitcast and shift.
5175 ir_constant
*exponent_shift
= imm(23);
5176 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5178 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5180 /* Exponent of floating-point values in the range [0.5, 1.0). */
5181 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5183 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5184 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5186 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5187 * to unsigned integers to ensure that 1 bits aren't shifted in.
5189 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5190 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5191 imm(0, vec_elem
)))));
5193 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5194 body
.emit(assign(bits
, bitcast_f2u(x
)));
5195 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5196 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5197 imm(0u, vec_elem
)))));
5198 body
.emit(ret(bitcast_u2f(bits
)));
5203 ir_function_signature
*
5204 builtin_builder::_uaddCarry(const glsl_type
*type
)
5206 ir_variable
*x
= in_var(type
, "x");
5207 ir_variable
*y
= in_var(type
, "y");
5208 ir_variable
*carry
= out_var(type
, "carry");
5209 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, carry
);
5211 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5212 body
.emit(ret(add(x
, y
)));
5217 ir_function_signature
*
5218 builtin_builder::_usubBorrow(const glsl_type
*type
)
5220 ir_variable
*x
= in_var(type
, "x");
5221 ir_variable
*y
= in_var(type
, "y");
5222 ir_variable
*borrow
= out_var(type
, "borrow");
5223 MAKE_SIG(type
, gpu_shader5_or_es31_or_integer_functions
, 3, x
, y
, borrow
);
5225 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5226 body
.emit(ret(sub(x
, y
)));
5232 * For both imulExtended() and umulExtended() built-ins.
5234 ir_function_signature
*
5235 builtin_builder::_mulExtended(const glsl_type
*type
)
5237 ir_variable
*x
= in_var(type
, "x");
5238 ir_variable
*y
= in_var(type
, "y");
5239 ir_variable
*msb
= out_var(type
, "msb");
5240 ir_variable
*lsb
= out_var(type
, "lsb");
5241 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31_or_integer_functions
, 4, x
, y
, msb
, lsb
);
5243 body
.emit(assign(msb
, imul_high(x
, y
)));
5244 body
.emit(assign(lsb
, mul(x
, y
)));
5249 ir_function_signature
*
5250 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5252 ir_variable
*interpolant
= in_var(type
, "interpolant");
5253 interpolant
->data
.must_be_shader_input
= 1;
5254 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5256 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5261 ir_function_signature
*
5262 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5264 ir_variable
*interpolant
= in_var(type
, "interpolant");
5265 interpolant
->data
.must_be_shader_input
= 1;
5266 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5267 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5269 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5274 ir_function_signature
*
5275 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5277 ir_variable
*interpolant
= in_var(type
, "interpolant");
5278 interpolant
->data
.must_be_shader_input
= 1;
5279 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5280 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5282 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5287 ir_function_signature
*
5288 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
,
5289 enum ir_intrinsic_id id
)
5291 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5292 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 1, counter
);
5296 ir_function_signature
*
5297 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
,
5298 enum ir_intrinsic_id id
)
5300 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5301 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5302 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 2, counter
, data
);
5306 ir_function_signature
*
5307 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
,
5308 enum ir_intrinsic_id id
)
5310 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5311 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5312 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5313 MAKE_INTRINSIC(glsl_type::uint_type
, id
, avail
, 3, counter
, compare
, data
);
5317 ir_function_signature
*
5318 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5319 const glsl_type
*type
,
5320 enum ir_intrinsic_id id
)
5322 ir_variable
*atomic
= in_var(type
, "atomic");
5323 ir_variable
*data
= in_var(type
, "data");
5324 MAKE_INTRINSIC(type
, id
, avail
, 2, atomic
, data
);
5328 ir_function_signature
*
5329 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5330 const glsl_type
*type
,
5331 enum ir_intrinsic_id id
)
5333 ir_variable
*atomic
= in_var(type
, "atomic");
5334 ir_variable
*data1
= in_var(type
, "data1");
5335 ir_variable
*data2
= in_var(type
, "data2");
5336 MAKE_INTRINSIC(type
, id
, avail
, 3, atomic
, data1
, data2
);
5340 ir_function_signature
*
5341 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5342 builtin_available_predicate avail
)
5344 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5345 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5347 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5348 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5350 body
.emit(ret(retval
));
5354 ir_function_signature
*
5355 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5356 builtin_available_predicate avail
)
5358 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5359 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5360 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5362 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5364 /* Instead of generating an __intrinsic_atomic_sub, generate an
5365 * __intrinsic_atomic_add with the data parameter negated.
5367 if (strcmp("__intrinsic_atomic_sub", intrinsic
) == 0) {
5368 ir_variable
*const neg_data
=
5369 body
.make_temp(glsl_type::uint_type
, "neg_data");
5371 body
.emit(assign(neg_data
, neg(data
)));
5373 exec_list parameters
;
5375 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(counter
));
5376 parameters
.push_tail(new(mem_ctx
) ir_dereference_variable(neg_data
));
5378 ir_function
*const func
=
5379 shader
->symbols
->get_function("__intrinsic_atomic_add");
5380 ir_instruction
*const c
= call(func
, retval
, parameters
);
5383 assert(parameters
.is_empty());
5387 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5391 body
.emit(ret(retval
));
5395 ir_function_signature
*
5396 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5397 builtin_available_predicate avail
)
5399 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5400 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5401 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5402 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5404 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5405 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5407 body
.emit(ret(retval
));
5411 ir_function_signature
*
5412 builtin_builder::_atomic_op2(const char *intrinsic
,
5413 builtin_available_predicate avail
,
5414 const glsl_type
*type
)
5416 ir_variable
*atomic
= in_var(type
, "atomic_var");
5417 ir_variable
*data
= in_var(type
, "atomic_data");
5418 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5420 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5421 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5423 body
.emit(ret(retval
));
5427 ir_function_signature
*
5428 builtin_builder::_atomic_op3(const char *intrinsic
,
5429 builtin_available_predicate avail
,
5430 const glsl_type
*type
)
5432 ir_variable
*atomic
= in_var(type
, "atomic_var");
5433 ir_variable
*data1
= in_var(type
, "atomic_data1");
5434 ir_variable
*data2
= in_var(type
, "atomic_data2");
5435 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5437 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5438 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5440 body
.emit(ret(retval
));
5444 ir_function_signature
*
5445 builtin_builder::_min3(const glsl_type
*type
)
5447 ir_variable
*x
= in_var(type
, "x");
5448 ir_variable
*y
= in_var(type
, "y");
5449 ir_variable
*z
= in_var(type
, "z");
5450 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5452 ir_expression
*min3
= min2(x
, min2(y
,z
));
5453 body
.emit(ret(min3
));
5458 ir_function_signature
*
5459 builtin_builder::_max3(const glsl_type
*type
)
5461 ir_variable
*x
= in_var(type
, "x");
5462 ir_variable
*y
= in_var(type
, "y");
5463 ir_variable
*z
= in_var(type
, "z");
5464 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5466 ir_expression
*max3
= max2(x
, max2(y
,z
));
5467 body
.emit(ret(max3
));
5472 ir_function_signature
*
5473 builtin_builder::_mid3(const glsl_type
*type
)
5475 ir_variable
*x
= in_var(type
, "x");
5476 ir_variable
*y
= in_var(type
, "y");
5477 ir_variable
*z
= in_var(type
, "z");
5478 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5480 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5481 body
.emit(ret(mid3
));
5486 static builtin_available_predicate
5487 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5489 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5490 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5491 return shader_image_atomic_exchange_float
;
5493 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5494 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5495 return shader_image_atomic
;
5498 return shader_image_load_store
;
5501 ir_function_signature
*
5502 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5503 unsigned num_arguments
,
5506 const glsl_type
*data_type
= glsl_type::get_instance(
5507 image_type
->sampled_type
,
5508 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5510 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5511 glsl_type::void_type
: data_type
);
5513 /* Addressing arguments that are always present. */
5514 ir_variable
*image
= in_var(image_type
, "image");
5515 ir_variable
*coord
= in_var(
5516 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5518 ir_function_signature
*sig
= new_sig(
5519 ret_type
, get_image_available_predicate(image_type
, flags
),
5522 /* Sample index for multisample images. */
5523 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5524 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5526 /* Data arguments. */
5527 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5528 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5529 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5530 ralloc_free(arg_name
);
5533 /* Set the maximal set of qualifiers allowed for this image
5534 * built-in. Function calls with arguments having fewer
5535 * qualifiers than present in the prototype are allowed by the
5536 * spec, but not with more, i.e. this will make the compiler
5537 * accept everything that needs to be accepted, and reject cases
5538 * like loads from write-only or stores to read-only images.
5540 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5541 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5542 image
->data
.image_coherent
= true;
5543 image
->data
.image_volatile
= true;
5544 image
->data
.image_restrict
= true;
5549 ir_function_signature
*
5550 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5551 unsigned /* num_arguments */,
5552 unsigned /* flags */)
5554 const glsl_type
*ret_type
;
5555 unsigned num_components
= image_type
->coordinate_components();
5557 /* From the ARB_shader_image_size extension:
5558 * "Cube images return the dimensions of one face."
5560 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5561 !image_type
->sampler_array
) {
5565 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5566 * supported by mesa.
5568 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5570 ir_variable
*image
= in_var(image_type
, "image");
5571 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5573 /* Set the maximal set of qualifiers allowed for this image
5574 * built-in. Function calls with arguments having fewer
5575 * qualifiers than present in the prototype are allowed by the
5576 * spec, but not with more, i.e. this will make the compiler
5577 * accept everything that needs to be accepted, and reject cases
5578 * like loads from write-only or stores to read-only images.
5580 image
->data
.image_read_only
= true;
5581 image
->data
.image_write_only
= true;
5582 image
->data
.image_coherent
= true;
5583 image
->data
.image_volatile
= true;
5584 image
->data
.image_restrict
= true;
5589 ir_function_signature
*
5590 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5591 unsigned /* num_arguments */,
5592 unsigned /* flags */)
5594 ir_variable
*image
= in_var(image_type
, "image");
5595 ir_function_signature
*sig
=
5596 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5598 /* Set the maximal set of qualifiers allowed for this image
5599 * built-in. Function calls with arguments having fewer
5600 * qualifiers than present in the prototype are allowed by the
5601 * spec, but not with more, i.e. this will make the compiler
5602 * accept everything that needs to be accepted, and reject cases
5603 * like loads from write-only or stores to read-only images.
5605 image
->data
.image_read_only
= true;
5606 image
->data
.image_write_only
= true;
5607 image
->data
.image_coherent
= true;
5608 image
->data
.image_volatile
= true;
5609 image
->data
.image_restrict
= true;
5614 ir_function_signature
*
5615 builtin_builder::_image(image_prototype_ctr prototype
,
5616 const glsl_type
*image_type
,
5617 const char *intrinsic_name
,
5618 unsigned num_arguments
,
5620 enum ir_intrinsic_id id
)
5622 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5623 num_arguments
, flags
);
5625 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5626 ir_factory
body(&sig
->body
, mem_ctx
);
5627 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5629 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5630 body
.emit(call(f
, NULL
, sig
->parameters
));
5632 ir_variable
*ret_val
=
5633 body
.make_temp(sig
->return_type
, "_ret_val");
5634 body
.emit(call(f
, ret_val
, sig
->parameters
));
5635 body
.emit(ret(ret_val
));
5638 sig
->is_defined
= true;
5641 sig
->intrinsic_id
= id
;
5647 ir_function_signature
*
5648 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
,
5649 enum ir_intrinsic_id id
)
5651 MAKE_INTRINSIC(glsl_type::void_type
, id
, avail
, 0);
5655 ir_function_signature
*
5656 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5657 builtin_available_predicate avail
)
5659 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5660 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5661 NULL
, sig
->parameters
));
5665 ir_function_signature
*
5666 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5667 const glsl_type
*type
)
5669 MAKE_INTRINSIC(type
, ir_intrinsic_shader_clock
, avail
, 0);
5673 ir_function_signature
*
5674 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5675 const glsl_type
*type
)
5677 MAKE_SIG(type
, avail
, 0);
5679 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5681 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5682 retval
, sig
->parameters
));
5683 body
.emit(ret(retval
));
5687 ir_function_signature
*
5688 builtin_builder::_vote(enum ir_expression_operation opcode
)
5690 ir_variable
*value
= in_var(glsl_type::bool_type
, "value");
5692 MAKE_SIG(glsl_type::bool_type
, vote
, 1, value
);
5693 body
.emit(ret(expr(opcode
, value
)));
5699 /******************************************************************************/
5701 /* The singleton instance of builtin_builder. */
5702 static builtin_builder builtins
;
5703 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5706 * External API (exposing the built-in module to the rest of the compiler):
5710 _mesa_glsl_initialize_builtin_functions()
5712 mtx_lock(&builtins_lock
);
5713 builtins
.initialize();
5714 mtx_unlock(&builtins_lock
);
5718 _mesa_glsl_release_builtin_functions()
5720 mtx_lock(&builtins_lock
);
5722 mtx_unlock(&builtins_lock
);
5725 ir_function_signature
*
5726 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5727 const char *name
, exec_list
*actual_parameters
)
5729 ir_function_signature
* s
;
5730 mtx_lock(&builtins_lock
);
5731 s
= builtins
.find(state
, name
, actual_parameters
);
5732 mtx_unlock(&builtins_lock
);
5737 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5740 mtx_lock(&builtins_lock
);
5741 f
= builtins
.shader
->symbols
->get_function(name
);
5742 mtx_unlock(&builtins_lock
);
5747 _mesa_glsl_get_builtin_function_shader()
5749 return builtins
.shader
;
5754 * Get the function signature for main from a shader
5756 ir_function_signature
*
5757 _mesa_get_main_function_signature(glsl_symbol_table
*symbols
)
5759 ir_function
*const f
= symbols
->get_function("main");
5761 exec_list void_parameters
;
5763 /* Look for the 'void main()' signature and ensure that it's defined.
5764 * This keeps the linker from accidentally pick a shader that just
5765 * contains a prototype for main.
5767 * We don't have to check for multiple definitions of main (in multiple
5768 * shaders) because that would have already been caught above.
5770 ir_function_signature
*sig
=
5771 f
->matching_signature(NULL
, &void_parameters
, false);
5772 if ((sig
!= NULL
) && sig
->is_defined
) {