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
->EXT_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 texture_array_lod(const _mesa_glsl_parse_state
*state
)
219 return lod_exists_in_stage(state
) &&
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_levels(const _mesa_glsl_parse_state
*state
)
261 return state
->is_version(430, 0) ||
262 state
->ARB_texture_query_levels_enable
;
266 texture_query_lod(const _mesa_glsl_parse_state
*state
)
268 return state
->target
== fragment_shader
&&
269 state
->ARB_texture_query_lod_enable
;
273 texture_gather(const _mesa_glsl_parse_state
*state
)
275 return state
->is_version(400, 0) ||
276 state
->ARB_texture_gather_enable
||
277 state
->ARB_gpu_shader5_enable
;
280 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
281 * used for relaxation of const offset requirements.
284 texture_gather_only(const _mesa_glsl_parse_state
*state
)
286 return !state
->is_version(400, 0) &&
287 !state
->ARB_gpu_shader5_enable
&&
288 state
->ARB_texture_gather_enable
;
291 /* Desktop GL or OES_standard_derivatives + fragment shader only */
293 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
295 return state
->target
== fragment_shader
&&
296 (!state
->es_shader
|| state
->OES_standard_derivatives_enable
);
300 tex1d_lod(const _mesa_glsl_parse_state
*state
)
302 return !state
->es_shader
&& lod_exists_in_stage(state
);
305 /** True if sampler3D exists */
307 tex3d(const _mesa_glsl_parse_state
*state
)
309 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
310 * OES_texture_3D extension, and in GLSL ES 3.00.
312 return !state
->es_shader
||
313 state
->OES_texture_3D_enable
||
314 state
->language_version
>= 300;
318 fs_tex3d(const _mesa_glsl_parse_state
*state
)
320 return state
->target
== fragment_shader
&&
321 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
325 tex3d_lod(const _mesa_glsl_parse_state
*state
)
327 return tex3d(state
) && lod_exists_in_stage(state
);
331 /******************************************************************************/
336 * builtin_builder: A singleton object representing the core of the built-in
339 * It generates IR for every built-in function signature, and organizes them
342 class builtin_builder
{
349 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
350 const char *name
, exec_list
*actual_parameters
);
355 * A shader to hold all the built-in signatures; created by this module.
357 * This includes signatures for every built-in, regardless of version or
358 * enabled extensions. The availability predicate associated with each
359 * signature allows matching_signature() to filter out the irrelevant ones.
363 /** Global variables used by built-in functions. */
364 ir_variable
*gl_ModelViewProjectionMatrix
;
365 ir_variable
*gl_Vertex
;
367 void create_shader();
368 void create_builtins();
371 * IR builder helpers:
373 * These convenience functions assist in emitting IR, but don't necessarily
374 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
377 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
378 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
379 ir_constant
*imm(float f
, unsigned vector_elements
=1);
380 ir_constant
*imm(int i
, unsigned vector_elements
=1);
381 ir_constant
*imm(unsigned u
, unsigned vector_elements
=1);
382 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
383 ir_dereference_variable
*var_ref(ir_variable
*var
);
384 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
385 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
387 ir_expression
*asin_expr(ir_variable
*x
);
389 /** Create a new function and add the given signatures. */
390 void add_function(const char *name
, ...);
392 ir_function_signature
*new_sig(const glsl_type
*return_type
,
393 builtin_available_predicate avail
,
394 int num_params
, ...);
397 * Function signature generators:
400 ir_function_signature
*unop(builtin_available_predicate avail
,
401 ir_expression_operation opcode
,
402 const glsl_type
*return_type
,
403 const glsl_type
*param_type
);
404 ir_function_signature
*binop(ir_expression_operation opcode
,
405 builtin_available_predicate avail
,
406 const glsl_type
*return_type
,
407 const glsl_type
*param0_type
,
408 const glsl_type
*param1_type
);
410 #define B0(X) ir_function_signature *_##X();
411 #define B1(X) ir_function_signature *_##X(const glsl_type *);
412 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
413 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
414 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
415 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
452 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
453 const glsl_type
*val_type
,
454 const glsl_type
*blend_type
);
463 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
464 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
465 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
466 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
467 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
468 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
469 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
470 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
471 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
472 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
484 B0(determinant_mat2
);
485 B0(determinant_mat3
);
486 B0(determinant_mat4
);
494 BA1(greaterThanEqual
);
501 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
502 const glsl_type
*return_type
,
503 const glsl_type
*sampler_type
);
505 /** Flags to _texture() */
506 #define TEX_PROJECT 1
508 #define TEX_COMPONENT 4
509 #define TEX_OFFSET_NONCONST 8
511 ir_function_signature
*_texture(ir_texture_opcode opcode
,
512 builtin_available_predicate avail
,
513 const glsl_type
*return_type
,
514 const glsl_type
*sampler_type
,
515 const glsl_type
*coord_type
,
517 B0(textureCubeArrayShadow
);
518 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
519 const glsl_type
*return_type
,
520 const glsl_type
*sampler_type
,
521 const glsl_type
*coord_type
,
522 const glsl_type
*offset_type
= NULL
);
528 B1(textureQueryLevels
);
558 } /* anonymous namespace */
561 * Core builtin_builder functionality:
564 builtin_builder::builtin_builder()
566 gl_ModelViewProjectionMatrix(NULL
),
572 builtin_builder::~builtin_builder()
574 ralloc_free(mem_ctx
);
577 ir_function_signature
*
578 builtin_builder::find(_mesa_glsl_parse_state
*state
,
579 const char *name
, exec_list
*actual_parameters
)
581 /* The shader currently being compiled requested a built-in function;
582 * it needs to link against builtin_builder::shader in order to get them.
584 * Even if we don't find a matching signature, we still need to do this so
585 * that the "no matching signature" error will list potential candidates
586 * from the available built-ins.
588 state
->builtins_to_link
[0] = shader
;
589 state
->num_builtins_to_link
= 1;
591 ir_function
*f
= shader
->symbols
->get_function(name
);
595 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
603 builtin_builder::initialize()
605 /* If already initialized, don't do it again. */
609 mem_ctx
= ralloc_context(NULL
);
615 builtin_builder::release()
617 ralloc_free(mem_ctx
);
625 builtin_builder::create_shader()
627 /* The target doesn't actually matter. There's no target for generic
628 * GLSL utility code that could be linked against any stage, so just
629 * arbitrarily pick GL_VERTEX_SHADER.
631 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
632 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
634 gl_ModelViewProjectionMatrix
=
635 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
636 "gl_ModelViewProjectionMatrix",
639 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
641 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
642 shader
->symbols
->add_variable(gl_Vertex
);
648 * Create ir_function and ir_function_signature objects for each built-in.
650 * Contains a list of every available built-in.
653 builtin_builder::create_builtins()
656 add_function(#NAME, \
657 _##NAME(glsl_type::float_type), \
658 _##NAME(glsl_type::vec2_type), \
659 _##NAME(glsl_type::vec3_type), \
660 _##NAME(glsl_type::vec4_type), \
664 add_function(#NAME, \
665 _##NAME(glsl_type::float_type), \
666 _##NAME(glsl_type::vec2_type), \
667 _##NAME(glsl_type::vec3_type), \
668 _##NAME(glsl_type::vec4_type), \
669 _##NAME(glsl_type::int_type), \
670 _##NAME(glsl_type::ivec2_type), \
671 _##NAME(glsl_type::ivec3_type), \
672 _##NAME(glsl_type::ivec4_type), \
676 add_function(#NAME, \
677 _##NAME(always_available, glsl_type::float_type), \
678 _##NAME(always_available, glsl_type::vec2_type), \
679 _##NAME(always_available, glsl_type::vec3_type), \
680 _##NAME(always_available, glsl_type::vec4_type), \
682 _##NAME(always_available, glsl_type::int_type), \
683 _##NAME(always_available, glsl_type::ivec2_type), \
684 _##NAME(always_available, glsl_type::ivec3_type), \
685 _##NAME(always_available, glsl_type::ivec4_type), \
687 _##NAME(v130, glsl_type::uint_type), \
688 _##NAME(v130, glsl_type::uvec2_type), \
689 _##NAME(v130, glsl_type::uvec3_type), \
690 _##NAME(v130, glsl_type::uvec4_type), \
694 add_function(#NAME, \
695 _##NAME(glsl_type::int_type), \
696 _##NAME(glsl_type::ivec2_type), \
697 _##NAME(glsl_type::ivec3_type), \
698 _##NAME(glsl_type::ivec4_type), \
700 _##NAME(glsl_type::uint_type), \
701 _##NAME(glsl_type::uvec2_type), \
702 _##NAME(glsl_type::uvec3_type), \
703 _##NAME(glsl_type::uvec4_type), \
707 add_function(#NAME, \
708 _##NAME(always_available, glsl_type::float_type), \
709 _##NAME(always_available, glsl_type::vec2_type), \
710 _##NAME(always_available, glsl_type::vec3_type), \
711 _##NAME(always_available, glsl_type::vec4_type), \
713 _##NAME(always_available, glsl_type::int_type), \
714 _##NAME(always_available, glsl_type::ivec2_type), \
715 _##NAME(always_available, glsl_type::ivec3_type), \
716 _##NAME(always_available, glsl_type::ivec4_type), \
718 _##NAME(v130, glsl_type::uint_type), \
719 _##NAME(v130, glsl_type::uvec2_type), \
720 _##NAME(v130, glsl_type::uvec3_type), \
721 _##NAME(v130, glsl_type::uvec4_type), \
723 _##NAME(always_available, glsl_type::bool_type), \
724 _##NAME(always_available, glsl_type::bvec2_type), \
725 _##NAME(always_available, glsl_type::bvec3_type), \
726 _##NAME(always_available, glsl_type::bvec4_type), \
729 #define FIU2_MIXED(NAME) \
730 add_function(#NAME, \
731 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
732 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
733 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
734 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
736 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
737 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
738 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
740 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
741 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
742 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
743 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
745 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
746 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
747 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
749 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
750 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
751 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
752 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
754 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
755 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
756 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
768 _atan(glsl_type::float_type
),
769 _atan(glsl_type::vec2_type
),
770 _atan(glsl_type::vec3_type
),
771 _atan(glsl_type::vec4_type
),
772 _atan2(glsl_type::float_type
),
773 _atan2(glsl_type::vec2_type
),
774 _atan2(glsl_type::vec3_type
),
775 _atan2(glsl_type::vec4_type
),
801 _mod(glsl_type::float_type
, glsl_type::float_type
),
802 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
803 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
804 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
806 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
807 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
808 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
818 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
819 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
820 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
821 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
823 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
824 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
825 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
827 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
828 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
829 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
830 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
832 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
833 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
834 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
835 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
837 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
838 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
839 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
840 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
842 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
843 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
844 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
845 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
849 _step(glsl_type::float_type
, glsl_type::float_type
),
850 _step(glsl_type::float_type
, glsl_type::vec2_type
),
851 _step(glsl_type::float_type
, glsl_type::vec3_type
),
852 _step(glsl_type::float_type
, glsl_type::vec4_type
),
854 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
855 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
856 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
859 add_function("smoothstep",
860 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
861 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
862 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
863 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
865 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
866 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
867 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
875 add_function("intBitsToFloat",
876 _intBitsToFloat(glsl_type::int_type
),
877 _intBitsToFloat(glsl_type::ivec2_type
),
878 _intBitsToFloat(glsl_type::ivec3_type
),
879 _intBitsToFloat(glsl_type::ivec4_type
),
881 add_function("uintBitsToFloat",
882 _uintBitsToFloat(glsl_type::uint_type
),
883 _uintBitsToFloat(glsl_type::uvec2_type
),
884 _uintBitsToFloat(glsl_type::uvec3_type
),
885 _uintBitsToFloat(glsl_type::uvec4_type
),
888 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3
), NULL
);
889 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
890 add_function("packUnorm4x8", _packUnorm4x8(shader_packing
), NULL
);
891 add_function("packSnorm4x8", _packSnorm4x8(shader_packing
), NULL
);
892 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3
), NULL
);
893 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
894 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing
), NULL
);
895 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing
), NULL
);
896 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
897 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
903 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
906 add_function("ftransform", _ftransform(), NULL
);
911 add_function("matrixCompMult",
912 _matrixCompMult(glsl_type::mat2_type
),
913 _matrixCompMult(glsl_type::mat3_type
),
914 _matrixCompMult(glsl_type::mat4_type
),
915 _matrixCompMult(glsl_type::mat2x3_type
),
916 _matrixCompMult(glsl_type::mat2x4_type
),
917 _matrixCompMult(glsl_type::mat3x2_type
),
918 _matrixCompMult(glsl_type::mat3x4_type
),
919 _matrixCompMult(glsl_type::mat4x2_type
),
920 _matrixCompMult(glsl_type::mat4x3_type
),
922 add_function("outerProduct",
923 _outerProduct(glsl_type::mat2_type
),
924 _outerProduct(glsl_type::mat3_type
),
925 _outerProduct(glsl_type::mat4_type
),
926 _outerProduct(glsl_type::mat2x3_type
),
927 _outerProduct(glsl_type::mat2x4_type
),
928 _outerProduct(glsl_type::mat3x2_type
),
929 _outerProduct(glsl_type::mat3x4_type
),
930 _outerProduct(glsl_type::mat4x2_type
),
931 _outerProduct(glsl_type::mat4x3_type
),
933 add_function("determinant",
938 add_function("inverse",
943 add_function("transpose",
944 _transpose(glsl_type::mat2_type
),
945 _transpose(glsl_type::mat3_type
),
946 _transpose(glsl_type::mat4_type
),
947 _transpose(glsl_type::mat2x3_type
),
948 _transpose(glsl_type::mat2x4_type
),
949 _transpose(glsl_type::mat3x2_type
),
950 _transpose(glsl_type::mat3x4_type
),
951 _transpose(glsl_type::mat4x2_type
),
952 _transpose(glsl_type::mat4x3_type
),
957 FIU(greaterThanEqual
)
962 _any(glsl_type::bvec2_type
),
963 _any(glsl_type::bvec3_type
),
964 _any(glsl_type::bvec4_type
),
968 _all(glsl_type::bvec2_type
),
969 _all(glsl_type::bvec3_type
),
970 _all(glsl_type::bvec4_type
),
974 _not(glsl_type::bvec2_type
),
975 _not(glsl_type::bvec3_type
),
976 _not(glsl_type::bvec4_type
),
979 add_function("textureSize",
980 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
981 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
982 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
984 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
985 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
986 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
988 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
989 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
990 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
992 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
993 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
994 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
996 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
997 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
998 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
1000 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
1001 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
1002 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
1003 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
1004 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
1005 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
1007 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
1008 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
1010 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
1011 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
1012 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
1013 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
1015 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
1016 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
1017 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
1018 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
1020 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
1021 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
1022 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
1023 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
1024 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
1025 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
1027 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
1028 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
1029 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
1032 add_function("texture",
1033 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1034 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1035 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1037 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1038 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1039 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1041 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1042 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1043 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1045 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1046 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1047 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1049 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1050 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1051 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1053 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1054 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1055 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1057 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1058 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1059 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1061 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1062 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1063 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1065 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1066 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1067 /* samplerCubeArrayShadow is special; it has an extra parameter
1068 * for the shadow comparitor since there is no vec5 type.
1070 _textureCubeArrayShadow(),
1072 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1073 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1074 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1076 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1078 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1079 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1080 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1082 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1083 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1084 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1086 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1087 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1088 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1090 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1091 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1092 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1094 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1095 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1096 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1098 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1099 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1100 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1102 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1103 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1104 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1106 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1107 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1108 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1110 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1113 add_function("textureLod",
1114 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1115 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1116 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1118 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1119 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1120 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1122 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1123 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1124 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1126 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1127 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1128 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1130 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1131 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1133 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1134 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1135 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1137 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1138 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1139 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1141 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1142 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1143 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1145 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1148 add_function("textureOffset",
1149 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1150 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1151 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1153 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1154 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1155 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1157 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1158 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1159 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1161 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1162 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1163 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1165 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1167 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1168 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1170 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1171 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1172 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1174 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1175 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1176 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1178 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1180 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1181 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1182 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1184 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1185 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1186 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1188 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1189 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1190 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1192 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1193 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1195 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1196 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1197 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1199 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1200 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1201 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1203 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1206 add_function("textureProj",
1207 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1208 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1209 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1210 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1211 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1212 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1214 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1215 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1216 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1217 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1218 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1219 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1221 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1222 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1223 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1225 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1226 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1228 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1229 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1230 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1231 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1232 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1233 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1235 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1237 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1238 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1239 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1240 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1241 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1242 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1244 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1245 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1246 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1247 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1248 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1249 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1251 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1252 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1253 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1255 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1256 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1259 add_function("texelFetch",
1260 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1261 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1262 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1264 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1265 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1266 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1268 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1269 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1270 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1272 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1273 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1274 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1276 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1277 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1278 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1280 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1281 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1282 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1284 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1285 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1286 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1288 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1289 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1290 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1292 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1293 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1294 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1297 add_function("texelFetchOffset",
1298 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1299 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1300 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1302 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1303 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1304 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1306 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1307 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1308 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1310 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1311 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1312 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1314 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1315 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1316 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1318 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1319 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1320 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1324 add_function("textureProjOffset",
1325 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1326 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1327 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1328 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1329 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1330 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1332 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1333 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1334 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1335 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1336 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1337 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1339 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1340 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1341 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1343 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1344 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1346 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1347 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1348 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1349 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1350 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1351 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1353 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1355 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1356 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1357 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1358 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1359 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1360 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1362 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1363 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1364 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1365 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1366 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1367 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1369 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1370 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1371 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1373 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1374 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1377 add_function("textureLodOffset",
1378 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1379 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1380 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1382 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1383 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1384 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1386 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1387 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1388 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1390 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1391 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1393 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1394 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1395 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1397 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1398 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1399 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1401 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1404 add_function("textureProjLod",
1405 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1406 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1407 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1408 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1409 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1410 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1412 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1413 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1414 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1415 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1416 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1417 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1419 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1420 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1421 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1423 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1424 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1427 add_function("textureProjLodOffset",
1428 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1429 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1430 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1431 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1432 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1433 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1435 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1436 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1437 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1438 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1439 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1440 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1442 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1443 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1444 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1446 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1447 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1450 add_function("textureGrad",
1451 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1452 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
),
1453 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
),
1455 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1456 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1457 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1459 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1460 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1461 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1463 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1464 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1465 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1467 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1468 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1469 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1471 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1473 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1474 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1475 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec4_type
),
1477 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1478 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
),
1479 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
),
1481 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1482 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1483 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1485 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1486 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1487 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1489 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1490 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1493 add_function("textureGradOffset",
1494 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1495 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1496 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::float_type
, TEX_OFFSET
),
1498 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1499 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1500 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1502 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1503 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1504 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1506 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1507 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1508 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1510 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1512 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1513 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1515 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1516 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1517 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1519 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1520 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1521 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1523 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1524 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
, TEX_OFFSET
),
1527 add_function("textureProjGrad",
1528 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1529 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1530 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1531 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1532 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1533 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1535 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1536 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1537 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1538 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1539 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1540 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1542 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1543 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1544 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1546 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1547 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1548 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1549 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1550 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1551 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1553 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1555 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1556 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1559 add_function("textureProjGradOffset",
1560 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1561 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1562 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1563 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1564 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1565 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1567 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1568 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1569 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1570 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1571 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1572 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1574 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1575 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1576 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1578 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1579 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1580 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1581 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1582 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1583 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1585 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1587 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1588 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1591 add_function("EmitVertex", _EmitVertex(), NULL
);
1592 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1594 add_function("textureQueryLOD",
1595 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1596 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1597 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1599 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1600 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1601 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1603 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1604 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1605 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1607 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1608 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1609 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1611 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1612 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1613 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1615 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1616 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1617 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1619 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1620 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1621 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1623 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1624 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1625 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1626 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1627 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1628 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1631 add_function("textureQueryLevels",
1632 _textureQueryLevels(glsl_type::sampler1D_type
),
1633 _textureQueryLevels(glsl_type::sampler2D_type
),
1634 _textureQueryLevels(glsl_type::sampler3D_type
),
1635 _textureQueryLevels(glsl_type::samplerCube_type
),
1636 _textureQueryLevels(glsl_type::sampler1DArray_type
),
1637 _textureQueryLevels(glsl_type::sampler2DArray_type
),
1638 _textureQueryLevels(glsl_type::samplerCubeArray_type
),
1639 _textureQueryLevels(glsl_type::sampler1DShadow_type
),
1640 _textureQueryLevels(glsl_type::sampler2DShadow_type
),
1641 _textureQueryLevels(glsl_type::samplerCubeShadow_type
),
1642 _textureQueryLevels(glsl_type::sampler1DArrayShadow_type
),
1643 _textureQueryLevels(glsl_type::sampler2DArrayShadow_type
),
1644 _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type
),
1646 _textureQueryLevels(glsl_type::isampler1D_type
),
1647 _textureQueryLevels(glsl_type::isampler2D_type
),
1648 _textureQueryLevels(glsl_type::isampler3D_type
),
1649 _textureQueryLevels(glsl_type::isamplerCube_type
),
1650 _textureQueryLevels(glsl_type::isampler1DArray_type
),
1651 _textureQueryLevels(glsl_type::isampler2DArray_type
),
1652 _textureQueryLevels(glsl_type::isamplerCubeArray_type
),
1654 _textureQueryLevels(glsl_type::usampler1D_type
),
1655 _textureQueryLevels(glsl_type::usampler2D_type
),
1656 _textureQueryLevels(glsl_type::usampler3D_type
),
1657 _textureQueryLevels(glsl_type::usamplerCube_type
),
1658 _textureQueryLevels(glsl_type::usampler1DArray_type
),
1659 _textureQueryLevels(glsl_type::usampler2DArray_type
),
1660 _textureQueryLevels(glsl_type::usamplerCubeArray_type
),
1664 add_function("texture1D",
1665 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1666 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1669 add_function("texture1DArray",
1670 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1671 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1674 add_function("texture1DProj",
1675 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1676 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1677 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1678 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1681 add_function("texture1DLod",
1682 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1685 add_function("texture1DArrayLod",
1686 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::vec2_type
),
1689 add_function("texture1DProjLod",
1690 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1691 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1694 add_function("texture2D",
1695 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1696 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1697 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec2_type
),
1700 add_function("texture2DArray",
1701 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1702 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1705 add_function("texture2DProj",
1706 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1707 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1708 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1709 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1710 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1711 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1714 add_function("texture2DLod",
1715 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1718 add_function("texture2DArrayLod",
1719 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1722 add_function("texture2DProjLod",
1723 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1724 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1727 add_function("texture3D",
1728 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1729 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1732 add_function("texture3DProj",
1733 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1734 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1737 add_function("texture3DLod",
1738 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1741 add_function("texture3DProjLod",
1742 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1745 add_function("textureCube",
1746 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1747 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1750 add_function("textureCubeLod",
1751 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1754 add_function("texture2DRect",
1755 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1758 add_function("texture2DRectProj",
1759 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1760 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1763 add_function("shadow1D",
1764 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1765 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1768 add_function("shadow1DArray",
1769 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1770 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1773 add_function("shadow2D",
1774 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1775 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1778 add_function("shadow2DArray",
1779 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1780 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec4_type
),
1783 add_function("shadow1DProj",
1784 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1785 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1788 add_function("shadow2DProj",
1789 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1790 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1793 add_function("shadow1DLod",
1794 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1797 add_function("shadow2DLod",
1798 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1801 add_function("shadow1DArrayLod",
1802 _texture(ir_txl
, texture_array_lod
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, glsl_type::vec3_type
),
1805 add_function("shadow1DProjLod",
1806 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1809 add_function("shadow2DProjLod",
1810 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1813 add_function("shadow2DRect",
1814 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1817 add_function("shadow2DRectProj",
1818 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1821 add_function("texture1DGradARB",
1822 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::float_type
),
1825 add_function("texture1DProjGradARB",
1826 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec2_type
, TEX_PROJECT
),
1827 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1830 add_function("texture2DGradARB",
1831 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1834 add_function("texture2DProjGradARB",
1835 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1836 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1839 add_function("texture3DGradARB",
1840 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1843 add_function("texture3DProjGradARB",
1844 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1847 add_function("textureCubeGradARB",
1848 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1851 add_function("shadow1DGradARB",
1852 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec3_type
),
1855 add_function("shadow1DProjGradARB",
1856 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1859 add_function("shadow2DGradARB",
1860 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec3_type
),
1863 add_function("shadow2DProjGradARB",
1864 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1867 add_function("texture2DRectGradARB",
1868 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1871 add_function("texture2DRectProjGradARB",
1872 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec3_type
, TEX_PROJECT
),
1873 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1876 add_function("shadow2DRectGradARB",
1877 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec3_type
),
1880 add_function("shadow2DRectProjGradARB",
1881 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec4_type
, TEX_PROJECT
),
1884 add_function("textureGather",
1885 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1886 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1887 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1889 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
),
1890 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
),
1891 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
),
1893 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
),
1894 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
),
1895 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
),
1897 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1898 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1899 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1901 _texture(ir_tg4
, texture_gather
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
),
1902 _texture(ir_tg4
, texture_gather
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
),
1903 _texture(ir_tg4
, texture_gather
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
),
1905 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1906 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1907 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1909 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1910 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1911 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_COMPONENT
),
1913 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1914 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1915 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1917 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1918 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1919 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, glsl_type::vec3_type
, TEX_COMPONENT
),
1921 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1922 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1923 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, glsl_type::vec4_type
, TEX_COMPONENT
),
1925 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1926 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
),
1927 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1928 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec4_type
),
1929 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
),
1932 add_function("textureGatherOffset",
1933 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1934 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1935 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET
),
1937 _texture(ir_tg4
, texture_gather_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1938 _texture(ir_tg4
, texture_gather_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1939 _texture(ir_tg4
, texture_gather_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET
),
1941 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1942 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1943 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1945 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1946 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1947 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1949 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1950 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1951 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1953 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1954 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1955 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1957 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1958 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1959 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1961 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1962 _texture(ir_tg4
, gpu_shader5
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1963 _texture(ir_tg4
, gpu_shader5
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
| TEX_COMPONENT
),
1965 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1966 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, glsl_type::vec3_type
, TEX_OFFSET_NONCONST
),
1967 _texture(ir_tg4
, gpu_shader5
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, glsl_type::vec2_type
, TEX_OFFSET_NONCONST
),
1986 add_function("ldexp",
1987 _ldexp(glsl_type::float_type
, glsl_type::int_type
),
1988 _ldexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
1989 _ldexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
1990 _ldexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
1993 add_function("frexp",
1994 _frexp(glsl_type::float_type
, glsl_type::int_type
),
1995 _frexp(glsl_type::vec2_type
, glsl_type::ivec2_type
),
1996 _frexp(glsl_type::vec3_type
, glsl_type::ivec3_type
),
1997 _frexp(glsl_type::vec4_type
, glsl_type::ivec4_type
),
1999 add_function("uaddCarry",
2000 _uaddCarry(glsl_type::uint_type
),
2001 _uaddCarry(glsl_type::uvec2_type
),
2002 _uaddCarry(glsl_type::uvec3_type
),
2003 _uaddCarry(glsl_type::uvec4_type
),
2005 add_function("usubBorrow",
2006 _usubBorrow(glsl_type::uint_type
),
2007 _usubBorrow(glsl_type::uvec2_type
),
2008 _usubBorrow(glsl_type::uvec3_type
),
2009 _usubBorrow(glsl_type::uvec4_type
),
2011 add_function("imulExtended",
2012 _mulExtended(glsl_type::int_type
),
2013 _mulExtended(glsl_type::ivec2_type
),
2014 _mulExtended(glsl_type::ivec3_type
),
2015 _mulExtended(glsl_type::ivec4_type
),
2017 add_function("umulExtended",
2018 _mulExtended(glsl_type::uint_type
),
2019 _mulExtended(glsl_type::uvec2_type
),
2020 _mulExtended(glsl_type::uvec3_type
),
2021 _mulExtended(glsl_type::uvec4_type
),
2031 builtin_builder::add_function(const char *name
, ...)
2035 ir_function
*f
= new(mem_ctx
) ir_function(name
);
2039 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
2043 sig
->is_defined
= true;
2047 stuff
.push_tail(sig
);
2048 validate_ir_tree(&stuff
);
2051 f
->add_signature(sig
);
2055 shader
->symbols
->add_function(f
);
2059 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
2061 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
2065 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
2067 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
2071 builtin_builder::imm(float f
, unsigned vector_elements
)
2073 return new(mem_ctx
) ir_constant(f
, vector_elements
);
2077 builtin_builder::imm(int i
, unsigned vector_elements
)
2079 return new(mem_ctx
) ir_constant(i
, vector_elements
);
2083 builtin_builder::imm(unsigned u
, unsigned vector_elements
)
2085 return new(mem_ctx
) ir_constant(u
, vector_elements
);
2089 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
2091 return new(mem_ctx
) ir_constant(type
, &data
);
2094 ir_dereference_variable
*
2095 builtin_builder::var_ref(ir_variable
*var
)
2097 return new(mem_ctx
) ir_dereference_variable(var
);
2100 ir_dereference_array
*
2101 builtin_builder::array_ref(ir_variable
*var
, int idx
)
2103 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
2106 /** Return an element of a matrix */
2108 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
2110 return swizzle(array_ref(var
, column
), row
, 1);
2114 * Implementations of built-in functions:
2117 ir_function_signature
*
2118 builtin_builder::new_sig(const glsl_type
*return_type
,
2119 builtin_available_predicate avail
,
2125 ir_function_signature
*sig
=
2126 new(mem_ctx
) ir_function_signature(return_type
, avail
);
2129 va_start(ap
, num_params
);
2130 for (int i
= 0; i
< num_params
; i
++) {
2131 plist
.push_tail(va_arg(ap
, ir_variable
*));
2135 sig
->replace_parameters(&plist
);
2139 #define MAKE_SIG(return_type, avail, ...) \
2140 ir_function_signature *sig = \
2141 new_sig(return_type, avail, __VA_ARGS__); \
2142 ir_factory body(&sig->body, mem_ctx);
2144 ir_function_signature
*
2145 builtin_builder::unop(builtin_available_predicate avail
,
2146 ir_expression_operation opcode
,
2147 const glsl_type
*return_type
,
2148 const glsl_type
*param_type
)
2150 ir_variable
*x
= in_var(param_type
, "x");
2151 MAKE_SIG(return_type
, avail
, 1, x
);
2152 body
.emit(ret(expr(opcode
, x
)));
2156 #define UNOP(NAME, OPCODE, AVAIL) \
2157 ir_function_signature * \
2158 builtin_builder::_##NAME(const glsl_type *type) \
2160 return unop(&AVAIL, OPCODE, type, type); \
2163 ir_function_signature
*
2164 builtin_builder::binop(ir_expression_operation opcode
,
2165 builtin_available_predicate avail
,
2166 const glsl_type
*return_type
,
2167 const glsl_type
*param0_type
,
2168 const glsl_type
*param1_type
)
2170 ir_variable
*x
= in_var(param0_type
, "x");
2171 ir_variable
*y
= in_var(param1_type
, "y");
2172 MAKE_SIG(return_type
, avail
, 2, x
, y
);
2173 body
.emit(ret(expr(opcode
, x
, y
)));
2177 #define BINOP(NAME, OPCODE, AVAIL) \
2178 ir_function_signature * \
2179 builtin_builder::_##NAME(const glsl_type *return_type, \
2180 const glsl_type *param0_type, \
2181 const glsl_type *param1_type) \
2183 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
2187 * Angle and Trigonometry Functions @{
2190 ir_function_signature
*
2191 builtin_builder::_radians(const glsl_type
*type
)
2193 ir_variable
*degrees
= in_var(type
, "degrees");
2194 MAKE_SIG(type
, always_available
, 1, degrees
);
2195 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
2199 ir_function_signature
*
2200 builtin_builder::_degrees(const glsl_type
*type
)
2202 ir_variable
*radians
= in_var(type
, "radians");
2203 MAKE_SIG(type
, always_available
, 1, radians
);
2204 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2208 UNOP(sin
, ir_unop_sin
, always_available
)
2209 UNOP(cos
, ir_unop_cos
, always_available
)
2211 ir_function_signature
*
2212 builtin_builder::_tan(const glsl_type
*type
)
2214 ir_variable
*theta
= in_var(type
, "theta");
2215 MAKE_SIG(type
, always_available
, 1, theta
);
2216 body
.emit(ret(div(sin(theta
), cos(theta
))));
2221 builtin_builder::asin_expr(ir_variable
*x
)
2224 sub(imm(1.5707964f
),
2225 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2226 add(imm(1.5707964f
),
2228 add(imm(-0.21460183f
),
2230 add(imm(0.086566724f
),
2231 mul(abs(x
), imm(-0.03102955f
))))))))));
2235 ir_function_signature
*
2236 builtin_builder::_asin(const glsl_type
*type
)
2238 ir_variable
*x
= in_var(type
, "x");
2239 MAKE_SIG(type
, always_available
, 1, x
);
2241 body
.emit(ret(asin_expr(x
)));
2246 ir_function_signature
*
2247 builtin_builder::_acos(const glsl_type
*type
)
2249 ir_variable
*x
= in_var(type
, "x");
2250 MAKE_SIG(type
, always_available
, 1, x
);
2252 body
.emit(ret(sub(imm(1.5707964f
), asin_expr(x
))));
2257 ir_function_signature
*
2258 builtin_builder::_atan2(const glsl_type
*type
)
2260 ir_variable
*vec_y
= in_var(type
, "vec_y");
2261 ir_variable
*vec_x
= in_var(type
, "vec_x");
2262 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2264 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2265 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2266 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2267 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2268 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2269 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2270 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2272 /* If |x| >= 1.0e-8 * |y|: */
2274 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2276 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2278 /* Then...call atan(y/x) */
2279 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2280 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2281 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2283 outer_then
.emit(assign(r
, asin_expr(r
)));
2285 /* ...and fix it up: */
2286 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2287 inner_if
->then_instructions
.push_tail(
2288 if_tree(gequal(y
, imm(0.0f
)),
2289 assign(r
, add(r
, imm(3.141593f
))),
2290 assign(r
, sub(r
, imm(3.141593f
)))));
2291 outer_then
.emit(inner_if
);
2294 outer_if
->else_instructions
.push_tail(
2295 assign(r
, mul(sign(y
), imm(1.5707965f
))));
2297 body
.emit(outer_if
);
2299 body
.emit(assign(vec_result
, r
, 1 << i
));
2301 body
.emit(ret(vec_result
));
2306 ir_function_signature
*
2307 builtin_builder::_atan(const glsl_type
*type
)
2309 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2310 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2312 ir_variable
*t
= body
.make_temp(type
, "t");
2313 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2316 body
.emit(ret(asin_expr(t
)));
2321 ir_function_signature
*
2322 builtin_builder::_sinh(const glsl_type
*type
)
2324 ir_variable
*x
= in_var(type
, "x");
2325 MAKE_SIG(type
, v130
, 1, x
);
2327 /* 0.5 * (e^x - e^(-x)) */
2328 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2333 ir_function_signature
*
2334 builtin_builder::_cosh(const glsl_type
*type
)
2336 ir_variable
*x
= in_var(type
, "x");
2337 MAKE_SIG(type
, v130
, 1, x
);
2339 /* 0.5 * (e^x + e^(-x)) */
2340 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2345 ir_function_signature
*
2346 builtin_builder::_tanh(const glsl_type
*type
)
2348 ir_variable
*x
= in_var(type
, "x");
2349 MAKE_SIG(type
, v130
, 1, x
);
2351 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2352 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2353 add(exp(x
), exp(neg(x
))))));
2358 ir_function_signature
*
2359 builtin_builder::_asinh(const glsl_type
*type
)
2361 ir_variable
*x
= in_var(type
, "x");
2362 MAKE_SIG(type
, v130
, 1, x
);
2364 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2369 ir_function_signature
*
2370 builtin_builder::_acosh(const glsl_type
*type
)
2372 ir_variable
*x
= in_var(type
, "x");
2373 MAKE_SIG(type
, v130
, 1, x
);
2375 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2379 ir_function_signature
*
2380 builtin_builder::_atanh(const glsl_type
*type
)
2382 ir_variable
*x
= in_var(type
, "x");
2383 MAKE_SIG(type
, v130
, 1, x
);
2385 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2386 sub(imm(1.0f
), x
))))));
2392 * Exponential Functions @{
2395 ir_function_signature
*
2396 builtin_builder::_pow(const glsl_type
*type
)
2398 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2401 UNOP(exp
, ir_unop_exp
, always_available
)
2402 UNOP(log
, ir_unop_log
, always_available
)
2403 UNOP(exp2
, ir_unop_exp2
, always_available
)
2404 UNOP(log2
, ir_unop_log2
, always_available
)
2405 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2406 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2410 UNOP(abs
, ir_unop_abs
, always_available
)
2411 UNOP(sign
, ir_unop_sign
, always_available
)
2412 UNOP(floor
, ir_unop_floor
, always_available
)
2413 UNOP(trunc
, ir_unop_trunc
, v130
)
2414 UNOP(round
, ir_unop_round_even
, always_available
)
2415 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2416 UNOP(ceil
, ir_unop_ceil
, always_available
)
2417 UNOP(fract
, ir_unop_fract
, always_available
)
2419 ir_function_signature
*
2420 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2422 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2425 ir_function_signature
*
2426 builtin_builder::_modf(const glsl_type
*type
)
2428 ir_variable
*x
= in_var(type
, "x");
2429 ir_variable
*i
= out_var(type
, "i");
2430 MAKE_SIG(type
, v130
, 2, x
, i
);
2432 ir_variable
*t
= body
.make_temp(type
, "t");
2433 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2434 body
.emit(assign(i
, t
));
2435 body
.emit(ret(sub(x
, t
)));
2440 ir_function_signature
*
2441 builtin_builder::_min(builtin_available_predicate avail
,
2442 const glsl_type
*x_type
, const glsl_type
*y_type
)
2444 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2447 ir_function_signature
*
2448 builtin_builder::_max(builtin_available_predicate avail
,
2449 const glsl_type
*x_type
, const glsl_type
*y_type
)
2451 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2454 ir_function_signature
*
2455 builtin_builder::_clamp(builtin_available_predicate avail
,
2456 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2458 ir_variable
*x
= in_var(val_type
, "x");
2459 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2460 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2461 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2463 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2468 ir_function_signature
*
2469 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2471 ir_variable
*x
= in_var(val_type
, "x");
2472 ir_variable
*y
= in_var(val_type
, "y");
2473 ir_variable
*a
= in_var(blend_type
, "a");
2474 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2476 body
.emit(ret(lrp(x
, y
, a
)));
2481 ir_function_signature
*
2482 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2483 const glsl_type
*val_type
,
2484 const glsl_type
*blend_type
)
2486 ir_variable
*x
= in_var(val_type
, "x");
2487 ir_variable
*y
= in_var(val_type
, "y");
2488 ir_variable
*a
= in_var(blend_type
, "a");
2489 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2491 /* csel matches the ternary operator in that a selector of true choses the
2492 * first argument. This differs from mix(x, y, false) which choses the
2493 * second argument (to remain consistent with the interpolating version of
2494 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2496 * To handle the behavior mismatch, reverse the x and y arguments.
2498 body
.emit(ret(csel(a
, y
, x
)));
2503 ir_function_signature
*
2504 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2506 ir_variable
*edge
= in_var(edge_type
, "edge");
2507 ir_variable
*x
= in_var(x_type
, "x");
2508 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2510 ir_variable
*t
= body
.make_temp(x_type
, "t");
2511 if (x_type
->vector_elements
== 1) {
2512 /* Both are floats */
2513 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2514 } else if (edge_type
->vector_elements
== 1) {
2515 /* x is a vector but edge is a float */
2516 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2517 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2520 /* Both are vectors */
2521 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2522 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2531 ir_function_signature
*
2532 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2534 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2535 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2536 ir_variable
*x
= in_var(x_type
, "x");
2537 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2539 /* From the GLSL 1.10 specification:
2542 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2543 * return t * t * (3 - 2 * t);
2546 ir_variable
*t
= body
.make_temp(x_type
, "t");
2547 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2548 imm(0.0f
), imm(1.0f
))));
2550 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2555 ir_function_signature
*
2556 builtin_builder::_isnan(const glsl_type
*type
)
2558 ir_variable
*x
= in_var(type
, "x");
2559 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2561 body
.emit(ret(nequal(x
, x
)));
2566 ir_function_signature
*
2567 builtin_builder::_isinf(const glsl_type
*type
)
2569 ir_variable
*x
= in_var(type
, "x");
2570 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2572 ir_constant_data infinities
;
2573 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2574 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2577 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2582 ir_function_signature
*
2583 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2585 ir_variable
*x
= in_var(type
, "x");
2586 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2587 body
.emit(ret(bitcast_f2i(x
)));
2591 ir_function_signature
*
2592 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2594 ir_variable
*x
= in_var(type
, "x");
2595 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2596 body
.emit(ret(bitcast_f2u(x
)));
2600 ir_function_signature
*
2601 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2603 ir_variable
*x
= in_var(type
, "x");
2604 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2605 body
.emit(ret(bitcast_i2f(x
)));
2609 ir_function_signature
*
2610 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2612 ir_variable
*x
= in_var(type
, "x");
2613 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2614 body
.emit(ret(bitcast_u2f(x
)));
2618 ir_function_signature
*
2619 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2621 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2622 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2623 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2627 ir_function_signature
*
2628 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2630 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2631 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2632 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2636 ir_function_signature
*
2637 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2639 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2640 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2641 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
2645 ir_function_signature
*
2646 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
2648 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2649 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2650 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
2654 ir_function_signature
*
2655 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
2657 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2658 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2659 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
2663 ir_function_signature
*
2664 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
2666 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2667 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2668 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
2673 ir_function_signature
*
2674 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
2676 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2677 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2678 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
2682 ir_function_signature
*
2683 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
2685 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2686 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2687 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
2691 ir_function_signature
*
2692 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
2694 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2695 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2696 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
2700 ir_function_signature
*
2701 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
2703 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2704 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2705 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
2709 ir_function_signature
*
2710 builtin_builder::_length(const glsl_type
*type
)
2712 ir_variable
*x
= in_var(type
, "x");
2713 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
2715 body
.emit(ret(sqrt(dotlike(x
, x
))));
2720 ir_function_signature
*
2721 builtin_builder::_distance(const glsl_type
*type
)
2723 ir_variable
*p0
= in_var(type
, "p0");
2724 ir_variable
*p1
= in_var(type
, "p1");
2725 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
2727 if (type
->vector_elements
== 1) {
2728 body
.emit(ret(abs(sub(p0
, p1
))));
2730 ir_variable
*p
= body
.make_temp(type
, "p");
2731 body
.emit(assign(p
, sub(p0
, p1
)));
2732 body
.emit(ret(sqrt(dot(p
, p
))));
2738 ir_function_signature
*
2739 builtin_builder::_dot(const glsl_type
*type
)
2741 if (type
->vector_elements
== 1)
2742 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
2744 return binop(ir_binop_dot
, always_available
,
2745 glsl_type::float_type
, type
, type
);
2748 ir_function_signature
*
2749 builtin_builder::_cross(const glsl_type
*type
)
2751 ir_variable
*a
= in_var(type
, "a");
2752 ir_variable
*b
= in_var(type
, "b");
2753 MAKE_SIG(type
, always_available
, 2, a
, b
);
2755 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
2756 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
2758 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
2759 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
2764 ir_function_signature
*
2765 builtin_builder::_normalize(const glsl_type
*type
)
2767 ir_variable
*x
= in_var(type
, "x");
2768 MAKE_SIG(type
, always_available
, 1, x
);
2770 if (type
->vector_elements
== 1) {
2771 body
.emit(ret(sign(x
)));
2773 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
2779 ir_function_signature
*
2780 builtin_builder::_ftransform()
2782 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
2784 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
2785 glsl_type::vec4_type
,
2786 var_ref(gl_ModelViewProjectionMatrix
),
2787 var_ref(gl_Vertex
))));
2789 /* FINISHME: Once the ir_expression() constructor handles type inference
2790 * for matrix operations, we can simplify this to:
2792 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
2797 ir_function_signature
*
2798 builtin_builder::_faceforward(const glsl_type
*type
)
2800 ir_variable
*N
= in_var(type
, "N");
2801 ir_variable
*I
= in_var(type
, "I");
2802 ir_variable
*Nref
= in_var(type
, "Nref");
2803 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
2805 body
.emit(if_tree(less(dotlike(Nref
, I
), imm(0.0f
)),
2806 ret(N
), ret(neg(N
))));
2811 ir_function_signature
*
2812 builtin_builder::_reflect(const glsl_type
*type
)
2814 ir_variable
*I
= in_var(type
, "I");
2815 ir_variable
*N
= in_var(type
, "N");
2816 MAKE_SIG(type
, always_available
, 2, I
, N
);
2818 /* I - 2 * dot(N, I) * N */
2819 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dotlike(N
, I
), N
)))));
2824 ir_function_signature
*
2825 builtin_builder::_refract(const glsl_type
*type
)
2827 ir_variable
*I
= in_var(type
, "I");
2828 ir_variable
*N
= in_var(type
, "N");
2829 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
2830 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
2832 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
2833 body
.emit(assign(n_dot_i
, dotlike(N
, I
)));
2835 /* From the GLSL 1.10 specification:
2836 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
2838 * return genType(0.0)
2840 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
2842 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
2843 body
.emit(assign(k
, sub(imm(1.0f
),
2844 mul(eta
, mul(eta
, sub(imm(1.0f
),
2845 mul(n_dot_i
, n_dot_i
)))))));
2846 body
.emit(if_tree(less(k
, imm(0.0f
)),
2847 ret(ir_constant::zero(mem_ctx
, type
)),
2848 ret(sub(mul(eta
, I
),
2849 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
2854 ir_function_signature
*
2855 builtin_builder::_matrixCompMult(const glsl_type
*type
)
2857 ir_variable
*x
= in_var(type
, "x");
2858 ir_variable
*y
= in_var(type
, "y");
2859 MAKE_SIG(type
, always_available
, 2, x
, y
);
2861 ir_variable
*z
= body
.make_temp(type
, "z");
2862 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2863 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
2870 ir_function_signature
*
2871 builtin_builder::_outerProduct(const glsl_type
*type
)
2873 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
2874 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
2875 MAKE_SIG(type
, v120
, 2, c
, r
);
2877 ir_variable
*m
= body
.make_temp(type
, "m");
2878 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2879 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
2886 ir_function_signature
*
2887 builtin_builder::_transpose(const glsl_type
*orig_type
)
2889 const glsl_type
*transpose_type
=
2890 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
2891 orig_type
->matrix_columns
,
2892 orig_type
->vector_elements
);
2894 ir_variable
*m
= in_var(orig_type
, "m");
2895 MAKE_SIG(transpose_type
, v120
, 1, m
);
2897 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
2898 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
2899 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
2900 body
.emit(assign(array_ref(t
, j
),
2901 matrix_elt(m
, i
, j
),
2910 ir_function_signature
*
2911 builtin_builder::_determinant_mat2()
2913 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
2914 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2916 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2917 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
2922 ir_function_signature
*
2923 builtin_builder::_determinant_mat3()
2925 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
2926 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2929 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
2930 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
2933 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
2934 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
2937 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
2938 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
2940 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
2941 mul(matrix_elt(m
, 0, 1), f2
)),
2942 mul(matrix_elt(m
, 0, 2), f3
))));
2947 ir_function_signature
*
2948 builtin_builder::_determinant_mat4()
2950 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
2951 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2953 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
2954 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
2955 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
2956 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
2957 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
2958 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
2959 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
2960 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
2961 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
2962 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
2963 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
2964 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
2965 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
2966 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
2967 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
2968 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
2969 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
2970 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
2971 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
2973 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)))));
2974 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)))));
2975 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)))));
2976 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)))));
2977 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)))));
2978 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)))));
2979 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)))));
2980 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)))));
2981 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)))));
2982 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)))));
2983 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)))));
2984 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)))));
2985 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)))));
2986 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)))));
2987 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)))));
2988 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)))));
2989 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)))));
2990 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)))));
2991 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)))));
2993 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
2995 body
.emit(assign(adj_0
,
2996 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
2997 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
2998 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3000 body
.emit(assign(adj_0
, neg(
3001 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3002 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3003 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3005 body
.emit(assign(adj_0
,
3006 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3007 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3008 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3010 body
.emit(assign(adj_0
, neg(
3011 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3012 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3013 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3016 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
3021 ir_function_signature
*
3022 builtin_builder::_inverse_mat2()
3024 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
3025 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
3027 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
3028 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
3029 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
3030 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
3031 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
3033 ir_expression
*det
=
3034 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3035 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
3037 body
.emit(ret(div(adj
, det
)));
3041 ir_function_signature
*
3042 builtin_builder::_inverse_mat3()
3044 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
3045 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
3047 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
3048 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
3049 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
3051 body
.emit(assign(f11_22_21_12
,
3052 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
3053 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
3054 body
.emit(assign(f10_22_20_12
,
3055 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
3056 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
3057 body
.emit(assign(f10_21_20_11
,
3058 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
3059 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
3061 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
3062 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
3063 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
3064 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
3066 body
.emit(assign(array_ref(adj
, 0), neg(
3067 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
3068 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
3070 body
.emit(assign(array_ref(adj
, 1),
3071 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
3072 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
3074 body
.emit(assign(array_ref(adj
, 2), neg(
3075 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
3076 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
3079 body
.emit(assign(array_ref(adj
, 0),
3080 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
3081 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
3083 body
.emit(assign(array_ref(adj
, 1), neg(
3084 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
3085 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
3087 body
.emit(assign(array_ref(adj
, 2),
3088 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
3089 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
3092 ir_expression
*det
=
3093 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
3094 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
3095 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
3097 body
.emit(ret(div(adj
, det
)));
3102 ir_function_signature
*
3103 builtin_builder::_inverse_mat4()
3105 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
3106 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
3108 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
3109 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
3110 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
3111 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
3112 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
3113 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
3114 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
3115 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
3116 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
3117 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
3118 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
3119 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
3120 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
3121 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
3122 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
3123 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
3124 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
3125 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
3126 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
3128 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)))));
3129 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)))));
3130 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)))));
3131 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)))));
3132 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)))));
3133 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)))));
3134 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)))));
3135 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)))));
3136 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)))));
3137 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)))));
3138 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)))));
3139 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)))));
3140 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)))));
3141 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)))));
3142 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)))));
3143 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)))));
3144 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)))));
3145 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)))));
3146 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)))));
3148 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
3149 body
.emit(assign(array_ref(adj
, 0),
3150 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
3151 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
3152 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
3154 body
.emit(assign(array_ref(adj
, 1), neg(
3155 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
3156 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
3157 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
3159 body
.emit(assign(array_ref(adj
, 2),
3160 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
3161 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
3162 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
3164 body
.emit(assign(array_ref(adj
, 3), neg(
3165 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
3166 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
3167 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
3170 body
.emit(assign(array_ref(adj
, 0), neg(
3171 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
3172 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
3173 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
3175 body
.emit(assign(array_ref(adj
, 1),
3176 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
3177 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
3178 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
3180 body
.emit(assign(array_ref(adj
, 2), neg(
3181 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
3182 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
3183 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
3185 body
.emit(assign(array_ref(adj
, 3),
3186 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
3187 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
3188 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
3191 body
.emit(assign(array_ref(adj
, 0),
3192 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
3193 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
3194 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
3196 body
.emit(assign(array_ref(adj
, 1), neg(
3197 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
3198 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
3199 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3201 body
.emit(assign(array_ref(adj
, 2),
3202 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3203 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3204 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3206 body
.emit(assign(array_ref(adj
, 3), neg(
3207 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3208 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3209 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3212 body
.emit(assign(array_ref(adj
, 0), neg(
3213 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3214 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3215 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3217 body
.emit(assign(array_ref(adj
, 1),
3218 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3219 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3220 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3222 body
.emit(assign(array_ref(adj
, 2), neg(
3223 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3224 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3225 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3227 body
.emit(assign(array_ref(adj
, 3),
3228 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3229 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3230 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3233 ir_expression
*det
=
3234 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3235 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3236 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3237 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3239 body
.emit(ret(div(adj
, det
)));
3245 ir_function_signature
*
3246 builtin_builder::_lessThan(builtin_available_predicate avail
,
3247 const glsl_type
*type
)
3249 return binop(ir_binop_less
, avail
,
3250 glsl_type::bvec(type
->vector_elements
), type
, type
);
3253 ir_function_signature
*
3254 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3255 const glsl_type
*type
)
3257 return binop(ir_binop_lequal
, avail
,
3258 glsl_type::bvec(type
->vector_elements
), type
, type
);
3261 ir_function_signature
*
3262 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3263 const glsl_type
*type
)
3265 return binop(ir_binop_greater
, avail
,
3266 glsl_type::bvec(type
->vector_elements
), type
, type
);
3269 ir_function_signature
*
3270 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3271 const glsl_type
*type
)
3273 return binop(ir_binop_gequal
, avail
,
3274 glsl_type::bvec(type
->vector_elements
), type
, type
);
3277 ir_function_signature
*
3278 builtin_builder::_equal(builtin_available_predicate avail
,
3279 const glsl_type
*type
)
3281 return binop(ir_binop_equal
, avail
,
3282 glsl_type::bvec(type
->vector_elements
), type
, type
);
3285 ir_function_signature
*
3286 builtin_builder::_notEqual(builtin_available_predicate avail
,
3287 const glsl_type
*type
)
3289 return binop(ir_binop_nequal
, avail
,
3290 glsl_type::bvec(type
->vector_elements
), type
, type
);
3293 ir_function_signature
*
3294 builtin_builder::_any(const glsl_type
*type
)
3296 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3299 ir_function_signature
*
3300 builtin_builder::_all(const glsl_type
*type
)
3302 ir_variable
*v
= in_var(type
, "v");
3303 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3305 switch (type
->vector_elements
) {
3307 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3310 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3314 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3323 UNOP(not, ir_unop_logic_not
, always_available
)
3326 has_lod(const glsl_type
*sampler_type
)
3328 assert(sampler_type
->is_sampler());
3330 switch (sampler_type
->sampler_dimensionality
) {
3331 case GLSL_SAMPLER_DIM_RECT
:
3332 case GLSL_SAMPLER_DIM_BUF
:
3333 case GLSL_SAMPLER_DIM_MS
:
3340 ir_function_signature
*
3341 builtin_builder::_textureSize(builtin_available_predicate avail
,
3342 const glsl_type
*return_type
,
3343 const glsl_type
*sampler_type
)
3345 ir_variable
*s
= in_var(sampler_type
, "sampler");
3346 /* The sampler always exists; add optional lod later. */
3347 MAKE_SIG(return_type
, avail
, 1, s
);
3349 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3350 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3352 if (has_lod(sampler_type
)) {
3353 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3354 sig
->parameters
.push_tail(lod
);
3355 tex
->lod_info
.lod
= var_ref(lod
);
3357 tex
->lod_info
.lod
= imm(0u);
3360 body
.emit(ret(tex
));
3365 ir_function_signature
*
3366 builtin_builder::_texture(ir_texture_opcode opcode
,
3367 builtin_available_predicate avail
,
3368 const glsl_type
*return_type
,
3369 const glsl_type
*sampler_type
,
3370 const glsl_type
*coord_type
,
3373 ir_variable
*s
= in_var(sampler_type
, "sampler");
3374 ir_variable
*P
= in_var(coord_type
, "P");
3375 /* The sampler and coordinate always exist; add optional parameters later. */
3376 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3378 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3379 tex
->set_sampler(var_ref(s
), return_type
);
3381 const int coord_size
= sampler_type
->sampler_coordinate_components();
3383 if (coord_size
== coord_type
->vector_elements
) {
3384 tex
->coordinate
= var_ref(P
);
3386 /* The incoming coordinate also has the projector or shadow comparitor,
3387 * so we need to swizzle those away.
3389 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3392 /* The projector is always in the last component. */
3393 if (flags
& TEX_PROJECT
)
3394 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3396 if (sampler_type
->sampler_shadow
) {
3397 if (opcode
== ir_tg4
) {
3398 /* gather has refz as a separate parameter, immediately after the
3401 ir_variable
*refz
= in_var(glsl_type::float_type
, "refz");
3402 sig
->parameters
.push_tail(refz
);
3403 tex
->shadow_comparitor
= var_ref(refz
);
3405 /* The shadow comparitor is normally in the Z component, but a few types
3406 * have sufficiently large coordinates that it's in W.
3408 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3412 if (opcode
== ir_txl
) {
3413 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3414 sig
->parameters
.push_tail(lod
);
3415 tex
->lod_info
.lod
= var_ref(lod
);
3416 } else if (opcode
== ir_txd
) {
3417 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3418 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3419 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3420 sig
->parameters
.push_tail(dPdx
);
3421 sig
->parameters
.push_tail(dPdy
);
3422 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3423 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3426 if (flags
& (TEX_OFFSET
| TEX_OFFSET_NONCONST
)) {
3427 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3428 ir_variable
*offset
=
3429 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset",
3430 (flags
& TEX_OFFSET
) ? ir_var_const_in
: ir_var_function_in
);
3431 sig
->parameters
.push_tail(offset
);
3432 tex
->offset
= var_ref(offset
);
3435 if (opcode
== ir_tg4
) {
3436 if (flags
& TEX_COMPONENT
) {
3437 ir_variable
*component
=
3438 new(mem_ctx
) ir_variable(glsl_type::int_type
, "comp", ir_var_const_in
);
3439 sig
->parameters
.push_tail(component
);
3440 tex
->lod_info
.component
= var_ref(component
);
3443 tex
->lod_info
.component
= imm(0);
3447 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3448 * inconsistent with both textureLodOffset and textureGradOffset.
3450 if (opcode
== ir_txb
) {
3451 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3452 sig
->parameters
.push_tail(bias
);
3453 tex
->lod_info
.bias
= var_ref(bias
);
3456 body
.emit(ret(tex
));
3461 ir_function_signature
*
3462 builtin_builder::_textureCubeArrayShadow()
3464 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3465 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3466 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3467 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3469 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3470 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3472 tex
->coordinate
= var_ref(P
);
3473 tex
->shadow_comparitor
= var_ref(compare
);
3475 body
.emit(ret(tex
));
3480 ir_function_signature
*
3481 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3482 const glsl_type
*return_type
,
3483 const glsl_type
*sampler_type
,
3484 const glsl_type
*coord_type
,
3485 const glsl_type
*offset_type
)
3487 ir_variable
*s
= in_var(sampler_type
, "sampler");
3488 ir_variable
*P
= in_var(coord_type
, "P");
3489 /* The sampler and coordinate always exist; add optional parameters later. */
3490 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3492 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3493 tex
->coordinate
= var_ref(P
);
3494 tex
->set_sampler(var_ref(s
), return_type
);
3496 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3497 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3498 sig
->parameters
.push_tail(sample
);
3499 tex
->lod_info
.sample_index
= var_ref(sample
);
3500 tex
->op
= ir_txf_ms
;
3501 } else if (has_lod(sampler_type
)) {
3502 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3503 sig
->parameters
.push_tail(lod
);
3504 tex
->lod_info
.lod
= var_ref(lod
);
3506 tex
->lod_info
.lod
= imm(0u);
3509 if (offset_type
!= NULL
) {
3510 ir_variable
*offset
=
3511 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3512 sig
->parameters
.push_tail(offset
);
3513 tex
->offset
= var_ref(offset
);
3516 body
.emit(ret(tex
));
3521 ir_function_signature
*
3522 builtin_builder::_EmitVertex()
3524 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3526 body
.emit(new(mem_ctx
) ir_emit_vertex());
3531 ir_function_signature
*
3532 builtin_builder::_EndPrimitive()
3534 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3536 body
.emit(new(mem_ctx
) ir_end_primitive());
3541 ir_function_signature
*
3542 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3543 const glsl_type
*coord_type
)
3545 ir_variable
*s
= in_var(sampler_type
, "sampler");
3546 ir_variable
*coord
= in_var(coord_type
, "coord");
3547 /* The sampler and coordinate always exist; add optional parameters later. */
3548 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3550 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3551 tex
->coordinate
= var_ref(coord
);
3552 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3554 body
.emit(ret(tex
));
3559 ir_function_signature
*
3560 builtin_builder::_textureQueryLevels(const glsl_type
*sampler_type
)
3562 ir_variable
*s
= in_var(sampler_type
, "sampler");
3563 const glsl_type
*return_type
= glsl_type::int_type
;
3564 MAKE_SIG(return_type
, texture_query_levels
, 1, s
);
3566 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_query_levels
);
3567 tex
->set_sampler(var_ref(s
), return_type
);
3569 body
.emit(ret(tex
));
3574 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3575 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3577 ir_function_signature
*
3578 builtin_builder::_fwidth(const glsl_type
*type
)
3580 ir_variable
*p
= in_var(type
, "p");
3581 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3583 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3588 ir_function_signature
*
3589 builtin_builder::_noise1(const glsl_type
*type
)
3591 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
3594 ir_function_signature
*
3595 builtin_builder::_noise2(const glsl_type
*type
)
3597 ir_variable
*p
= in_var(type
, "p");
3598 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
3600 ir_constant_data b_offset
;
3601 b_offset
.f
[0] = 601.0f
;
3602 b_offset
.f
[1] = 313.0f
;
3603 b_offset
.f
[2] = 29.0f
;
3604 b_offset
.f
[3] = 277.0f
;
3606 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3607 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3608 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
3609 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3610 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3611 body
.emit(assign(t
, a
, WRITEMASK_X
));
3612 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3618 ir_function_signature
*
3619 builtin_builder::_noise3(const glsl_type
*type
)
3621 ir_variable
*p
= in_var(type
, "p");
3622 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
3624 ir_constant_data b_offset
;
3625 b_offset
.f
[0] = 601.0f
;
3626 b_offset
.f
[1] = 313.0f
;
3627 b_offset
.f
[2] = 29.0f
;
3628 b_offset
.f
[3] = 277.0f
;
3630 ir_constant_data c_offset
;
3631 c_offset
.f
[0] = 1559.0f
;
3632 c_offset
.f
[1] = 113.0f
;
3633 c_offset
.f
[2] = 1861.0f
;
3634 c_offset
.f
[3] = 797.0f
;
3636 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3637 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3638 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3639 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
3640 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3641 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3642 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
3643 body
.emit(assign(t
, a
, WRITEMASK_X
));
3644 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3645 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3651 ir_function_signature
*
3652 builtin_builder::_noise4(const glsl_type
*type
)
3654 ir_variable
*p
= in_var(type
, "p");
3655 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
3657 ir_variable
*_p
= body
.make_temp(type
, "_p");
3659 ir_constant_data p_offset
;
3660 p_offset
.f
[0] = 1559.0f
;
3661 p_offset
.f
[1] = 113.0f
;
3662 p_offset
.f
[2] = 1861.0f
;
3663 p_offset
.f
[3] = 797.0f
;
3665 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
3667 ir_constant_data offset
;
3668 offset
.f
[0] = 601.0f
;
3669 offset
.f
[1] = 313.0f
;
3670 offset
.f
[2] = 29.0f
;
3671 offset
.f
[3] = 277.0f
;
3673 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3674 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3675 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3676 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
3677 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
3678 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3679 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
3680 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
3681 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
3682 body
.emit(assign(t
, a
, WRITEMASK_X
));
3683 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3684 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3685 body
.emit(assign(t
, d
, WRITEMASK_W
));
3691 ir_function_signature
*
3692 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
3694 ir_variable
*value
= in_var(type
, "value");
3695 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3696 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3697 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
3699 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
3704 ir_function_signature
*
3705 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
3707 ir_variable
*base
= in_var(type
, "base");
3708 ir_variable
*insert
= in_var(type
, "insert");
3709 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3710 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3711 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
3713 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
3718 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
3720 ir_function_signature
*
3721 builtin_builder::_bitCount(const glsl_type
*type
)
3723 return unop(gpu_shader5
, ir_unop_bit_count
,
3724 glsl_type::ivec(type
->vector_elements
), type
);
3727 ir_function_signature
*
3728 builtin_builder::_findLSB(const glsl_type
*type
)
3730 return unop(gpu_shader5
, ir_unop_find_lsb
,
3731 glsl_type::ivec(type
->vector_elements
), type
);
3734 ir_function_signature
*
3735 builtin_builder::_findMSB(const glsl_type
*type
)
3737 return unop(gpu_shader5
, ir_unop_find_msb
,
3738 glsl_type::ivec(type
->vector_elements
), type
);
3741 ir_function_signature
*
3742 builtin_builder::_fma(const glsl_type
*type
)
3744 ir_variable
*a
= in_var(type
, "a");
3745 ir_variable
*b
= in_var(type
, "b");
3746 ir_variable
*c
= in_var(type
, "c");
3747 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
3749 body
.emit(ret(fma(a
, b
, c
)));
3754 ir_function_signature
*
3755 builtin_builder::_ldexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3757 return binop(ir_binop_ldexp
, gpu_shader5
, x_type
, x_type
, exp_type
);
3760 ir_function_signature
*
3761 builtin_builder::_frexp(const glsl_type
*x_type
, const glsl_type
*exp_type
)
3763 ir_variable
*x
= in_var(x_type
, "x");
3764 ir_variable
*exponent
= out_var(exp_type
, "exp");
3765 MAKE_SIG(x_type
, gpu_shader5
, 2, x
, exponent
);
3767 const unsigned vec_elem
= x_type
->vector_elements
;
3768 const glsl_type
*bvec
= glsl_type::get_instance(GLSL_TYPE_BOOL
, vec_elem
, 1);
3769 const glsl_type
*uvec
= glsl_type::get_instance(GLSL_TYPE_UINT
, vec_elem
, 1);
3771 /* Single-precision floating-point values are stored as
3776 * An exponent shift of 23 will shift the mantissa out, leaving only the
3777 * exponent and sign bit (which itself may be zero, if the absolute value
3778 * was taken before the bitcast and shift.
3780 ir_constant
*exponent_shift
= imm(23);
3781 ir_constant
*exponent_bias
= imm(-126, vec_elem
);
3783 ir_constant
*sign_mantissa_mask
= imm(0x807fffffu
, vec_elem
);
3785 /* Exponent of floating-point values in the range [0.5, 1.0). */
3786 ir_constant
*exponent_value
= imm(0x3f000000u
, vec_elem
);
3788 ir_variable
*is_not_zero
= body
.make_temp(bvec
, "is_not_zero");
3789 body
.emit(assign(is_not_zero
, nequal(abs(x
), imm(0.0f
, vec_elem
))));
3791 /* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast
3792 * to unsigned integers to ensure that 1 bits aren't shifted in.
3794 body
.emit(assign(exponent
, rshift(bitcast_f2i(abs(x
)), exponent_shift
)));
3795 body
.emit(assign(exponent
, add(exponent
, csel(is_not_zero
, exponent_bias
,
3796 imm(0, vec_elem
)))));
3798 ir_variable
*bits
= body
.make_temp(uvec
, "bits");
3799 body
.emit(assign(bits
, bitcast_f2u(x
)));
3800 body
.emit(assign(bits
, bit_and(bits
, sign_mantissa_mask
)));
3801 body
.emit(assign(bits
, bit_or(bits
, csel(is_not_zero
, exponent_value
,
3802 imm(0u, vec_elem
)))));
3803 body
.emit(ret(bitcast_u2f(bits
)));
3808 ir_function_signature
*
3809 builtin_builder::_uaddCarry(const glsl_type
*type
)
3811 ir_variable
*x
= in_var(type
, "x");
3812 ir_variable
*y
= in_var(type
, "y");
3813 ir_variable
*carry
= out_var(type
, "carry");
3814 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, carry
);
3816 body
.emit(assign(carry
, ir_builder::carry(x
, y
)));
3817 body
.emit(ret(add(x
, y
)));
3822 ir_function_signature
*
3823 builtin_builder::_usubBorrow(const glsl_type
*type
)
3825 ir_variable
*x
= in_var(type
, "x");
3826 ir_variable
*y
= in_var(type
, "y");
3827 ir_variable
*borrow
= out_var(type
, "borrow");
3828 MAKE_SIG(type
, gpu_shader5
, 3, x
, y
, borrow
);
3830 body
.emit(assign(borrow
, ir_builder::borrow(x
, y
)));
3831 body
.emit(ret(sub(x
, y
)));
3837 * For both imulExtended() and umulExtended() built-ins.
3839 ir_function_signature
*
3840 builtin_builder::_mulExtended(const glsl_type
*type
)
3842 ir_variable
*x
= in_var(type
, "x");
3843 ir_variable
*y
= in_var(type
, "y");
3844 ir_variable
*msb
= out_var(type
, "msb");
3845 ir_variable
*lsb
= out_var(type
, "lsb");
3846 MAKE_SIG(glsl_type::void_type
, gpu_shader5
, 4, x
, y
, msb
, lsb
);
3848 body
.emit(assign(msb
, imul_high(x
, y
)));
3849 body
.emit(assign(lsb
, mul(x
, y
)));
3855 /******************************************************************************/
3857 /* The singleton instance of builtin_builder. */
3858 static builtin_builder builtins
;
3861 * External API (exposing the built-in module to the rest of the compiler):
3865 _mesa_glsl_initialize_builtin_functions()
3867 builtins
.initialize();
3871 _mesa_glsl_release_builtin_functions()
3876 ir_function_signature
*
3877 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
3878 const char *name
, exec_list
*actual_parameters
)
3880 return builtins
.find(state
, name
, actual_parameters
);