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 es31_not_gs5(const _mesa_glsl_parse_state
*state
)
250 return state
->is_version(0, 310) && !gpu_shader5_es(state
);
254 gpu_shader5_or_es31(const _mesa_glsl_parse_state
*state
)
256 return state
->is_version(400, 310) || state
->ARB_gpu_shader5_enable
;
260 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state
*state
)
262 return state
->ARB_shading_language_packing_enable
||
263 state
->ARB_gpu_shader5_enable
||
264 state
->is_version(400, 310);
268 fs_interpolate_at(const _mesa_glsl_parse_state
*state
)
270 return state
->stage
== MESA_SHADER_FRAGMENT
&&
271 (state
->is_version(400, 320) ||
272 state
->ARB_gpu_shader5_enable
||
273 state
->OES_shader_multisample_interpolation_enable
);
278 texture_array_lod(const _mesa_glsl_parse_state
*state
)
280 return lod_exists_in_stage(state
) &&
281 state
->EXT_texture_array_enable
;
285 fs_texture_array(const _mesa_glsl_parse_state
*state
)
287 return state
->stage
== MESA_SHADER_FRAGMENT
&&
288 state
->EXT_texture_array_enable
;
292 texture_array(const _mesa_glsl_parse_state
*state
)
294 return state
->EXT_texture_array_enable
;
298 texture_multisample(const _mesa_glsl_parse_state
*state
)
300 return state
->is_version(150, 310) ||
301 state
->ARB_texture_multisample_enable
;
305 texture_multisample_array(const _mesa_glsl_parse_state
*state
)
307 return state
->is_version(150, 320) ||
308 state
->ARB_texture_multisample_enable
||
309 state
->OES_texture_storage_multisample_2d_array_enable
;
313 texture_samples_identical(const _mesa_glsl_parse_state
*state
)
315 return texture_multisample(state
) &&
316 state
->EXT_shader_samples_identical_enable
;
320 texture_samples_identical_array(const _mesa_glsl_parse_state
*state
)
322 return texture_multisample_array(state
) &&
323 state
->EXT_shader_samples_identical_enable
;
327 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
329 return state
->stage
== MESA_SHADER_FRAGMENT
&&
330 (state
->is_version(400, 0) ||
331 state
->ARB_texture_cube_map_array_enable
);
335 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
337 return state
->is_version(400, 0) ||
338 state
->ARB_texture_cube_map_array_enable
;
342 texture_query_levels(const _mesa_glsl_parse_state
*state
)
344 return state
->is_version(430, 0) ||
345 state
->ARB_texture_query_levels_enable
;
349 texture_query_lod(const _mesa_glsl_parse_state
*state
)
351 return state
->stage
== MESA_SHADER_FRAGMENT
&&
352 state
->ARB_texture_query_lod_enable
;
356 texture_gather(const _mesa_glsl_parse_state
*state
)
358 return state
->is_version(400, 0) ||
359 state
->ARB_texture_gather_enable
||
360 state
->ARB_gpu_shader5_enable
;
364 texture_gather_or_es31(const _mesa_glsl_parse_state
*state
)
366 return state
->is_version(400, 310) ||
367 state
->ARB_texture_gather_enable
||
368 state
->ARB_gpu_shader5_enable
;
371 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
372 * used for relaxation of const offset requirements.
375 texture_gather_only_or_es31(const _mesa_glsl_parse_state
*state
)
377 return !state
->is_version(400, 320) &&
378 !state
->ARB_gpu_shader5_enable
&&
379 !state
->EXT_gpu_shader5_enable
&&
380 !state
->OES_gpu_shader5_enable
&&
381 (state
->ARB_texture_gather_enable
||
382 state
->is_version(0, 310));
385 /* Desktop GL or OES_standard_derivatives + fragment shader only */
387 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
389 return state
->stage
== MESA_SHADER_FRAGMENT
&&
390 (state
->is_version(110, 300) ||
391 state
->OES_standard_derivatives_enable
);
395 fs_derivative_control(const _mesa_glsl_parse_state
*state
)
397 return state
->stage
== MESA_SHADER_FRAGMENT
&&
398 (state
->is_version(450, 0) ||
399 state
->ARB_derivative_control_enable
);
403 tex1d_lod(const _mesa_glsl_parse_state
*state
)
405 return !state
->es_shader
&& lod_exists_in_stage(state
);
408 /** True if sampler3D exists */
410 tex3d(const _mesa_glsl_parse_state
*state
)
412 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
413 * OES_texture_3D extension, and in GLSL ES 3.00.
415 return !state
->es_shader
||
416 state
->OES_texture_3D_enable
||
417 state
->language_version
>= 300;
421 fs_tex3d(const _mesa_glsl_parse_state
*state
)
423 return state
->stage
== MESA_SHADER_FRAGMENT
&&
424 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
428 tex3d_lod(const _mesa_glsl_parse_state
*state
)
430 return tex3d(state
) && lod_exists_in_stage(state
);
434 shader_atomic_counters(const _mesa_glsl_parse_state
*state
)
436 return state
->has_atomic_counters();
440 shader_atomic_counter_ops(const _mesa_glsl_parse_state
*state
)
442 return state
->ARB_shader_atomic_counter_ops_enable
;
446 shader_clock(const _mesa_glsl_parse_state
*state
)
448 return state
->ARB_shader_clock_enable
;
452 shader_storage_buffer_object(const _mesa_glsl_parse_state
*state
)
454 return state
->has_shader_storage_buffer_objects();
458 shader_trinary_minmax(const _mesa_glsl_parse_state
*state
)
460 return state
->AMD_shader_trinary_minmax_enable
;
464 shader_image_load_store(const _mesa_glsl_parse_state
*state
)
466 return (state
->is_version(420, 310) ||
467 state
->ARB_shader_image_load_store_enable
);
471 shader_image_atomic(const _mesa_glsl_parse_state
*state
)
473 return (state
->is_version(420, 320) ||
474 state
->ARB_shader_image_load_store_enable
||
475 state
->OES_shader_image_atomic_enable
);
479 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state
*state
)
481 return (state
->is_version(450, 320) ||
482 state
->ARB_ES3_1_compatibility_enable
||
483 state
->OES_shader_image_atomic_enable
);
487 shader_image_size(const _mesa_glsl_parse_state
*state
)
489 return state
->is_version(430, 310) ||
490 state
->ARB_shader_image_size_enable
;
494 shader_samples(const _mesa_glsl_parse_state
*state
)
496 return state
->is_version(450, 0) ||
497 state
->ARB_shader_texture_image_samples_enable
;
501 gs_streams(const _mesa_glsl_parse_state
*state
)
503 return gpu_shader5(state
) && gs_only(state
);
507 fp64(const _mesa_glsl_parse_state
*state
)
509 return state
->has_double();
513 compute_shader(const _mesa_glsl_parse_state
*state
)
515 return state
->stage
== MESA_SHADER_COMPUTE
;
519 buffer_atomics_supported(const _mesa_glsl_parse_state
*state
)
521 return compute_shader(state
) || shader_storage_buffer_object(state
);
525 barrier_supported(const _mesa_glsl_parse_state
*state
)
527 return compute_shader(state
) ||
528 state
->stage
== MESA_SHADER_TESS_CTRL
;
533 /******************************************************************************/
538 * builtin_builder: A singleton object representing the core of the built-in
541 * It generates IR for every built-in function signature, and organizes them
544 class builtin_builder
{
551 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
552 const char *name
, exec_list
*actual_parameters
);
555 * A shader to hold all the built-in signatures; created by this module.
557 * This includes signatures for every built-in, regardless of version or
558 * enabled extensions. The availability predicate associated with each
559 * signature allows matching_signature() to filter out the irrelevant ones.
566 /** Global variables used by built-in functions. */
567 ir_variable
*gl_ModelViewProjectionMatrix
;
568 ir_variable
*gl_Vertex
;
570 void create_shader();
571 void create_intrinsics();
572 void create_builtins();
575 * IR builder helpers:
577 * These convenience functions assist in emitting IR, but don't necessarily
578 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
581 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
582 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
583 ir_constant
*imm(float f
, unsigned vector_elements
=1);
584 ir_constant
*imm(bool b
, unsigned vector_elements
=1);
585 ir_constant
*imm(int i
, unsigned vector_elements
=1);
586 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
587 ir_constant
*imm(double d
, unsigned vector_elements
=1);
588 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
589 ir_dereference_variable
*var_ref(ir_variable
*var
);
590 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
591 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
593 ir_expression
*asin_expr(ir_variable
*x
, float p0
, float p1
);
594 void do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
);
597 * Call function \param f with parameters specified as the linked
598 * list \param params of \c ir_variable objects. \param ret should
599 * point to the ir_variable that will hold the function return
600 * value, or be \c NULL if the function has void return type.
602 ir_call
*call(ir_function
*f
, ir_variable
*ret
, exec_list params
);
604 /** Create a new function and add the given signatures. */
605 void add_function(const char *name
, ...);
607 typedef ir_function_signature
*(builtin_builder::*image_prototype_ctr
)(const glsl_type
*image_type
,
608 unsigned num_arguments
,
612 * Create a new image built-in function for all known image types.
613 * \p flags is a bitfield of \c image_function_flags flags.
615 void add_image_function(const char *name
,
616 const char *intrinsic_name
,
617 image_prototype_ctr prototype
,
618 unsigned num_arguments
,
622 * Create new functions for all known image built-ins and types.
623 * If \p glsl is \c true, use the GLSL built-in names and emit code
624 * to call into the actual compiler intrinsic. If \p glsl is
625 * false, emit a function prototype with no body for each image
628 void add_image_functions(bool glsl
);
630 ir_function_signature
*new_sig(const glsl_type
*return_type
,
631 builtin_available_predicate avail
,
632 int num_params
, ...);
635 * Function signature generators:
638 ir_function_signature
*unop(builtin_available_predicate avail
,
639 ir_expression_operation opcode
,
640 const glsl_type
*return_type
,
641 const glsl_type
*param_type
);
642 ir_function_signature
*binop(builtin_available_predicate avail
,
643 ir_expression_operation opcode
,
644 const glsl_type
*return_type
,
645 const glsl_type
*param0_type
,
646 const glsl_type
*param1_type
);
648 #define B0(X) ir_function_signature *_##X();
649 #define B1(X) ir_function_signature *_##X(const glsl_type *);
650 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
651 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
652 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
653 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
690 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
691 const glsl_type
*val_type
,
692 const glsl_type
*blend_type
);
701 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
702 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
703 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
704 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
705 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
706 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
707 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
708 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
709 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
710 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
711 ir_function_signature
*_packDouble2x32(builtin_available_predicate avail
);
712 ir_function_signature
*_unpackDouble2x32(builtin_available_predicate avail
);
725 BA1(determinant_mat2
);
726 BA1(determinant_mat3
);
727 BA1(determinant_mat4
);
735 BA1(greaterThanEqual
);
744 /** Flags to _texture() */
745 #define TEX_PROJECT 1
747 #define TEX_COMPONENT 4
748 #define TEX_OFFSET_NONCONST 8
749 #define TEX_OFFSET_ARRAY 16
751 ir_function_signature
*_texture(ir_texture_opcode opcode
,
752 builtin_available_predicate avail
,
753 const glsl_type
*return_type
,
754 const glsl_type
*sampler_type
,
755 const glsl_type
*coord_type
,
757 B0(textureCubeArrayShadow
);
758 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
759 const glsl_type
*return_type
,
760 const glsl_type
*sampler_type
,
761 const glsl_type
*coord_type
,
762 const glsl_type
*offset_type
= NULL
);
766 ir_function_signature
*_EmitStreamVertex(builtin_available_predicate avail
,
767 const glsl_type
*stream_type
);
768 ir_function_signature
*_EndStreamPrimitive(builtin_available_predicate avail
,
769 const glsl_type
*stream_type
);
772 BA2(textureQueryLod
);
773 B1(textureQueryLevels
);
774 BA2(textureSamplesIdentical
);
802 B1(interpolateAtCentroid
)
803 B1(interpolateAtOffset
)
804 B1(interpolateAtSample
)
806 ir_function_signature
*_atomic_counter_intrinsic(builtin_available_predicate avail
);
807 ir_function_signature
*_atomic_counter_intrinsic1(builtin_available_predicate avail
);
808 ir_function_signature
*_atomic_counter_intrinsic2(builtin_available_predicate avail
);
809 ir_function_signature
*_atomic_counter_op(const char *intrinsic
,
810 builtin_available_predicate avail
);
811 ir_function_signature
*_atomic_counter_op1(const char *intrinsic
,
812 builtin_available_predicate avail
);
813 ir_function_signature
*_atomic_counter_op2(const char *intrinsic
,
814 builtin_available_predicate avail
);
816 ir_function_signature
*_atomic_intrinsic2(builtin_available_predicate avail
,
817 const glsl_type
*type
);
818 ir_function_signature
*_atomic_op2(const char *intrinsic
,
819 builtin_available_predicate avail
,
820 const glsl_type
*type
);
821 ir_function_signature
*_atomic_intrinsic3(builtin_available_predicate avail
,
822 const glsl_type
*type
);
823 ir_function_signature
*_atomic_op3(const char *intrinsic
,
824 builtin_available_predicate avail
,
825 const glsl_type
*type
);
831 ir_function_signature
*_image_prototype(const glsl_type
*image_type
,
832 unsigned num_arguments
,
834 ir_function_signature
*_image_size_prototype(const glsl_type
*image_type
,
835 unsigned num_arguments
,
837 ir_function_signature
*_image_samples_prototype(const glsl_type
*image_type
,
838 unsigned num_arguments
,
840 ir_function_signature
*_image(image_prototype_ctr prototype
,
841 const glsl_type
*image_type
,
842 const char *intrinsic_name
,
843 unsigned num_arguments
,
846 ir_function_signature
*_memory_barrier_intrinsic(
847 builtin_available_predicate avail
);
848 ir_function_signature
*_memory_barrier(const char *intrinsic_name
,
849 builtin_available_predicate avail
);
851 ir_function_signature
*_shader_clock_intrinsic(builtin_available_predicate avail
,
852 const glsl_type
*type
);
853 ir_function_signature
*_shader_clock(builtin_available_predicate avail
,
854 const glsl_type
*type
);
865 enum image_function_flags
{
866 IMAGE_FUNCTION_EMIT_STUB
= (1 << 0),
867 IMAGE_FUNCTION_RETURNS_VOID
= (1 << 1),
868 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
= (1 << 2),
869 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
= (1 << 3),
870 IMAGE_FUNCTION_READ_ONLY
= (1 << 4),
871 IMAGE_FUNCTION_WRITE_ONLY
= (1 << 5),
872 IMAGE_FUNCTION_AVAIL_ATOMIC
= (1 << 6),
873 IMAGE_FUNCTION_MS_ONLY
= (1 << 7),
874 IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
= (1 << 8)
877 } /* anonymous namespace */
880 * Core builtin_builder functionality:
883 builtin_builder::builtin_builder()
885 gl_ModelViewProjectionMatrix(NULL
),
891 builtin_builder::~builtin_builder()
893 ralloc_free(mem_ctx
);
896 ir_function_signature
*
897 builtin_builder::find(_mesa_glsl_parse_state
*state
,
898 const char *name
, exec_list
*actual_parameters
)
900 /* The shader currently being compiled requested a built-in function;
901 * it needs to link against builtin_builder::shader in order to get them.
903 * Even if we don't find a matching signature, we still need to do this so
904 * that the "no matching signature" error will list potential candidates
905 * from the available built-ins.
907 state
->uses_builtin_functions
= true;
909 ir_function
*f
= shader
->symbols
->get_function(name
);
913 ir_function_signature
*sig
=
914 f
->matching_signature(state
, actual_parameters
, true);
922 builtin_builder::initialize()
924 /* If already initialized, don't do it again. */
928 mem_ctx
= ralloc_context(NULL
);
935 builtin_builder::release()
937 ralloc_free(mem_ctx
);
945 builtin_builder::create_shader()
947 /* The target doesn't actually matter. There's no target for generic
948 * GLSL utility code that could be linked against any stage, so just
949 * arbitrarily pick GL_VERTEX_SHADER.
951 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
952 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
954 gl_ModelViewProjectionMatrix
=
955 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
956 "gl_ModelViewProjectionMatrix",
959 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
961 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
962 shader
->symbols
->add_variable(gl_Vertex
);
968 * Create ir_function and ir_function_signature objects for each
972 builtin_builder::create_intrinsics()
974 add_function("__intrinsic_atomic_read",
975 _atomic_counter_intrinsic(shader_atomic_counters
),
977 add_function("__intrinsic_atomic_increment",
978 _atomic_counter_intrinsic(shader_atomic_counters
),
980 add_function("__intrinsic_atomic_predecrement",
981 _atomic_counter_intrinsic(shader_atomic_counters
),
984 add_function("__intrinsic_atomic_add",
985 _atomic_intrinsic2(buffer_atomics_supported
,
986 glsl_type::uint_type
),
987 _atomic_intrinsic2(buffer_atomics_supported
,
988 glsl_type::int_type
),
989 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
991 add_function("__intrinsic_atomic_sub",
992 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
994 add_function("__intrinsic_atomic_min",
995 _atomic_intrinsic2(buffer_atomics_supported
,
996 glsl_type::uint_type
),
997 _atomic_intrinsic2(buffer_atomics_supported
,
998 glsl_type::int_type
),
999 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1001 add_function("__intrinsic_atomic_max",
1002 _atomic_intrinsic2(buffer_atomics_supported
,
1003 glsl_type::uint_type
),
1004 _atomic_intrinsic2(buffer_atomics_supported
,
1005 glsl_type::int_type
),
1006 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1008 add_function("__intrinsic_atomic_and",
1009 _atomic_intrinsic2(buffer_atomics_supported
,
1010 glsl_type::uint_type
),
1011 _atomic_intrinsic2(buffer_atomics_supported
,
1012 glsl_type::int_type
),
1013 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1015 add_function("__intrinsic_atomic_or",
1016 _atomic_intrinsic2(buffer_atomics_supported
,
1017 glsl_type::uint_type
),
1018 _atomic_intrinsic2(buffer_atomics_supported
,
1019 glsl_type::int_type
),
1020 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1022 add_function("__intrinsic_atomic_xor",
1023 _atomic_intrinsic2(buffer_atomics_supported
,
1024 glsl_type::uint_type
),
1025 _atomic_intrinsic2(buffer_atomics_supported
,
1026 glsl_type::int_type
),
1027 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1029 add_function("__intrinsic_atomic_exchange",
1030 _atomic_intrinsic2(buffer_atomics_supported
,
1031 glsl_type::uint_type
),
1032 _atomic_intrinsic2(buffer_atomics_supported
,
1033 glsl_type::int_type
),
1034 _atomic_counter_intrinsic1(shader_atomic_counter_ops
),
1036 add_function("__intrinsic_atomic_comp_swap",
1037 _atomic_intrinsic3(buffer_atomics_supported
,
1038 glsl_type::uint_type
),
1039 _atomic_intrinsic3(buffer_atomics_supported
,
1040 glsl_type::int_type
),
1041 _atomic_counter_intrinsic2(shader_atomic_counter_ops
),
1044 add_image_functions(false);
1046 add_function("__intrinsic_memory_barrier",
1047 _memory_barrier_intrinsic(shader_image_load_store
),
1049 add_function("__intrinsic_group_memory_barrier",
1050 _memory_barrier_intrinsic(compute_shader
),
1052 add_function("__intrinsic_memory_barrier_atomic_counter",
1053 _memory_barrier_intrinsic(compute_shader
),
1055 add_function("__intrinsic_memory_barrier_buffer",
1056 _memory_barrier_intrinsic(compute_shader
),
1058 add_function("__intrinsic_memory_barrier_image",
1059 _memory_barrier_intrinsic(compute_shader
),
1061 add_function("__intrinsic_memory_barrier_shared",
1062 _memory_barrier_intrinsic(compute_shader
),
1065 add_function("__intrinsic_shader_clock",
1066 _shader_clock_intrinsic(shader_clock
,
1067 glsl_type::uvec2_type
),
1072 * Create ir_function and ir_function_signature objects for each built-in.
1074 * Contains a list of every available built-in.
1077 builtin_builder::create_builtins()
1080 add_function(#NAME, \
1081 _##NAME(glsl_type::float_type), \
1082 _##NAME(glsl_type::vec2_type), \
1083 _##NAME(glsl_type::vec3_type), \
1084 _##NAME(glsl_type::vec4_type), \
1088 add_function(#NAME, \
1089 _##NAME(always_available, glsl_type::float_type), \
1090 _##NAME(always_available, glsl_type::vec2_type), \
1091 _##NAME(always_available, glsl_type::vec3_type), \
1092 _##NAME(always_available, glsl_type::vec4_type), \
1093 _##NAME(fp64, glsl_type::double_type), \
1094 _##NAME(fp64, glsl_type::dvec2_type), \
1095 _##NAME(fp64, glsl_type::dvec3_type), \
1096 _##NAME(fp64, glsl_type::dvec4_type), \
1099 #define FD130(NAME) \
1100 add_function(#NAME, \
1101 _##NAME(v130, glsl_type::float_type), \
1102 _##NAME(v130, glsl_type::vec2_type), \
1103 _##NAME(v130, glsl_type::vec3_type), \
1104 _##NAME(v130, glsl_type::vec4_type), \
1105 _##NAME(fp64, glsl_type::double_type), \
1106 _##NAME(fp64, glsl_type::dvec2_type), \
1107 _##NAME(fp64, glsl_type::dvec3_type), \
1108 _##NAME(fp64, glsl_type::dvec4_type), \
1111 #define FDGS5(NAME) \
1112 add_function(#NAME, \
1113 _##NAME(gpu_shader5_es, glsl_type::float_type), \
1114 _##NAME(gpu_shader5_es, glsl_type::vec2_type), \
1115 _##NAME(gpu_shader5_es, glsl_type::vec3_type), \
1116 _##NAME(gpu_shader5_es, glsl_type::vec4_type), \
1117 _##NAME(fp64, glsl_type::double_type), \
1118 _##NAME(fp64, glsl_type::dvec2_type), \
1119 _##NAME(fp64, glsl_type::dvec3_type), \
1120 _##NAME(fp64, glsl_type::dvec4_type), \
1124 add_function(#NAME, \
1125 _##NAME(glsl_type::float_type), \
1126 _##NAME(glsl_type::vec2_type), \
1127 _##NAME(glsl_type::vec3_type), \
1128 _##NAME(glsl_type::vec4_type), \
1129 _##NAME(glsl_type::int_type), \
1130 _##NAME(glsl_type::ivec2_type), \
1131 _##NAME(glsl_type::ivec3_type), \
1132 _##NAME(glsl_type::ivec4_type), \
1136 add_function(#NAME, \
1137 _##NAME(always_available, glsl_type::float_type), \
1138 _##NAME(always_available, glsl_type::vec2_type), \
1139 _##NAME(always_available, glsl_type::vec3_type), \
1140 _##NAME(always_available, glsl_type::vec4_type), \
1141 _##NAME(always_available, glsl_type::int_type), \
1142 _##NAME(always_available, glsl_type::ivec2_type), \
1143 _##NAME(always_available, glsl_type::ivec3_type), \
1144 _##NAME(always_available, glsl_type::ivec4_type), \
1145 _##NAME(fp64, glsl_type::double_type), \
1146 _##NAME(fp64, glsl_type::dvec2_type), \
1147 _##NAME(fp64, glsl_type::dvec3_type), \
1148 _##NAME(fp64, glsl_type::dvec4_type), \
1151 #define FIUD(NAME) \
1152 add_function(#NAME, \
1153 _##NAME(always_available, glsl_type::float_type), \
1154 _##NAME(always_available, glsl_type::vec2_type), \
1155 _##NAME(always_available, glsl_type::vec3_type), \
1156 _##NAME(always_available, glsl_type::vec4_type), \
1158 _##NAME(always_available, glsl_type::int_type), \
1159 _##NAME(always_available, glsl_type::ivec2_type), \
1160 _##NAME(always_available, glsl_type::ivec3_type), \
1161 _##NAME(always_available, glsl_type::ivec4_type), \
1163 _##NAME(v130, glsl_type::uint_type), \
1164 _##NAME(v130, glsl_type::uvec2_type), \
1165 _##NAME(v130, glsl_type::uvec3_type), \
1166 _##NAME(v130, glsl_type::uvec4_type), \
1167 _##NAME(fp64, glsl_type::double_type), \
1168 _##NAME(fp64, glsl_type::dvec2_type), \
1169 _##NAME(fp64, glsl_type::dvec3_type), \
1170 _##NAME(fp64, glsl_type::dvec4_type), \
1174 add_function(#NAME, \
1175 _##NAME(glsl_type::int_type), \
1176 _##NAME(glsl_type::ivec2_type), \
1177 _##NAME(glsl_type::ivec3_type), \
1178 _##NAME(glsl_type::ivec4_type), \
1180 _##NAME(glsl_type::uint_type), \
1181 _##NAME(glsl_type::uvec2_type), \
1182 _##NAME(glsl_type::uvec3_type), \
1183 _##NAME(glsl_type::uvec4_type), \
1186 #define FIUBD(NAME) \
1187 add_function(#NAME, \
1188 _##NAME(always_available, glsl_type::float_type), \
1189 _##NAME(always_available, glsl_type::vec2_type), \
1190 _##NAME(always_available, glsl_type::vec3_type), \
1191 _##NAME(always_available, glsl_type::vec4_type), \
1193 _##NAME(always_available, glsl_type::int_type), \
1194 _##NAME(always_available, glsl_type::ivec2_type), \
1195 _##NAME(always_available, glsl_type::ivec3_type), \
1196 _##NAME(always_available, glsl_type::ivec4_type), \
1198 _##NAME(v130, glsl_type::uint_type), \
1199 _##NAME(v130, glsl_type::uvec2_type), \
1200 _##NAME(v130, glsl_type::uvec3_type), \
1201 _##NAME(v130, glsl_type::uvec4_type), \
1203 _##NAME(always_available, glsl_type::bool_type), \
1204 _##NAME(always_available, glsl_type::bvec2_type), \
1205 _##NAME(always_available, glsl_type::bvec3_type), \
1206 _##NAME(always_available, glsl_type::bvec4_type), \
1208 _##NAME(fp64, glsl_type::double_type), \
1209 _##NAME(fp64, glsl_type::dvec2_type), \
1210 _##NAME(fp64, glsl_type::dvec3_type), \
1211 _##NAME(fp64, glsl_type::dvec4_type), \
1214 #define FIUD2_MIXED(NAME) \
1215 add_function(#NAME, \
1216 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
1217 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
1218 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
1219 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
1221 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
1222 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
1223 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
1225 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
1226 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
1227 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
1228 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
1230 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
1231 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
1232 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
1234 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
1235 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
1236 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
1237 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
1239 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
1240 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
1241 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
1243 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \
1244 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \
1245 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \
1246 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \
1247 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \
1248 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \
1249 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \
1260 add_function("atan",
1261 _atan(glsl_type::float_type
),
1262 _atan(glsl_type::vec2_type
),
1263 _atan(glsl_type::vec3_type
),
1264 _atan(glsl_type::vec4_type
),
1265 _atan2(glsl_type::float_type
),
1266 _atan2(glsl_type::vec2_type
),
1267 _atan2(glsl_type::vec3_type
),
1268 _atan2(glsl_type::vec4_type
),
1294 _mod(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1295 _mod(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1296 _mod(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1297 _mod(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1299 _mod(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1300 _mod(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1301 _mod(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1303 _mod(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1304 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1305 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1306 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1308 _mod(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1309 _mod(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1310 _mod(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1320 _mix_lrp(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1321 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::float_type
),
1322 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::float_type
),
1323 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::float_type
),
1325 _mix_lrp(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1326 _mix_lrp(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1327 _mix_lrp(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1329 _mix_lrp(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1330 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::double_type
),
1331 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::double_type
),
1332 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::double_type
),
1334 _mix_lrp(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1335 _mix_lrp(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1336 _mix_lrp(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1338 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
1339 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
1340 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
1341 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
1343 _mix_sel(fp64
, glsl_type::double_type
, glsl_type::bool_type
),
1344 _mix_sel(fp64
, glsl_type::dvec2_type
, glsl_type::bvec2_type
),
1345 _mix_sel(fp64
, glsl_type::dvec3_type
, glsl_type::bvec3_type
),
1346 _mix_sel(fp64
, glsl_type::dvec4_type
, glsl_type::bvec4_type
),
1348 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
1349 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
1350 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
1351 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
1353 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
1354 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
1355 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
1356 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
1358 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
1359 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
1360 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
1361 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
1364 add_function("step",
1365 _step(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1366 _step(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1367 _step(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1368 _step(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1370 _step(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1371 _step(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1372 _step(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1373 _step(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1374 _step(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1375 _step(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1376 _step(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1378 _step(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1379 _step(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1380 _step(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1383 add_function("smoothstep",
1384 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::float_type
),
1385 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec2_type
),
1386 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec3_type
),
1387 _smoothstep(always_available
, glsl_type::float_type
, glsl_type::vec4_type
),
1389 _smoothstep(always_available
, glsl_type::vec2_type
, glsl_type::vec2_type
),
1390 _smoothstep(always_available
, glsl_type::vec3_type
, glsl_type::vec3_type
),
1391 _smoothstep(always_available
, glsl_type::vec4_type
, glsl_type::vec4_type
),
1392 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::double_type
),
1393 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec2_type
),
1394 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec3_type
),
1395 _smoothstep(fp64
, glsl_type::double_type
, glsl_type::dvec4_type
),
1397 _smoothstep(fp64
, glsl_type::dvec2_type
, glsl_type::dvec2_type
),
1398 _smoothstep(fp64
, glsl_type::dvec3_type
, glsl_type::dvec3_type
),
1399 _smoothstep(fp64
, glsl_type::dvec4_type
, glsl_type::dvec4_type
),
1407 add_function("intBitsToFloat",
1408 _intBitsToFloat(glsl_type::int_type
),
1409 _intBitsToFloat(glsl_type::ivec2_type
),
1410 _intBitsToFloat(glsl_type::ivec3_type
),
1411 _intBitsToFloat(glsl_type::ivec4_type
),
1413 add_function("uintBitsToFloat",
1414 _uintBitsToFloat(glsl_type::uint_type
),
1415 _uintBitsToFloat(glsl_type::uvec2_type
),
1416 _uintBitsToFloat(glsl_type::uvec3_type
),
1417 _uintBitsToFloat(glsl_type::uvec4_type
),
1420 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1421 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
1422 add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1423 add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1424 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5
), NULL
);
1425 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
1426 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1427 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5
), NULL
);
1428 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
1429 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
1430 add_function("packDouble2x32", _packDouble2x32(fp64
), NULL
);
1431 add_function("unpackDouble2x32", _unpackDouble2x32(fp64
), NULL
);
1438 add_function("cross", _cross(always_available
, glsl_type::vec3_type
),
1439 _cross(fp64
, glsl_type::dvec3_type
), NULL
);
1442 add_function("ftransform", _ftransform(), NULL
);
1447 add_function("matrixCompMult",
1448 _matrixCompMult(always_available
, glsl_type::mat2_type
),
1449 _matrixCompMult(always_available
, glsl_type::mat3_type
),
1450 _matrixCompMult(always_available
, glsl_type::mat4_type
),
1451 _matrixCompMult(always_available
, glsl_type::mat2x3_type
),
1452 _matrixCompMult(always_available
, glsl_type::mat2x4_type
),
1453 _matrixCompMult(always_available
, glsl_type::mat3x2_type
),
1454 _matrixCompMult(always_available
, glsl_type::mat3x4_type
),
1455 _matrixCompMult(always_available
, glsl_type::mat4x2_type
),
1456 _matrixCompMult(always_available
, glsl_type::mat4x3_type
),
1457 _matrixCompMult(fp64
, glsl_type::dmat2_type
),
1458 _matrixCompMult(fp64
, glsl_type::dmat3_type
),
1459 _matrixCompMult(fp64
, glsl_type::dmat4_type
),
1460 _matrixCompMult(fp64
, glsl_type::dmat2x3_type
),
1461 _matrixCompMult(fp64
, glsl_type::dmat2x4_type
),
1462 _matrixCompMult(fp64
, glsl_type::dmat3x2_type
),
1463 _matrixCompMult(fp64
, glsl_type::dmat3x4_type
),
1464 _matrixCompMult(fp64
, glsl_type::dmat4x2_type
),
1465 _matrixCompMult(fp64
, glsl_type::dmat4x3_type
),
1467 add_function("outerProduct",
1468 _outerProduct(v120
, glsl_type::mat2_type
),
1469 _outerProduct(v120
, glsl_type::mat3_type
),
1470 _outerProduct(v120
, glsl_type::mat4_type
),
1471 _outerProduct(v120
, glsl_type::mat2x3_type
),
1472 _outerProduct(v120
, glsl_type::mat2x4_type
),
1473 _outerProduct(v120
, glsl_type::mat3x2_type
),
1474 _outerProduct(v120
, glsl_type::mat3x4_type
),
1475 _outerProduct(v120
, glsl_type::mat4x2_type
),
1476 _outerProduct(v120
, glsl_type::mat4x3_type
),
1477 _outerProduct(fp64
, glsl_type::dmat2_type
),
1478 _outerProduct(fp64
, glsl_type::dmat3_type
),
1479 _outerProduct(fp64
, glsl_type::dmat4_type
),
1480 _outerProduct(fp64
, glsl_type::dmat2x3_type
),
1481 _outerProduct(fp64
, glsl_type::dmat2x4_type
),
1482 _outerProduct(fp64
, glsl_type::dmat3x2_type
),
1483 _outerProduct(fp64
, glsl_type::dmat3x4_type
),
1484 _outerProduct(fp64
, glsl_type::dmat4x2_type
),
1485 _outerProduct(fp64
, glsl_type::dmat4x3_type
),
1487 add_function("determinant",
1488 _determinant_mat2(v120
, glsl_type::mat2_type
),
1489 _determinant_mat3(v120
, glsl_type::mat3_type
),
1490 _determinant_mat4(v120
, glsl_type::mat4_type
),
1491 _determinant_mat2(fp64
, glsl_type::dmat2_type
),
1492 _determinant_mat3(fp64
, glsl_type::dmat3_type
),
1493 _determinant_mat4(fp64
, glsl_type::dmat4_type
),
1496 add_function("inverse",
1497 _inverse_mat2(v140_or_es3
, glsl_type::mat2_type
),
1498 _inverse_mat3(v140_or_es3
, glsl_type::mat3_type
),
1499 _inverse_mat4(v140_or_es3
, glsl_type::mat4_type
),
1500 _inverse_mat2(fp64
, glsl_type::dmat2_type
),
1501 _inverse_mat3(fp64
, glsl_type::dmat3_type
),
1502 _inverse_mat4(fp64
, glsl_type::dmat4_type
),
1504 add_function("transpose",
1505 _transpose(v120
, glsl_type::mat2_type
),
1506 _transpose(v120
, glsl_type::mat3_type
),
1507 _transpose(v120
, glsl_type::mat4_type
),
1508 _transpose(v120
, glsl_type::mat2x3_type
),
1509 _transpose(v120
, glsl_type::mat2x4_type
),
1510 _transpose(v120
, glsl_type::mat3x2_type
),
1511 _transpose(v120
, glsl_type::mat3x4_type
),
1512 _transpose(v120
, glsl_type::mat4x2_type
),
1513 _transpose(v120
, glsl_type::mat4x3_type
),
1514 _transpose(fp64
, glsl_type::dmat2_type
),
1515 _transpose(fp64
, glsl_type::dmat3_type
),
1516 _transpose(fp64
, glsl_type::dmat4_type
),
1517 _transpose(fp64
, glsl_type::dmat2x3_type
),
1518 _transpose(fp64
, glsl_type::dmat2x4_type
),
1519 _transpose(fp64
, glsl_type::dmat3x2_type
),
1520 _transpose(fp64
, glsl_type::dmat3x4_type
),
1521 _transpose(fp64
, glsl_type::dmat4x2_type
),
1522 _transpose(fp64
, glsl_type::dmat4x3_type
),
1527 FIUD(greaterThanEqual
)
1532 _any(glsl_type::bvec2_type
),
1533 _any(glsl_type::bvec3_type
),
1534 _any(glsl_type::bvec4_type
),
1538 _all(glsl_type::bvec2_type
),
1539 _all(glsl_type::bvec3_type
),
1540 _all(glsl_type::bvec4_type
),
1544 _not(glsl_type::bvec2_type
),
1545 _not(glsl_type::bvec3_type
),
1546 _not(glsl_type::bvec4_type
),
1549 add_function("textureSize",
1550 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
1551 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
1552 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
1554 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
1555 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
1556 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
1558 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
1559 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
1560 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
1562 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
1563 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
1564 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
1566 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
1567 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
1568 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1570 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1571 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1572 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1573 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1574 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1575 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1577 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1578 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1580 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1581 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1582 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1583 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1585 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1586 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1587 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1588 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1590 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1591 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1592 _textureSize(texture_buffer
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1593 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1594 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1595 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1597 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1598 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1599 _textureSize(texture_multisample_array
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1602 add_function("textureSamples",
1603 _textureSamples(glsl_type::sampler2DMS_type
),
1604 _textureSamples(glsl_type::isampler2DMS_type
),
1605 _textureSamples(glsl_type::usampler2DMS_type
),
1607 _textureSamples(glsl_type::sampler2DMSArray_type
),
1608 _textureSamples(glsl_type::isampler2DMSArray_type
),
1609 _textureSamples(glsl_type::usampler2DMSArray_type
),
1612 add_function("texture",
1613 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1614 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1615 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1617 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1618 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1619 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1621 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1622 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1623 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1625 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1626 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1627 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1629 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1630 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1631 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1633 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1634 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1635 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1637 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1638 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1639 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1641 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1642 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1643 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1645 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1646 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1647 /* samplerCubeArrayShadow is special; it has an extra parameter
1648 * for the shadow comparitor since there is no vec5 type.
1650 _textureCubeArrayShadow(),
1652 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1653 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1654 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1656 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1658 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1659 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1660 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1662 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1663 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1664 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1666 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1667 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1668 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1670 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1671 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1672 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1674 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1675 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1676 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1678 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1679 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1680 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1682 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1683 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1684 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1686 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1687 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1688 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1690 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1693 add_function("textureLod",
1694 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1695 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1696 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1698 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1699 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1700 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1702 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1703 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1704 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1706 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1707 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1708 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1710 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1711 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1713 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1714 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1715 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1717 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1718 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1719 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1721 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1722 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1723 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1725 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1728 add_function("textureOffset",
1729 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1730 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1731 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1733 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1734 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1735 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1737 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1738 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1739 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1741 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1742 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1743 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1745 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1747 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1748 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1750 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1751 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1752 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1754 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1755 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1756 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1758 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1759 /* The next one was forgotten in GLSL 1.30 spec. It's from
1760 * EXT_gpu_shader4 originally. It was added in 4.30 with the
1761 * wrong syntax. This was corrected in 4.40. 4.30 indicates
1762 * that it was intended to be included previously, so allow it
1765 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1767 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1768 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1769 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1771 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1772 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1773 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1775 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1776 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1777 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1779 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1780 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1782 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1783 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1784 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1786 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1787 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1788 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1790 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1793 add_function("textureProj",
1794 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1795 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1796 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1797 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1798 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1799 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1801 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1802 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1803 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1804 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1805 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1806 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1808 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1809 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1810 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1812 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1813 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1815 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1816 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1817 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1818 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1819 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1820 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1822 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1824 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1825 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1826 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1827 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1828 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1829 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1831 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1832 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1833 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1834 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1835 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1836 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1838 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1839 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1840 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1842 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1843 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1846 add_function("texelFetch",
1847 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1848 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1849 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1851 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1852 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1853 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1855 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1856 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1857 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1859 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1860 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1861 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1863 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1864 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1865 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1867 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1868 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1869 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1871 _texelFetch(texture_buffer
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1872 _texelFetch(texture_buffer
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1873 _texelFetch(texture_buffer
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1875 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1876 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1877 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1879 _texelFetch(texture_multisample_array
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1880 _texelFetch(texture_multisample_array
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1881 _texelFetch(texture_multisample_array
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1884 add_function("texelFetchOffset",
1885 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1886 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1887 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1889 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1890 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1891 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1893 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1894 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1895 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1897 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1898 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1899 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1901 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1902 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1903 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1905 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1906 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1907 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1911 add_function("textureProjOffset",
1912 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1913 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1914 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1915 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1916 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1917 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1919 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1920 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1921 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1922 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1923 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1924 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1926 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1927 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1928 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1930 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1931 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1933 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1934 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1935 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1936 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1937 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1938 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1940 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1942 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1943 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1944 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1945 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1946 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1947 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1949 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1950 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1951 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1952 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1953 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1954 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1956 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1957 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1958 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1960 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1961 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1964 add_function("textureLodOffset",
1965 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1966 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1967 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1969 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1970 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1971 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1973 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1974 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1975 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1977 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1978 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1980 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1981 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1982 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1984 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1985 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1986 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1988 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1991 add_function("textureProjLod",
1992 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1993 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1994 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1995 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1996 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1997 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1999 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2000 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2001 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2002 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2003 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2004 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2006 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2007 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2008 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2010 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2011 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2014 add_function("textureProjLodOffset",
2015 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2016 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2017 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2018 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2019 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2020 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2022 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2023 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2024 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2025 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2026 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2027 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2029 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2030 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2031 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2033 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2034 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2037 add_function("textureGrad",
2038 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2039 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2040 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2042 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2043 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2044 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2046 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2047 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2048 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2050 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2051 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2052 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2054 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2055 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2056 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2058 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2060 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2061 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2062 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
2064 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2065 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
2066 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
2068 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2069 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2070 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2072 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2073 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2074 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2076 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2077 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2080 add_function("textureGradOffset",
2081 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2082 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2083 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
2085 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2086 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2087 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2089 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2090 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2091 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2093 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2094 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2095 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2097 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2099 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2100 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2102 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2103 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2104 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2106 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2107 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2108 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2110 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2111 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
2114 add_function("textureProjGrad",
2115 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2116 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2117 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2118 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2119 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2120 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2122 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2123 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2124 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2125 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2126 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2127 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2129 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2130 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2131 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2133 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2134 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2135 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2136 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2137 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2138 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2140 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2142 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2143 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2146 add_function("textureProjGradOffset",
2147 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2148 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2149 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
2150 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2151 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2152 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2154 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2155 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2156 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2157 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2158 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2159 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2161 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2162 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2163 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2165 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2166 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2167 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
2168 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2169 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2170 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2172 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2174 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2175 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
2178 add_function("EmitVertex", _EmitVertex(), NULL
);
2179 add_function("EndPrimitive", _EndPrimitive(), NULL
);
2180 add_function("EmitStreamVertex",
2181 _EmitStreamVertex(gs_streams
, glsl_type::uint_type
),
2182 _EmitStreamVertex(gs_streams
, glsl_type::int_type
),
2184 add_function("EndStreamPrimitive",
2185 _EndStreamPrimitive(gs_streams
, glsl_type::uint_type
),
2186 _EndStreamPrimitive(gs_streams
, glsl_type::int_type
),
2188 add_function("barrier", _barrier(), NULL
);
2190 add_function("textureQueryLOD",
2191 _textureQueryLod(texture_query_lod
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2192 _textureQueryLod(texture_query_lod
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2193 _textureQueryLod(texture_query_lod
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2195 _textureQueryLod(texture_query_lod
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2196 _textureQueryLod(texture_query_lod
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2197 _textureQueryLod(texture_query_lod
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2199 _textureQueryLod(texture_query_lod
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2200 _textureQueryLod(texture_query_lod
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2201 _textureQueryLod(texture_query_lod
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2203 _textureQueryLod(texture_query_lod
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2204 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2205 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2207 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2208 _textureQueryLod(texture_query_lod
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2209 _textureQueryLod(texture_query_lod
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2211 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2212 _textureQueryLod(texture_query_lod
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2213 _textureQueryLod(texture_query_lod
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2215 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2216 _textureQueryLod(texture_query_lod
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2217 _textureQueryLod(texture_query_lod
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2219 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2220 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2221 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2222 _textureQueryLod(texture_query_lod
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2223 _textureQueryLod(texture_query_lod
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2224 _textureQueryLod(texture_query_lod
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2227 add_function("textureQueryLod",
2228 _textureQueryLod(v400_fs_only
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2229 _textureQueryLod(v400_fs_only
, glsl_type::isampler1D_type
, glsl_type::float_type
),
2230 _textureQueryLod(v400_fs_only
, glsl_type::usampler1D_type
, glsl_type::float_type
),
2232 _textureQueryLod(v400_fs_only
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2233 _textureQueryLod(v400_fs_only
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2234 _textureQueryLod(v400_fs_only
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2236 _textureQueryLod(v400_fs_only
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2237 _textureQueryLod(v400_fs_only
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
2238 _textureQueryLod(v400_fs_only
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
2240 _textureQueryLod(v400_fs_only
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2241 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2242 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2244 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArray_type
, glsl_type::float_type
),
2245 _textureQueryLod(v400_fs_only
, glsl_type::isampler1DArray_type
, glsl_type::float_type
),
2246 _textureQueryLod(v400_fs_only
, glsl_type::usampler1DArray_type
, glsl_type::float_type
),
2248 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
2249 _textureQueryLod(v400_fs_only
, glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
2250 _textureQueryLod(v400_fs_only
, glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
2252 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
2253 _textureQueryLod(v400_fs_only
, glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
2254 _textureQueryLod(v400_fs_only
, glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
2256 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
2257 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2258 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2259 _textureQueryLod(v400_fs_only
, glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
2260 _textureQueryLod(v400_fs_only
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
2261 _textureQueryLod(v400_fs_only
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
2264 add_function("textureQueryLevels",
2265 _textureQueryLevels(glsl_type::sampler1D_type
),
2266 _textureQueryLevels(glsl_type::sampler2D_type
),
2267 _textureQueryLevels(glsl_type::sampler3D_type
),
2268 _textureQueryLevels(glsl_type::samplerCube_type
),
2269 _textureQueryLevels(glsl_type::sampler1DArray_type
),
2270 _textureQueryLevels(glsl_type::sampler2DArray_type
),
2271 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
2272 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
2273 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
2274 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
2275 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
2276 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
2277 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
2279 _textureQueryLevels(glsl_type::isampler1D_type
),
2280 _textureQueryLevels(glsl_type::isampler2D_type
),
2281 _textureQueryLevels(glsl_type::isampler3D_type
),
2282 _textureQueryLevels(glsl_type::isamplerCube_type
),
2283 _textureQueryLevels(glsl_type::isampler1DArray_type
),
2284 _textureQueryLevels(glsl_type::isampler2DArray_type
),
2285 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
2287 _textureQueryLevels(glsl_type::usampler1D_type
),
2288 _textureQueryLevels(glsl_type::usampler2D_type
),
2289 _textureQueryLevels(glsl_type::usampler3D_type
),
2290 _textureQueryLevels(glsl_type::usamplerCube_type
),
2291 _textureQueryLevels(glsl_type::usampler1DArray_type
),
2292 _textureQueryLevels(glsl_type::usampler2DArray_type
),
2293 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
2297 add_function("textureSamplesIdenticalEXT",
2298 _textureSamplesIdentical(texture_samples_identical
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
2299 _textureSamplesIdentical(texture_samples_identical
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
2300 _textureSamplesIdentical(texture_samples_identical
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
2302 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
2303 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
2304 _textureSamplesIdentical(texture_samples_identical_array
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
2307 add_function("texture1D",
2308 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2309 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2312 add_function("texture1DArray",
2313 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2314 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2317 add_function("texture1DProj",
2318 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2319 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2320 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2321 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2324 add_function("texture1DLod",
2325 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2328 add_function("texture1DArrayLod",
2329 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
2332 add_function("texture1DProjLod",
2333 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2334 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2337 add_function("texture2D",
2338 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2339 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2340 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
2343 add_function("texture2DArray",
2344 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2345 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2348 add_function("texture2DProj",
2349 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2350 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2351 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2352 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2353 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2354 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2357 add_function("texture2DLod",
2358 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2361 add_function("texture2DArrayLod",
2362 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2365 add_function("texture2DProjLod",
2366 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2367 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2370 add_function("texture3D",
2371 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2372 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2375 add_function("texture3DProj",
2376 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2377 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2380 add_function("texture3DLod",
2381 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2384 add_function("texture3DProjLod",
2385 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2388 add_function("textureCube",
2389 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2390 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2393 add_function("textureCubeLod",
2394 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2397 add_function("texture2DRect",
2398 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2401 add_function("texture2DRectProj",
2402 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2403 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2406 add_function("shadow1D",
2407 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2408 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2411 add_function("shadow1DArray",
2412 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2413 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2416 add_function("shadow2D",
2417 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2418 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2421 add_function("shadow2DArray",
2422 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2423 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
2426 add_function("shadow1DProj",
2427 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2428 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2431 add_function("shadow2DProj",
2432 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2433 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2436 add_function("shadow1DLod",
2437 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2440 add_function("shadow2DLod",
2441 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2444 add_function("shadow1DArrayLod",
2445 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
2448 add_function("shadow1DProjLod",
2449 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2452 add_function("shadow2DProjLod",
2453 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2456 add_function("shadow2DRect",
2457 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2460 add_function("shadow2DRectProj",
2461 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2464 add_function("texture1DGradARB",
2465 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
2468 add_function("texture1DProjGradARB",
2469 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
2470 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2473 add_function("texture2DGradARB",
2474 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2477 add_function("texture2DProjGradARB",
2478 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2479 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2482 add_function("texture3DGradARB",
2483 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
2486 add_function("texture3DProjGradARB",
2487 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2490 add_function("textureCubeGradARB",
2491 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2494 add_function("shadow1DGradARB",
2495 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
2498 add_function("shadow1DProjGradARB",
2499 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2502 add_function("shadow2DGradARB",
2503 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
2506 add_function("shadow2DProjGradARB",
2507 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2510 add_function("texture2DRectGradARB",
2511 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2514 add_function("texture2DRectProjGradARB",
2515 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
2516 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2519 add_function("shadow2DRectGradARB",
2520 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
2523 add_function("shadow2DRectProjGradARB",
2524 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
2527 add_function("textureGather",
2528 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
2529 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
2530 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
2532 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
2533 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
2534 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
2536 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
2537 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
2538 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
2540 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
2541 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
2542 _texture(ir_tg4
, texture_gather_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
2544 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
2545 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
2546 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
2548 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2549 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2550 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2552 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2553 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2554 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
2556 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2557 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2558 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2560 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2561 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2562 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
2564 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2565 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2566 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
2568 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
2569 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
2570 _texture(ir_tg4
, gpu_shader5_or_es31
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
2571 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
2572 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
2575 add_function("textureGatherOffset",
2576 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2577 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2578 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2580 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2581 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2582 _texture(ir_tg4
, texture_gather_only_or_es31
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2584 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2585 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2586 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
| TEX_COMPONENT
),
2588 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2589 _texture(ir_tg4
, es31_not_gs5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2590 _texture(ir_tg4
, es31_not_gs5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
| TEX_COMPONENT
),
2592 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2593 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2594 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2596 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2597 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2598 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2600 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2601 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2602 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2604 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2605 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2606 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2608 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2609 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2610 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2612 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2613 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2614 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
2616 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2617 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
2618 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
2620 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET
),
2621 _texture(ir_tg4
, es31_not_gs5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
2624 add_function("textureGatherOffsets",
2625 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2626 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2627 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2629 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2630 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2631 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2633 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2634 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2635 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2637 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2638 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2639 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2641 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2642 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2643 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2645 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2646 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2647 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
| TEX_COMPONENT
),
2649 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2650 _texture(ir_tg4
, gpu_shader5_es
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_ARRAY
),
2651 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_ARRAY
),
2676 add_function("ldexp",
2677 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
2678 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2679 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2680 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2681 _ldexp(glsl_type::double_type
, glsl_type::int_type
),
2682 _ldexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2683 _ldexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2684 _ldexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2687 add_function("frexp",
2688 _frexp(glsl_type::float_type
, glsl_type::int_type
),
2689 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
2690 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
2691 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
2692 _dfrexp(glsl_type::double_type
, glsl_type::int_type
),
2693 _dfrexp(glsl_type::dvec2_type
, glsl_type::ivec2_type
),
2694 _dfrexp(glsl_type::dvec3_type
, glsl_type::ivec3_type
),
2695 _dfrexp(glsl_type::dvec4_type
, glsl_type::ivec4_type
),
2697 add_function("uaddCarry",
2698 _uaddCarry(glsl_type::uint_type
),
2699 _uaddCarry(glsl_type::uvec2_type
),
2700 _uaddCarry(glsl_type::uvec3_type
),
2701 _uaddCarry(glsl_type::uvec4_type
),
2703 add_function("usubBorrow",
2704 _usubBorrow(glsl_type::uint_type
),
2705 _usubBorrow(glsl_type::uvec2_type
),
2706 _usubBorrow(glsl_type::uvec3_type
),
2707 _usubBorrow(glsl_type::uvec4_type
),
2709 add_function("imulExtended",
2710 _mulExtended(glsl_type::int_type
),
2711 _mulExtended(glsl_type::ivec2_type
),
2712 _mulExtended(glsl_type::ivec3_type
),
2713 _mulExtended(glsl_type::ivec4_type
),
2715 add_function("umulExtended",
2716 _mulExtended(glsl_type::uint_type
),
2717 _mulExtended(glsl_type::uvec2_type
),
2718 _mulExtended(glsl_type::uvec3_type
),
2719 _mulExtended(glsl_type::uvec4_type
),
2721 add_function("interpolateAtCentroid",
2722 _interpolateAtCentroid(glsl_type::float_type
),
2723 _interpolateAtCentroid(glsl_type::vec2_type
),
2724 _interpolateAtCentroid(glsl_type::vec3_type
),
2725 _interpolateAtCentroid(glsl_type::vec4_type
),
2727 add_function("interpolateAtOffset",
2728 _interpolateAtOffset(glsl_type::float_type
),
2729 _interpolateAtOffset(glsl_type::vec2_type
),
2730 _interpolateAtOffset(glsl_type::vec3_type
),
2731 _interpolateAtOffset(glsl_type::vec4_type
),
2733 add_function("interpolateAtSample",
2734 _interpolateAtSample(glsl_type::float_type
),
2735 _interpolateAtSample(glsl_type::vec2_type
),
2736 _interpolateAtSample(glsl_type::vec3_type
),
2737 _interpolateAtSample(glsl_type::vec4_type
),
2740 add_function("atomicCounter",
2741 _atomic_counter_op("__intrinsic_atomic_read",
2742 shader_atomic_counters
),
2744 add_function("atomicCounterIncrement",
2745 _atomic_counter_op("__intrinsic_atomic_increment",
2746 shader_atomic_counters
),
2748 add_function("atomicCounterDecrement",
2749 _atomic_counter_op("__intrinsic_atomic_predecrement",
2750 shader_atomic_counters
),
2753 add_function("atomicCounterAddARB",
2754 _atomic_counter_op1("__intrinsic_atomic_add",
2755 shader_atomic_counter_ops
),
2757 add_function("atomicCounterSubtractARB",
2758 _atomic_counter_op1("__intrinsic_atomic_sub",
2759 shader_atomic_counter_ops
),
2761 add_function("atomicCounterMinARB",
2762 _atomic_counter_op1("__intrinsic_atomic_min",
2763 shader_atomic_counter_ops
),
2765 add_function("atomicCounterMaxARB",
2766 _atomic_counter_op1("__intrinsic_atomic_max",
2767 shader_atomic_counter_ops
),
2769 add_function("atomicCounterAndARB",
2770 _atomic_counter_op1("__intrinsic_atomic_and",
2771 shader_atomic_counter_ops
),
2773 add_function("atomicCounterOrARB",
2774 _atomic_counter_op1("__intrinsic_atomic_or",
2775 shader_atomic_counter_ops
),
2777 add_function("atomicCounterXorARB",
2778 _atomic_counter_op1("__intrinsic_atomic_xor",
2779 shader_atomic_counter_ops
),
2781 add_function("atomicCounterExchangeARB",
2782 _atomic_counter_op1("__intrinsic_atomic_exchange",
2783 shader_atomic_counter_ops
),
2785 add_function("atomicCounterCompSwapARB",
2786 _atomic_counter_op2("__intrinsic_atomic_comp_swap",
2787 shader_atomic_counter_ops
),
2790 add_function("atomicAdd",
2791 _atomic_op2("__intrinsic_atomic_add",
2792 buffer_atomics_supported
,
2793 glsl_type::uint_type
),
2794 _atomic_op2("__intrinsic_atomic_add",
2795 buffer_atomics_supported
,
2796 glsl_type::int_type
),
2798 add_function("atomicMin",
2799 _atomic_op2("__intrinsic_atomic_min",
2800 buffer_atomics_supported
,
2801 glsl_type::uint_type
),
2802 _atomic_op2("__intrinsic_atomic_min",
2803 buffer_atomics_supported
,
2804 glsl_type::int_type
),
2806 add_function("atomicMax",
2807 _atomic_op2("__intrinsic_atomic_max",
2808 buffer_atomics_supported
,
2809 glsl_type::uint_type
),
2810 _atomic_op2("__intrinsic_atomic_max",
2811 buffer_atomics_supported
,
2812 glsl_type::int_type
),
2814 add_function("atomicAnd",
2815 _atomic_op2("__intrinsic_atomic_and",
2816 buffer_atomics_supported
,
2817 glsl_type::uint_type
),
2818 _atomic_op2("__intrinsic_atomic_and",
2819 buffer_atomics_supported
,
2820 glsl_type::int_type
),
2822 add_function("atomicOr",
2823 _atomic_op2("__intrinsic_atomic_or",
2824 buffer_atomics_supported
,
2825 glsl_type::uint_type
),
2826 _atomic_op2("__intrinsic_atomic_or",
2827 buffer_atomics_supported
,
2828 glsl_type::int_type
),
2830 add_function("atomicXor",
2831 _atomic_op2("__intrinsic_atomic_xor",
2832 buffer_atomics_supported
,
2833 glsl_type::uint_type
),
2834 _atomic_op2("__intrinsic_atomic_xor",
2835 buffer_atomics_supported
,
2836 glsl_type::int_type
),
2838 add_function("atomicExchange",
2839 _atomic_op2("__intrinsic_atomic_exchange",
2840 buffer_atomics_supported
,
2841 glsl_type::uint_type
),
2842 _atomic_op2("__intrinsic_atomic_exchange",
2843 buffer_atomics_supported
,
2844 glsl_type::int_type
),
2846 add_function("atomicCompSwap",
2847 _atomic_op3("__intrinsic_atomic_comp_swap",
2848 buffer_atomics_supported
,
2849 glsl_type::uint_type
),
2850 _atomic_op3("__intrinsic_atomic_comp_swap",
2851 buffer_atomics_supported
,
2852 glsl_type::int_type
),
2855 add_function("min3",
2856 _min3(glsl_type::float_type
),
2857 _min3(glsl_type::vec2_type
),
2858 _min3(glsl_type::vec3_type
),
2859 _min3(glsl_type::vec4_type
),
2861 _min3(glsl_type::int_type
),
2862 _min3(glsl_type::ivec2_type
),
2863 _min3(glsl_type::ivec3_type
),
2864 _min3(glsl_type::ivec4_type
),
2866 _min3(glsl_type::uint_type
),
2867 _min3(glsl_type::uvec2_type
),
2868 _min3(glsl_type::uvec3_type
),
2869 _min3(glsl_type::uvec4_type
),
2872 add_function("max3",
2873 _max3(glsl_type::float_type
),
2874 _max3(glsl_type::vec2_type
),
2875 _max3(glsl_type::vec3_type
),
2876 _max3(glsl_type::vec4_type
),
2878 _max3(glsl_type::int_type
),
2879 _max3(glsl_type::ivec2_type
),
2880 _max3(glsl_type::ivec3_type
),
2881 _max3(glsl_type::ivec4_type
),
2883 _max3(glsl_type::uint_type
),
2884 _max3(glsl_type::uvec2_type
),
2885 _max3(glsl_type::uvec3_type
),
2886 _max3(glsl_type::uvec4_type
),
2889 add_function("mid3",
2890 _mid3(glsl_type::float_type
),
2891 _mid3(glsl_type::vec2_type
),
2892 _mid3(glsl_type::vec3_type
),
2893 _mid3(glsl_type::vec4_type
),
2895 _mid3(glsl_type::int_type
),
2896 _mid3(glsl_type::ivec2_type
),
2897 _mid3(glsl_type::ivec3_type
),
2898 _mid3(glsl_type::ivec4_type
),
2900 _mid3(glsl_type::uint_type
),
2901 _mid3(glsl_type::uvec2_type
),
2902 _mid3(glsl_type::uvec3_type
),
2903 _mid3(glsl_type::uvec4_type
),
2906 add_image_functions(true);
2908 add_function("memoryBarrier",
2909 _memory_barrier("__intrinsic_memory_barrier",
2910 shader_image_load_store
),
2912 add_function("groupMemoryBarrier",
2913 _memory_barrier("__intrinsic_group_memory_barrier",
2916 add_function("memoryBarrierAtomicCounter",
2917 _memory_barrier("__intrinsic_memory_barrier_atomic_counter",
2920 add_function("memoryBarrierBuffer",
2921 _memory_barrier("__intrinsic_memory_barrier_buffer",
2924 add_function("memoryBarrierImage",
2925 _memory_barrier("__intrinsic_memory_barrier_image",
2928 add_function("memoryBarrierShared",
2929 _memory_barrier("__intrinsic_memory_barrier_shared",
2933 add_function("clock2x32ARB",
2934 _shader_clock(shader_clock
,
2935 glsl_type::uvec2_type
),
2946 builtin_builder::add_function(const char *name
, ...)
2950 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2954 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2960 stuff
.push_tail(sig
);
2961 validate_ir_tree(&stuff
);
2964 f
->add_signature(sig
);
2968 shader
->symbols
->add_function(f
);
2972 builtin_builder::add_image_function(const char *name
,
2973 const char *intrinsic_name
,
2974 image_prototype_ctr prototype
,
2975 unsigned num_arguments
,
2978 static const glsl_type
*const types
[] = {
2979 glsl_type::image1D_type
,
2980 glsl_type::image2D_type
,
2981 glsl_type::image3D_type
,
2982 glsl_type::image2DRect_type
,
2983 glsl_type::imageCube_type
,
2984 glsl_type::imageBuffer_type
,
2985 glsl_type::image1DArray_type
,
2986 glsl_type::image2DArray_type
,
2987 glsl_type::imageCubeArray_type
,
2988 glsl_type::image2DMS_type
,
2989 glsl_type::image2DMSArray_type
,
2990 glsl_type::iimage1D_type
,
2991 glsl_type::iimage2D_type
,
2992 glsl_type::iimage3D_type
,
2993 glsl_type::iimage2DRect_type
,
2994 glsl_type::iimageCube_type
,
2995 glsl_type::iimageBuffer_type
,
2996 glsl_type::iimage1DArray_type
,
2997 glsl_type::iimage2DArray_type
,
2998 glsl_type::iimageCubeArray_type
,
2999 glsl_type::iimage2DMS_type
,
3000 glsl_type::iimage2DMSArray_type
,
3001 glsl_type::uimage1D_type
,
3002 glsl_type::uimage2D_type
,
3003 glsl_type::uimage3D_type
,
3004 glsl_type::uimage2DRect_type
,
3005 glsl_type::uimageCube_type
,
3006 glsl_type::uimageBuffer_type
,
3007 glsl_type::uimage1DArray_type
,
3008 glsl_type::uimage2DArray_type
,
3009 glsl_type::uimageCubeArray_type
,
3010 glsl_type::uimage2DMS_type
,
3011 glsl_type::uimage2DMSArray_type
3014 ir_function
*f
= new(mem_ctx
) ir_function(name
);
3016 for (unsigned i
= 0; i
< ARRAY_SIZE(types
); ++i
) {
3017 if ((types
[i
]->sampled_type
!= GLSL_TYPE_FLOAT
||
3018 (flags
& IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
)) &&
3019 (types
[i
]->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
||
3020 !(flags
& IMAGE_FUNCTION_MS_ONLY
)))
3021 f
->add_signature(_image(prototype
, types
[i
], intrinsic_name
,
3022 num_arguments
, flags
));
3025 shader
->symbols
->add_function(f
);
3029 builtin_builder::add_image_functions(bool glsl
)
3031 const unsigned flags
= (glsl
? IMAGE_FUNCTION_EMIT_STUB
: 0);
3033 add_image_function(glsl
? "imageLoad" : "__intrinsic_image_load",
3034 "__intrinsic_image_load",
3035 &builtin_builder::_image_prototype
, 0,
3036 (flags
| IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3037 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3038 IMAGE_FUNCTION_READ_ONLY
));
3040 add_image_function(glsl
? "imageStore" : "__intrinsic_image_store",
3041 "__intrinsic_image_store",
3042 &builtin_builder::_image_prototype
, 1,
3043 (flags
| IMAGE_FUNCTION_RETURNS_VOID
|
3044 IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
|
3045 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3046 IMAGE_FUNCTION_WRITE_ONLY
));
3048 const unsigned atom_flags
= flags
| IMAGE_FUNCTION_AVAIL_ATOMIC
;
3050 add_image_function(glsl
? "imageAtomicAdd" : "__intrinsic_image_atomic_add",
3051 "__intrinsic_image_atomic_add",
3052 &builtin_builder::_image_prototype
, 1, atom_flags
);
3054 add_image_function(glsl
? "imageAtomicMin" : "__intrinsic_image_atomic_min",
3055 "__intrinsic_image_atomic_min",
3056 &builtin_builder::_image_prototype
, 1, atom_flags
);
3058 add_image_function(glsl
? "imageAtomicMax" : "__intrinsic_image_atomic_max",
3059 "__intrinsic_image_atomic_max",
3060 &builtin_builder::_image_prototype
, 1, atom_flags
);
3062 add_image_function(glsl
? "imageAtomicAnd" : "__intrinsic_image_atomic_and",
3063 "__intrinsic_image_atomic_and",
3064 &builtin_builder::_image_prototype
, 1, atom_flags
);
3066 add_image_function(glsl
? "imageAtomicOr" : "__intrinsic_image_atomic_or",
3067 "__intrinsic_image_atomic_or",
3068 &builtin_builder::_image_prototype
, 1, atom_flags
);
3070 add_image_function(glsl
? "imageAtomicXor" : "__intrinsic_image_atomic_xor",
3071 "__intrinsic_image_atomic_xor",
3072 &builtin_builder::_image_prototype
, 1, atom_flags
);
3074 add_image_function((glsl
? "imageAtomicExchange" :
3075 "__intrinsic_image_atomic_exchange"),
3076 "__intrinsic_image_atomic_exchange",
3077 &builtin_builder::_image_prototype
, 1,
3078 (flags
| IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
3079 IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
));
3081 add_image_function((glsl
? "imageAtomicCompSwap" :
3082 "__intrinsic_image_atomic_comp_swap"),
3083 "__intrinsic_image_atomic_comp_swap",
3084 &builtin_builder::_image_prototype
, 2, atom_flags
);
3086 add_image_function(glsl
? "imageSize" : "__intrinsic_image_size",
3087 "__intrinsic_image_size",
3088 &builtin_builder::_image_size_prototype
, 1,
3089 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
);
3091 add_image_function(glsl
? "imageSamples" : "__intrinsic_image_samples",
3092 "__intrinsic_image_samples",
3093 &builtin_builder::_image_samples_prototype
, 1,
3094 flags
| IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE
|
3095 IMAGE_FUNCTION_MS_ONLY
);
3099 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
3101 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
3105 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
3107 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
3111 builtin_builder::imm(bool b
, unsigned vector_elements
)
3113 return new(mem_ctx
) ir_constant(b
, vector_elements
);
3117 builtin_builder::imm(float f
, unsigned vector_elements
)
3119 return new(mem_ctx
) ir_constant(f
, vector_elements
);
3123 builtin_builder::imm(int i
, unsigned vector_elements
)
3125 return new(mem_ctx
) ir_constant(i
, vector_elements
);
3129 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
3131 return new(mem_ctx
) ir_constant(u
, vector_elements
);
3135 builtin_builder::imm(double d
, unsigned vector_elements
)
3137 return new(mem_ctx
) ir_constant(d
, vector_elements
);
3141 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
3143 return new(mem_ctx
) ir_constant(type
, &data
);
3146 #define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val)
3148 ir_dereference_variable
*
3149 builtin_builder::var_ref(ir_variable
*var
)
3151 return new(mem_ctx
) ir_dereference_variable(var
);
3154 ir_dereference_array
*
3155 builtin_builder::array_ref(ir_variable
*var
, int idx
)
3157 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
3160 /** Return an element of a matrix */
3162 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
3164 return swizzle(array_ref(var
, column
), row
, 1);
3168 * Implementations of built-in functions:
3171 ir_function_signature
*
3172 builtin_builder::new_sig(const glsl_type
*return_type
,
3173 builtin_available_predicate avail
,
3179 ir_function_signature
*sig
=
3180 new(mem_ctx
) ir_function_signature(return_type
, avail
);
3183 va_start(ap
, num_params
);
3184 for (int i
= 0; i
< num_params
; i
++) {
3185 plist
.push_tail(va_arg(ap
, ir_variable
*));
3189 sig
->replace_parameters(&plist
);
3193 #define MAKE_SIG(return_type, avail, ...) \
3194 ir_function_signature *sig = \
3195 new_sig(return_type, avail, __VA_ARGS__); \
3196 ir_factory body(&sig->body, mem_ctx); \
3197 sig->is_defined = true;
3199 #define MAKE_INTRINSIC(return_type, avail, ...) \
3200 ir_function_signature *sig = \
3201 new_sig(return_type, avail, __VA_ARGS__); \
3202 sig->is_intrinsic = true;
3204 ir_function_signature
*
3205 builtin_builder::unop(builtin_available_predicate avail
,
3206 ir_expression_operation opcode
,
3207 const glsl_type
*return_type
,
3208 const glsl_type
*param_type
)
3210 ir_variable
*x
= in_var(param_type
, "x");
3211 MAKE_SIG(return_type
, avail
, 1, x
);
3212 body
.emit(ret(expr(opcode
, x
)));
3216 #define UNOP(NAME, OPCODE, AVAIL) \
3217 ir_function_signature * \
3218 builtin_builder::_##NAME(const glsl_type *type) \
3220 return unop(&AVAIL, OPCODE, type, type); \
3223 #define UNOPA(NAME, OPCODE) \
3224 ir_function_signature * \
3225 builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \
3227 return unop(avail, OPCODE, type, type); \
3230 ir_function_signature
*
3231 builtin_builder::binop(builtin_available_predicate avail
,
3232 ir_expression_operation opcode
,
3233 const glsl_type
*return_type
,
3234 const glsl_type
*param0_type
,
3235 const glsl_type
*param1_type
)
3237 ir_variable
*x
= in_var(param0_type
, "x");
3238 ir_variable
*y
= in_var(param1_type
, "y");
3239 MAKE_SIG(return_type
, avail
, 2, x
, y
);
3240 body
.emit(ret(expr(opcode
, x
, y
)));
3244 #define BINOP(NAME, OPCODE, AVAIL) \
3245 ir_function_signature * \
3246 builtin_builder::_##NAME(const glsl_type *return_type, \
3247 const glsl_type *param0_type, \
3248 const glsl_type *param1_type) \
3250 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
3254 * Angle and Trigonometry Functions @{
3257 ir_function_signature
*
3258 builtin_builder::_radians(const glsl_type
*type
)
3260 ir_variable
*degrees
= in_var(type
, "degrees");
3261 MAKE_SIG(type
, always_available
, 1, degrees
);
3262 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
3266 ir_function_signature
*
3267 builtin_builder::_degrees(const glsl_type
*type
)
3269 ir_variable
*radians
= in_var(type
, "radians");
3270 MAKE_SIG(type
, always_available
, 1, radians
);
3271 body
.emit(ret(mul(radians
, imm(57.29578f
))));
3275 UNOP(sin
, ir_unop_sin
, always_available
)
3276 UNOP(cos
, ir_unop_cos
, always_available
)
3278 ir_function_signature
*
3279 builtin_builder::_tan(const glsl_type
*type
)
3281 ir_variable
*theta
= in_var(type
, "theta");
3282 MAKE_SIG(type
, always_available
, 1, theta
);
3283 body
.emit(ret(div(sin(theta
), cos(theta
))));
3288 builtin_builder::asin_expr(ir_variable
*x
, float p0
, float p1
)
3292 mul(sqrt(sub(imm(1.0f
), abs(x
))),
3295 add(imm(M_PI_4f
- 1.0f
),
3298 mul(abs(x
), imm(p1
))))))))));
3302 builtin_builder::call(ir_function
*f
, ir_variable
*ret
, exec_list params
)
3304 exec_list actual_params
;
3306 foreach_in_list(ir_variable
, var
, ¶ms
) {
3307 actual_params
.push_tail(var_ref(var
));
3310 ir_function_signature
*sig
=
3311 f
->exact_matching_signature(NULL
, &actual_params
);
3315 ir_dereference_variable
*deref
=
3316 (sig
->return_type
->is_void() ? NULL
: var_ref(ret
));
3318 return new(mem_ctx
) ir_call(sig
, deref
, &actual_params
);
3321 ir_function_signature
*
3322 builtin_builder::_asin(const glsl_type
*type
)
3324 ir_variable
*x
= in_var(type
, "x");
3325 MAKE_SIG(type
, always_available
, 1, x
);
3327 body
.emit(ret(asin_expr(x
, 0.086566724f
, -0.03102955f
)));
3332 ir_function_signature
*
3333 builtin_builder::_acos(const glsl_type
*type
)
3335 ir_variable
*x
= in_var(type
, "x");
3336 MAKE_SIG(type
, always_available
, 1, x
);
3338 body
.emit(ret(sub(imm(M_PI_2f
), asin_expr(x
, 0.08132463f
, -0.02363318f
))));
3343 ir_function_signature
*
3344 builtin_builder::_atan2(const glsl_type
*type
)
3346 ir_variable
*vec_y
= in_var(type
, "vec_y");
3347 ir_variable
*vec_x
= in_var(type
, "vec_x");
3348 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
3350 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
3351 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
3352 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3353 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
3354 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
3355 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
3356 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
3358 /* If |x| >= 1.0e-8 * |y|: */
3360 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
3362 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
3364 /* Then...call atan(y/x) */
3365 do_atan(outer_then
, glsl_type::float_type
, r
, div(y
, x
));
3367 /* ...and fix it up: */
3368 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
3369 inner_if
->then_instructions
.push_tail(
3370 if_tree(gequal(y
, imm(0.0f
)),
3371 assign(r
, add(r
, imm(M_PIf
))),
3372 assign(r
, sub(r
, imm(M_PIf
)))));
3373 outer_then
.emit(inner_if
);
3376 outer_if
->else_instructions
.push_tail(
3377 assign(r
, mul(sign(y
), imm(M_PI_2f
))));
3379 body
.emit(outer_if
);
3381 body
.emit(assign(vec_result
, r
, 1 << i
));
3383 body
.emit(ret(vec_result
));
3389 builtin_builder::do_atan(ir_factory
&body
, const glsl_type
*type
, ir_variable
*res
, operand y_over_x
)
3392 * range-reduction, first step:
3394 * / y_over_x if |y_over_x| <= 1.0;
3396 * \ 1.0 / y_over_x otherwise
3398 ir_variable
*x
= body
.make_temp(type
, "atan_x");
3399 body
.emit(assign(x
, div(min2(abs(y_over_x
),
3405 * approximate atan by evaluating polynomial:
3407 * x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
3408 * x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
3409 * x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
3411 ir_variable
*tmp
= body
.make_temp(type
, "atan_tmp");
3412 body
.emit(assign(tmp
, mul(x
, x
)));
3413 body
.emit(assign(tmp
, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f
),
3415 imm(0.0536813784310406f
)),
3417 imm(0.1173503194786851f
)),
3419 imm(0.1938924977115610f
)),
3421 imm(0.3326756418091246f
)),
3423 imm(0.9999793128310355f
)),
3426 /* range-reduction fixup */
3427 body
.emit(assign(tmp
, add(tmp
,
3428 mul(b2f(greater(abs(y_over_x
),
3429 imm(1.0f
, type
->components()))),
3435 body
.emit(assign(res
, mul(tmp
, sign(y_over_x
))));
3438 ir_function_signature
*
3439 builtin_builder::_atan(const glsl_type
*type
)
3441 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
3442 MAKE_SIG(type
, always_available
, 1, y_over_x
);
3444 ir_variable
*tmp
= body
.make_temp(type
, "tmp");
3445 do_atan(body
, type
, tmp
, y_over_x
);
3446 body
.emit(ret(tmp
));
3451 ir_function_signature
*
3452 builtin_builder::_sinh(const glsl_type
*type
)
3454 ir_variable
*x
= in_var(type
, "x");
3455 MAKE_SIG(type
, v130
, 1, x
);
3457 /* 0.5 * (e^x - e^(-x)) */
3458 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
3463 ir_function_signature
*
3464 builtin_builder::_cosh(const glsl_type
*type
)
3466 ir_variable
*x
= in_var(type
, "x");
3467 MAKE_SIG(type
, v130
, 1, x
);
3469 /* 0.5 * (e^x + e^(-x)) */
3470 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
3475 ir_function_signature
*
3476 builtin_builder::_tanh(const glsl_type
*type
)
3478 ir_variable
*x
= in_var(type
, "x");
3479 MAKE_SIG(type
, v130
, 1, x
);
3481 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
3482 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
3483 add(exp(x
), exp(neg(x
))))));
3488 ir_function_signature
*
3489 builtin_builder::_asinh(const glsl_type
*type
)
3491 ir_variable
*x
= in_var(type
, "x");
3492 MAKE_SIG(type
, v130
, 1, x
);
3494 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
3499 ir_function_signature
*
3500 builtin_builder::_acosh(const glsl_type
*type
)
3502 ir_variable
*x
= in_var(type
, "x");
3503 MAKE_SIG(type
, v130
, 1, x
);
3505 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
3509 ir_function_signature
*
3510 builtin_builder::_atanh(const glsl_type
*type
)
3512 ir_variable
*x
= in_var(type
, "x");
3513 MAKE_SIG(type
, v130
, 1, x
);
3515 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
3516 sub(imm(1.0f
), x
))))));
3522 * Exponential Functions @{
3525 ir_function_signature
*
3526 builtin_builder::_pow(const glsl_type
*type
)
3528 return binop(always_available
, ir_binop_pow
, type
, type
, type
);
3531 UNOP(exp
, ir_unop_exp
, always_available
)
3532 UNOP(log
, ir_unop_log
, always_available
)
3533 UNOP(exp2
, ir_unop_exp2
, always_available
)
3534 UNOP(log2
, ir_unop_log2
, always_available
)
3535 UNOPA(sqrt
, ir_unop_sqrt
)
3536 UNOPA(inversesqrt
, ir_unop_rsq
)
3540 UNOPA(abs
, ir_unop_abs
)
3541 UNOPA(sign
, ir_unop_sign
)
3542 UNOPA(floor
, ir_unop_floor
)
3543 UNOPA(trunc
, ir_unop_trunc
)
3544 UNOPA(round
, ir_unop_round_even
)
3545 UNOPA(roundEven
, ir_unop_round_even
)
3546 UNOPA(ceil
, ir_unop_ceil
)
3547 UNOPA(fract
, ir_unop_fract
)
3549 ir_function_signature
*
3550 builtin_builder::_mod(builtin_available_predicate avail
,
3551 const glsl_type
*x_type
, const glsl_type
*y_type
)
3553 return binop(avail
, ir_binop_mod
, x_type
, x_type
, y_type
);
3556 ir_function_signature
*
3557 builtin_builder::_modf(builtin_available_predicate avail
, const glsl_type
*type
)
3559 ir_variable
*x
= in_var(type
, "x");
3560 ir_variable
*i
= out_var(type
, "i");
3561 MAKE_SIG(type
, avail
, 2, x
, i
);
3563 ir_variable
*t
= body
.make_temp(type
, "t");
3564 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
3565 body
.emit(assign(i
, t
));
3566 body
.emit(ret(sub(x
, t
)));
3571 ir_function_signature
*
3572 builtin_builder::_min(builtin_available_predicate avail
,
3573 const glsl_type
*x_type
, const glsl_type
*y_type
)
3575 return binop(avail
, ir_binop_min
, x_type
, x_type
, y_type
);
3578 ir_function_signature
*
3579 builtin_builder::_max(builtin_available_predicate avail
,
3580 const glsl_type
*x_type
, const glsl_type
*y_type
)
3582 return binop(avail
, ir_binop_max
, x_type
, x_type
, y_type
);
3585 ir_function_signature
*
3586 builtin_builder::_clamp(builtin_available_predicate avail
,
3587 const glsl_type
*val_type
, const glsl_type
*bound_type
)
3589 ir_variable
*x
= in_var(val_type
, "x");
3590 ir_variable
*minVal
= in_var(bound_type
, "minVal");
3591 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
3592 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
3594 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
3599 ir_function_signature
*
3600 builtin_builder::_mix_lrp(builtin_available_predicate avail
, const glsl_type
*val_type
, const glsl_type
*blend_type
)
3602 ir_variable
*x
= in_var(val_type
, "x");
3603 ir_variable
*y
= in_var(val_type
, "y");
3604 ir_variable
*a
= in_var(blend_type
, "a");
3605 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3607 body
.emit(ret(lrp(x
, y
, a
)));
3612 ir_function_signature
*
3613 builtin_builder::_mix_sel(builtin_available_predicate avail
,
3614 const glsl_type
*val_type
,
3615 const glsl_type
*blend_type
)
3617 ir_variable
*x
= in_var(val_type
, "x");
3618 ir_variable
*y
= in_var(val_type
, "y");
3619 ir_variable
*a
= in_var(blend_type
, "a");
3620 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
3622 /* csel matches the ternary operator in that a selector of true choses the
3623 * first argument. This differs from mix(x, y, false) which choses the
3624 * second argument (to remain consistent with the interpolating version of
3625 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
3627 * To handle the behavior mismatch, reverse the x and y arguments.
3629 body
.emit(ret(csel(a
, y
, x
)));
3634 ir_function_signature
*
3635 builtin_builder::_step(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3637 ir_variable
*edge
= in_var(edge_type
, "edge");
3638 ir_variable
*x
= in_var(x_type
, "x");
3639 MAKE_SIG(x_type
, avail
, 2, edge
, x
);
3641 ir_variable
*t
= body
.make_temp(x_type
, "t");
3642 if (x_type
->vector_elements
== 1) {
3643 /* Both are floats */
3644 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3645 body
.emit(assign(t
, f2d(b2f(gequal(x
, edge
)))));
3647 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
3648 } else if (edge_type
->vector_elements
== 1) {
3649 /* x is a vector but edge is a float */
3650 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3651 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3652 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), edge
))), 1 << i
));
3654 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
3657 /* Both are vectors */
3658 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
3659 if (edge_type
->base_type
== GLSL_TYPE_DOUBLE
)
3660 body
.emit(assign(t
, f2d(b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1)))),
3663 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
3673 ir_function_signature
*
3674 builtin_builder::_smoothstep(builtin_available_predicate avail
, const glsl_type
*edge_type
, const glsl_type
*x_type
)
3676 ir_variable
*edge0
= in_var(edge_type
, "edge0");
3677 ir_variable
*edge1
= in_var(edge_type
, "edge1");
3678 ir_variable
*x
= in_var(x_type
, "x");
3679 MAKE_SIG(x_type
, avail
, 3, edge0
, edge1
, x
);
3681 /* From the GLSL 1.10 specification:
3684 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
3685 * return t * t * (3 - 2 * t);
3688 ir_variable
*t
= body
.make_temp(x_type
, "t");
3689 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
3690 IMM_FP(x_type
, 0.0), IMM_FP(x_type
, 1.0))));
3692 body
.emit(ret(mul(t
, mul(t
, sub(IMM_FP(x_type
, 3.0), mul(IMM_FP(x_type
, 2.0), t
))))));
3697 ir_function_signature
*
3698 builtin_builder::_isnan(builtin_available_predicate avail
, const glsl_type
*type
)
3700 ir_variable
*x
= in_var(type
, "x");
3701 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3703 body
.emit(ret(nequal(x
, x
)));
3708 ir_function_signature
*
3709 builtin_builder::_isinf(builtin_available_predicate avail
, const glsl_type
*type
)
3711 ir_variable
*x
= in_var(type
, "x");
3712 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), avail
, 1, x
);
3714 ir_constant_data infinities
;
3715 for (int i
= 0; i
< type
->vector_elements
; i
++) {
3716 switch (type
->base_type
) {
3717 case GLSL_TYPE_FLOAT
:
3718 infinities
.f
[i
] = INFINITY
;
3720 case GLSL_TYPE_DOUBLE
:
3721 infinities
.d
[i
] = INFINITY
;
3724 unreachable("unknown type");
3728 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
3733 ir_function_signature
*
3734 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
3736 ir_variable
*x
= in_var(type
, "x");
3737 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3738 body
.emit(ret(bitcast_f2i(x
)));
3742 ir_function_signature
*
3743 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
3745 ir_variable
*x
= in_var(type
, "x");
3746 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3747 body
.emit(ret(bitcast_f2u(x
)));
3751 ir_function_signature
*
3752 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
3754 ir_variable
*x
= in_var(type
, "x");
3755 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3756 body
.emit(ret(bitcast_i2f(x
)));
3760 ir_function_signature
*
3761 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
3763 ir_variable
*x
= in_var(type
, "x");
3764 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
3765 body
.emit(ret(bitcast_u2f(x
)));
3769 ir_function_signature
*
3770 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
3772 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3773 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3774 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
3778 ir_function_signature
*
3779 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
3781 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3782 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3783 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
3787 ir_function_signature
*
3788 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
3790 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3791 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3792 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
3796 ir_function_signature
*
3797 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
3799 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
3800 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3801 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
3805 ir_function_signature
*
3806 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
3808 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3809 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3810 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
3814 ir_function_signature
*
3815 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
3817 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3818 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3819 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
3824 ir_function_signature
*
3825 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
3827 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3828 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3829 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
3833 ir_function_signature
*
3834 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
3836 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3837 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
3838 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
3842 ir_function_signature
*
3843 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
3845 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
3846 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
3847 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
3851 ir_function_signature
*
3852 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
3854 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
3855 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
3856 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
3860 ir_function_signature
*
3861 builtin_builder::_packDouble2x32(builtin_available_predicate avail
)
3863 ir_variable
*v
= in_var(glsl_type::uvec2_type
, "v");
3864 MAKE_SIG(glsl_type::double_type
, avail
, 1, v
);
3865 body
.emit(ret(expr(ir_unop_pack_double_2x32
, v
)));
3869 ir_function_signature
*
3870 builtin_builder::_unpackDouble2x32(builtin_available_predicate avail
)
3872 ir_variable
*p
= in_var(glsl_type::double_type
, "p");
3873 MAKE_SIG(glsl_type::uvec2_type
, avail
, 1, p
);
3874 body
.emit(ret(expr(ir_unop_unpack_double_2x32
, p
)));
3878 ir_function_signature
*
3879 builtin_builder::_length(builtin_available_predicate avail
, const glsl_type
*type
)
3881 ir_variable
*x
= in_var(type
, "x");
3882 MAKE_SIG(type
->get_base_type(), avail
, 1, x
);
3884 body
.emit(ret(sqrt(dot(x
, x
))));
3889 ir_function_signature
*
3890 builtin_builder::_distance(builtin_available_predicate avail
, const glsl_type
*type
)
3892 ir_variable
*p0
= in_var(type
, "p0");
3893 ir_variable
*p1
= in_var(type
, "p1");
3894 MAKE_SIG(type
->get_base_type(), avail
, 2, p0
, p1
);
3896 if (type
->vector_elements
== 1) {
3897 body
.emit(ret(abs(sub(p0
, p1
))));
3899 ir_variable
*p
= body
.make_temp(type
, "p");
3900 body
.emit(assign(p
, sub(p0
, p1
)));
3901 body
.emit(ret(sqrt(dot(p
, p
))));
3907 ir_function_signature
*
3908 builtin_builder::_dot(builtin_available_predicate avail
, const glsl_type
*type
)
3910 if (type
->vector_elements
== 1)
3911 return binop(avail
, ir_binop_mul
, type
, type
, type
);
3913 return binop(avail
, ir_binop_dot
,
3914 type
->get_base_type(), type
, type
);
3917 ir_function_signature
*
3918 builtin_builder::_cross(builtin_available_predicate avail
, const glsl_type
*type
)
3920 ir_variable
*a
= in_var(type
, "a");
3921 ir_variable
*b
= in_var(type
, "b");
3922 MAKE_SIG(type
, avail
, 2, a
, b
);
3924 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
3925 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
3927 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
3928 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
3933 ir_function_signature
*
3934 builtin_builder::_normalize(builtin_available_predicate avail
, const glsl_type
*type
)
3936 ir_variable
*x
= in_var(type
, "x");
3937 MAKE_SIG(type
, avail
, 1, x
);
3939 if (type
->vector_elements
== 1) {
3940 body
.emit(ret(sign(x
)));
3942 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
3948 ir_function_signature
*
3949 builtin_builder::_ftransform()
3951 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
3953 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
3954 glsl_type::vec4_type
,
3955 var_ref(gl_ModelViewProjectionMatrix
),
3956 var_ref(gl_Vertex
))));
3958 /* FINISHME: Once the ir_expression() constructor handles type inference
3959 * for matrix operations, we can simplify this to:
3961 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
3966 ir_function_signature
*
3967 builtin_builder::_faceforward(builtin_available_predicate avail
, const glsl_type
*type
)
3969 ir_variable
*N
= in_var(type
, "N");
3970 ir_variable
*I
= in_var(type
, "I");
3971 ir_variable
*Nref
= in_var(type
, "Nref");
3972 MAKE_SIG(type
, avail
, 3, N
, I
, Nref
);
3974 body
.emit(if_tree(less(dot(Nref
, I
), IMM_FP(type
, 0.0)),
3975 ret(N
), ret(neg(N
))));
3980 ir_function_signature
*
3981 builtin_builder::_reflect(builtin_available_predicate avail
, const glsl_type
*type
)
3983 ir_variable
*I
= in_var(type
, "I");
3984 ir_variable
*N
= in_var(type
, "N");
3985 MAKE_SIG(type
, avail
, 2, I
, N
);
3987 /* I - 2 * dot(N, I) * N */
3988 body
.emit(ret(sub(I
, mul(IMM_FP(type
, 2.0), mul(dot(N
, I
), N
)))));
3993 ir_function_signature
*
3994 builtin_builder::_refract(builtin_available_predicate avail
, const glsl_type
*type
)
3996 ir_variable
*I
= in_var(type
, "I");
3997 ir_variable
*N
= in_var(type
, "N");
3998 ir_variable
*eta
= in_var(type
->get_base_type(), "eta");
3999 MAKE_SIG(type
, avail
, 3, I
, N
, eta
);
4001 ir_variable
*n_dot_i
= body
.make_temp(type
->get_base_type(), "n_dot_i");
4002 body
.emit(assign(n_dot_i
, dot(N
, I
)));
4004 /* From the GLSL 1.10 specification:
4005 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
4007 * return genType(0.0)
4009 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
4011 ir_variable
*k
= body
.make_temp(type
->get_base_type(), "k");
4012 body
.emit(assign(k
, sub(IMM_FP(type
, 1.0),
4013 mul(eta
, mul(eta
, sub(IMM_FP(type
, 1.0),
4014 mul(n_dot_i
, n_dot_i
)))))));
4015 body
.emit(if_tree(less(k
, IMM_FP(type
, 0.0)),
4016 ret(ir_constant::zero(mem_ctx
, type
)),
4017 ret(sub(mul(eta
, I
),
4018 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
4023 ir_function_signature
*
4024 builtin_builder::_matrixCompMult(builtin_available_predicate avail
, const glsl_type
*type
)
4026 ir_variable
*x
= in_var(type
, "x");
4027 ir_variable
*y
= in_var(type
, "y");
4028 MAKE_SIG(type
, avail
, 2, x
, y
);
4030 ir_variable
*z
= body
.make_temp(type
, "z");
4031 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4032 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
4039 ir_function_signature
*
4040 builtin_builder::_outerProduct(builtin_available_predicate avail
, const glsl_type
*type
)
4045 if (type
->base_type
== GLSL_TYPE_DOUBLE
) {
4046 r
= in_var(glsl_type::dvec(type
->matrix_columns
), "r");
4047 c
= in_var(glsl_type::dvec(type
->vector_elements
), "c");
4049 r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
4050 c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
4052 MAKE_SIG(type
, avail
, 2, c
, r
);
4054 ir_variable
*m
= body
.make_temp(type
, "m");
4055 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
4056 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
4063 ir_function_signature
*
4064 builtin_builder::_transpose(builtin_available_predicate avail
, const glsl_type
*orig_type
)
4066 const glsl_type
*transpose_type
=
4067 glsl_type::get_instance(orig_type
->base_type
,
4068 orig_type
->matrix_columns
,
4069 orig_type
->vector_elements
);
4071 ir_variable
*m
= in_var(orig_type
, "m");
4072 MAKE_SIG(transpose_type
, avail
, 1, m
);
4074 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
4075 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
4076 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
4077 body
.emit(assign(array_ref(t
, j
),
4078 matrix_elt(m
, i
, j
),
4087 ir_function_signature
*
4088 builtin_builder::_determinant_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4090 ir_variable
*m
= in_var(type
, "m");
4091 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4093 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4094 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
4099 ir_function_signature
*
4100 builtin_builder::_determinant_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4102 ir_variable
*m
= in_var(type
, "m");
4103 MAKE_SIG(type
->get_base_type(), avail
, 1, m
);
4106 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4107 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
4110 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4111 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
4114 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4115 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
4117 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
4118 mul(matrix_elt(m
, 0, 1), f2
)),
4119 mul(matrix_elt(m
, 0, 2), f3
))));
4124 ir_function_signature
*
4125 builtin_builder::_determinant_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4127 ir_variable
*m
= in_var(type
, "m");
4128 const glsl_type
*btype
= type
->get_base_type();
4129 MAKE_SIG(btype
, avail
, 1, m
);
4131 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4132 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4133 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4134 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4135 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4136 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4137 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4138 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4139 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4140 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4141 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4142 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4143 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4144 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4145 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4146 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4147 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4148 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4149 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4151 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)))));
4152 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)))));
4153 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)))));
4154 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)))));
4155 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)))));
4156 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)))));
4157 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)))));
4158 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)))));
4159 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)))));
4160 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)))));
4161 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)))));
4162 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)))));
4163 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)))));
4164 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)))));
4165 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)))));
4166 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)))));
4167 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)))));
4168 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)))));
4169 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)))));
4171 ir_variable
*adj_0
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::vec4_type
: glsl_type::dvec4_type
, "adj_0");
4173 body
.emit(assign(adj_0
,
4174 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4175 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4176 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4178 body
.emit(assign(adj_0
, neg(
4179 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4180 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4181 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4183 body
.emit(assign(adj_0
,
4184 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4185 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4186 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4188 body
.emit(assign(adj_0
, neg(
4189 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4190 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4191 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4194 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
4199 ir_function_signature
*
4200 builtin_builder::_inverse_mat2(builtin_available_predicate avail
, const glsl_type
*type
)
4202 ir_variable
*m
= in_var(type
, "m");
4203 MAKE_SIG(type
, avail
, 1, m
);
4205 ir_variable
*adj
= body
.make_temp(type
, "adj");
4206 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
4207 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
4208 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
4209 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
4211 ir_expression
*det
=
4212 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4213 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
4215 body
.emit(ret(div(adj
, det
)));
4219 ir_function_signature
*
4220 builtin_builder::_inverse_mat3(builtin_available_predicate avail
, const glsl_type
*type
)
4222 ir_variable
*m
= in_var(type
, "m");
4223 const glsl_type
*btype
= type
->get_base_type();
4224 MAKE_SIG(type
, avail
, 1, m
);
4226 ir_variable
*f11_22_21_12
= body
.make_temp(btype
, "f11_22_21_12");
4227 ir_variable
*f10_22_20_12
= body
.make_temp(btype
, "f10_22_20_12");
4228 ir_variable
*f10_21_20_11
= body
.make_temp(btype
, "f10_21_20_11");
4230 body
.emit(assign(f11_22_21_12
,
4231 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
4232 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
4233 body
.emit(assign(f10_22_20_12
,
4234 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
4235 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
4236 body
.emit(assign(f10_21_20_11
,
4237 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
4238 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
4240 ir_variable
*adj
= body
.make_temp(type
, "adj");
4241 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
4242 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
4243 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
4245 body
.emit(assign(array_ref(adj
, 0), neg(
4246 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
4247 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
4249 body
.emit(assign(array_ref(adj
, 1),
4250 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
4251 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
4253 body
.emit(assign(array_ref(adj
, 2), neg(
4254 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
4255 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
4258 body
.emit(assign(array_ref(adj
, 0),
4259 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
4260 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
4262 body
.emit(assign(array_ref(adj
, 1), neg(
4263 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
4264 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
4266 body
.emit(assign(array_ref(adj
, 2),
4267 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
4268 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
4271 ir_expression
*det
=
4272 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
4273 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
4274 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
4276 body
.emit(ret(div(adj
, det
)));
4281 ir_function_signature
*
4282 builtin_builder::_inverse_mat4(builtin_available_predicate avail
, const glsl_type
*type
)
4284 ir_variable
*m
= in_var(type
, "m");
4285 const glsl_type
*btype
= type
->get_base_type();
4286 MAKE_SIG(type
, avail
, 1, m
);
4288 ir_variable
*SubFactor00
= body
.make_temp(btype
, "SubFactor00");
4289 ir_variable
*SubFactor01
= body
.make_temp(btype
, "SubFactor01");
4290 ir_variable
*SubFactor02
= body
.make_temp(btype
, "SubFactor02");
4291 ir_variable
*SubFactor03
= body
.make_temp(btype
, "SubFactor03");
4292 ir_variable
*SubFactor04
= body
.make_temp(btype
, "SubFactor04");
4293 ir_variable
*SubFactor05
= body
.make_temp(btype
, "SubFactor05");
4294 ir_variable
*SubFactor06
= body
.make_temp(btype
, "SubFactor06");
4295 ir_variable
*SubFactor07
= body
.make_temp(btype
, "SubFactor07");
4296 ir_variable
*SubFactor08
= body
.make_temp(btype
, "SubFactor08");
4297 ir_variable
*SubFactor09
= body
.make_temp(btype
, "SubFactor09");
4298 ir_variable
*SubFactor10
= body
.make_temp(btype
, "SubFactor10");
4299 ir_variable
*SubFactor11
= body
.make_temp(btype
, "SubFactor11");
4300 ir_variable
*SubFactor12
= body
.make_temp(btype
, "SubFactor12");
4301 ir_variable
*SubFactor13
= body
.make_temp(btype
, "SubFactor13");
4302 ir_variable
*SubFactor14
= body
.make_temp(btype
, "SubFactor14");
4303 ir_variable
*SubFactor15
= body
.make_temp(btype
, "SubFactor15");
4304 ir_variable
*SubFactor16
= body
.make_temp(btype
, "SubFactor16");
4305 ir_variable
*SubFactor17
= body
.make_temp(btype
, "SubFactor17");
4306 ir_variable
*SubFactor18
= body
.make_temp(btype
, "SubFactor18");
4308 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)))));
4309 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)))));
4310 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)))));
4311 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)))));
4312 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)))));
4313 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)))));
4314 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)))));
4315 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)))));
4316 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)))));
4317 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)))));
4318 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)))));
4319 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)))));
4320 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)))));
4321 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)))));
4322 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)))));
4323 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)))));
4324 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)))));
4325 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)))));
4326 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)))));
4328 ir_variable
*adj
= body
.make_temp(btype
== glsl_type::float_type
? glsl_type::mat4_type
: glsl_type::dmat4_type
, "adj");
4329 body
.emit(assign(array_ref(adj
, 0),
4330 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
4331 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
4332 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
4334 body
.emit(assign(array_ref(adj
, 1), neg(
4335 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
4336 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
4337 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
4339 body
.emit(assign(array_ref(adj
, 2),
4340 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
4341 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
4342 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
4344 body
.emit(assign(array_ref(adj
, 3), neg(
4345 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
4346 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
4347 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
4350 body
.emit(assign(array_ref(adj
, 0), neg(
4351 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
4352 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
4353 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
4355 body
.emit(assign(array_ref(adj
, 1),
4356 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
4357 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
4358 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
4360 body
.emit(assign(array_ref(adj
, 2), neg(
4361 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
4362 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
4363 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
4365 body
.emit(assign(array_ref(adj
, 3),
4366 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
4367 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
4368 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
4371 body
.emit(assign(array_ref(adj
, 0),
4372 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
4373 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
4374 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
4376 body
.emit(assign(array_ref(adj
, 1), neg(
4377 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
4378 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
4379 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
4381 body
.emit(assign(array_ref(adj
, 2),
4382 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
4383 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
4384 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
4386 body
.emit(assign(array_ref(adj
, 3), neg(
4387 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
4388 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
4389 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
4392 body
.emit(assign(array_ref(adj
, 0), neg(
4393 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
4394 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
4395 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
4397 body
.emit(assign(array_ref(adj
, 1),
4398 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
4399 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
4400 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
4402 body
.emit(assign(array_ref(adj
, 2), neg(
4403 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
4404 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
4405 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
4407 body
.emit(assign(array_ref(adj
, 3),
4408 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
4409 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
4410 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
4413 ir_expression
*det
=
4414 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
4415 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
4416 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
4417 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
4419 body
.emit(ret(div(adj
, det
)));
4425 ir_function_signature
*
4426 builtin_builder::_lessThan(builtin_available_predicate avail
,
4427 const glsl_type
*type
)
4429 return binop(avail
, ir_binop_less
,
4430 glsl_type::bvec(type
->vector_elements
), type
, type
);
4433 ir_function_signature
*
4434 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
4435 const glsl_type
*type
)
4437 return binop(avail
, ir_binop_lequal
,
4438 glsl_type::bvec(type
->vector_elements
), type
, type
);
4441 ir_function_signature
*
4442 builtin_builder::_greaterThan(builtin_available_predicate avail
,
4443 const glsl_type
*type
)
4445 return binop(avail
, ir_binop_greater
,
4446 glsl_type::bvec(type
->vector_elements
), type
, type
);
4449 ir_function_signature
*
4450 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
4451 const glsl_type
*type
)
4453 return binop(avail
, ir_binop_gequal
,
4454 glsl_type::bvec(type
->vector_elements
), type
, type
);
4457 ir_function_signature
*
4458 builtin_builder::_equal(builtin_available_predicate avail
,
4459 const glsl_type
*type
)
4461 return binop(avail
, ir_binop_equal
,
4462 glsl_type::bvec(type
->vector_elements
), type
, type
);
4465 ir_function_signature
*
4466 builtin_builder::_notEqual(builtin_available_predicate avail
,
4467 const glsl_type
*type
)
4469 return binop(avail
, ir_binop_nequal
,
4470 glsl_type::bvec(type
->vector_elements
), type
, type
);
4473 ir_function_signature
*
4474 builtin_builder::_any(const glsl_type
*type
)
4476 ir_variable
*v
= in_var(type
, "v");
4477 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4479 const unsigned vec_elem
= v
->type
->vector_elements
;
4480 body
.emit(ret(expr(ir_binop_any_nequal
, v
, imm(false, vec_elem
))));
4485 ir_function_signature
*
4486 builtin_builder::_all(const glsl_type
*type
)
4488 ir_variable
*v
= in_var(type
, "v");
4489 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
4491 const unsigned vec_elem
= v
->type
->vector_elements
;
4492 body
.emit(ret(expr(ir_binop_all_equal
, v
, imm(true, vec_elem
))));
4497 UNOP(not, ir_unop_logic_not
, always_available
)
4500 has_lod(const glsl_type
*sampler_type
)
4502 assert(sampler_type
->is_sampler());
4504 switch (sampler_type
->sampler_dimensionality
) {
4505 case GLSL_SAMPLER_DIM_RECT
:
4506 case GLSL_SAMPLER_DIM_BUF
:
4507 case GLSL_SAMPLER_DIM_MS
:
4514 ir_function_signature
*
4515 builtin_builder::_textureSize(builtin_available_predicate avail
,
4516 const glsl_type
*return_type
,
4517 const glsl_type
*sampler_type
)
4519 ir_variable
*s
= in_var(sampler_type
, "sampler");
4520 /* The sampler always exists; add optional lod later. */
4521 MAKE_SIG(return_type
, avail
, 1, s
);
4523 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
4524 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
4526 if (has_lod(sampler_type
)) {
4527 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4528 sig
->parameters
.push_tail(lod
);
4529 tex
->lod_info
.lod
= var_ref(lod
);
4531 tex
->lod_info
.lod
= imm(0u);
4534 body
.emit(ret(tex
));
4539 ir_function_signature
*
4540 builtin_builder::_textureSamples(const glsl_type
*sampler_type
)
4542 ir_variable
*s
= in_var(sampler_type
, "sampler");
4543 MAKE_SIG(glsl_type::int_type
, shader_samples
, 1, s
);
4545 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_texture_samples
);
4546 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), glsl_type::int_type
);
4547 body
.emit(ret(tex
));
4552 ir_function_signature
*
4553 builtin_builder::_texture(ir_texture_opcode opcode
,
4554 builtin_available_predicate avail
,
4555 const glsl_type
*return_type
,
4556 const glsl_type
*sampler_type
,
4557 const glsl_type
*coord_type
,
4560 ir_variable
*s
= in_var(sampler_type
, "sampler");
4561 ir_variable
*P
= in_var(coord_type
, "P");
4562 /* The sampler and coordinate always exist; add optional parameters later. */
4563 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4565 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
4566 tex
->set_sampler(var_ref(s
), return_type
);
4568 const int coord_size
= sampler_type
->coordinate_components();
4570 if (coord_size
== coord_type
->vector_elements
) {
4571 tex
->coordinate
= var_ref(P
);
4573 /* The incoming coordinate also has the projector or shadow comparitor,
4574 * so we need to swizzle those away.
4576 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
4579 /* The projector is always in the last component. */
4580 if (flags
& TEX_PROJECT
)
4581 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
4583 if (sampler_type
->sampler_shadow
) {
4584 if (opcode
== ir_tg4
) {
4585 /* gather has refz as a separate parameter, immediately after the
4588 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
4589 sig
->parameters
.push_tail(refz
);
4590 tex
->shadow_comparitor
= var_ref(refz
);
4592 /* The shadow comparitor is normally in the Z component, but a few types
4593 * have sufficiently large coordinates that it's in W.
4595 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
4599 if (opcode
== ir_txl
) {
4600 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
4601 sig
->parameters
.push_tail(lod
);
4602 tex
->lod_info
.lod
= var_ref(lod
);
4603 } else if (opcode
== ir_txd
) {
4604 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4605 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
4606 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
4607 sig
->parameters
.push_tail(dPdx
);
4608 sig
->parameters
.push_tail(dPdy
);
4609 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
4610 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
4613 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
4614 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
4615 ir_variable
*offset
=
4616 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
4617 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
4618 sig
->parameters
.push_tail(offset
);
4619 tex
->offset
= var_ref(offset
);
4622 if (flags
& TEX_OFFSET_ARRAY
) {
4623 ir_variable
*offsets
=
4624 new(mem_ctx
) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type
, 4),
4625 "offsets", ir_var_const_in
);
4626 sig
->parameters
.push_tail(offsets
);
4627 tex
->offset
= var_ref(offsets
);
4630 if (opcode
== ir_tg4
) {
4631 if (flags
& TEX_COMPONENT
) {
4632 ir_variable
*component
=
4633 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
4634 sig
->parameters
.push_tail(component
);
4635 tex
->lod_info
.component
= var_ref(component
);
4638 tex
->lod_info
.component
= imm(0);
4642 /* The "bias" parameter comes /after/ the "offset" parameter, which is
4643 * inconsistent with both textureLodOffset and textureGradOffset.
4645 if (opcode
== ir_txb
) {
4646 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
4647 sig
->parameters
.push_tail(bias
);
4648 tex
->lod_info
.bias
= var_ref(bias
);
4651 body
.emit(ret(tex
));
4656 ir_function_signature
*
4657 builtin_builder::_textureCubeArrayShadow()
4659 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
4660 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
4661 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
4662 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
4664 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
4665 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
4667 tex
->coordinate
= var_ref(P
);
4668 tex
->shadow_comparitor
= var_ref(compare
);
4670 body
.emit(ret(tex
));
4675 ir_function_signature
*
4676 builtin_builder::_texelFetch(builtin_available_predicate avail
,
4677 const glsl_type
*return_type
,
4678 const glsl_type
*sampler_type
,
4679 const glsl_type
*coord_type
,
4680 const glsl_type
*offset_type
)
4682 ir_variable
*s
= in_var(sampler_type
, "sampler");
4683 ir_variable
*P
= in_var(coord_type
, "P");
4684 /* The sampler and coordinate always exist; add optional parameters later. */
4685 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4687 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
4688 tex
->coordinate
= var_ref(P
);
4689 tex
->set_sampler(var_ref(s
), return_type
);
4691 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
4692 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
4693 sig
->parameters
.push_tail(sample
);
4694 tex
->lod_info
.sample_index
= var_ref(sample
);
4695 tex
->op
= ir_txf_ms
;
4696 } else if (has_lod(sampler_type
)) {
4697 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
4698 sig
->parameters
.push_tail(lod
);
4699 tex
->lod_info
.lod
= var_ref(lod
);
4701 tex
->lod_info
.lod
= imm(0u);
4704 if (offset_type
!= NULL
) {
4705 ir_variable
*offset
=
4706 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
4707 sig
->parameters
.push_tail(offset
);
4708 tex
->offset
= var_ref(offset
);
4711 body
.emit(ret(tex
));
4716 ir_function_signature
*
4717 builtin_builder::_EmitVertex()
4719 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4721 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4722 body
.emit(new(mem_ctx
) ir_emit_vertex(stream
));
4727 ir_function_signature
*
4728 builtin_builder::_EmitStreamVertex(builtin_available_predicate avail
,
4729 const glsl_type
*stream_type
)
4731 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4733 * "Emit the current values of output variables to the current output
4734 * primitive on stream stream. The argument to stream must be a constant
4735 * integral expression."
4737 ir_variable
*stream
=
4738 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4740 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4742 body
.emit(new(mem_ctx
) ir_emit_vertex(var_ref(stream
)));
4747 ir_function_signature
*
4748 builtin_builder::_EndPrimitive()
4750 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
4752 ir_rvalue
*stream
= new(mem_ctx
) ir_constant(0, 1);
4753 body
.emit(new(mem_ctx
) ir_end_primitive(stream
));
4758 ir_function_signature
*
4759 builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail
,
4760 const glsl_type
*stream_type
)
4762 /* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:
4764 * "Completes the current output primitive on stream stream and starts
4765 * a new one. The argument to stream must be a constant integral
4768 ir_variable
*stream
=
4769 new(mem_ctx
) ir_variable(stream_type
, "stream", ir_var_const_in
);
4771 MAKE_SIG(glsl_type::void_type
, avail
, 1, stream
);
4773 body
.emit(new(mem_ctx
) ir_end_primitive(var_ref(stream
)));
4778 ir_function_signature
*
4779 builtin_builder::_barrier()
4781 MAKE_SIG(glsl_type::void_type
, barrier_supported
, 0);
4783 body
.emit(new(mem_ctx
) ir_barrier());
4787 ir_function_signature
*
4788 builtin_builder::_textureQueryLod(builtin_available_predicate avail
,
4789 const glsl_type
*sampler_type
,
4790 const glsl_type
*coord_type
)
4792 ir_variable
*s
= in_var(sampler_type
, "sampler");
4793 ir_variable
*coord
= in_var(coord_type
, "coord");
4794 /* The sampler and coordinate always exist; add optional parameters later. */
4795 MAKE_SIG(glsl_type::vec2_type
, avail
, 2, s
, coord
);
4797 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
4798 tex
->coordinate
= var_ref(coord
);
4799 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
4801 body
.emit(ret(tex
));
4806 ir_function_signature
*
4807 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
4809 ir_variable
*s
= in_var(sampler_type
, "sampler");
4810 const glsl_type
*return_type
= glsl_type::int_type
;
4811 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
4813 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
4814 tex
->set_sampler(var_ref(s
), return_type
);
4816 body
.emit(ret(tex
));
4821 ir_function_signature
*
4822 builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail
,
4823 const glsl_type
*sampler_type
,
4824 const glsl_type
*coord_type
)
4826 ir_variable
*s
= in_var(sampler_type
, "sampler");
4827 ir_variable
*P
= in_var(coord_type
, "P");
4828 const glsl_type
*return_type
= glsl_type::bool_type
;
4829 MAKE_SIG(return_type
, avail
, 2, s
, P
);
4831 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_samples_identical
);
4832 tex
->coordinate
= var_ref(P
);
4833 tex
->set_sampler(var_ref(s
), return_type
);
4835 body
.emit(ret(tex
));
4840 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
4841 UNOP(dFdxCoarse
, ir_unop_dFdx_coarse
, fs_derivative_control
)
4842 UNOP(dFdxFine
, ir_unop_dFdx_fine
, fs_derivative_control
)
4843 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
4844 UNOP(dFdyCoarse
, ir_unop_dFdy_coarse
, fs_derivative_control
)
4845 UNOP(dFdyFine
, ir_unop_dFdy_fine
, fs_derivative_control
)
4847 ir_function_signature
*
4848 builtin_builder::_fwidth(const glsl_type
*type
)
4850 ir_variable
*p
= in_var(type
, "p");
4851 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
4853 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
4858 ir_function_signature
*
4859 builtin_builder::_fwidthCoarse(const glsl_type
*type
)
4861 ir_variable
*p
= in_var(type
, "p");
4862 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4864 body
.emit(ret(add(abs(expr(ir_unop_dFdx_coarse
, p
)),
4865 abs(expr(ir_unop_dFdy_coarse
, p
)))));
4870 ir_function_signature
*
4871 builtin_builder::_fwidthFine(const glsl_type
*type
)
4873 ir_variable
*p
= in_var(type
, "p");
4874 MAKE_SIG(type
, fs_derivative_control
, 1, p
);
4876 body
.emit(ret(add(abs(expr(ir_unop_dFdx_fine
, p
)),
4877 abs(expr(ir_unop_dFdy_fine
, p
)))));
4882 ir_function_signature
*
4883 builtin_builder::_noise1(const glsl_type
*type
)
4885 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
4888 ir_function_signature
*
4889 builtin_builder::_noise2(const glsl_type
*type
)
4891 ir_variable
*p
= in_var(type
, "p");
4892 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
4894 ir_constant_data b_offset
;
4895 b_offset
.f
[0] = 601.0f
;
4896 b_offset
.f
[1] = 313.0f
;
4897 b_offset
.f
[2] = 29.0f
;
4898 b_offset
.f
[3] = 277.0f
;
4900 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4901 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4902 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
4903 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4904 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4905 body
.emit(assign(t
, a
, WRITEMASK_X
));
4906 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4912 ir_function_signature
*
4913 builtin_builder::_noise3(const glsl_type
*type
)
4915 ir_variable
*p
= in_var(type
, "p");
4916 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
4918 ir_constant_data b_offset
;
4919 b_offset
.f
[0] = 601.0f
;
4920 b_offset
.f
[1] = 313.0f
;
4921 b_offset
.f
[2] = 29.0f
;
4922 b_offset
.f
[3] = 277.0f
;
4924 ir_constant_data c_offset
;
4925 c_offset
.f
[0] = 1559.0f
;
4926 c_offset
.f
[1] = 113.0f
;
4927 c_offset
.f
[2] = 1861.0f
;
4928 c_offset
.f
[3] = 797.0f
;
4930 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4931 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4932 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4933 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
4934 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4935 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
4936 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
4937 body
.emit(assign(t
, a
, WRITEMASK_X
));
4938 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4939 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4945 ir_function_signature
*
4946 builtin_builder::_noise4(const glsl_type
*type
)
4948 ir_variable
*p
= in_var(type
, "p");
4949 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
4951 ir_variable
*_p
= body
.make_temp(type
, "_p");
4953 ir_constant_data p_offset
;
4954 p_offset
.f
[0] = 1559.0f
;
4955 p_offset
.f
[1] = 113.0f
;
4956 p_offset
.f
[2] = 1861.0f
;
4957 p_offset
.f
[3] = 797.0f
;
4959 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
4961 ir_constant_data offset
;
4962 offset
.f
[0] = 601.0f
;
4963 offset
.f
[1] = 313.0f
;
4964 offset
.f
[2] = 29.0f
;
4965 offset
.f
[3] = 277.0f
;
4967 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
4968 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
4969 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
4970 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
4971 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
4972 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
4973 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
4974 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
4975 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
4976 body
.emit(assign(t
, a
, WRITEMASK_X
));
4977 body
.emit(assign(t
, b
, WRITEMASK_Y
));
4978 body
.emit(assign(t
, c
, WRITEMASK_Z
));
4979 body
.emit(assign(t
, d
, WRITEMASK_W
));
4985 ir_function_signature
*
4986 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
4988 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
4989 ir_variable
*value
= in_var(type
, "value");
4990 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
4991 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
4992 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, value
, offset
, bits
);
4994 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
4995 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
4997 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
,
4998 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
4999 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5004 ir_function_signature
*
5005 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
5007 bool is_uint
= type
->base_type
== GLSL_TYPE_UINT
;
5008 ir_variable
*base
= in_var(type
, "base");
5009 ir_variable
*insert
= in_var(type
, "insert");
5010 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
5011 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
5012 MAKE_SIG(type
, gpu_shader5_or_es31
, 4, base
, insert
, offset
, bits
);
5014 operand cast_offset
= is_uint
? i2u(offset
) : operand(offset
);
5015 operand cast_bits
= is_uint
? i2u(bits
) : operand(bits
);
5017 body
.emit(ret(bitfield_insert(base
, insert
,
5018 swizzle(cast_offset
, SWIZZLE_XXXX
, type
->vector_elements
),
5019 swizzle(cast_bits
, SWIZZLE_XXXX
, type
->vector_elements
))));
5024 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5_or_es31
)
5026 ir_function_signature
*
5027 builtin_builder::_bitCount(const glsl_type
*type
)
5029 return unop(gpu_shader5_or_es31
, ir_unop_bit_count
,
5030 glsl_type::ivec(type
->vector_elements
), type
);
5033 ir_function_signature
*
5034 builtin_builder::_findLSB(const glsl_type
*type
)
5036 return unop(gpu_shader5_or_es31
, ir_unop_find_lsb
,
5037 glsl_type::ivec(type
->vector_elements
), type
);
5040 ir_function_signature
*
5041 builtin_builder::_findMSB(const glsl_type
*type
)
5043 return unop(gpu_shader5_or_es31
, ir_unop_find_msb
,
5044 glsl_type::ivec(type
->vector_elements
), type
);
5047 ir_function_signature
*
5048 builtin_builder::_fma(builtin_available_predicate avail
, const glsl_type
*type
)
5050 ir_variable
*a
= in_var(type
, "a");
5051 ir_variable
*b
= in_var(type
, "b");
5052 ir_variable
*c
= in_var(type
, "c");
5053 MAKE_SIG(type
, avail
, 3, a
, b
, c
);
5055 body
.emit(ret(ir_builder::fma(a
, b
, c
)));
5060 ir_function_signature
*
5061 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5063 return binop(x_type
->base_type
== GLSL_TYPE_DOUBLE
? fp64
: gpu_shader5_or_es31
,
5064 ir_binop_ldexp
, x_type
, x_type
, exp_type
);
5067 ir_function_signature
*
5068 builtin_builder::_dfrexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5070 ir_variable
*x
= in_var(x_type
, "x");
5071 ir_variable
*exponent
= out_var(exp_type
, "exp");
5072 MAKE_SIG(x_type
, fp64
, 2, x
, exponent
);
5074 body
.emit(assign(exponent
, expr(ir_unop_frexp_exp
, x
)));
5076 body
.emit(ret(expr(ir_unop_frexp_sig
, x
)));
5080 ir_function_signature
*
5081 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
5083 ir_variable
*x
= in_var(x_type
, "x");
5084 ir_variable
*exponent
= out_var(exp_type
, "exp");
5085 MAKE_SIG(x_type
, gpu_shader5_or_es31
, 2, x
, exponent
);
5087 const unsigned vec_elem
= x_type
->vector_elements
;
5088 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
5089 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
5091 /* Single-precision floating-point values are stored as
5096 * An exponent shift of 23 will shift the mantissa out, leaving only the
5097 * exponent and sign bit (which itself may be zero, if the absolute value
5098 * was taken before the bitcast and shift.
5100 ir_constant
*exponent_shift
= imm(23);
5101 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
5103 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
5105 /* Exponent of floating-point values in the range [0.5, 1.0). */
5106 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
5108 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
5109 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
5111 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
5112 * to unsigned integers to ensure that 1 bits aren't shifted in.
5114 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
5115 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
5116 imm(0, vec_elem
)))));
5118 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
5119 body
.emit(assign(bits
, bitcast_f2u(x
)));
5120 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
5121 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
5122 imm(0u, vec_elem
)))));
5123 body
.emit(ret(bitcast_u2f(bits
)));
5128 ir_function_signature
*
5129 builtin_builder::_uaddCarry(const glsl_type
*type
)
5131 ir_variable
*x
= in_var(type
, "x");
5132 ir_variable
*y
= in_var(type
, "y");
5133 ir_variable
*carry
= out_var(type
, "carry");
5134 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, carry
);
5136 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
5137 body
.emit(ret(add(x
, y
)));
5142 ir_function_signature
*
5143 builtin_builder::_usubBorrow(const glsl_type
*type
)
5145 ir_variable
*x
= in_var(type
, "x");
5146 ir_variable
*y
= in_var(type
, "y");
5147 ir_variable
*borrow
= out_var(type
, "borrow");
5148 MAKE_SIG(type
, gpu_shader5_or_es31
, 3, x
, y
, borrow
);
5150 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
5151 body
.emit(ret(sub(x
, y
)));
5157 * For both imulExtended() and umulExtended() built-ins.
5159 ir_function_signature
*
5160 builtin_builder::_mulExtended(const glsl_type
*type
)
5162 ir_variable
*x
= in_var(type
, "x");
5163 ir_variable
*y
= in_var(type
, "y");
5164 ir_variable
*msb
= out_var(type
, "msb");
5165 ir_variable
*lsb
= out_var(type
, "lsb");
5166 MAKE_SIG(glsl_type::void_type
, gpu_shader5_or_es31
, 4, x
, y
, msb
, lsb
);
5168 body
.emit(assign(msb
, imul_high(x
, y
)));
5169 body
.emit(assign(lsb
, mul(x
, y
)));
5174 ir_function_signature
*
5175 builtin_builder::_interpolateAtCentroid(const glsl_type
*type
)
5177 ir_variable
*interpolant
= in_var(type
, "interpolant");
5178 interpolant
->data
.must_be_shader_input
= 1;
5179 MAKE_SIG(type
, fs_interpolate_at
, 1, interpolant
);
5181 body
.emit(ret(interpolate_at_centroid(interpolant
)));
5186 ir_function_signature
*
5187 builtin_builder::_interpolateAtOffset(const glsl_type
*type
)
5189 ir_variable
*interpolant
= in_var(type
, "interpolant");
5190 interpolant
->data
.must_be_shader_input
= 1;
5191 ir_variable
*offset
= in_var(glsl_type::vec2_type
, "offset");
5192 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, offset
);
5194 body
.emit(ret(interpolate_at_offset(interpolant
, offset
)));
5199 ir_function_signature
*
5200 builtin_builder::_interpolateAtSample(const glsl_type
*type
)
5202 ir_variable
*interpolant
= in_var(type
, "interpolant");
5203 interpolant
->data
.must_be_shader_input
= 1;
5204 ir_variable
*sample_num
= in_var(glsl_type::int_type
, "sample_num");
5205 MAKE_SIG(type
, fs_interpolate_at
, 2, interpolant
, sample_num
);
5207 body
.emit(ret(interpolate_at_sample(interpolant
, sample_num
)));
5212 ir_function_signature
*
5213 builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail
)
5215 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5216 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 1, counter
);
5220 ir_function_signature
*
5221 builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail
)
5223 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5224 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5225 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 2, counter
, data
);
5229 ir_function_signature
*
5230 builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail
)
5232 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "counter");
5233 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5234 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5235 MAKE_INTRINSIC(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5239 ir_function_signature
*
5240 builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail
,
5241 const glsl_type
*type
)
5243 ir_variable
*atomic
= in_var(type
, "atomic");
5244 ir_variable
*data
= in_var(type
, "data");
5245 MAKE_INTRINSIC(type
, avail
, 2, atomic
, data
);
5249 ir_function_signature
*
5250 builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail
,
5251 const glsl_type
*type
)
5253 ir_variable
*atomic
= in_var(type
, "atomic");
5254 ir_variable
*data1
= in_var(type
, "data1");
5255 ir_variable
*data2
= in_var(type
, "data2");
5256 MAKE_INTRINSIC(type
, avail
, 3, atomic
, data1
, data2
);
5260 ir_function_signature
*
5261 builtin_builder::_atomic_counter_op(const char *intrinsic
,
5262 builtin_available_predicate avail
)
5264 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5265 MAKE_SIG(glsl_type::uint_type
, avail
, 1, counter
);
5267 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5268 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5270 body
.emit(ret(retval
));
5274 ir_function_signature
*
5275 builtin_builder::_atomic_counter_op1(const char *intrinsic
,
5276 builtin_available_predicate avail
)
5278 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5279 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5280 MAKE_SIG(glsl_type::uint_type
, avail
, 2, counter
, data
);
5282 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5283 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5285 body
.emit(ret(retval
));
5289 ir_function_signature
*
5290 builtin_builder::_atomic_counter_op2(const char *intrinsic
,
5291 builtin_available_predicate avail
)
5293 ir_variable
*counter
= in_var(glsl_type::atomic_uint_type
, "atomic_counter");
5294 ir_variable
*compare
= in_var(glsl_type::uint_type
, "compare");
5295 ir_variable
*data
= in_var(glsl_type::uint_type
, "data");
5296 MAKE_SIG(glsl_type::uint_type
, avail
, 3, counter
, compare
, data
);
5298 ir_variable
*retval
= body
.make_temp(glsl_type::uint_type
, "atomic_retval");
5299 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5301 body
.emit(ret(retval
));
5305 ir_function_signature
*
5306 builtin_builder::_atomic_op2(const char *intrinsic
,
5307 builtin_available_predicate avail
,
5308 const glsl_type
*type
)
5310 ir_variable
*atomic
= in_var(type
, "atomic_var");
5311 ir_variable
*data
= in_var(type
, "atomic_data");
5312 MAKE_SIG(type
, avail
, 2, atomic
, data
);
5314 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5315 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5317 body
.emit(ret(retval
));
5321 ir_function_signature
*
5322 builtin_builder::_atomic_op3(const char *intrinsic
,
5323 builtin_available_predicate avail
,
5324 const glsl_type
*type
)
5326 ir_variable
*atomic
= in_var(type
, "atomic_var");
5327 ir_variable
*data1
= in_var(type
, "atomic_data1");
5328 ir_variable
*data2
= in_var(type
, "atomic_data2");
5329 MAKE_SIG(type
, avail
, 3, atomic
, data1
, data2
);
5331 ir_variable
*retval
= body
.make_temp(type
, "atomic_retval");
5332 body
.emit(call(shader
->symbols
->get_function(intrinsic
), retval
,
5334 body
.emit(ret(retval
));
5338 ir_function_signature
*
5339 builtin_builder::_min3(const glsl_type
*type
)
5341 ir_variable
*x
= in_var(type
, "x");
5342 ir_variable
*y
= in_var(type
, "y");
5343 ir_variable
*z
= in_var(type
, "z");
5344 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5346 ir_expression
*min3
= min2(x
, min2(y
,z
));
5347 body
.emit(ret(min3
));
5352 ir_function_signature
*
5353 builtin_builder::_max3(const glsl_type
*type
)
5355 ir_variable
*x
= in_var(type
, "x");
5356 ir_variable
*y
= in_var(type
, "y");
5357 ir_variable
*z
= in_var(type
, "z");
5358 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5360 ir_expression
*max3
= max2(x
, max2(y
,z
));
5361 body
.emit(ret(max3
));
5366 ir_function_signature
*
5367 builtin_builder::_mid3(const glsl_type
*type
)
5369 ir_variable
*x
= in_var(type
, "x");
5370 ir_variable
*y
= in_var(type
, "y");
5371 ir_variable
*z
= in_var(type
, "z");
5372 MAKE_SIG(type
, shader_trinary_minmax
, 3, x
, y
, z
);
5374 ir_expression
*mid3
= max2(min2(x
, y
), max2(min2(x
, z
), min2(y
, z
)));
5375 body
.emit(ret(mid3
));
5380 static builtin_available_predicate
5381 get_image_available_predicate(const glsl_type
*type
, unsigned flags
)
5383 if ((flags
& IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
) &&
5384 type
->sampled_type
== GLSL_TYPE_FLOAT
)
5385 return shader_image_atomic_exchange_float
;
5387 else if (flags
& (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE
|
5388 IMAGE_FUNCTION_AVAIL_ATOMIC
))
5389 return shader_image_atomic
;
5392 return shader_image_load_store
;
5395 ir_function_signature
*
5396 builtin_builder::_image_prototype(const glsl_type
*image_type
,
5397 unsigned num_arguments
,
5400 const glsl_type
*data_type
= glsl_type::get_instance(
5401 image_type
->sampled_type
,
5402 (flags
& IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE
? 4 : 1),
5404 const glsl_type
*ret_type
= (flags
& IMAGE_FUNCTION_RETURNS_VOID
?
5405 glsl_type::void_type
: data_type
);
5407 /* Addressing arguments that are always present. */
5408 ir_variable
*image
= in_var(image_type
, "image");
5409 ir_variable
*coord
= in_var(
5410 glsl_type::ivec(image_type
->coordinate_components()), "coord");
5412 ir_function_signature
*sig
= new_sig(
5413 ret_type
, get_image_available_predicate(image_type
, flags
),
5416 /* Sample index for multisample images. */
5417 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
)
5418 sig
->parameters
.push_tail(in_var(glsl_type::int_type
, "sample"));
5420 /* Data arguments. */
5421 for (unsigned i
= 0; i
< num_arguments
; ++i
) {
5422 char *arg_name
= ralloc_asprintf(NULL
, "arg%d", i
);
5423 sig
->parameters
.push_tail(in_var(data_type
, arg_name
));
5424 ralloc_free(arg_name
);
5427 /* Set the maximal set of qualifiers allowed for this image
5428 * built-in. Function calls with arguments having fewer
5429 * qualifiers than present in the prototype are allowed by the
5430 * spec, but not with more, i.e. this will make the compiler
5431 * accept everything that needs to be accepted, and reject cases
5432 * like loads from write-only or stores to read-only images.
5434 image
->data
.image_read_only
= (flags
& IMAGE_FUNCTION_READ_ONLY
) != 0;
5435 image
->data
.image_write_only
= (flags
& IMAGE_FUNCTION_WRITE_ONLY
) != 0;
5436 image
->data
.image_coherent
= true;
5437 image
->data
.image_volatile
= true;
5438 image
->data
.image_restrict
= true;
5443 ir_function_signature
*
5444 builtin_builder::_image_size_prototype(const glsl_type
*image_type
,
5445 unsigned /* num_arguments */,
5446 unsigned /* flags */)
5448 const glsl_type
*ret_type
;
5449 unsigned num_components
= image_type
->coordinate_components();
5451 /* From the ARB_shader_image_size extension:
5452 * "Cube images return the dimensions of one face."
5454 if (image_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_CUBE
&&
5455 !image_type
->sampler_array
) {
5459 /* FIXME: Add the highp precision qualifier for GLES 3.10 when it is
5460 * supported by mesa.
5462 ret_type
= glsl_type::get_instance(GLSL_TYPE_INT
, num_components
, 1);
5464 ir_variable
*image
= in_var(image_type
, "image");
5465 ir_function_signature
*sig
= new_sig(ret_type
, shader_image_size
, 1, image
);
5467 /* Set the maximal set of qualifiers allowed for this image
5468 * built-in. Function calls with arguments having fewer
5469 * qualifiers than present in the prototype are allowed by the
5470 * spec, but not with more, i.e. this will make the compiler
5471 * accept everything that needs to be accepted, and reject cases
5472 * like loads from write-only or stores to read-only images.
5474 image
->data
.image_read_only
= true;
5475 image
->data
.image_write_only
= true;
5476 image
->data
.image_coherent
= true;
5477 image
->data
.image_volatile
= true;
5478 image
->data
.image_restrict
= true;
5483 ir_function_signature
*
5484 builtin_builder::_image_samples_prototype(const glsl_type
*image_type
,
5485 unsigned /* num_arguments */,
5486 unsigned /* flags */)
5488 ir_variable
*image
= in_var(image_type
, "image");
5489 ir_function_signature
*sig
=
5490 new_sig(glsl_type::int_type
, shader_samples
, 1, image
);
5492 /* Set the maximal set of qualifiers allowed for this image
5493 * built-in. Function calls with arguments having fewer
5494 * qualifiers than present in the prototype are allowed by the
5495 * spec, but not with more, i.e. this will make the compiler
5496 * accept everything that needs to be accepted, and reject cases
5497 * like loads from write-only or stores to read-only images.
5499 image
->data
.image_read_only
= true;
5500 image
->data
.image_write_only
= true;
5501 image
->data
.image_coherent
= true;
5502 image
->data
.image_volatile
= true;
5503 image
->data
.image_restrict
= true;
5508 ir_function_signature
*
5509 builtin_builder::_image(image_prototype_ctr prototype
,
5510 const glsl_type
*image_type
,
5511 const char *intrinsic_name
,
5512 unsigned num_arguments
,
5515 ir_function_signature
*sig
= (this->*prototype
)(image_type
,
5516 num_arguments
, flags
);
5518 if (flags
& IMAGE_FUNCTION_EMIT_STUB
) {
5519 ir_factory
body(&sig
->body
, mem_ctx
);
5520 ir_function
*f
= shader
->symbols
->get_function(intrinsic_name
);
5522 if (flags
& IMAGE_FUNCTION_RETURNS_VOID
) {
5523 body
.emit(call(f
, NULL
, sig
->parameters
));
5525 ir_variable
*ret_val
=
5526 body
.make_temp(sig
->return_type
, "_ret_val");
5527 body
.emit(call(f
, ret_val
, sig
->parameters
));
5528 body
.emit(ret(ret_val
));
5531 sig
->is_defined
= true;
5534 sig
->is_intrinsic
= true;
5540 ir_function_signature
*
5541 builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail
)
5543 MAKE_INTRINSIC(glsl_type::void_type
, avail
, 0);
5547 ir_function_signature
*
5548 builtin_builder::_memory_barrier(const char *intrinsic_name
,
5549 builtin_available_predicate avail
)
5551 MAKE_SIG(glsl_type::void_type
, avail
, 0);
5552 body
.emit(call(shader
->symbols
->get_function(intrinsic_name
),
5553 NULL
, sig
->parameters
));
5557 ir_function_signature
*
5558 builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail
,
5559 const glsl_type
*type
)
5561 MAKE_INTRINSIC(type
, avail
, 0);
5565 ir_function_signature
*
5566 builtin_builder::_shader_clock(builtin_available_predicate avail
,
5567 const glsl_type
*type
)
5569 MAKE_SIG(type
, avail
, 0);
5571 ir_variable
*retval
= body
.make_temp(type
, "clock_retval");
5573 body
.emit(call(shader
->symbols
->get_function("__intrinsic_shader_clock"),
5574 retval
, sig
->parameters
));
5575 body
.emit(ret(retval
));
5581 /******************************************************************************/
5583 /* The singleton instance of builtin_builder. */
5584 static builtin_builder builtins
;
5585 static mtx_t builtins_lock
= _MTX_INITIALIZER_NP
;
5588 * External API (exposing the built-in module to the rest of the compiler):
5592 _mesa_glsl_initialize_builtin_functions()
5594 mtx_lock(&builtins_lock
);
5595 builtins
.initialize();
5596 mtx_unlock(&builtins_lock
);
5600 _mesa_glsl_release_builtin_functions()
5602 mtx_lock(&builtins_lock
);
5604 mtx_unlock(&builtins_lock
);
5607 ir_function_signature
*
5608 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
5609 const char *name
, exec_list
*actual_parameters
)
5611 ir_function_signature
* s
;
5612 mtx_lock(&builtins_lock
);
5613 s
= builtins
.find(state
, name
, actual_parameters
);
5614 mtx_unlock(&builtins_lock
);
5619 _mesa_glsl_find_builtin_function_by_name(const char *name
)
5622 mtx_lock(&builtins_lock
);
5623 f
= builtins
.shader
->symbols
->get_function(name
);
5624 mtx_unlock(&builtins_lock
);
5629 _mesa_glsl_get_builtin_function_shader()
5631 return builtins
.shader
;
5636 * Get the function signature for main from a shader
5638 ir_function_signature
*
5639 _mesa_get_main_function_signature(gl_shader
*sh
)
5641 ir_function
*const f
= sh
->symbols
->get_function("main");
5643 exec_list void_parameters
;
5645 /* Look for the 'void main()' signature and ensure that it's defined.
5646 * This keeps the linker from accidentally pick a shader that just
5647 * contains a prototype for main.
5649 * We don't have to check for multiple definitions of main (in multiple
5650 * shaders) because that would have already been caught above.
5652 ir_function_signature
*sig
=
5653 f
->matching_signature(NULL
, &void_parameters
, false);
5654 if ((sig
!= NULL
) && sig
->is_defined
) {