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 using namespace ir_builder
;
68 * Availability predicates:
72 always_available(const _mesa_glsl_parse_state
*state
)
78 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
80 return state
->target
== vertex_shader
&&
81 state
->language_version
<= 130 &&
86 fs_only(const _mesa_glsl_parse_state
*state
)
88 return state
->target
== fragment_shader
;
92 gs_only(const _mesa_glsl_parse_state
*state
)
94 return state
->target
== geometry_shader
;
98 v110(const _mesa_glsl_parse_state
*state
)
100 return !state
->es_shader
;
104 v110_fs_only(const _mesa_glsl_parse_state
*state
)
106 return !state
->es_shader
&& state
->target
== fragment_shader
;
110 v120(const _mesa_glsl_parse_state
*state
)
112 return state
->is_version(120, 300);
116 v130(const _mesa_glsl_parse_state
*state
)
118 return state
->is_version(130, 300);
122 v130_fs_only(const _mesa_glsl_parse_state
*state
)
124 return state
->is_version(130, 300) &&
125 state
->target
== fragment_shader
;
129 v140(const _mesa_glsl_parse_state
*state
)
131 return state
->is_version(140, 0);
135 texture_rectangle(const _mesa_glsl_parse_state
*state
)
137 return state
->ARB_texture_rectangle_enable
;
141 texture_external(const _mesa_glsl_parse_state
*state
)
143 return state
->OES_EGL_image_external_enable
;
146 /** True if texturing functions with explicit LOD are allowed. */
148 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
150 /* Texturing functions with "Lod" in their name exist:
151 * - In the vertex shader stage (for all languages)
152 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
153 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
155 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
156 * don't need to explicitly check state->es_shader.
158 return state
->target
== vertex_shader
||
159 state
->is_version(130, 300) ||
160 state
->ARB_shader_texture_lod_enable
;
164 v110_lod(const _mesa_glsl_parse_state
*state
)
166 return !state
->es_shader
&& lod_exists_in_stage(state
);
170 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
172 return state
->ARB_shader_texture_lod_enable
;
176 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
178 return state
->ARB_shader_texture_lod_enable
&&
179 state
->ARB_texture_rectangle_enable
;
183 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
185 return state
->is_version(330, 300) ||
186 state
->ARB_shader_bit_encoding_enable
||
187 state
->ARB_gpu_shader5_enable
;
191 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
193 return v130(state
) && state
->MESA_shader_integer_mix_enable
;
197 shader_packing(const _mesa_glsl_parse_state
*state
)
199 return state
->ARB_shading_language_packing_enable
||
200 state
->is_version(400, 0);
204 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
206 return state
->ARB_shading_language_packing_enable
||
207 state
->is_version(400, 300);
211 gpu_shader5(const _mesa_glsl_parse_state
*state
)
213 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
217 vs_texture_array(const _mesa_glsl_parse_state
*state
)
219 return state
->target
== vertex_shader
&&
220 state
->EXT_texture_array_enable
;
224 fs_texture_array(const _mesa_glsl_parse_state
*state
)
226 return state
->target
== fragment_shader
&&
227 state
->EXT_texture_array_enable
;
231 texture_array(const _mesa_glsl_parse_state
*state
)
233 return state
->EXT_texture_array_enable
;
237 texture_multisample(const _mesa_glsl_parse_state
*state
)
239 return state
->is_version(150, 0) ||
240 state
->ARB_texture_multisample_enable
;
244 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
246 return state
->target
== fragment_shader
&&
247 (state
->is_version(400, 0) ||
248 state
->ARB_texture_cube_map_array_enable
);
252 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(400, 0) ||
255 state
->ARB_texture_cube_map_array_enable
;
259 texture_query_lod(const _mesa_glsl_parse_state
*state
)
261 return state
->target
== fragment_shader
&&
262 state
->ARB_texture_query_lod_enable
;
265 /* Desktop GL or OES_standard_derivatives + fragment shader only */
267 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
269 return state
->target
== fragment_shader
&&
270 (!state
->es_shader
|| state
->OES_standard_derivatives_enable
);
274 tex1d_lod(const _mesa_glsl_parse_state
*state
)
276 return !state
->es_shader
&& lod_exists_in_stage(state
);
279 /** True if sampler3D exists */
281 tex3d(const _mesa_glsl_parse_state
*state
)
283 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
284 * OES_texture_3D extension, and in GLSL ES 3.00.
286 return !state
->es_shader
||
287 state
->OES_texture_3D_enable
||
288 state
->language_version
>= 300;
292 fs_tex3d(const _mesa_glsl_parse_state
*state
)
294 return state
->target
== fragment_shader
&&
295 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
299 tex3d_lod(const _mesa_glsl_parse_state
*state
)
301 return tex3d(state
) && lod_exists_in_stage(state
);
305 /******************************************************************************/
308 * builtin_builder: A singleton object representing the core of the built-in
311 * It generates IR for every built-in function signature, and organizes them
314 class builtin_builder
{
321 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
322 const char *name
, exec_list
*actual_parameters
);
327 * A shader to hold all the built-in signatures; created by this module.
329 * This includes signatures for every built-in, regardless of version or
330 * enabled extensions. The availability predicate associated with each
331 * signature allows matching_signature() to filter out the irrelevant ones.
335 /** Global variables used by built-in functions. */
336 ir_variable
*gl_ModelViewProjectionMatrix
;
337 ir_variable
*gl_Vertex
;
339 void create_shader();
340 void create_builtins();
343 * IR builder helpers:
345 * These convenience functions assist in emitting IR, but don't necessarily
346 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
349 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
350 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
351 ir_constant
*imm(float f
);
352 ir_constant
*imm(int i
);
353 ir_constant
*imm(unsigned u
);
354 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
355 ir_dereference_variable
*var_ref(ir_variable
*var
);
356 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
357 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
359 ir_expression
*asin_expr(ir_variable
*x
);
361 /** Create a new function and add the given signatures. */
362 void add_function(const char *name
, ...);
364 ir_function_signature
*new_sig(const glsl_type
*return_type
,
365 builtin_available_predicate avail
,
366 int num_params
, ...);
369 * Function signature generators:
372 ir_function_signature
*unop(builtin_available_predicate avail
,
373 ir_expression_operation opcode
,
374 const glsl_type
*return_type
,
375 const glsl_type
*param_type
);
376 ir_function_signature
*binop(ir_expression_operation opcode
,
377 builtin_available_predicate avail
,
378 const glsl_type
*return_type
,
379 const glsl_type
*param0_type
,
380 const glsl_type
*param1_type
);
382 #define B0(X) ir_function_signature *_##X();
383 #define B1(X) ir_function_signature *_##X(const glsl_type *);
384 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
385 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
386 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
387 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
424 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
425 const glsl_type
*val_type
,
426 const glsl_type
*blend_type
);
435 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
436 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
437 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
438 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
439 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
440 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
441 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
442 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
443 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
444 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
456 B0(determinant_mat2
);
457 B0(determinant_mat3
);
458 B0(determinant_mat4
);
466 BA1(greaterThanEqual
);
473 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
474 const glsl_type
*return_type
,
475 const glsl_type
*sampler_type
);
477 /** Flags to _texture() */
478 #define TEX_PROJECT 1
481 ir_function_signature
*_texture(ir_texture_opcode opcode
,
482 builtin_available_predicate avail
,
483 const glsl_type
*return_type
,
484 const glsl_type
*sampler_type
,
485 const glsl_type
*coord_type
,
487 B0(textureCubeArrayShadow
);
488 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
489 const glsl_type
*return_type
,
490 const glsl_type
*sampler_type
,
491 const glsl_type
*coord_type
,
492 const glsl_type
*offset_type
= NULL
);
523 * Core builtin_builder functionality:
526 builtin_builder::builtin_builder()
528 gl_ModelViewProjectionMatrix(NULL
),
534 builtin_builder::~builtin_builder()
536 ralloc_free(mem_ctx
);
539 ir_function_signature
*
540 builtin_builder::find(_mesa_glsl_parse_state
*state
,
541 const char *name
, exec_list
*actual_parameters
)
543 /* The shader currently being compiled requested a built-in function;
544 * it needs to link against builtin_builder::shader in order to get them.
546 * Even if we don't find a matching signature, we still need to do this so
547 * that the "no matching signature" error will list potential candidates
548 * from the available built-ins.
550 state
->builtins_to_link
[0] = shader
;
551 state
->num_builtins_to_link
= 1;
553 ir_function
*f
= shader
->symbols
->get_function(name
);
557 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
565 builtin_builder::initialize()
567 /* If already initialized, don't do it again. */
571 mem_ctx
= ralloc_context(NULL
);
577 builtin_builder::release()
579 ralloc_free(mem_ctx
);
584 builtin_builder::create_shader()
586 /* The target doesn't actually matter. There's no target for generic
587 * GLSL utility code that could be linked against any stage, so just
588 * arbitrarily pick GL_VERTEX_SHADER.
590 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
591 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
593 gl_ModelViewProjectionMatrix
=
594 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
595 "gl_ModelViewProjectionMatrix",
598 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
600 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
601 shader
->symbols
->add_variable(gl_Vertex
);
607 * Create ir_function and ir_function_signature objects for each built-in.
609 * Contains a list of every available built-in.
612 builtin_builder::create_builtins()
615 add_function(#NAME, \
616 _##NAME(glsl_type::float_type), \
617 _##NAME(glsl_type::vec2_type), \
618 _##NAME(glsl_type::vec3_type), \
619 _##NAME(glsl_type::vec4_type), \
623 add_function(#NAME, \
624 _##NAME(glsl_type::float_type), \
625 _##NAME(glsl_type::vec2_type), \
626 _##NAME(glsl_type::vec3_type), \
627 _##NAME(glsl_type::vec4_type), \
628 _##NAME(glsl_type::int_type), \
629 _##NAME(glsl_type::ivec2_type), \
630 _##NAME(glsl_type::ivec3_type), \
631 _##NAME(glsl_type::ivec4_type), \
635 add_function(#NAME, \
636 _##NAME(always_available, glsl_type::float_type), \
637 _##NAME(always_available, glsl_type::vec2_type), \
638 _##NAME(always_available, glsl_type::vec3_type), \
639 _##NAME(always_available, glsl_type::vec4_type), \
641 _##NAME(always_available, glsl_type::int_type), \
642 _##NAME(always_available, glsl_type::ivec2_type), \
643 _##NAME(always_available, glsl_type::ivec3_type), \
644 _##NAME(always_available, glsl_type::ivec4_type), \
646 _##NAME(v130, glsl_type::uint_type), \
647 _##NAME(v130, glsl_type::uvec2_type), \
648 _##NAME(v130, glsl_type::uvec3_type), \
649 _##NAME(v130, glsl_type::uvec4_type), \
653 add_function(#NAME, \
654 _##NAME(glsl_type::int_type), \
655 _##NAME(glsl_type::ivec2_type), \
656 _##NAME(glsl_type::ivec3_type), \
657 _##NAME(glsl_type::ivec4_type), \
659 _##NAME(glsl_type::uint_type), \
660 _##NAME(glsl_type::uvec2_type), \
661 _##NAME(glsl_type::uvec3_type), \
662 _##NAME(glsl_type::uvec4_type), \
666 add_function(#NAME, \
667 _##NAME(always_available, glsl_type::float_type), \
668 _##NAME(always_available, glsl_type::vec2_type), \
669 _##NAME(always_available, glsl_type::vec3_type), \
670 _##NAME(always_available, glsl_type::vec4_type), \
672 _##NAME(always_available, glsl_type::int_type), \
673 _##NAME(always_available, glsl_type::ivec2_type), \
674 _##NAME(always_available, glsl_type::ivec3_type), \
675 _##NAME(always_available, glsl_type::ivec4_type), \
677 _##NAME(v130, glsl_type::uint_type), \
678 _##NAME(v130, glsl_type::uvec2_type), \
679 _##NAME(v130, glsl_type::uvec3_type), \
680 _##NAME(v130, glsl_type::uvec4_type), \
682 _##NAME(always_available, glsl_type::bool_type), \
683 _##NAME(always_available, glsl_type::bvec2_type), \
684 _##NAME(always_available, glsl_type::bvec3_type), \
685 _##NAME(always_available, glsl_type::bvec4_type), \
688 #define FIU2_MIXED(NAME) \
689 add_function(#NAME, \
690 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
691 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
692 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
693 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
695 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
696 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
697 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
699 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
700 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
701 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
702 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
704 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
705 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
706 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
708 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
709 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
710 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
711 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
713 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
714 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
715 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
727 _atan(glsl_type::float_type
),
728 _atan(glsl_type::vec2_type
),
729 _atan(glsl_type::vec3_type
),
730 _atan(glsl_type::vec4_type
),
731 _atan2(glsl_type::float_type
),
732 _atan2(glsl_type::vec2_type
),
733 _atan2(glsl_type::vec3_type
),
734 _atan2(glsl_type::vec4_type
),
760 _mod(glsl_type::float_type
, glsl_type::float_type
),
761 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
762 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
763 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
765 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
766 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
767 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
777 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
778 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
779 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
780 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
782 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
783 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
784 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
786 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
787 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
788 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
789 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
791 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
792 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
793 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
794 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
796 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
797 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
798 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
799 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
801 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
802 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
803 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
804 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
808 _step(glsl_type::float_type
, glsl_type::float_type
),
809 _step(glsl_type::float_type
, glsl_type::vec2_type
),
810 _step(glsl_type::float_type
, glsl_type::vec3_type
),
811 _step(glsl_type::float_type
, glsl_type::vec4_type
),
813 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
814 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
815 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
818 add_function("smoothstep",
819 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
820 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
821 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
822 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
824 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
825 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
826 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
834 add_function("intBitsToFloat",
835 _intBitsToFloat(glsl_type::int_type
),
836 _intBitsToFloat(glsl_type::ivec2_type
),
837 _intBitsToFloat(glsl_type::ivec3_type
),
838 _intBitsToFloat(glsl_type::ivec4_type
),
840 add_function("uintBitsToFloat",
841 _uintBitsToFloat(glsl_type::uint_type
),
842 _uintBitsToFloat(glsl_type::uvec2_type
),
843 _uintBitsToFloat(glsl_type::uvec3_type
),
844 _uintBitsToFloat(glsl_type::uvec4_type
),
847 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3
), NULL
);
848 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
849 add_function("packUnorm4x8", _packUnorm4x8(shader_packing
), NULL
);
850 add_function("packSnorm4x8", _packSnorm4x8(shader_packing
), NULL
);
851 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3
), NULL
);
852 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
853 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing
), NULL
);
854 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing
), NULL
);
855 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
856 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
862 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
865 add_function("ftransform", _ftransform(), NULL
);
870 add_function("matrixCompMult",
871 _matrixCompMult(glsl_type::mat2_type
),
872 _matrixCompMult(glsl_type::mat3_type
),
873 _matrixCompMult(glsl_type::mat4_type
),
874 _matrixCompMult(glsl_type::mat2x3_type
),
875 _matrixCompMult(glsl_type::mat2x4_type
),
876 _matrixCompMult(glsl_type::mat3x2_type
),
877 _matrixCompMult(glsl_type::mat3x4_type
),
878 _matrixCompMult(glsl_type::mat4x2_type
),
879 _matrixCompMult(glsl_type::mat4x3_type
),
881 add_function("outerProduct",
882 _outerProduct(glsl_type::mat2_type
),
883 _outerProduct(glsl_type::mat3_type
),
884 _outerProduct(glsl_type::mat4_type
),
885 _outerProduct(glsl_type::mat2x3_type
),
886 _outerProduct(glsl_type::mat2x4_type
),
887 _outerProduct(glsl_type::mat3x2_type
),
888 _outerProduct(glsl_type::mat3x4_type
),
889 _outerProduct(glsl_type::mat4x2_type
),
890 _outerProduct(glsl_type::mat4x3_type
),
892 add_function("determinant",
897 add_function("inverse",
902 add_function("transpose",
903 _transpose(glsl_type::mat2_type
),
904 _transpose(glsl_type::mat3_type
),
905 _transpose(glsl_type::mat4_type
),
906 _transpose(glsl_type::mat2x3_type
),
907 _transpose(glsl_type::mat2x4_type
),
908 _transpose(glsl_type::mat3x2_type
),
909 _transpose(glsl_type::mat3x4_type
),
910 _transpose(glsl_type::mat4x2_type
),
911 _transpose(glsl_type::mat4x3_type
),
916 FIU(greaterThanEqual
)
921 _any(glsl_type::bvec2_type
),
922 _any(glsl_type::bvec3_type
),
923 _any(glsl_type::bvec4_type
),
927 _all(glsl_type::bvec2_type
),
928 _all(glsl_type::bvec3_type
),
929 _all(glsl_type::bvec4_type
),
933 _not(glsl_type::bvec2_type
),
934 _not(glsl_type::bvec3_type
),
935 _not(glsl_type::bvec4_type
),
938 add_function("textureSize",
939 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
940 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
941 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
943 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
944 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
945 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
947 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
948 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
949 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
951 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
952 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
953 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
955 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
956 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
957 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
959 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
960 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
961 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
962 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
963 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
964 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
966 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
967 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
969 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
970 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
971 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
972 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
974 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
975 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
976 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
977 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
979 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
980 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
981 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
982 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
983 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
984 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
986 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
987 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
988 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
991 add_function("texture",
992 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
993 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
994 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
996 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
997 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
998 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1000 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1001 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1002 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1004 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1005 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1006 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1008 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1009 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1010 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1012 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1013 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1014 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1016 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1017 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1018 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1020 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1021 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1022 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1024 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1025 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1026 /* samplerCubeArrayShadow is special; it has an extra parameter
1027 * for the shadow comparitor since there is no vec5 type.
1029 _textureCubeArrayShadow(),
1031 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1032 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1033 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1035 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1037 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1038 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1039 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1041 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1042 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1043 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1045 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1046 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1047 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1049 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1050 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1051 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1053 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1054 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1055 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1057 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1058 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1059 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1061 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1062 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1063 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1065 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1066 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1067 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1069 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1072 add_function("textureLod",
1073 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1074 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1075 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1077 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1078 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1079 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1081 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1082 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1083 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1085 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1086 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1087 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1089 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1090 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1092 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1093 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1094 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1096 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1097 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1098 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1100 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1101 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1102 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1104 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1107 add_function("textureOffset",
1108 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1109 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1110 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1112 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1113 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1114 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1116 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1117 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1118 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1120 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1121 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1122 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1124 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1126 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1127 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1129 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1130 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1131 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1133 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1134 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1135 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1137 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1139 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1140 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1141 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1143 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1144 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1145 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1147 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1148 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1149 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1151 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1152 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1154 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1155 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1156 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1158 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1159 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1160 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1162 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1165 add_function("textureProj",
1166 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1167 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1168 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1169 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1170 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1171 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1173 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1174 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1175 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1176 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1177 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1178 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1180 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1181 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1182 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1184 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1185 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1187 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1188 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1189 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1190 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1191 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1192 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1194 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1196 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1197 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1198 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1199 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1200 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1201 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1203 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1204 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1205 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1206 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1207 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1208 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1210 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1211 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1212 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1214 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1215 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1218 add_function("texelFetch",
1219 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1220 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1221 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1223 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1224 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1225 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1227 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1228 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1229 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1231 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1232 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1233 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1235 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1236 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1237 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1239 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1240 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1241 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1243 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1244 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1245 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1247 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1248 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1249 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1251 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1252 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1253 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1256 add_function("texelFetchOffset",
1257 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1258 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1259 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1261 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1262 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1263 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1265 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1266 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1267 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1269 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1270 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1271 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1273 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1274 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1275 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1277 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1278 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1279 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1283 add_function("textureProjOffset",
1284 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1285 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1286 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1287 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1288 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1289 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1291 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1292 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1293 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1294 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1295 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1296 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1298 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1299 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1300 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1302 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1303 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1305 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1306 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1307 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1308 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1309 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1310 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1312 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1314 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1315 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1316 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1317 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1318 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1319 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1321 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1322 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1323 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1324 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1325 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1326 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1328 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1329 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1330 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1332 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1333 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1336 add_function("textureLodOffset",
1337 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1338 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1339 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1341 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1342 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1343 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1345 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1346 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1347 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1349 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1350 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1352 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1353 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1354 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1356 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1357 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1358 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1360 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1363 add_function("textureProjLod",
1364 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1365 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1366 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1367 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1368 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1369 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1371 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1372 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1373 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1374 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1375 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1376 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1378 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1379 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1380 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1382 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1383 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1386 add_function("textureProjLodOffset",
1387 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1388 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1389 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1390 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1391 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1392 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1394 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1395 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1396 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1397 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1398 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1399 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1401 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1402 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1403 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1405 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1406 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1409 add_function("textureGrad",
1410 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1411 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1412 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1414 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1415 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1416 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1418 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1419 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1420 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1422 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1423 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1424 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1426 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1427 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1428 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1430 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1432 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1433 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1434 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1436 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1437 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1438 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1440 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1441 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1442 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1444 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1445 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1446 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1448 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1449 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1452 add_function("textureGradOffset",
1453 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1454 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1455 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1457 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1458 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1459 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1461 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1462 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1463 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1465 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1466 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1467 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1469 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1471 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1472 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1474 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1475 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1476 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1478 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1479 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1480 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1482 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1483 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1486 add_function("textureProjGrad",
1487 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1488 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1489 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1490 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1491 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1492 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1494 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1495 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1496 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1497 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1498 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1499 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1501 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1502 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1503 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1505 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1506 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1507 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1508 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1509 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1510 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1512 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1514 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1515 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1518 add_function("textureProjGradOffset",
1519 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1520 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1521 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1522 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1523 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1524 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1526 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1527 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1528 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1529 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1530 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1531 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1533 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1534 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1535 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1537 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1538 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1539 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1540 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1541 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1542 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1544 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1546 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1547 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1550 add_function("EmitVertex", _EmitVertex(), NULL
);
1551 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1553 add_function("textureQueryLOD",
1554 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1555 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1556 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1558 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1559 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1560 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1562 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1563 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1564 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1566 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1567 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1568 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1570 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1571 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1572 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1574 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1575 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1576 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1578 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1579 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1580 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1582 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1583 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1584 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1585 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1586 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1587 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1590 add_function("texture1D",
1591 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1592 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1595 add_function("texture1DArray",
1596 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1597 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1600 add_function("texture1DProj",
1601 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1602 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1603 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1604 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1607 add_function("texture1DLod",
1608 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1611 add_function("texture1DArrayLod",
1612 _texture(ir_txl
, vs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1615 add_function("texture1DProjLod",
1616 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1617 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1620 add_function("texture2D",
1621 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1622 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1623 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1626 add_function("texture2DArray",
1627 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1628 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1631 add_function("texture2DProj",
1632 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1633 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1634 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1635 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1636 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1637 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1640 add_function("texture2DLod",
1641 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1644 add_function("texture2DArrayLod",
1645 _texture(ir_txl
, vs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1648 add_function("texture2DProjLod",
1649 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1650 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1653 add_function("texture3D",
1654 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1655 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1658 add_function("texture3DProj",
1659 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1660 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1663 add_function("texture3DLod",
1664 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1667 add_function("texture3DProjLod",
1668 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1671 add_function("textureCube",
1672 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1673 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1676 add_function("textureCubeLod",
1677 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1680 add_function("texture2DRect",
1681 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1684 add_function("texture2DRectProj",
1685 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1686 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1689 add_function("shadow1D",
1690 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1691 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1694 add_function("shadow1DArray",
1695 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1696 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1699 add_function("shadow2D",
1700 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1701 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1704 add_function("shadow2DArray",
1705 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1706 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1709 add_function("shadow1DProj",
1710 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1711 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1714 add_function("shadow2DProj",
1715 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1716 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1719 add_function("shadow1DLod",
1720 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1723 add_function("shadow2DLod",
1724 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1727 add_function("shadow1DArrayLod",
1728 _texture(ir_txl
, vs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1731 add_function("shadow1DProjLod",
1732 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1735 add_function("shadow2DProjLod",
1736 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1739 add_function("shadow2DRect",
1740 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1743 add_function("shadow2DRectProj",
1744 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1747 add_function("texture1DGradARB",
1748 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1751 add_function("texture1DProjGradARB",
1752 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1753 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1756 add_function("texture2DGradARB",
1757 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1760 add_function("texture2DProjGradARB",
1761 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1762 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1765 add_function("texture3DGradARB",
1766 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1769 add_function("texture3DProjGradARB",
1770 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1773 add_function("textureCubeGradARB",
1774 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1777 add_function("shadow1DGradARB",
1778 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1781 add_function("shadow1DProjGradARB",
1782 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1785 add_function("shadow2DGradARB",
1786 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1789 add_function("shadow2DProjGradARB",
1790 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1793 add_function("texture2DRectGradARB",
1794 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1797 add_function("texture2DRectProjGradARB",
1798 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1799 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1802 add_function("shadow2DRectGradARB",
1803 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1806 add_function("shadow2DRectProjGradARB",
1807 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1833 builtin_builder::add_function(const char *name
, ...)
1837 ir_function
*f
= new(mem_ctx
) ir_function(name
);
1841 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
1845 sig
->is_defined
= true;
1849 stuff
.push_tail(sig
);
1850 validate_ir_tree(&stuff
);
1853 f
->add_signature(sig
);
1857 shader
->symbols
->add_function(f
);
1861 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
1863 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
1867 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
1869 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
1873 builtin_builder::imm(float f
)
1875 return new(mem_ctx
) ir_constant(f
);
1879 builtin_builder::imm(int i
)
1881 return new(mem_ctx
) ir_constant(i
);
1885 builtin_builder::imm(unsigned u
)
1887 return new(mem_ctx
) ir_constant(u
);
1891 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
1893 return new(mem_ctx
) ir_constant(type
, &data
);
1896 ir_dereference_variable
*
1897 builtin_builder::var_ref(ir_variable
*var
)
1899 return new(mem_ctx
) ir_dereference_variable(var
);
1902 ir_dereference_array
*
1903 builtin_builder::array_ref(ir_variable
*var
, int idx
)
1905 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
1908 /** Return an element of a matrix */
1910 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
1912 return swizzle(array_ref(var
, column
), row
, 1);
1916 * Implementations of built-in functions:
1919 ir_function_signature
*
1920 builtin_builder::new_sig(const glsl_type
*return_type
,
1921 builtin_available_predicate avail
,
1927 ir_function_signature
*sig
=
1928 new(mem_ctx
) ir_function_signature(return_type
, avail
);
1931 va_start(ap
, num_params
);
1932 for (int i
= 0; i
< num_params
; i
++) {
1933 plist
.push_tail(va_arg(ap
, ir_variable
*));
1937 sig
->replace_parameters(&plist
);
1941 #define MAKE_SIG(return_type, avail, ...) \
1942 ir_function_signature *sig = \
1943 new_sig(return_type, avail, __VA_ARGS__); \
1944 ir_factory body(&sig->body, mem_ctx);
1946 ir_function_signature
*
1947 builtin_builder::unop(builtin_available_predicate avail
,
1948 ir_expression_operation opcode
,
1949 const glsl_type
*return_type
,
1950 const glsl_type
*param_type
)
1952 ir_variable
*x
= in_var(param_type
, "x");
1953 MAKE_SIG(return_type
, avail
, 1, x
);
1954 body
.emit(ret(expr(opcode
, x
)));
1958 #define UNOP(NAME, OPCODE, AVAIL) \
1959 ir_function_signature * \
1960 builtin_builder::_##NAME(const glsl_type *type) \
1962 return unop(&AVAIL, OPCODE, type, type); \
1965 ir_function_signature
*
1966 builtin_builder::binop(ir_expression_operation opcode
,
1967 builtin_available_predicate avail
,
1968 const glsl_type
*return_type
,
1969 const glsl_type
*param0_type
,
1970 const glsl_type
*param1_type
)
1972 ir_variable
*x
= in_var(param0_type
, "x");
1973 ir_variable
*y
= in_var(param1_type
, "y");
1974 MAKE_SIG(return_type
, avail
, 2, x
, y
);
1975 body
.emit(ret(expr(opcode
, x
, y
)));
1979 #define BINOP(NAME, OPCODE, AVAIL) \
1980 ir_function_signature * \
1981 builtin_builder::_##NAME(const glsl_type *return_type, \
1982 const glsl_type *param0_type, \
1983 const glsl_type *param1_type) \
1985 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
1989 * Angle and Trigonometry Functions @{
1992 ir_function_signature
*
1993 builtin_builder::_radians(const glsl_type
*type
)
1995 ir_variable
*degrees
= in_var(type
, "degrees");
1996 MAKE_SIG(type
, always_available
, 1, degrees
);
1997 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2001 ir_function_signature
*
2002 builtin_builder::_degrees(const glsl_type
*type
)
2004 ir_variable
*radians
= in_var(type
, "radians");
2005 MAKE_SIG(type
, always_available
, 1, radians
);
2006 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2010 UNOP(sin
, ir_unop_sin
, always_available
)
2011 UNOP(cos
, ir_unop_cos
, always_available
)
2013 ir_function_signature
*
2014 builtin_builder::_tan(const glsl_type
*type
)
2016 ir_variable
*theta
= in_var(type
, "theta");
2017 MAKE_SIG(type
, always_available
, 1, theta
);
2018 body
.emit(ret(div(sin(theta
), cos(theta
))));
2023 builtin_builder::asin_expr(ir_variable
*x
)
2026 sub(imm(1.5707964f
),
2027 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2028 add(imm(1.5707964f
),
2030 add(imm(-0.21460183f
),
2032 add(imm(0.086566724f
),
2033 mul(abs(x
), imm(-0.03102955f
))))))))));
2037 ir_function_signature
*
2038 builtin_builder::_asin(const glsl_type
*type
)
2040 ir_variable
*x
= in_var(type
, "x");
2041 MAKE_SIG(type
, always_available
, 1, x
);
2043 body
.emit(ret(asin_expr(x
)));
2048 ir_function_signature
*
2049 builtin_builder::_acos(const glsl_type
*type
)
2051 ir_variable
*x
= in_var(type
, "x");
2052 MAKE_SIG(type
, always_available
, 1, x
);
2054 body
.emit(ret(sub(imm(1.5707964f
), asin_expr(x
))));
2059 ir_function_signature
*
2060 builtin_builder::_atan2(const glsl_type
*type
)
2062 ir_variable
*vec_y
= in_var(type
, "vec_y");
2063 ir_variable
*vec_x
= in_var(type
, "vec_x");
2064 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2066 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2067 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2068 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2069 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2070 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2071 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2072 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2074 /* If |x| >= 1.0e-8 * |y|: */
2076 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2078 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2080 /* Then...call atan(y/x) */
2081 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2082 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2083 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2085 outer_then
.emit(assign(r
, asin_expr(r
)));
2087 /* ...and fix it up: */
2088 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2089 inner_if
->then_instructions
.push_tail(
2090 if_tree(gequal(y
, imm(0.0f
)),
2091 assign(r
, add(r
, imm(3.141593f
))),
2092 assign(r
, sub(r
, imm(3.141593f
)))));
2093 outer_then
.emit(inner_if
);
2096 outer_if
->else_instructions
.push_tail(
2097 assign(r
, mul(sign(y
), imm(1.5707965f
))));
2099 body
.emit(outer_if
);
2101 body
.emit(assign(vec_result
, r
, 1 << i
));
2103 body
.emit(ret(vec_result
));
2108 ir_function_signature
*
2109 builtin_builder::_atan(const glsl_type
*type
)
2111 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2112 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2114 ir_variable
*t
= body
.make_temp(type
, "t");
2115 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2118 body
.emit(ret(asin_expr(t
)));
2123 ir_function_signature
*
2124 builtin_builder::_sinh(const glsl_type
*type
)
2126 ir_variable
*x
= in_var(type
, "x");
2127 MAKE_SIG(type
, v130
, 1, x
);
2129 /* 0.5 * (e^x - e^(-x)) */
2130 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2135 ir_function_signature
*
2136 builtin_builder::_cosh(const glsl_type
*type
)
2138 ir_variable
*x
= in_var(type
, "x");
2139 MAKE_SIG(type
, v130
, 1, x
);
2141 /* 0.5 * (e^x + e^(-x)) */
2142 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2147 ir_function_signature
*
2148 builtin_builder::_tanh(const glsl_type
*type
)
2150 ir_variable
*x
= in_var(type
, "x");
2151 MAKE_SIG(type
, v130
, 1, x
);
2153 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2154 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2155 add(exp(x
), exp(neg(x
))))));
2160 ir_function_signature
*
2161 builtin_builder::_asinh(const glsl_type
*type
)
2163 ir_variable
*x
= in_var(type
, "x");
2164 MAKE_SIG(type
, v130
, 1, x
);
2166 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2171 ir_function_signature
*
2172 builtin_builder::_acosh(const glsl_type
*type
)
2174 ir_variable
*x
= in_var(type
, "x");
2175 MAKE_SIG(type
, v130
, 1, x
);
2177 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2181 ir_function_signature
*
2182 builtin_builder::_atanh(const glsl_type
*type
)
2184 ir_variable
*x
= in_var(type
, "x");
2185 MAKE_SIG(type
, v130
, 1, x
);
2187 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2188 sub(imm(1.0f
), x
))))));
2194 * Exponential Functions @{
2197 ir_function_signature
*
2198 builtin_builder::_pow(const glsl_type
*type
)
2200 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2203 UNOP(exp
, ir_unop_exp
, always_available
)
2204 UNOP(log
, ir_unop_log
, always_available
)
2205 UNOP(exp2
, ir_unop_exp2
, always_available
)
2206 UNOP(log2
, ir_unop_log2
, always_available
)
2207 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2208 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2212 UNOP(abs
, ir_unop_abs
, always_available
)
2213 UNOP(sign
, ir_unop_sign
, always_available
)
2214 UNOP(floor
, ir_unop_floor
, always_available
)
2215 UNOP(trunc
, ir_unop_trunc
, v130
)
2216 UNOP(round
, ir_unop_round_even
, always_available
)
2217 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2218 UNOP(ceil
, ir_unop_ceil
, always_available
)
2219 UNOP(fract
, ir_unop_fract
, always_available
)
2221 ir_function_signature
*
2222 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2224 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2227 ir_function_signature
*
2228 builtin_builder::_modf(const glsl_type
*type
)
2230 ir_variable
*x
= in_var(type
, "x");
2231 ir_variable
*i
= out_var(type
, "i");
2232 MAKE_SIG(type
, v130
, 2, x
, i
);
2234 ir_variable
*t
= body
.make_temp(type
, "t");
2235 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2236 body
.emit(assign(i
, t
));
2237 body
.emit(ret(sub(x
, t
)));
2242 ir_function_signature
*
2243 builtin_builder::_min(builtin_available_predicate avail
,
2244 const glsl_type
*x_type
, const glsl_type
*y_type
)
2246 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2249 ir_function_signature
*
2250 builtin_builder::_max(builtin_available_predicate avail
,
2251 const glsl_type
*x_type
, const glsl_type
*y_type
)
2253 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2256 ir_function_signature
*
2257 builtin_builder::_clamp(builtin_available_predicate avail
,
2258 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2260 ir_variable
*x
= in_var(val_type
, "x");
2261 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2262 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2263 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2265 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2270 ir_function_signature
*
2271 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2273 ir_variable
*x
= in_var(val_type
, "x");
2274 ir_variable
*y
= in_var(val_type
, "y");
2275 ir_variable
*a
= in_var(blend_type
, "a");
2276 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2278 body
.emit(ret(lrp(x
, y
, a
)));
2283 ir_function_signature
*
2284 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2285 const glsl_type
*val_type
,
2286 const glsl_type
*blend_type
)
2288 ir_variable
*x
= in_var(val_type
, "x");
2289 ir_variable
*y
= in_var(val_type
, "y");
2290 ir_variable
*a
= in_var(blend_type
, "a");
2291 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2293 /* csel matches the ternary operator in that a selector of true choses the
2294 * first argument. This differs from mix(x, y, false) which choses the
2295 * second argument (to remain consistent with the interpolating version of
2296 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2298 * To handle the behavior mismatch, reverse the x and y arguments.
2300 body
.emit(ret(csel(a
, y
, x
)));
2305 ir_function_signature
*
2306 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2308 ir_variable
*edge
= in_var(edge_type
, "edge");
2309 ir_variable
*x
= in_var(x_type
, "x");
2310 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2312 ir_variable
*t
= body
.make_temp(x_type
, "t");
2313 if (x_type
->vector_elements
== 1) {
2314 /* Both are floats */
2315 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2316 } else if (edge_type
->vector_elements
== 1) {
2317 /* x is a vector but edge is a float */
2318 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2319 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2322 /* Both are vectors */
2323 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2324 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2333 ir_function_signature
*
2334 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2336 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2337 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2338 ir_variable
*x
= in_var(x_type
, "x");
2339 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2341 /* From the GLSL 1.10 specification:
2344 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2345 * return t * t * (3 - 2 * t);
2348 ir_variable
*t
= body
.make_temp(x_type
, "t");
2349 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2350 imm(0.0f
), imm(1.0f
))));
2352 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2357 ir_function_signature
*
2358 builtin_builder::_isnan(const glsl_type
*type
)
2360 ir_variable
*x
= in_var(type
, "x");
2361 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2363 body
.emit(ret(nequal(x
, x
)));
2368 ir_function_signature
*
2369 builtin_builder::_isinf(const glsl_type
*type
)
2371 ir_variable
*x
= in_var(type
, "x");
2372 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2374 ir_constant_data infinities
;
2375 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2376 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2379 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2384 ir_function_signature
*
2385 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2387 ir_variable
*x
= in_var(type
, "x");
2388 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2389 body
.emit(ret(bitcast_f2i(x
)));
2393 ir_function_signature
*
2394 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2396 ir_variable
*x
= in_var(type
, "x");
2397 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2398 body
.emit(ret(bitcast_f2u(x
)));
2402 ir_function_signature
*
2403 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2405 ir_variable
*x
= in_var(type
, "x");
2406 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2407 body
.emit(ret(bitcast_i2f(x
)));
2411 ir_function_signature
*
2412 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2414 ir_variable
*x
= in_var(type
, "x");
2415 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2416 body
.emit(ret(bitcast_u2f(x
)));
2420 ir_function_signature
*
2421 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2423 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2424 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2425 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2429 ir_function_signature
*
2430 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2432 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2433 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2434 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2438 ir_function_signature
*
2439 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2441 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2442 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2443 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
2447 ir_function_signature
*
2448 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
2450 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2451 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2452 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
2456 ir_function_signature
*
2457 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
2459 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2460 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2461 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
2465 ir_function_signature
*
2466 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
2468 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2469 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2470 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
2475 ir_function_signature
*
2476 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
2478 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2479 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2480 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
2484 ir_function_signature
*
2485 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
2487 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2488 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2489 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
2493 ir_function_signature
*
2494 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
2496 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2497 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2498 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
2502 ir_function_signature
*
2503 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
2505 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2506 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2507 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
2511 ir_function_signature
*
2512 builtin_builder::_length(const glsl_type
*type
)
2514 ir_variable
*x
= in_var(type
, "x");
2515 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
2517 body
.emit(ret(sqrt(dotlike(x
, x
))));
2522 ir_function_signature
*
2523 builtin_builder::_distance(const glsl_type
*type
)
2525 ir_variable
*p0
= in_var(type
, "p0");
2526 ir_variable
*p1
= in_var(type
, "p1");
2527 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
2529 if (type
->vector_elements
== 1) {
2530 body
.emit(ret(abs(sub(p0
, p1
))));
2532 ir_variable
*p
= body
.make_temp(type
, "p");
2533 body
.emit(assign(p
, sub(p0
, p1
)));
2534 body
.emit(ret(sqrt(dot(p
, p
))));
2540 ir_function_signature
*
2541 builtin_builder::_dot(const glsl_type
*type
)
2543 if (type
->vector_elements
== 1)
2544 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
2546 return binop(ir_binop_dot
, always_available
,
2547 glsl_type::float_type
, type
, type
);
2550 ir_function_signature
*
2551 builtin_builder::_cross(const glsl_type
*type
)
2553 ir_variable
*a
= in_var(type
, "a");
2554 ir_variable
*b
= in_var(type
, "b");
2555 MAKE_SIG(type
, always_available
, 2, a
, b
);
2557 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
2558 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
2560 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
2561 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
2566 ir_function_signature
*
2567 builtin_builder::_normalize(const glsl_type
*type
)
2569 ir_variable
*x
= in_var(type
, "x");
2570 MAKE_SIG(type
, always_available
, 1, x
);
2572 if (type
->vector_elements
== 1) {
2573 body
.emit(ret(sign(x
)));
2575 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
2581 ir_function_signature
*
2582 builtin_builder::_ftransform()
2584 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
2586 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
2587 glsl_type::vec4_type
,
2588 var_ref(gl_ModelViewProjectionMatrix
),
2589 var_ref(gl_Vertex
))));
2591 /* FINISHME: Once the ir_expression() constructor handles type inference
2592 * for matrix operations, we can simplify this to:
2594 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
2599 ir_function_signature
*
2600 builtin_builder::_faceforward(const glsl_type
*type
)
2602 ir_variable
*N
= in_var(type
, "N");
2603 ir_variable
*I
= in_var(type
, "I");
2604 ir_variable
*Nref
= in_var(type
, "Nref");
2605 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
2607 body
.emit(if_tree(less(dotlike(Nref
, I
), imm(0.0f
)),
2608 ret(N
), ret(neg(N
))));
2613 ir_function_signature
*
2614 builtin_builder::_reflect(const glsl_type
*type
)
2616 ir_variable
*I
= in_var(type
, "I");
2617 ir_variable
*N
= in_var(type
, "N");
2618 MAKE_SIG(type
, always_available
, 2, I
, N
);
2620 /* I - 2 * dot(N, I) * N */
2621 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dotlike(N
, I
), N
)))));
2626 ir_function_signature
*
2627 builtin_builder::_refract(const glsl_type
*type
)
2629 ir_variable
*I
= in_var(type
, "I");
2630 ir_variable
*N
= in_var(type
, "N");
2631 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
2632 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
2634 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
2635 body
.emit(assign(n_dot_i
, dotlike(N
, I
)));
2637 /* From the GLSL 1.10 specification:
2638 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
2640 * return genType(0.0)
2642 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
2644 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
2645 body
.emit(assign(k
, sub(imm(1.0f
),
2646 mul(eta
, mul(eta
, sub(imm(1.0f
),
2647 mul(n_dot_i
, n_dot_i
)))))));
2648 body
.emit(if_tree(less(k
, imm(0.0f
)),
2649 ret(ir_constant::zero(mem_ctx
, type
)),
2650 ret(sub(mul(eta
, I
),
2651 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
2656 ir_function_signature
*
2657 builtin_builder::_matrixCompMult(const glsl_type
*type
)
2659 ir_variable
*x
= in_var(type
, "x");
2660 ir_variable
*y
= in_var(type
, "y");
2661 MAKE_SIG(type
, always_available
, 2, x
, y
);
2663 ir_variable
*z
= body
.make_temp(type
, "z");
2664 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2665 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
2672 ir_function_signature
*
2673 builtin_builder::_outerProduct(const glsl_type
*type
)
2675 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
2676 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
2677 MAKE_SIG(type
, v120
, 2, c
, r
);
2679 ir_variable
*m
= body
.make_temp(type
, "m");
2680 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2681 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
2688 ir_function_signature
*
2689 builtin_builder::_transpose(const glsl_type
*orig_type
)
2691 const glsl_type
*transpose_type
=
2692 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
2693 orig_type
->matrix_columns
,
2694 orig_type
->vector_elements
);
2696 ir_variable
*m
= in_var(orig_type
, "m");
2697 MAKE_SIG(transpose_type
, v120
, 1, m
);
2699 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
2700 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
2701 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
2702 body
.emit(assign(array_ref(t
, j
),
2703 matrix_elt(m
, i
, j
),
2712 ir_function_signature
*
2713 builtin_builder::_determinant_mat2()
2715 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
2716 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2718 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2719 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
2724 ir_function_signature
*
2725 builtin_builder::_determinant_mat3()
2727 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
2728 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2731 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
2732 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
2735 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
2736 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
2739 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
2740 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
2742 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
2743 mul(matrix_elt(m
, 0, 1), f2
)),
2744 mul(matrix_elt(m
, 0, 2), f3
))));
2749 ir_function_signature
*
2750 builtin_builder::_determinant_mat4()
2752 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
2753 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2755 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
2756 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
2757 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
2758 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
2759 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
2760 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
2761 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
2762 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
2763 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
2764 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
2765 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
2766 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
2767 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
2768 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
2769 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
2770 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
2771 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
2772 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
2773 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
2775 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)))));
2776 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)))));
2777 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)))));
2778 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)))));
2779 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)))));
2780 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)))));
2781 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)))));
2782 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)))));
2783 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)))));
2784 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)))));
2785 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)))));
2786 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)))));
2787 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)))));
2788 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)))));
2789 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)))));
2790 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)))));
2791 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)))));
2792 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)))));
2793 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)))));
2795 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
2797 body
.emit(assign(adj_0
,
2798 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
2799 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
2800 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
2802 body
.emit(assign(adj_0
, neg(
2803 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
2804 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
2805 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
2807 body
.emit(assign(adj_0
,
2808 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
2809 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
2810 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
2812 body
.emit(assign(adj_0
, neg(
2813 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
2814 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
2815 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
2818 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
2823 ir_function_signature
*
2824 builtin_builder::_inverse_mat2()
2826 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
2827 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
2829 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
2830 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
2831 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
2832 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
2833 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
2835 ir_expression
*det
=
2836 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2837 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
2839 body
.emit(ret(div(adj
, det
)));
2843 ir_function_signature
*
2844 builtin_builder::_inverse_mat3()
2846 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
2847 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
2849 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
2850 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
2851 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
2853 body
.emit(assign(f11_22_21_12
,
2854 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
2855 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
2856 body
.emit(assign(f10_22_20_12
,
2857 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
2858 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
2859 body
.emit(assign(f10_21_20_11
,
2860 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
2861 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
2863 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
2864 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
2865 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
2866 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
2868 body
.emit(assign(array_ref(adj
, 0), neg(
2869 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
2870 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
2872 body
.emit(assign(array_ref(adj
, 1),
2873 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
2874 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
2876 body
.emit(assign(array_ref(adj
, 2), neg(
2877 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
2878 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
2881 body
.emit(assign(array_ref(adj
, 0),
2882 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
2883 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
2885 body
.emit(assign(array_ref(adj
, 1), neg(
2886 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
2887 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
2889 body
.emit(assign(array_ref(adj
, 2),
2890 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2891 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
2894 ir_expression
*det
=
2895 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
2896 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
2897 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
2899 body
.emit(ret(div(adj
, det
)));
2904 ir_function_signature
*
2905 builtin_builder::_inverse_mat4()
2907 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
2908 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
2910 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
2911 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
2912 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
2913 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
2914 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
2915 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
2916 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
2917 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
2918 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
2919 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
2920 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
2921 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
2922 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
2923 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
2924 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
2925 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
2926 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
2927 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
2928 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
2930 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)))));
2931 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)))));
2932 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)))));
2933 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)))));
2934 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)))));
2935 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)))));
2936 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)))));
2937 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)))));
2938 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)))));
2939 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)))));
2940 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)))));
2941 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)))));
2942 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)))));
2943 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)))));
2944 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)))));
2945 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)))));
2946 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)))));
2947 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)))));
2948 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)))));
2950 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
2951 body
.emit(assign(array_ref(adj
, 0),
2952 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
2953 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
2954 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
2956 body
.emit(assign(array_ref(adj
, 1), neg(
2957 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
2958 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
2959 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
2961 body
.emit(assign(array_ref(adj
, 2),
2962 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
2963 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
2964 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
2966 body
.emit(assign(array_ref(adj
, 3), neg(
2967 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
2968 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
2969 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
2972 body
.emit(assign(array_ref(adj
, 0), neg(
2973 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
2974 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
2975 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
2977 body
.emit(assign(array_ref(adj
, 1),
2978 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
2979 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
2980 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
2982 body
.emit(assign(array_ref(adj
, 2), neg(
2983 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
2984 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
2985 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
2987 body
.emit(assign(array_ref(adj
, 3),
2988 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
2989 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
2990 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
2993 body
.emit(assign(array_ref(adj
, 0),
2994 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
2995 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
2996 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
2998 body
.emit(assign(array_ref(adj
, 1), neg(
2999 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3000 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3001 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3003 body
.emit(assign(array_ref(adj
, 2),
3004 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3005 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3006 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3008 body
.emit(assign(array_ref(adj
, 3), neg(
3009 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3010 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3011 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3014 body
.emit(assign(array_ref(adj
, 0), neg(
3015 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3016 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3017 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3019 body
.emit(assign(array_ref(adj
, 1),
3020 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3021 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3022 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3024 body
.emit(assign(array_ref(adj
, 2), neg(
3025 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3026 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3027 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3029 body
.emit(assign(array_ref(adj
, 3),
3030 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3031 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3032 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3035 ir_expression
*det
=
3036 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3037 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3038 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3039 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3041 body
.emit(ret(div(adj
, det
)));
3047 ir_function_signature
*
3048 builtin_builder::_lessThan(builtin_available_predicate avail
,
3049 const glsl_type
*type
)
3051 return binop(ir_binop_less
, avail
,
3052 glsl_type::bvec(type
->vector_elements
), type
, type
);
3055 ir_function_signature
*
3056 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3057 const glsl_type
*type
)
3059 return binop(ir_binop_lequal
, avail
,
3060 glsl_type::bvec(type
->vector_elements
), type
, type
);
3063 ir_function_signature
*
3064 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3065 const glsl_type
*type
)
3067 return binop(ir_binop_greater
, avail
,
3068 glsl_type::bvec(type
->vector_elements
), type
, type
);
3071 ir_function_signature
*
3072 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3073 const glsl_type
*type
)
3075 return binop(ir_binop_gequal
, avail
,
3076 glsl_type::bvec(type
->vector_elements
), type
, type
);
3079 ir_function_signature
*
3080 builtin_builder::_equal(builtin_available_predicate avail
,
3081 const glsl_type
*type
)
3083 return binop(ir_binop_equal
, avail
,
3084 glsl_type::bvec(type
->vector_elements
), type
, type
);
3087 ir_function_signature
*
3088 builtin_builder::_notEqual(builtin_available_predicate avail
,
3089 const glsl_type
*type
)
3091 return binop(ir_binop_nequal
, avail
,
3092 glsl_type::bvec(type
->vector_elements
), type
, type
);
3095 ir_function_signature
*
3096 builtin_builder::_any(const glsl_type
*type
)
3098 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3101 ir_function_signature
*
3102 builtin_builder::_all(const glsl_type
*type
)
3104 ir_variable
*v
= in_var(type
, "v");
3105 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3107 switch (type
->vector_elements
) {
3109 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3112 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3116 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3125 UNOP(not, ir_unop_logic_not
, always_available
)
3128 has_lod(const glsl_type
*sampler_type
)
3130 assert(sampler_type
->is_sampler());
3132 switch (sampler_type
->sampler_dimensionality
) {
3133 case GLSL_SAMPLER_DIM_RECT
:
3134 case GLSL_SAMPLER_DIM_BUF
:
3135 case GLSL_SAMPLER_DIM_MS
:
3142 ir_function_signature
*
3143 builtin_builder::_textureSize(builtin_available_predicate avail
,
3144 const glsl_type
*return_type
,
3145 const glsl_type
*sampler_type
)
3147 ir_variable
*s
= in_var(sampler_type
, "sampler");
3148 /* The sampler always exists; add optional lod later. */
3149 MAKE_SIG(return_type
, avail
, 1, s
);
3151 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3152 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3154 if (has_lod(sampler_type
)) {
3155 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3156 sig
->parameters
.push_tail(lod
);
3157 tex
->lod_info
.lod
= var_ref(lod
);
3159 tex
->lod_info
.lod
= imm(0u);
3162 body
.emit(ret(tex
));
3167 ir_function_signature
*
3168 builtin_builder::_texture(ir_texture_opcode opcode
,
3169 builtin_available_predicate avail
,
3170 const glsl_type
*return_type
,
3171 const glsl_type
*sampler_type
,
3172 const glsl_type
*coord_type
,
3175 ir_variable
*s
= in_var(sampler_type
, "sampler");
3176 ir_variable
*P
= in_var(coord_type
, "P");
3177 /* The sampler and coordinate always exist; add optional parameters later. */
3178 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3180 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3181 tex
->set_sampler(var_ref(s
), return_type
);
3183 const int coord_size
= sampler_type
->sampler_coordinate_components();
3185 if (coord_size
== coord_type
->vector_elements
) {
3186 tex
->coordinate
= var_ref(P
);
3188 /* The incoming coordinate also has the projector or shadow comparitor,
3189 * so we need to swizzle those away.
3191 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3194 /* The projector is always in the last component. */
3195 if (flags
& TEX_PROJECT
)
3196 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3198 /* The shadow comparitor is normally in the Z component, but a few types
3199 * have sufficiently large coordinates that it's in W.
3201 if (sampler_type
->sampler_shadow
)
3202 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3204 if (opcode
== ir_txl
) {
3205 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3206 sig
->parameters
.push_tail(lod
);
3207 tex
->lod_info
.lod
= var_ref(lod
);
3208 } else if (opcode
== ir_txd
) {
3209 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3210 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3211 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3212 sig
->parameters
.push_tail(dPdx
);
3213 sig
->parameters
.push_tail(dPdy
);
3214 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3215 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3218 if (flags
& TEX_OFFSET
) {
3219 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3220 ir_variable
*offset
=
3221 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset", ir_var_const_in
);
3222 sig
->parameters
.push_tail(offset
);
3223 tex
->offset
= var_ref(offset
);
3226 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3227 * inconsistent with both textureLodOffset and textureGradOffset.
3229 if (opcode
== ir_txb
) {
3230 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3231 sig
->parameters
.push_tail(bias
);
3232 tex
->lod_info
.bias
= var_ref(bias
);
3235 body
.emit(ret(tex
));
3240 ir_function_signature
*
3241 builtin_builder::_textureCubeArrayShadow()
3243 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3244 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3245 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3246 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3248 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3249 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3251 tex
->coordinate
= var_ref(P
);
3252 tex
->shadow_comparitor
= var_ref(compare
);
3254 body
.emit(ret(tex
));
3259 ir_function_signature
*
3260 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3261 const glsl_type
*return_type
,
3262 const glsl_type
*sampler_type
,
3263 const glsl_type
*coord_type
,
3264 const glsl_type
*offset_type
)
3266 ir_variable
*s
= in_var(sampler_type
, "sampler");
3267 ir_variable
*P
= in_var(coord_type
, "P");
3268 /* The sampler and coordinate always exist; add optional parameters later. */
3269 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3271 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3272 tex
->coordinate
= var_ref(P
);
3273 tex
->set_sampler(var_ref(s
), return_type
);
3275 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3276 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3277 sig
->parameters
.push_tail(sample
);
3278 tex
->lod_info
.sample_index
= var_ref(sample
);
3279 tex
->op
= ir_txf_ms
;
3280 } else if (has_lod(sampler_type
)) {
3281 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3282 sig
->parameters
.push_tail(lod
);
3283 tex
->lod_info
.lod
= var_ref(lod
);
3285 tex
->lod_info
.lod
= imm(0u);
3288 if (offset_type
!= NULL
) {
3289 ir_variable
*offset
=
3290 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3291 sig
->parameters
.push_tail(offset
);
3292 tex
->offset
= var_ref(offset
);
3295 body
.emit(ret(tex
));
3300 ir_function_signature
*
3301 builtin_builder::_EmitVertex()
3303 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3305 body
.emit(new(mem_ctx
) ir_emit_vertex());
3310 ir_function_signature
*
3311 builtin_builder::_EndPrimitive()
3313 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3315 body
.emit(new(mem_ctx
) ir_end_primitive());
3320 ir_function_signature
*
3321 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3322 const glsl_type
*coord_type
)
3324 ir_variable
*s
= in_var(sampler_type
, "sampler");
3325 ir_variable
*coord
= in_var(coord_type
, "coord");
3326 /* The sampler and coordinate always exist; add optional parameters later. */
3327 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3329 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3330 tex
->coordinate
= var_ref(coord
);
3331 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3333 body
.emit(ret(tex
));
3338 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3339 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3341 ir_function_signature
*
3342 builtin_builder::_fwidth(const glsl_type
*type
)
3344 ir_variable
*p
= in_var(type
, "p");
3345 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3347 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3352 ir_function_signature
*
3353 builtin_builder::_noise1(const glsl_type
*type
)
3355 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
3358 ir_function_signature
*
3359 builtin_builder::_noise2(const glsl_type
*type
)
3361 ir_variable
*p
= in_var(type
, "p");
3362 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
3364 ir_constant_data b_offset
;
3365 b_offset
.f
[0] = 601.0f
;
3366 b_offset
.f
[1] = 313.0f
;
3367 b_offset
.f
[2] = 29.0f
;
3368 b_offset
.f
[3] = 277.0f
;
3370 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3371 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3372 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
3373 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3374 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3375 body
.emit(assign(t
, a
, WRITEMASK_X
));
3376 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3382 ir_function_signature
*
3383 builtin_builder::_noise3(const glsl_type
*type
)
3385 ir_variable
*p
= in_var(type
, "p");
3386 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
3388 ir_constant_data b_offset
;
3389 b_offset
.f
[0] = 601.0f
;
3390 b_offset
.f
[1] = 313.0f
;
3391 b_offset
.f
[2] = 29.0f
;
3392 b_offset
.f
[3] = 277.0f
;
3394 ir_constant_data c_offset
;
3395 c_offset
.f
[0] = 1559.0f
;
3396 c_offset
.f
[1] = 113.0f
;
3397 c_offset
.f
[2] = 1861.0f
;
3398 c_offset
.f
[3] = 797.0f
;
3400 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3401 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3402 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3403 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
3404 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3405 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3406 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
3407 body
.emit(assign(t
, a
, WRITEMASK_X
));
3408 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3409 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3415 ir_function_signature
*
3416 builtin_builder::_noise4(const glsl_type
*type
)
3418 ir_variable
*p
= in_var(type
, "p");
3419 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
3421 ir_variable
*_p
= body
.make_temp(type
, "_p");
3423 ir_constant_data p_offset
;
3424 p_offset
.f
[0] = 1559.0f
;
3425 p_offset
.f
[1] = 113.0f
;
3426 p_offset
.f
[2] = 1861.0f
;
3427 p_offset
.f
[3] = 797.0f
;
3429 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
3431 ir_constant_data offset
;
3432 offset
.f
[0] = 601.0f
;
3433 offset
.f
[1] = 313.0f
;
3434 offset
.f
[2] = 29.0f
;
3435 offset
.f
[3] = 277.0f
;
3437 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3438 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3439 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3440 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
3441 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
3442 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3443 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
3444 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
3445 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
3446 body
.emit(assign(t
, a
, WRITEMASK_X
));
3447 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3448 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3449 body
.emit(assign(t
, d
, WRITEMASK_W
));
3455 ir_function_signature
*
3456 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
3458 ir_variable
*value
= in_var(type
, "value");
3459 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3460 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3461 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
3463 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
3468 ir_function_signature
*
3469 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
3471 ir_variable
*base
= in_var(type
, "base");
3472 ir_variable
*insert
= in_var(type
, "insert");
3473 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3474 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3475 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
3477 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
3482 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
3484 ir_function_signature
*
3485 builtin_builder::_bitCount(const glsl_type
*type
)
3487 return unop(gpu_shader5
, ir_unop_bit_count
,
3488 glsl_type::ivec(type
->vector_elements
), type
);
3491 ir_function_signature
*
3492 builtin_builder::_findLSB(const glsl_type
*type
)
3494 return unop(gpu_shader5
, ir_unop_find_lsb
,
3495 glsl_type::ivec(type
->vector_elements
), type
);
3498 ir_function_signature
*
3499 builtin_builder::_findMSB(const glsl_type
*type
)
3501 return unop(gpu_shader5
, ir_unop_find_msb
,
3502 glsl_type::ivec(type
->vector_elements
), type
);
3505 ir_function_signature
*
3506 builtin_builder::_fma(const glsl_type
*type
)
3508 ir_variable
*a
= in_var(type
, "a");
3509 ir_variable
*b
= in_var(type
, "b");
3510 ir_variable
*c
= in_var(type
, "c");
3511 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
3513 body
.emit(ret(fma(a
, b
, c
)));
3519 /******************************************************************************/
3521 /* The singleton instance of builtin_builder. */
3522 static builtin_builder builtins
;
3525 * External API (exposing the built-in module to the rest of the compiler):
3529 _mesa_glsl_initialize_builtin_functions()
3531 builtins
.initialize();
3535 _mesa_glsl_release_builtin_functions()
3540 ir_function_signature
*
3541 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
3542 const char *name
, exec_list
*actual_parameters
)
3544 return builtins
.find(state
, name
, actual_parameters
);