2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file builtin_functions.cpp
27 * Support for GLSL built-in functions.
29 * This file is split into several main components:
31 * 1. Availability predicates
33 * A series of small functions that check whether the current shader
34 * supports the version/extensions required to expose a built-in.
36 * 2. Core builtin_builder class functionality
38 * 3. Lists of built-in functions
40 * The builtin_builder::create_builtins() function contains lists of all
41 * built-in function signatures, where they're available, what types they
44 * 4. Implementations of built-in function signatures
46 * A series of functions which create ir_function_signatures and emit IR
47 * via ir_builder to implement them.
51 * A few functions the rest of the compiler can use to interact with the
52 * built-in function module. For example, searching for a built-in by
53 * name and parameters.
58 #include "main/core.h" /* for struct gl_shader */
59 #include "main/shaderobj.h"
60 #include "ir_builder.h"
61 #include "glsl_parser_extras.h"
62 #include "program/prog_instruction.h"
65 using namespace ir_builder
;
68 * Availability predicates:
72 always_available(const _mesa_glsl_parse_state
*state
)
78 compatibility_vs_only(const _mesa_glsl_parse_state
*state
)
80 return state
->target
== vertex_shader
&&
81 state
->language_version
<= 130 &&
86 fs_only(const _mesa_glsl_parse_state
*state
)
88 return state
->target
== fragment_shader
;
92 gs_only(const _mesa_glsl_parse_state
*state
)
94 return state
->target
== geometry_shader
;
98 v110(const _mesa_glsl_parse_state
*state
)
100 return !state
->es_shader
;
104 v110_fs_only(const _mesa_glsl_parse_state
*state
)
106 return !state
->es_shader
&& state
->target
== fragment_shader
;
110 v120(const _mesa_glsl_parse_state
*state
)
112 return state
->is_version(120, 300);
116 v130(const _mesa_glsl_parse_state
*state
)
118 return state
->is_version(130, 300);
122 v130_fs_only(const _mesa_glsl_parse_state
*state
)
124 return state
->is_version(130, 300) &&
125 state
->target
== fragment_shader
;
129 v140(const _mesa_glsl_parse_state
*state
)
131 return state
->is_version(140, 0);
135 texture_rectangle(const _mesa_glsl_parse_state
*state
)
137 return state
->ARB_texture_rectangle_enable
;
141 texture_external(const _mesa_glsl_parse_state
*state
)
143 return state
->OES_EGL_image_external_enable
;
146 /** True if texturing functions with explicit LOD are allowed. */
148 lod_exists_in_stage(const _mesa_glsl_parse_state
*state
)
150 /* Texturing functions with "Lod" in their name exist:
151 * - In the vertex shader stage (for all languages)
152 * - In any stage for GLSL 1.30+ or GLSL ES 3.00
153 * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
155 * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
156 * don't need to explicitly check state->es_shader.
158 return state
->target
== vertex_shader
||
159 state
->is_version(130, 300) ||
160 state
->ARB_shader_texture_lod_enable
;
164 v110_lod(const _mesa_glsl_parse_state
*state
)
166 return !state
->es_shader
&& lod_exists_in_stage(state
);
170 shader_texture_lod(const _mesa_glsl_parse_state
*state
)
172 return state
->ARB_shader_texture_lod_enable
;
176 shader_texture_lod_and_rect(const _mesa_glsl_parse_state
*state
)
178 return state
->ARB_shader_texture_lod_enable
&&
179 state
->ARB_texture_rectangle_enable
;
183 shader_bit_encoding(const _mesa_glsl_parse_state
*state
)
185 return state
->is_version(330, 300) ||
186 state
->ARB_shader_bit_encoding_enable
||
187 state
->ARB_gpu_shader5_enable
;
191 shader_integer_mix(const _mesa_glsl_parse_state
*state
)
193 return v130(state
) && state
->MESA_shader_integer_mix_enable
;
197 shader_packing(const _mesa_glsl_parse_state
*state
)
199 return state
->ARB_shading_language_packing_enable
||
200 state
->is_version(400, 0);
204 shader_packing_or_es3(const _mesa_glsl_parse_state
*state
)
206 return state
->ARB_shading_language_packing_enable
||
207 state
->is_version(400, 300);
211 gpu_shader5(const _mesa_glsl_parse_state
*state
)
213 return state
->is_version(400, 0) || state
->ARB_gpu_shader5_enable
;
217 vs_texture_array(const _mesa_glsl_parse_state
*state
)
219 return state
->target
== vertex_shader
&&
220 state
->EXT_texture_array_enable
;
224 fs_texture_array(const _mesa_glsl_parse_state
*state
)
226 return state
->target
== fragment_shader
&&
227 state
->EXT_texture_array_enable
;
231 texture_array(const _mesa_glsl_parse_state
*state
)
233 return state
->EXT_texture_array_enable
;
237 texture_multisample(const _mesa_glsl_parse_state
*state
)
239 return state
->is_version(150, 0) ||
240 state
->ARB_texture_multisample_enable
;
244 fs_texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
246 return state
->target
== fragment_shader
&&
247 (state
->is_version(400, 0) ||
248 state
->ARB_texture_cube_map_array_enable
);
252 texture_cube_map_array(const _mesa_glsl_parse_state
*state
)
254 return state
->is_version(400, 0) ||
255 state
->ARB_texture_cube_map_array_enable
;
259 texture_query_lod(const _mesa_glsl_parse_state
*state
)
261 return state
->target
== fragment_shader
&&
262 state
->ARB_texture_query_lod_enable
;
265 /* Desktop GL or OES_standard_derivatives + fragment shader only */
267 fs_oes_derivatives(const _mesa_glsl_parse_state
*state
)
269 return state
->target
== fragment_shader
&&
270 (!state
->es_shader
|| state
->OES_standard_derivatives_enable
);
274 tex1d_lod(const _mesa_glsl_parse_state
*state
)
276 return !state
->es_shader
&& lod_exists_in_stage(state
);
279 /** True if sampler3D exists */
281 tex3d(const _mesa_glsl_parse_state
*state
)
283 /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
284 * OES_texture_3D extension, and in GLSL ES 3.00.
286 return !state
->es_shader
||
287 state
->OES_texture_3D_enable
||
288 state
->language_version
>= 300;
292 fs_tex3d(const _mesa_glsl_parse_state
*state
)
294 return state
->target
== fragment_shader
&&
295 (!state
->es_shader
|| state
->OES_texture_3D_enable
);
299 tex3d_lod(const _mesa_glsl_parse_state
*state
)
301 return tex3d(state
) && lod_exists_in_stage(state
);
305 /******************************************************************************/
308 * builtin_builder: A singleton object representing the core of the built-in
311 * It generates IR for every built-in function signature, and organizes them
314 class builtin_builder
{
321 ir_function_signature
*find(_mesa_glsl_parse_state
*state
,
322 const char *name
, exec_list
*actual_parameters
);
327 * A shader to hold all the built-in signatures; created by this module.
329 * This includes signatures for every built-in, regardless of version or
330 * enabled extensions. The availability predicate associated with each
331 * signature allows matching_signature() to filter out the irrelevant ones.
335 /** Global variables used by built-in functions. */
336 ir_variable
*gl_ModelViewProjectionMatrix
;
337 ir_variable
*gl_Vertex
;
339 void create_shader();
340 void create_builtins();
343 * IR builder helpers:
345 * These convenience functions assist in emitting IR, but don't necessarily
346 * fit in ir_builder itself. Many of them rely on having a mem_ctx class
349 ir_variable
*in_var(const glsl_type
*type
, const char *name
);
350 ir_variable
*out_var(const glsl_type
*type
, const char *name
);
351 ir_constant
*imm(float f
);
352 ir_constant
*imm(int i
);
353 ir_constant
*imm(unsigned u
);
354 ir_constant
*imm(const glsl_type
*type
, const ir_constant_data
&);
355 ir_dereference_variable
*var_ref(ir_variable
*var
);
356 ir_dereference_array
*array_ref(ir_variable
*var
, int i
);
357 ir_swizzle
*matrix_elt(ir_variable
*var
, int col
, int row
);
359 ir_expression
*asin_expr(ir_variable
*x
);
361 /** Create a new function and add the given signatures. */
362 void add_function(const char *name
, ...);
364 ir_function_signature
*new_sig(const glsl_type
*return_type
,
365 builtin_available_predicate avail
,
366 int num_params
, ...);
369 * Function signature generators:
372 ir_function_signature
*unop(builtin_available_predicate avail
,
373 ir_expression_operation opcode
,
374 const glsl_type
*return_type
,
375 const glsl_type
*param_type
);
376 ir_function_signature
*binop(ir_expression_operation opcode
,
377 builtin_available_predicate avail
,
378 const glsl_type
*return_type
,
379 const glsl_type
*param0_type
,
380 const glsl_type
*param1_type
);
382 #define B0(X) ir_function_signature *_##X();
383 #define B1(X) ir_function_signature *_##X(const glsl_type *);
384 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
385 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
386 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
387 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
424 ir_function_signature
*_mix_sel(builtin_available_predicate avail
,
425 const glsl_type
*val_type
,
426 const glsl_type
*blend_type
);
435 ir_function_signature
*_packUnorm2x16(builtin_available_predicate avail
);
436 ir_function_signature
*_packSnorm2x16(builtin_available_predicate avail
);
437 ir_function_signature
*_packUnorm4x8(builtin_available_predicate avail
);
438 ir_function_signature
*_packSnorm4x8(builtin_available_predicate avail
);
439 ir_function_signature
*_unpackUnorm2x16(builtin_available_predicate avail
);
440 ir_function_signature
*_unpackSnorm2x16(builtin_available_predicate avail
);
441 ir_function_signature
*_unpackUnorm4x8(builtin_available_predicate avail
);
442 ir_function_signature
*_unpackSnorm4x8(builtin_available_predicate avail
);
443 ir_function_signature
*_packHalf2x16(builtin_available_predicate avail
);
444 ir_function_signature
*_unpackHalf2x16(builtin_available_predicate avail
);
456 B0(determinant_mat2
);
457 B0(determinant_mat3
);
458 B0(determinant_mat4
);
466 BA1(greaterThanEqual
);
473 ir_function_signature
*_textureSize(builtin_available_predicate avail
,
474 const glsl_type
*return_type
,
475 const glsl_type
*sampler_type
);
477 /** Flags to _texture() */
478 #define TEX_PROJECT 1
481 ir_function_signature
*_texture(ir_texture_opcode opcode
,
482 builtin_available_predicate avail
,
483 const glsl_type
*return_type
,
484 const glsl_type
*sampler_type
,
486 const glsl_type
*coord_type
,
488 B0(textureCubeArrayShadow
);
489 ir_function_signature
*_texelFetch(builtin_available_predicate avail
,
490 const glsl_type
*return_type
,
491 const glsl_type
*sampler_type
,
492 const glsl_type
*coord_type
,
493 const glsl_type
*offset_type
= NULL
);
524 * Core builtin_builder functionality:
527 builtin_builder::builtin_builder()
532 builtin_builder::~builtin_builder()
534 ralloc_free(mem_ctx
);
537 ir_function_signature
*
538 builtin_builder::find(_mesa_glsl_parse_state
*state
,
539 const char *name
, exec_list
*actual_parameters
)
541 /* The shader currently being compiled requested a built-in function;
542 * it needs to link against builtin_builder::shader in order to get them.
544 * Even if we don't find a matching signature, we still need to do this so
545 * that the "no matching signature" error will list potential candidates
546 * from the available built-ins.
548 state
->builtins_to_link
[0] = shader
;
549 state
->num_builtins_to_link
= 1;
551 ir_function
*f
= shader
->symbols
->get_function(name
);
555 ir_function_signature
*sig
= f
->matching_signature(state
, actual_parameters
);
563 builtin_builder::initialize()
565 /* If already initialized, don't do it again. */
569 mem_ctx
= ralloc_context(NULL
);
575 builtin_builder::release()
577 ralloc_free(mem_ctx
);
582 builtin_builder::create_shader()
584 /* The target doesn't actually matter. There's no target for generic
585 * GLSL utility code that could be linked against any stage, so just
586 * arbitrarily pick GL_VERTEX_SHADER.
588 shader
= _mesa_new_shader(NULL
, 0, GL_VERTEX_SHADER
);
589 shader
->symbols
= new(mem_ctx
) glsl_symbol_table
;
591 gl_ModelViewProjectionMatrix
=
592 new(mem_ctx
) ir_variable(glsl_type::mat4_type
,
593 "gl_ModelViewProjectionMatrix",
596 shader
->symbols
->add_variable(gl_ModelViewProjectionMatrix
);
598 gl_Vertex
= in_var(glsl_type::vec4_type
, "gl_Vertex");
599 shader
->symbols
->add_variable(gl_Vertex
);
605 * Create ir_function and ir_function_signature objects for each built-in.
607 * Contains a list of every available built-in.
610 builtin_builder::create_builtins()
613 add_function(#NAME, \
614 _##NAME(glsl_type::float_type), \
615 _##NAME(glsl_type::vec2_type), \
616 _##NAME(glsl_type::vec3_type), \
617 _##NAME(glsl_type::vec4_type), \
621 add_function(#NAME, \
622 _##NAME(glsl_type::float_type), \
623 _##NAME(glsl_type::vec2_type), \
624 _##NAME(glsl_type::vec3_type), \
625 _##NAME(glsl_type::vec4_type), \
626 _##NAME(glsl_type::int_type), \
627 _##NAME(glsl_type::ivec2_type), \
628 _##NAME(glsl_type::ivec3_type), \
629 _##NAME(glsl_type::ivec4_type), \
633 add_function(#NAME, \
634 _##NAME(always_available, glsl_type::float_type), \
635 _##NAME(always_available, glsl_type::vec2_type), \
636 _##NAME(always_available, glsl_type::vec3_type), \
637 _##NAME(always_available, glsl_type::vec4_type), \
639 _##NAME(always_available, glsl_type::int_type), \
640 _##NAME(always_available, glsl_type::ivec2_type), \
641 _##NAME(always_available, glsl_type::ivec3_type), \
642 _##NAME(always_available, glsl_type::ivec4_type), \
644 _##NAME(v130, glsl_type::uint_type), \
645 _##NAME(v130, glsl_type::uvec2_type), \
646 _##NAME(v130, glsl_type::uvec3_type), \
647 _##NAME(v130, glsl_type::uvec4_type), \
651 add_function(#NAME, \
652 _##NAME(glsl_type::int_type), \
653 _##NAME(glsl_type::ivec2_type), \
654 _##NAME(glsl_type::ivec3_type), \
655 _##NAME(glsl_type::ivec4_type), \
657 _##NAME(glsl_type::uint_type), \
658 _##NAME(glsl_type::uvec2_type), \
659 _##NAME(glsl_type::uvec3_type), \
660 _##NAME(glsl_type::uvec4_type), \
664 add_function(#NAME, \
665 _##NAME(always_available, glsl_type::float_type), \
666 _##NAME(always_available, glsl_type::vec2_type), \
667 _##NAME(always_available, glsl_type::vec3_type), \
668 _##NAME(always_available, glsl_type::vec4_type), \
670 _##NAME(always_available, glsl_type::int_type), \
671 _##NAME(always_available, glsl_type::ivec2_type), \
672 _##NAME(always_available, glsl_type::ivec3_type), \
673 _##NAME(always_available, glsl_type::ivec4_type), \
675 _##NAME(v130, glsl_type::uint_type), \
676 _##NAME(v130, glsl_type::uvec2_type), \
677 _##NAME(v130, glsl_type::uvec3_type), \
678 _##NAME(v130, glsl_type::uvec4_type), \
680 _##NAME(always_available, glsl_type::bool_type), \
681 _##NAME(always_available, glsl_type::bvec2_type), \
682 _##NAME(always_available, glsl_type::bvec3_type), \
683 _##NAME(always_available, glsl_type::bvec4_type), \
686 #define FIU2_MIXED(NAME) \
687 add_function(#NAME, \
688 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
689 _##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \
690 _##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \
691 _##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \
693 _##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \
694 _##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \
695 _##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \
697 _##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \
698 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \
699 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \
700 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \
702 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
703 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
704 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
706 _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \
707 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \
708 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \
709 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \
711 _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \
712 _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \
713 _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \
725 _atan(glsl_type::float_type
),
726 _atan(glsl_type::vec2_type
),
727 _atan(glsl_type::vec3_type
),
728 _atan(glsl_type::vec4_type
),
729 _atan2(glsl_type::float_type
),
730 _atan2(glsl_type::vec2_type
),
731 _atan2(glsl_type::vec3_type
),
732 _atan2(glsl_type::vec4_type
),
758 _mod(glsl_type::float_type
, glsl_type::float_type
),
759 _mod(glsl_type::vec2_type
, glsl_type::float_type
),
760 _mod(glsl_type::vec3_type
, glsl_type::float_type
),
761 _mod(glsl_type::vec4_type
, glsl_type::float_type
),
763 _mod(glsl_type::vec2_type
, glsl_type::vec2_type
),
764 _mod(glsl_type::vec3_type
, glsl_type::vec3_type
),
765 _mod(glsl_type::vec4_type
, glsl_type::vec4_type
),
775 _mix_lrp(glsl_type::float_type
, glsl_type::float_type
),
776 _mix_lrp(glsl_type::vec2_type
, glsl_type::float_type
),
777 _mix_lrp(glsl_type::vec3_type
, glsl_type::float_type
),
778 _mix_lrp(glsl_type::vec4_type
, glsl_type::float_type
),
780 _mix_lrp(glsl_type::vec2_type
, glsl_type::vec2_type
),
781 _mix_lrp(glsl_type::vec3_type
, glsl_type::vec3_type
),
782 _mix_lrp(glsl_type::vec4_type
, glsl_type::vec4_type
),
784 _mix_sel(v130
, glsl_type::float_type
, glsl_type::bool_type
),
785 _mix_sel(v130
, glsl_type::vec2_type
, glsl_type::bvec2_type
),
786 _mix_sel(v130
, glsl_type::vec3_type
, glsl_type::bvec3_type
),
787 _mix_sel(v130
, glsl_type::vec4_type
, glsl_type::bvec4_type
),
789 _mix_sel(shader_integer_mix
, glsl_type::int_type
, glsl_type::bool_type
),
790 _mix_sel(shader_integer_mix
, glsl_type::ivec2_type
, glsl_type::bvec2_type
),
791 _mix_sel(shader_integer_mix
, glsl_type::ivec3_type
, glsl_type::bvec3_type
),
792 _mix_sel(shader_integer_mix
, glsl_type::ivec4_type
, glsl_type::bvec4_type
),
794 _mix_sel(shader_integer_mix
, glsl_type::uint_type
, glsl_type::bool_type
),
795 _mix_sel(shader_integer_mix
, glsl_type::uvec2_type
, glsl_type::bvec2_type
),
796 _mix_sel(shader_integer_mix
, glsl_type::uvec3_type
, glsl_type::bvec3_type
),
797 _mix_sel(shader_integer_mix
, glsl_type::uvec4_type
, glsl_type::bvec4_type
),
799 _mix_sel(shader_integer_mix
, glsl_type::bool_type
, glsl_type::bool_type
),
800 _mix_sel(shader_integer_mix
, glsl_type::bvec2_type
, glsl_type::bvec2_type
),
801 _mix_sel(shader_integer_mix
, glsl_type::bvec3_type
, glsl_type::bvec3_type
),
802 _mix_sel(shader_integer_mix
, glsl_type::bvec4_type
, glsl_type::bvec4_type
),
806 _step(glsl_type::float_type
, glsl_type::float_type
),
807 _step(glsl_type::float_type
, glsl_type::vec2_type
),
808 _step(glsl_type::float_type
, glsl_type::vec3_type
),
809 _step(glsl_type::float_type
, glsl_type::vec4_type
),
811 _step(glsl_type::vec2_type
, glsl_type::vec2_type
),
812 _step(glsl_type::vec3_type
, glsl_type::vec3_type
),
813 _step(glsl_type::vec4_type
, glsl_type::vec4_type
),
816 add_function("smoothstep",
817 _smoothstep(glsl_type::float_type
, glsl_type::float_type
),
818 _smoothstep(glsl_type::float_type
, glsl_type::vec2_type
),
819 _smoothstep(glsl_type::float_type
, glsl_type::vec3_type
),
820 _smoothstep(glsl_type::float_type
, glsl_type::vec4_type
),
822 _smoothstep(glsl_type::vec2_type
, glsl_type::vec2_type
),
823 _smoothstep(glsl_type::vec3_type
, glsl_type::vec3_type
),
824 _smoothstep(glsl_type::vec4_type
, glsl_type::vec4_type
),
832 add_function("intBitsToFloat",
833 _intBitsToFloat(glsl_type::int_type
),
834 _intBitsToFloat(glsl_type::ivec2_type
),
835 _intBitsToFloat(glsl_type::ivec3_type
),
836 _intBitsToFloat(glsl_type::ivec4_type
),
838 add_function("uintBitsToFloat",
839 _uintBitsToFloat(glsl_type::uint_type
),
840 _uintBitsToFloat(glsl_type::uvec2_type
),
841 _uintBitsToFloat(glsl_type::uvec3_type
),
842 _uintBitsToFloat(glsl_type::uvec4_type
),
845 add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3
), NULL
);
846 add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3
), NULL
);
847 add_function("packUnorm4x8", _packUnorm4x8(shader_packing
), NULL
);
848 add_function("packSnorm4x8", _packSnorm4x8(shader_packing
), NULL
);
849 add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3
), NULL
);
850 add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3
), NULL
);
851 add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing
), NULL
);
852 add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing
), NULL
);
853 add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3
), NULL
);
854 add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3
), NULL
);
860 add_function("cross", _cross(glsl_type::vec3_type
), NULL
);
863 add_function("ftransform", _ftransform(), NULL
);
868 add_function("matrixCompMult",
869 _matrixCompMult(glsl_type::mat2_type
),
870 _matrixCompMult(glsl_type::mat3_type
),
871 _matrixCompMult(glsl_type::mat4_type
),
872 _matrixCompMult(glsl_type::mat2x3_type
),
873 _matrixCompMult(glsl_type::mat2x4_type
),
874 _matrixCompMult(glsl_type::mat3x2_type
),
875 _matrixCompMult(glsl_type::mat3x4_type
),
876 _matrixCompMult(glsl_type::mat4x2_type
),
877 _matrixCompMult(glsl_type::mat4x3_type
),
879 add_function("outerProduct",
880 _outerProduct(glsl_type::mat2_type
),
881 _outerProduct(glsl_type::mat3_type
),
882 _outerProduct(glsl_type::mat4_type
),
883 _outerProduct(glsl_type::mat2x3_type
),
884 _outerProduct(glsl_type::mat2x4_type
),
885 _outerProduct(glsl_type::mat3x2_type
),
886 _outerProduct(glsl_type::mat3x4_type
),
887 _outerProduct(glsl_type::mat4x2_type
),
888 _outerProduct(glsl_type::mat4x3_type
),
890 add_function("determinant",
895 add_function("inverse",
900 add_function("transpose",
901 _transpose(glsl_type::mat2_type
),
902 _transpose(glsl_type::mat3_type
),
903 _transpose(glsl_type::mat4_type
),
904 _transpose(glsl_type::mat2x3_type
),
905 _transpose(glsl_type::mat2x4_type
),
906 _transpose(glsl_type::mat3x2_type
),
907 _transpose(glsl_type::mat3x4_type
),
908 _transpose(glsl_type::mat4x2_type
),
909 _transpose(glsl_type::mat4x3_type
),
914 FIU(greaterThanEqual
)
919 _any(glsl_type::bvec2_type
),
920 _any(glsl_type::bvec3_type
),
921 _any(glsl_type::bvec4_type
),
925 _all(glsl_type::bvec2_type
),
926 _all(glsl_type::bvec3_type
),
927 _all(glsl_type::bvec4_type
),
931 _not(glsl_type::bvec2_type
),
932 _not(glsl_type::bvec3_type
),
933 _not(glsl_type::bvec4_type
),
936 add_function("textureSize",
937 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1D_type
),
938 _textureSize(v130
, glsl_type::int_type
, glsl_type::isampler1D_type
),
939 _textureSize(v130
, glsl_type::int_type
, glsl_type::usampler1D_type
),
941 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2D_type
),
942 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2D_type
),
943 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2D_type
),
945 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler3D_type
),
946 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler3D_type
),
947 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler3D_type
),
949 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCube_type
),
950 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isamplerCube_type
),
951 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usamplerCube_type
),
953 _textureSize(v130
, glsl_type::int_type
, glsl_type::sampler1DShadow_type
),
954 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DShadow_type
),
955 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::samplerCubeShadow_type
),
957 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArray_type
),
958 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler1DArray_type
),
959 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler1DArray_type
),
960 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArray_type
),
961 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::isampler2DArray_type
),
962 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::usampler2DArray_type
),
964 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler1DArrayShadow_type
),
965 _textureSize(v130
, glsl_type::ivec3_type
, glsl_type::sampler2DArrayShadow_type
),
967 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArray_type
),
968 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::isamplerCubeArray_type
),
969 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::usamplerCubeArray_type
),
970 _textureSize(texture_cube_map_array
, glsl_type::ivec3_type
, glsl_type::samplerCubeArrayShadow_type
),
972 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRect_type
),
973 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::isampler2DRect_type
),
974 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::usampler2DRect_type
),
975 _textureSize(v130
, glsl_type::ivec2_type
, glsl_type::sampler2DRectShadow_type
),
977 _textureSize(v140
, glsl_type::int_type
, glsl_type::samplerBuffer_type
),
978 _textureSize(v140
, glsl_type::int_type
, glsl_type::isamplerBuffer_type
),
979 _textureSize(v140
, glsl_type::int_type
, glsl_type::usamplerBuffer_type
),
980 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::sampler2DMS_type
),
981 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::isampler2DMS_type
),
982 _textureSize(texture_multisample
, glsl_type::ivec2_type
, glsl_type::usampler2DMS_type
),
984 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::sampler2DMSArray_type
),
985 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::isampler2DMSArray_type
),
986 _textureSize(texture_multisample
, glsl_type::ivec3_type
, glsl_type::usampler2DMSArray_type
),
989 add_function("texture",
990 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
991 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
),
992 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
),
994 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
995 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
),
996 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
),
998 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
999 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
),
1000 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
),
1002 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1003 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, 3, glsl_type::vec3_type
),
1004 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, 3, glsl_type::vec3_type
),
1006 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1007 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1008 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, 3, glsl_type::vec4_type
),
1010 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1011 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
),
1012 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
),
1014 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1015 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
),
1016 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
),
1018 _texture(ir_tex
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, 4, glsl_type::vec4_type
),
1019 _texture(ir_tex
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1020 _texture(ir_tex
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1022 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1023 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, 3, glsl_type::vec4_type
),
1024 /* samplerCubeArrayShadow is special; it has an extra parameter
1025 * for the shadow comparitor since there is no vec5 type.
1027 _textureCubeArrayShadow(),
1029 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec2_type
),
1030 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec2_type
),
1031 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec2_type
),
1033 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec3_type
),
1035 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1036 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
),
1037 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
),
1039 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1040 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
),
1041 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
),
1043 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1044 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
),
1045 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
),
1047 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1048 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, 3, glsl_type::vec3_type
),
1049 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, 3, glsl_type::vec3_type
),
1051 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1052 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1053 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, 3, glsl_type::vec4_type
),
1055 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1056 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
),
1057 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
),
1059 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1060 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
),
1061 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
),
1063 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, 4, glsl_type::vec4_type
),
1064 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1065 _texture(ir_txb
, fs_texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1067 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1070 add_function("textureLod",
1071 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1072 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
),
1073 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
),
1075 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1076 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
),
1077 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
),
1079 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1080 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
),
1081 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
),
1083 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1084 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, 3, glsl_type::vec3_type
),
1085 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, 3, glsl_type::vec3_type
),
1087 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1088 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1090 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1091 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
),
1092 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
),
1094 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1095 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
),
1096 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
),
1098 _texture(ir_txl
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, 4, glsl_type::vec4_type
),
1099 _texture(ir_txl
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1100 _texture(ir_txl
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1102 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1105 add_function("textureOffset",
1106 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1107 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1108 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1110 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1111 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1112 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1114 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1115 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1116 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1118 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1119 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1120 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1122 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1124 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
, TEX_OFFSET
),
1125 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1127 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1128 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1129 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1131 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1132 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1133 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1135 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1137 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1138 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1139 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1141 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1142 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1143 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1145 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1146 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1147 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1149 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
, TEX_OFFSET
),
1150 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1152 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1153 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1154 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1156 _texture(ir_txb
, v130_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1157 _texture(ir_txb
, v130_fs_only
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1158 _texture(ir_txb
, v130_fs_only
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1160 _texture(ir_txb
, v130_fs_only
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1163 add_function("textureProj",
1164 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1165 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1166 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1167 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1168 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1169 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1171 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1172 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1173 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1174 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1175 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1176 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1178 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1179 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1180 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1182 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1183 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1185 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1186 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1187 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1188 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1189 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1190 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1192 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1194 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1195 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1196 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1197 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1198 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1199 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1201 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1202 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1203 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1204 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1205 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1206 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1208 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1209 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1210 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1212 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1213 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1216 add_function("texelFetch",
1217 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
),
1218 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
),
1219 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
),
1221 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
),
1222 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
),
1223 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
),
1225 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
),
1226 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
),
1227 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
),
1229 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
),
1230 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
),
1231 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
),
1233 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
),
1234 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
),
1235 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
),
1237 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
),
1238 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
),
1239 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
),
1241 _texelFetch(v140
, glsl_type::vec4_type
, glsl_type::samplerBuffer_type
, glsl_type::int_type
),
1242 _texelFetch(v140
, glsl_type::ivec4_type
, glsl_type::isamplerBuffer_type
, glsl_type::int_type
),
1243 _texelFetch(v140
, glsl_type::uvec4_type
, glsl_type::usamplerBuffer_type
, glsl_type::int_type
),
1245 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMS_type
, glsl_type::ivec2_type
),
1246 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMS_type
, glsl_type::ivec2_type
),
1247 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMS_type
, glsl_type::ivec2_type
),
1249 _texelFetch(texture_multisample
, glsl_type::vec4_type
, glsl_type::sampler2DMSArray_type
, glsl_type::ivec3_type
),
1250 _texelFetch(texture_multisample
, glsl_type::ivec4_type
, glsl_type::isampler2DMSArray_type
, glsl_type::ivec3_type
),
1251 _texelFetch(texture_multisample
, glsl_type::uvec4_type
, glsl_type::usampler2DMSArray_type
, glsl_type::ivec3_type
),
1254 add_function("texelFetchOffset",
1255 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1256 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1257 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, glsl_type::int_type
, glsl_type::int_type
),
1259 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1260 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1261 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1263 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1264 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1265 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, glsl_type::ivec3_type
, glsl_type::ivec3_type
),
1267 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1268 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1269 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, glsl_type::ivec2_type
, glsl_type::ivec2_type
),
1271 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1272 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1273 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, glsl_type::ivec2_type
, glsl_type::int_type
),
1275 _texelFetch(v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1276 _texelFetch(v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1277 _texelFetch(v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, glsl_type::ivec3_type
, glsl_type::ivec2_type
),
1281 add_function("textureProjOffset",
1282 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1283 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1284 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1285 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1286 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1287 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1289 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1290 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1291 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1292 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1293 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1294 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1296 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1297 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1298 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1300 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1301 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1303 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1304 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1305 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1306 _texture(ir_tex
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1307 _texture(ir_tex
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1308 _texture(ir_tex
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1310 _texture(ir_tex
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1312 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1313 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1314 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1315 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1316 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1317 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1319 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1320 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1321 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1322 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1323 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1324 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1326 _texture(ir_txb
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1327 _texture(ir_txb
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1328 _texture(ir_txb
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1330 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1331 _texture(ir_txb
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1334 add_function("textureLodOffset",
1335 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1336 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1337 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1339 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1340 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1341 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1343 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1344 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1345 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1347 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
, TEX_OFFSET
),
1348 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1350 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1351 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1352 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1354 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1355 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1356 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1358 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1361 add_function("textureProjLod",
1362 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1363 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1364 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1365 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1366 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1367 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1369 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1370 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1371 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1372 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1373 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1374 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1376 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1377 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1378 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1380 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1381 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1384 add_function("textureProjLodOffset",
1385 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1386 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1387 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1388 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1389 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1390 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1392 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1393 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1394 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1395 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1396 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1397 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1399 _texture(ir_txl
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1400 _texture(ir_txl
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1401 _texture(ir_txl
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1403 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1404 _texture(ir_txl
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1407 add_function("textureGrad",
1408 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1409 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
),
1410 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
),
1412 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1413 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
),
1414 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
),
1416 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1417 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
),
1418 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
),
1420 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1421 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isamplerCube_type
, 3, glsl_type::vec3_type
),
1422 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usamplerCube_type
, 3, glsl_type::vec3_type
),
1424 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec2_type
),
1425 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec2_type
),
1426 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec2_type
),
1428 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec3_type
),
1430 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1431 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1432 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::samplerCubeShadow_type
, 3, glsl_type::vec4_type
),
1434 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1435 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
),
1436 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
),
1438 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1439 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
),
1440 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
),
1442 _texture(ir_txd
, texture_cube_map_array
, glsl_type::vec4_type
, glsl_type::samplerCubeArray_type
, 4, glsl_type::vec4_type
),
1443 _texture(ir_txd
, texture_cube_map_array
, glsl_type::ivec4_type
, glsl_type::isamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1444 _texture(ir_txd
, texture_cube_map_array
, glsl_type::uvec4_type
, glsl_type::usamplerCubeArray_type
, 4, glsl_type::vec4_type
),
1446 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1447 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, 3, glsl_type::vec4_type
),
1450 add_function("textureGradOffset",
1451 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1452 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1453 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::float_type
, TEX_OFFSET
),
1455 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1456 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1457 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1459 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1460 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1461 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1463 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1464 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1465 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1467 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1469 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
, TEX_OFFSET
),
1470 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1472 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1473 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1474 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1DArray_type
, 2, glsl_type::vec2_type
, TEX_OFFSET
),
1476 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1477 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1478 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DArray_type
, 3, glsl_type::vec3_type
, TEX_OFFSET
),
1480 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
, TEX_OFFSET
),
1481 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DArrayShadow_type
, 3, glsl_type::vec4_type
, TEX_OFFSET
),
1484 add_function("textureProjGrad",
1485 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1486 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1487 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1488 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1489 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1490 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1492 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1493 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1494 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1495 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1496 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1497 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1499 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1500 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1501 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1503 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1504 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1505 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1506 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1507 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1508 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1510 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1512 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1513 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1516 add_function("textureProjGradOffset",
1517 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1518 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1519 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
| TEX_OFFSET
),
1520 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1521 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1522 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1524 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1525 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1526 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1527 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1528 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1529 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1531 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1532 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1533 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1535 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1536 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1537 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
| TEX_OFFSET
),
1538 _texture(ir_txd
, v130
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1539 _texture(ir_txd
, v130
, glsl_type::ivec4_type
, glsl_type::isampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1540 _texture(ir_txd
, v130
, glsl_type::uvec4_type
, glsl_type::usampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1542 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1544 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1545 _texture(ir_txd
, v130
, glsl_type::float_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
| TEX_OFFSET
),
1548 add_function("EmitVertex", _EmitVertex(), NULL
);
1549 add_function("EndPrimitive", _EndPrimitive(), NULL
);
1551 add_function("textureQueryLOD",
1552 _textureQueryLod(glsl_type::sampler1D_type
, glsl_type::float_type
),
1553 _textureQueryLod(glsl_type::isampler1D_type
, glsl_type::float_type
),
1554 _textureQueryLod(glsl_type::usampler1D_type
, glsl_type::float_type
),
1556 _textureQueryLod(glsl_type::sampler2D_type
, glsl_type::vec2_type
),
1557 _textureQueryLod(glsl_type::isampler2D_type
, glsl_type::vec2_type
),
1558 _textureQueryLod(glsl_type::usampler2D_type
, glsl_type::vec2_type
),
1560 _textureQueryLod(glsl_type::sampler3D_type
, glsl_type::vec3_type
),
1561 _textureQueryLod(glsl_type::isampler3D_type
, glsl_type::vec3_type
),
1562 _textureQueryLod(glsl_type::usampler3D_type
, glsl_type::vec3_type
),
1564 _textureQueryLod(glsl_type::samplerCube_type
, glsl_type::vec3_type
),
1565 _textureQueryLod(glsl_type::isamplerCube_type
, glsl_type::vec3_type
),
1566 _textureQueryLod(glsl_type::usamplerCube_type
, glsl_type::vec3_type
),
1568 _textureQueryLod(glsl_type::sampler1DArray_type
, glsl_type::float_type
),
1569 _textureQueryLod(glsl_type::isampler1DArray_type
, glsl_type::float_type
),
1570 _textureQueryLod(glsl_type::usampler1DArray_type
, glsl_type::float_type
),
1572 _textureQueryLod(glsl_type::sampler2DArray_type
, glsl_type::vec2_type
),
1573 _textureQueryLod(glsl_type::isampler2DArray_type
, glsl_type::vec2_type
),
1574 _textureQueryLod(glsl_type::usampler2DArray_type
, glsl_type::vec2_type
),
1576 _textureQueryLod(glsl_type::samplerCubeArray_type
, glsl_type::vec3_type
),
1577 _textureQueryLod(glsl_type::isamplerCubeArray_type
, glsl_type::vec3_type
),
1578 _textureQueryLod(glsl_type::usamplerCubeArray_type
, glsl_type::vec3_type
),
1580 _textureQueryLod(glsl_type::sampler1DShadow_type
, glsl_type::float_type
),
1581 _textureQueryLod(glsl_type::sampler2DShadow_type
, glsl_type::vec2_type
),
1582 _textureQueryLod(glsl_type::samplerCubeShadow_type
, glsl_type::vec3_type
),
1583 _textureQueryLod(glsl_type::sampler1DArrayShadow_type
, glsl_type::float_type
),
1584 _textureQueryLod(glsl_type::sampler2DArrayShadow_type
, glsl_type::vec2_type
),
1585 _textureQueryLod(glsl_type::samplerCubeArrayShadow_type
, glsl_type::vec3_type
),
1588 add_function("texture1D",
1589 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1590 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1593 add_function("texture1DArray",
1594 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1595 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1598 add_function("texture1DProj",
1599 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1600 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1601 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1602 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1605 add_function("texture1DLod",
1606 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1609 add_function("texture1DArrayLod",
1610 _texture(ir_txl
, vs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArray_type
, 2, glsl_type::vec2_type
),
1613 add_function("texture1DProjLod",
1614 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1615 _texture(ir_txl
, tex1d_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1618 add_function("texture2D",
1619 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1620 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1621 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, 2, glsl_type::vec2_type
),
1624 add_function("texture2DArray",
1625 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1626 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1629 add_function("texture2DProj",
1630 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1631 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1632 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1633 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1634 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1635 _texture(ir_tex
, texture_external
, glsl_type::vec4_type
, glsl_type::samplerExternalOES_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1638 add_function("texture2DLod",
1639 _texture(ir_txl
, lod_exists_in_stage
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1642 add_function("texture2DArrayLod",
1643 _texture(ir_txl
, vs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArray_type
, 3, glsl_type::vec3_type
),
1646 add_function("texture2DProjLod",
1647 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1648 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1651 add_function("texture3D",
1652 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1653 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1656 add_function("texture3DProj",
1657 _texture(ir_tex
, tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1658 _texture(ir_txb
, fs_tex3d
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1661 add_function("texture3DLod",
1662 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1665 add_function("texture3DProjLod",
1666 _texture(ir_txl
, tex3d_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1669 add_function("textureCube",
1670 _texture(ir_tex
, always_available
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1671 _texture(ir_txb
, fs_only
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1674 add_function("textureCubeLod",
1675 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1678 add_function("texture2DRect",
1679 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec2_type
),
1682 add_function("texture2DRectProj",
1683 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1684 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1687 add_function("shadow1D",
1688 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1689 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1692 add_function("shadow1DArray",
1693 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1694 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1697 add_function("shadow2D",
1698 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1699 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1702 add_function("shadow2DArray",
1703 _texture(ir_tex
, texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, 3, glsl_type::vec4_type
),
1704 _texture(ir_txb
, fs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler2DArrayShadow_type
, 3, glsl_type::vec4_type
),
1707 add_function("shadow1DProj",
1708 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1709 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1712 add_function("shadow2DProj",
1713 _texture(ir_tex
, v110
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1714 _texture(ir_txb
, v110_fs_only
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1717 add_function("shadow1DLod",
1718 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1721 add_function("shadow2DLod",
1722 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1725 add_function("shadow1DArrayLod",
1726 _texture(ir_txl
, vs_texture_array
, glsl_type::vec4_type
, glsl_type::sampler1DArrayShadow_type
, 2, glsl_type::vec3_type
),
1729 add_function("shadow1DProjLod",
1730 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1733 add_function("shadow2DProjLod",
1734 _texture(ir_txl
, v110_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1737 add_function("shadow2DRect",
1738 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec3_type
),
1741 add_function("shadow2DRectProj",
1742 _texture(ir_tex
, texture_rectangle
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1745 add_function("texture1DGradARB",
1746 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::float_type
),
1749 add_function("texture1DProjGradARB",
1750 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec2_type
, TEX_PROJECT
),
1751 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1D_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1754 add_function("texture2DGradARB",
1755 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec2_type
),
1758 add_function("texture2DProjGradARB",
1759 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1760 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2D_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1763 add_function("texture3DGradARB",
1764 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec3_type
),
1767 add_function("texture3DProjGradARB",
1768 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler3D_type
, 3, glsl_type::vec4_type
, TEX_PROJECT
),
1771 add_function("textureCubeGradARB",
1772 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::samplerCube_type
, 3, glsl_type::vec3_type
),
1775 add_function("shadow1DGradARB",
1776 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec3_type
),
1779 add_function("shadow1DProjGradARB",
1780 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler1DShadow_type
, 1, glsl_type::vec4_type
, TEX_PROJECT
),
1783 add_function("shadow2DGradARB",
1784 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec3_type
),
1787 add_function("shadow2DProjGradARB",
1788 _texture(ir_txd
, shader_texture_lod
, glsl_type::vec4_type
, glsl_type::sampler2DShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1791 add_function("texture2DRectGradARB",
1792 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec2_type
),
1795 add_function("texture2DRectProjGradARB",
1796 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec3_type
, TEX_PROJECT
),
1797 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRect_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1800 add_function("shadow2DRectGradARB",
1801 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec3_type
),
1804 add_function("shadow2DRectProjGradARB",
1805 _texture(ir_txd
, shader_texture_lod_and_rect
, glsl_type::vec4_type
, glsl_type::sampler2DRectShadow_type
, 2, glsl_type::vec4_type
, TEX_PROJECT
),
1831 builtin_builder::add_function(const char *name
, ...)
1835 ir_function
*f
= new(mem_ctx
) ir_function(name
);
1839 ir_function_signature
*sig
= va_arg(ap
, ir_function_signature
*);
1843 sig
->is_defined
= true;
1847 stuff
.push_tail(sig
);
1848 validate_ir_tree(&stuff
);
1851 f
->add_signature(sig
);
1854 shader
->symbols
->add_function(f
);
1858 builtin_builder::in_var(const glsl_type
*type
, const char *name
)
1860 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_in
);
1864 builtin_builder::out_var(const glsl_type
*type
, const char *name
)
1866 return new(mem_ctx
) ir_variable(type
, name
, ir_var_function_out
);
1870 builtin_builder::imm(float f
)
1872 return new(mem_ctx
) ir_constant(f
);
1876 builtin_builder::imm(int i
)
1878 return new(mem_ctx
) ir_constant(i
);
1882 builtin_builder::imm(unsigned u
)
1884 return new(mem_ctx
) ir_constant(u
);
1888 builtin_builder::imm(const glsl_type
*type
, const ir_constant_data
&data
)
1890 return new(mem_ctx
) ir_constant(type
, &data
);
1893 ir_dereference_variable
*
1894 builtin_builder::var_ref(ir_variable
*var
)
1896 return new(mem_ctx
) ir_dereference_variable(var
);
1899 ir_dereference_array
*
1900 builtin_builder::array_ref(ir_variable
*var
, int idx
)
1902 return new(mem_ctx
) ir_dereference_array(var
, imm(idx
));
1905 /** Return an element of a matrix */
1907 builtin_builder::matrix_elt(ir_variable
*var
, int column
, int row
)
1909 return swizzle(array_ref(var
, column
), row
, 1);
1913 * Implementations of built-in functions:
1916 ir_function_signature
*
1917 builtin_builder::new_sig(const glsl_type
*return_type
,
1918 builtin_available_predicate avail
,
1924 ir_function_signature
*sig
=
1925 new(mem_ctx
) ir_function_signature(return_type
, avail
);
1928 va_start(ap
, num_params
);
1929 for (int i
= 0; i
< num_params
; i
++) {
1930 plist
.push_tail(va_arg(ap
, ir_variable
*));
1934 sig
->replace_parameters(&plist
);
1938 #define MAKE_SIG(return_type, avail, ...) \
1939 ir_function_signature *sig = \
1940 new_sig(return_type, avail, __VA_ARGS__); \
1941 ir_factory body(&sig->body, mem_ctx);
1943 ir_function_signature
*
1944 builtin_builder::unop(builtin_available_predicate avail
,
1945 ir_expression_operation opcode
,
1946 const glsl_type
*return_type
,
1947 const glsl_type
*param_type
)
1949 ir_variable
*x
= in_var(param_type
, "x");
1950 MAKE_SIG(return_type
, avail
, 1, x
);
1951 body
.emit(ret(expr(opcode
, x
)));
1955 #define UNOP(NAME, OPCODE, AVAIL) \
1956 ir_function_signature * \
1957 builtin_builder::_##NAME(const glsl_type *type) \
1959 return unop(&AVAIL, OPCODE, type, type); \
1962 ir_function_signature
*
1963 builtin_builder::binop(ir_expression_operation opcode
,
1964 builtin_available_predicate avail
,
1965 const glsl_type
*return_type
,
1966 const glsl_type
*param0_type
,
1967 const glsl_type
*param1_type
)
1969 ir_variable
*x
= in_var(param0_type
, "x");
1970 ir_variable
*y
= in_var(param1_type
, "y");
1971 MAKE_SIG(return_type
, avail
, 2, x
, y
);
1972 body
.emit(ret(expr(opcode
, x
, y
)));
1976 #define BINOP(NAME, OPCODE, AVAIL) \
1977 ir_function_signature * \
1978 builtin_builder::_##NAME(const glsl_type *return_type, \
1979 const glsl_type *param0_type, \
1980 const glsl_type *param1_type) \
1982 return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \
1986 * Angle and Trigonometry Functions @{
1989 ir_function_signature
*
1990 builtin_builder::_radians(const glsl_type
*type
)
1992 ir_variable
*degrees
= in_var(type
, "degrees");
1993 MAKE_SIG(type
, always_available
, 1, degrees
);
1994 body
.emit(ret(mul(degrees
, imm(0.0174532925f
))));
1998 ir_function_signature
*
1999 builtin_builder::_degrees(const glsl_type
*type
)
2001 ir_variable
*radians
= in_var(type
, "radians");
2002 MAKE_SIG(type
, always_available
, 1, radians
);
2003 body
.emit(ret(mul(radians
, imm(57.29578f
))));
2007 UNOP(sin
, ir_unop_sin
, always_available
)
2008 UNOP(cos
, ir_unop_cos
, always_available
)
2010 ir_function_signature
*
2011 builtin_builder::_tan(const glsl_type
*type
)
2013 ir_variable
*theta
= in_var(type
, "theta");
2014 MAKE_SIG(type
, always_available
, 1, theta
);
2015 body
.emit(ret(div(sin(theta
), cos(theta
))));
2020 builtin_builder::asin_expr(ir_variable
*x
)
2023 sub(imm(1.5707964f
),
2024 mul(sqrt(sub(imm(1.0f
), abs(x
))),
2025 add(imm(1.5707964f
),
2027 add(imm(-0.21460183f
),
2029 add(imm(0.086566724f
),
2030 mul(abs(x
), imm(-0.03102955f
))))))))));
2034 ir_function_signature
*
2035 builtin_builder::_asin(const glsl_type
*type
)
2037 ir_variable
*x
= in_var(type
, "x");
2038 MAKE_SIG(type
, always_available
, 1, x
);
2040 body
.emit(ret(asin_expr(x
)));
2045 ir_function_signature
*
2046 builtin_builder::_acos(const glsl_type
*type
)
2048 ir_variable
*x
= in_var(type
, "x");
2049 MAKE_SIG(type
, always_available
, 1, x
);
2051 body
.emit(ret(sub(imm(1.5707964f
), asin_expr(x
))));
2056 ir_function_signature
*
2057 builtin_builder::_atan2(const glsl_type
*type
)
2059 ir_variable
*vec_y
= in_var(type
, "vec_y");
2060 ir_variable
*vec_x
= in_var(type
, "vec_x");
2061 MAKE_SIG(type
, always_available
, 2, vec_y
, vec_x
);
2063 ir_variable
*vec_result
= body
.make_temp(type
, "vec_result");
2064 ir_variable
*r
= body
.make_temp(glsl_type::float_type
, "r");
2065 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2066 ir_variable
*y
= body
.make_temp(glsl_type::float_type
, "y");
2067 ir_variable
*x
= body
.make_temp(glsl_type::float_type
, "x");
2068 body
.emit(assign(y
, swizzle(vec_y
, i
, 1)));
2069 body
.emit(assign(x
, swizzle(vec_x
, i
, 1)));
2071 /* If |x| >= 1.0e-8 * |y|: */
2073 new(mem_ctx
) ir_if(greater(abs(x
), mul(imm(1.0e-8f
), abs(y
))));
2075 ir_factory
outer_then(&outer_if
->then_instructions
, mem_ctx
);
2077 /* Then...call atan(y/x) */
2078 ir_variable
*y_over_x
= outer_then
.make_temp(glsl_type::float_type
, "y_over_x");
2079 outer_then
.emit(assign(y_over_x
, div(y
, x
)));
2080 outer_then
.emit(assign(r
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2082 outer_then
.emit(assign(r
, asin_expr(r
)));
2084 /* ...and fix it up: */
2085 ir_if
*inner_if
= new(mem_ctx
) ir_if(less(x
, imm(0.0f
)));
2086 inner_if
->then_instructions
.push_tail(
2087 if_tree(gequal(y
, imm(0.0f
)),
2088 assign(r
, add(r
, imm(3.141593f
))),
2089 assign(r
, sub(r
, imm(3.141593f
)))));
2090 outer_then
.emit(inner_if
);
2093 outer_if
->else_instructions
.push_tail(
2094 assign(r
, mul(sign(y
), imm(1.5707965f
))));
2096 body
.emit(outer_if
);
2098 body
.emit(assign(vec_result
, r
, 1 << i
));
2100 body
.emit(ret(vec_result
));
2105 ir_function_signature
*
2106 builtin_builder::_atan(const glsl_type
*type
)
2108 ir_variable
*y_over_x
= in_var(type
, "y_over_x");
2109 MAKE_SIG(type
, always_available
, 1, y_over_x
);
2111 ir_variable
*t
= body
.make_temp(type
, "t");
2112 body
.emit(assign(t
, mul(y_over_x
, rsq(add(mul(y_over_x
, y_over_x
),
2115 body
.emit(ret(asin_expr(t
)));
2120 ir_function_signature
*
2121 builtin_builder::_sinh(const glsl_type
*type
)
2123 ir_variable
*x
= in_var(type
, "x");
2124 MAKE_SIG(type
, v130
, 1, x
);
2126 /* 0.5 * (e^x - e^(-x)) */
2127 body
.emit(ret(mul(imm(0.5f
), sub(exp(x
), exp(neg(x
))))));
2132 ir_function_signature
*
2133 builtin_builder::_cosh(const glsl_type
*type
)
2135 ir_variable
*x
= in_var(type
, "x");
2136 MAKE_SIG(type
, v130
, 1, x
);
2138 /* 0.5 * (e^x + e^(-x)) */
2139 body
.emit(ret(mul(imm(0.5f
), add(exp(x
), exp(neg(x
))))));
2144 ir_function_signature
*
2145 builtin_builder::_tanh(const glsl_type
*type
)
2147 ir_variable
*x
= in_var(type
, "x");
2148 MAKE_SIG(type
, v130
, 1, x
);
2150 /* (e^x - e^(-x)) / (e^x + e^(-x)) */
2151 body
.emit(ret(div(sub(exp(x
), exp(neg(x
))),
2152 add(exp(x
), exp(neg(x
))))));
2157 ir_function_signature
*
2158 builtin_builder::_asinh(const glsl_type
*type
)
2160 ir_variable
*x
= in_var(type
, "x");
2161 MAKE_SIG(type
, v130
, 1, x
);
2163 body
.emit(ret(mul(sign(x
), log(add(abs(x
), sqrt(add(mul(x
, x
),
2168 ir_function_signature
*
2169 builtin_builder::_acosh(const glsl_type
*type
)
2171 ir_variable
*x
= in_var(type
, "x");
2172 MAKE_SIG(type
, v130
, 1, x
);
2174 body
.emit(ret(log(add(x
, sqrt(sub(mul(x
, x
), imm(1.0f
)))))));
2178 ir_function_signature
*
2179 builtin_builder::_atanh(const glsl_type
*type
)
2181 ir_variable
*x
= in_var(type
, "x");
2182 MAKE_SIG(type
, v130
, 1, x
);
2184 body
.emit(ret(mul(imm(0.5f
), log(div(add(imm(1.0f
), x
),
2185 sub(imm(1.0f
), x
))))));
2191 * Exponential Functions @{
2194 ir_function_signature
*
2195 builtin_builder::_pow(const glsl_type
*type
)
2197 return binop(ir_binop_pow
, always_available
, type
, type
, type
);
2200 UNOP(exp
, ir_unop_exp
, always_available
)
2201 UNOP(log
, ir_unop_log
, always_available
)
2202 UNOP(exp2
, ir_unop_exp2
, always_available
)
2203 UNOP(log2
, ir_unop_log2
, always_available
)
2204 UNOP(sqrt
, ir_unop_sqrt
, always_available
)
2205 UNOP(inversesqrt
, ir_unop_rsq
, always_available
)
2209 UNOP(abs
, ir_unop_abs
, always_available
)
2210 UNOP(sign
, ir_unop_sign
, always_available
)
2211 UNOP(floor
, ir_unop_floor
, always_available
)
2212 UNOP(trunc
, ir_unop_trunc
, v130
)
2213 UNOP(round
, ir_unop_round_even
, always_available
)
2214 UNOP(roundEven
, ir_unop_round_even
, always_available
)
2215 UNOP(ceil
, ir_unop_ceil
, always_available
)
2216 UNOP(fract
, ir_unop_fract
, always_available
)
2218 ir_function_signature
*
2219 builtin_builder::_mod(const glsl_type
*x_type
, const glsl_type
*y_type
)
2221 return binop(ir_binop_mod
, always_available
, x_type
, x_type
, y_type
);
2224 ir_function_signature
*
2225 builtin_builder::_modf(const glsl_type
*type
)
2227 ir_variable
*x
= in_var(type
, "x");
2228 ir_variable
*i
= out_var(type
, "i");
2229 MAKE_SIG(type
, v130
, 2, x
, i
);
2231 ir_variable
*t
= body
.make_temp(type
, "t");
2232 body
.emit(assign(t
, expr(ir_unop_trunc
, x
)));
2233 body
.emit(assign(i
, t
));
2234 body
.emit(ret(sub(x
, t
)));
2239 ir_function_signature
*
2240 builtin_builder::_min(builtin_available_predicate avail
,
2241 const glsl_type
*x_type
, const glsl_type
*y_type
)
2243 return binop(ir_binop_min
, avail
, x_type
, x_type
, y_type
);
2246 ir_function_signature
*
2247 builtin_builder::_max(builtin_available_predicate avail
,
2248 const glsl_type
*x_type
, const glsl_type
*y_type
)
2250 return binop(ir_binop_max
, avail
, x_type
, x_type
, y_type
);
2253 ir_function_signature
*
2254 builtin_builder::_clamp(builtin_available_predicate avail
,
2255 const glsl_type
*val_type
, const glsl_type
*bound_type
)
2257 ir_variable
*x
= in_var(val_type
, "x");
2258 ir_variable
*minVal
= in_var(bound_type
, "minVal");
2259 ir_variable
*maxVal
= in_var(bound_type
, "maxVal");
2260 MAKE_SIG(val_type
, avail
, 3, x
, minVal
, maxVal
);
2262 body
.emit(ret(clamp(x
, minVal
, maxVal
)));
2267 ir_function_signature
*
2268 builtin_builder::_mix_lrp(const glsl_type
*val_type
, const glsl_type
*blend_type
)
2270 ir_variable
*x
= in_var(val_type
, "x");
2271 ir_variable
*y
= in_var(val_type
, "y");
2272 ir_variable
*a
= in_var(blend_type
, "a");
2273 MAKE_SIG(val_type
, always_available
, 3, x
, y
, a
);
2275 body
.emit(ret(lrp(x
, y
, a
)));
2280 ir_function_signature
*
2281 builtin_builder::_mix_sel(builtin_available_predicate avail
,
2282 const glsl_type
*val_type
,
2283 const glsl_type
*blend_type
)
2285 ir_variable
*x
= in_var(val_type
, "x");
2286 ir_variable
*y
= in_var(val_type
, "y");
2287 ir_variable
*a
= in_var(blend_type
, "a");
2288 MAKE_SIG(val_type
, avail
, 3, x
, y
, a
);
2290 /* csel matches the ternary operator in that a selector of true choses the
2291 * first argument. This differs from mix(x, y, false) which choses the
2292 * second argument (to remain consistent with the interpolating version of
2293 * mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.
2295 * To handle the behavior mismatch, reverse the x and y arguments.
2297 body
.emit(ret(csel(a
, y
, x
)));
2302 ir_function_signature
*
2303 builtin_builder::_step(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2305 ir_variable
*edge
= in_var(edge_type
, "edge");
2306 ir_variable
*x
= in_var(x_type
, "x");
2307 MAKE_SIG(x_type
, always_available
, 2, edge
, x
);
2309 ir_variable
*t
= body
.make_temp(x_type
, "t");
2310 if (x_type
->vector_elements
== 1) {
2311 /* Both are floats */
2312 body
.emit(assign(t
, b2f(gequal(x
, edge
))));
2313 } else if (edge_type
->vector_elements
== 1) {
2314 /* x is a vector but edge is a float */
2315 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2316 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), edge
)), 1 << i
));
2319 /* Both are vectors */
2320 for (int i
= 0; i
< x_type
->vector_elements
; i
++) {
2321 body
.emit(assign(t
, b2f(gequal(swizzle(x
, i
, 1), swizzle(edge
, i
, 1))),
2330 ir_function_signature
*
2331 builtin_builder::_smoothstep(const glsl_type
*edge_type
, const glsl_type
*x_type
)
2333 ir_variable
*edge0
= in_var(edge_type
, "edge0");
2334 ir_variable
*edge1
= in_var(edge_type
, "edge1");
2335 ir_variable
*x
= in_var(x_type
, "x");
2336 MAKE_SIG(x_type
, always_available
, 3, edge0
, edge1
, x
);
2338 /* From the GLSL 1.10 specification:
2341 * t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
2342 * return t * t * (3 - 2 * t);
2345 ir_variable
*t
= body
.make_temp(x_type
, "t");
2346 body
.emit(assign(t
, clamp(div(sub(x
, edge0
), sub(edge1
, edge0
)),
2347 imm(0.0f
), imm(1.0f
))));
2349 body
.emit(ret(mul(t
, mul(t
, sub(imm(3.0f
), mul(imm(2.0f
), t
))))));
2354 ir_function_signature
*
2355 builtin_builder::_isnan(const glsl_type
*type
)
2357 ir_variable
*x
= in_var(type
, "x");
2358 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2360 body
.emit(ret(nequal(x
, x
)));
2365 ir_function_signature
*
2366 builtin_builder::_isinf(const glsl_type
*type
)
2368 ir_variable
*x
= in_var(type
, "x");
2369 MAKE_SIG(glsl_type::bvec(type
->vector_elements
), v130
, 1, x
);
2371 ir_constant_data infinities
;
2372 for (int i
= 0; i
< type
->vector_elements
; i
++) {
2373 infinities
.f
[i
] = std::numeric_limits
<float>::infinity();
2376 body
.emit(ret(equal(abs(x
), imm(type
, infinities
))));
2381 ir_function_signature
*
2382 builtin_builder::_floatBitsToInt(const glsl_type
*type
)
2384 ir_variable
*x
= in_var(type
, "x");
2385 MAKE_SIG(glsl_type::ivec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2386 body
.emit(ret(bitcast_f2i(x
)));
2390 ir_function_signature
*
2391 builtin_builder::_floatBitsToUint(const glsl_type
*type
)
2393 ir_variable
*x
= in_var(type
, "x");
2394 MAKE_SIG(glsl_type::uvec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2395 body
.emit(ret(bitcast_f2u(x
)));
2399 ir_function_signature
*
2400 builtin_builder::_intBitsToFloat(const glsl_type
*type
)
2402 ir_variable
*x
= in_var(type
, "x");
2403 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2404 body
.emit(ret(bitcast_i2f(x
)));
2408 ir_function_signature
*
2409 builtin_builder::_uintBitsToFloat(const glsl_type
*type
)
2411 ir_variable
*x
= in_var(type
, "x");
2412 MAKE_SIG(glsl_type::vec(type
->vector_elements
), shader_bit_encoding
, 1, x
);
2413 body
.emit(ret(bitcast_u2f(x
)));
2417 ir_function_signature
*
2418 builtin_builder::_packUnorm2x16(builtin_available_predicate avail
)
2420 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2421 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2422 body
.emit(ret(expr(ir_unop_pack_unorm_2x16
, v
)));
2426 ir_function_signature
*
2427 builtin_builder::_packSnorm2x16(builtin_available_predicate avail
)
2429 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2430 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2431 body
.emit(ret(expr(ir_unop_pack_snorm_2x16
, v
)));
2435 ir_function_signature
*
2436 builtin_builder::_packUnorm4x8(builtin_available_predicate avail
)
2438 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2439 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2440 body
.emit(ret(expr(ir_unop_pack_unorm_4x8
, v
)));
2444 ir_function_signature
*
2445 builtin_builder::_packSnorm4x8(builtin_available_predicate avail
)
2447 ir_variable
*v
= in_var(glsl_type::vec4_type
, "v");
2448 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2449 body
.emit(ret(expr(ir_unop_pack_snorm_4x8
, v
)));
2453 ir_function_signature
*
2454 builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail
)
2456 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2457 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2458 body
.emit(ret(expr(ir_unop_unpack_unorm_2x16
, p
)));
2462 ir_function_signature
*
2463 builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail
)
2465 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2466 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2467 body
.emit(ret(expr(ir_unop_unpack_snorm_2x16
, p
)));
2472 ir_function_signature
*
2473 builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail
)
2475 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2476 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2477 body
.emit(ret(expr(ir_unop_unpack_unorm_4x8
, p
)));
2481 ir_function_signature
*
2482 builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail
)
2484 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2485 MAKE_SIG(glsl_type::vec4_type
, avail
, 1, p
);
2486 body
.emit(ret(expr(ir_unop_unpack_snorm_4x8
, p
)));
2490 ir_function_signature
*
2491 builtin_builder::_packHalf2x16(builtin_available_predicate avail
)
2493 ir_variable
*v
= in_var(glsl_type::vec2_type
, "v");
2494 MAKE_SIG(glsl_type::uint_type
, avail
, 1, v
);
2495 body
.emit(ret(expr(ir_unop_pack_half_2x16
, v
)));
2499 ir_function_signature
*
2500 builtin_builder::_unpackHalf2x16(builtin_available_predicate avail
)
2502 ir_variable
*p
= in_var(glsl_type::uint_type
, "p");
2503 MAKE_SIG(glsl_type::vec2_type
, avail
, 1, p
);
2504 body
.emit(ret(expr(ir_unop_unpack_half_2x16
, p
)));
2508 ir_function_signature
*
2509 builtin_builder::_length(const glsl_type
*type
)
2511 ir_variable
*x
= in_var(type
, "x");
2512 MAKE_SIG(glsl_type::float_type
, always_available
, 1, x
);
2514 body
.emit(ret(sqrt(dotlike(x
, x
))));
2519 ir_function_signature
*
2520 builtin_builder::_distance(const glsl_type
*type
)
2522 ir_variable
*p0
= in_var(type
, "p0");
2523 ir_variable
*p1
= in_var(type
, "p1");
2524 MAKE_SIG(glsl_type::float_type
, always_available
, 2, p0
, p1
);
2526 if (type
->vector_elements
== 1) {
2527 body
.emit(ret(abs(sub(p0
, p1
))));
2529 ir_variable
*p
= body
.make_temp(type
, "p");
2530 body
.emit(assign(p
, sub(p0
, p1
)));
2531 body
.emit(ret(sqrt(dot(p
, p
))));
2537 ir_function_signature
*
2538 builtin_builder::_dot(const glsl_type
*type
)
2540 if (type
->vector_elements
== 1)
2541 return binop(ir_binop_mul
, always_available
, type
, type
, type
);
2543 return binop(ir_binop_dot
, always_available
,
2544 glsl_type::float_type
, type
, type
);
2547 ir_function_signature
*
2548 builtin_builder::_cross(const glsl_type
*type
)
2550 ir_variable
*a
= in_var(type
, "a");
2551 ir_variable
*b
= in_var(type
, "b");
2552 MAKE_SIG(type
, always_available
, 2, a
, b
);
2554 int yzx
= MAKE_SWIZZLE4(SWIZZLE_Y
, SWIZZLE_Z
, SWIZZLE_X
, 0);
2555 int zxy
= MAKE_SWIZZLE4(SWIZZLE_Z
, SWIZZLE_X
, SWIZZLE_Y
, 0);
2557 body
.emit(ret(sub(mul(swizzle(a
, yzx
, 3), swizzle(b
, zxy
, 3)),
2558 mul(swizzle(a
, zxy
, 3), swizzle(b
, yzx
, 3)))));
2563 ir_function_signature
*
2564 builtin_builder::_normalize(const glsl_type
*type
)
2566 ir_variable
*x
= in_var(type
, "x");
2567 MAKE_SIG(type
, always_available
, 1, x
);
2569 if (type
->vector_elements
== 1) {
2570 body
.emit(ret(sign(x
)));
2572 body
.emit(ret(mul(x
, rsq(dot(x
, x
)))));
2578 ir_function_signature
*
2579 builtin_builder::_ftransform()
2581 MAKE_SIG(glsl_type::vec4_type
, compatibility_vs_only
, 0);
2583 body
.emit(ret(new(mem_ctx
) ir_expression(ir_binop_mul
,
2584 glsl_type::vec4_type
,
2585 var_ref(gl_ModelViewProjectionMatrix
),
2586 var_ref(gl_Vertex
))));
2588 /* FINISHME: Once the ir_expression() constructor handles type inference
2589 * for matrix operations, we can simplify this to:
2591 * body.emit(ret(mul(gl_ModelViewProjectionMatrix, gl_Vertex)));
2596 ir_function_signature
*
2597 builtin_builder::_faceforward(const glsl_type
*type
)
2599 ir_variable
*N
= in_var(type
, "N");
2600 ir_variable
*I
= in_var(type
, "I");
2601 ir_variable
*Nref
= in_var(type
, "Nref");
2602 MAKE_SIG(type
, always_available
, 3, N
, I
, Nref
);
2604 body
.emit(if_tree(less(dotlike(Nref
, I
), imm(0.0f
)),
2605 ret(N
), ret(neg(N
))));
2610 ir_function_signature
*
2611 builtin_builder::_reflect(const glsl_type
*type
)
2613 ir_variable
*I
= in_var(type
, "I");
2614 ir_variable
*N
= in_var(type
, "N");
2615 MAKE_SIG(type
, always_available
, 2, I
, N
);
2617 /* I - 2 * dot(N, I) * N */
2618 body
.emit(ret(sub(I
, mul(imm(2.0f
), mul(dotlike(N
, I
), N
)))));
2623 ir_function_signature
*
2624 builtin_builder::_refract(const glsl_type
*type
)
2626 ir_variable
*I
= in_var(type
, "I");
2627 ir_variable
*N
= in_var(type
, "N");
2628 ir_variable
*eta
= in_var(glsl_type::float_type
, "eta");
2629 MAKE_SIG(type
, always_available
, 3, I
, N
, eta
);
2631 ir_variable
*n_dot_i
= body
.make_temp(glsl_type::float_type
, "n_dot_i");
2632 body
.emit(assign(n_dot_i
, dotlike(N
, I
)));
2634 /* From the GLSL 1.10 specification:
2635 * k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
2637 * return genType(0.0)
2639 * return eta * I - (eta * dot(N, I) + sqrt(k)) * N
2641 ir_variable
*k
= body
.make_temp(glsl_type::float_type
, "k");
2642 body
.emit(assign(k
, sub(imm(1.0f
),
2643 mul(eta
, mul(eta
, sub(imm(1.0f
),
2644 mul(n_dot_i
, n_dot_i
)))))));
2645 body
.emit(if_tree(less(k
, imm(0.0f
)),
2646 ret(ir_constant::zero(mem_ctx
, type
)),
2647 ret(sub(mul(eta
, I
),
2648 mul(add(mul(eta
, n_dot_i
), sqrt(k
)), N
)))));
2653 ir_function_signature
*
2654 builtin_builder::_matrixCompMult(const glsl_type
*type
)
2656 ir_variable
*x
= in_var(type
, "x");
2657 ir_variable
*y
= in_var(type
, "y");
2658 MAKE_SIG(type
, always_available
, 2, x
, y
);
2660 ir_variable
*z
= body
.make_temp(type
, "z");
2661 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2662 body
.emit(assign(array_ref(z
, i
), mul(array_ref(x
, i
), array_ref(y
, i
))));
2669 ir_function_signature
*
2670 builtin_builder::_outerProduct(const glsl_type
*type
)
2672 ir_variable
*c
= in_var(glsl_type::vec(type
->vector_elements
), "c");
2673 ir_variable
*r
= in_var(glsl_type::vec(type
->matrix_columns
), "r");
2674 MAKE_SIG(type
, v120
, 2, c
, r
);
2676 ir_variable
*m
= body
.make_temp(type
, "m");
2677 for (int i
= 0; i
< type
->matrix_columns
; i
++) {
2678 body
.emit(assign(array_ref(m
, i
), mul(c
, swizzle(r
, i
, 1))));
2685 ir_function_signature
*
2686 builtin_builder::_transpose(const glsl_type
*orig_type
)
2688 const glsl_type
*transpose_type
=
2689 glsl_type::get_instance(GLSL_TYPE_FLOAT
,
2690 orig_type
->matrix_columns
,
2691 orig_type
->vector_elements
);
2693 ir_variable
*m
= in_var(orig_type
, "m");
2694 MAKE_SIG(transpose_type
, v120
, 1, m
);
2696 ir_variable
*t
= body
.make_temp(transpose_type
, "t");
2697 for (int i
= 0; i
< orig_type
->matrix_columns
; i
++) {
2698 for (int j
= 0; j
< orig_type
->vector_elements
; j
++) {
2699 body
.emit(assign(array_ref(t
, j
),
2700 matrix_elt(m
, i
, j
),
2709 ir_function_signature
*
2710 builtin_builder::_determinant_mat2()
2712 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
2713 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2715 body
.emit(ret(sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2716 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)))));
2721 ir_function_signature
*
2722 builtin_builder::_determinant_mat3()
2724 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
2725 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2728 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
2729 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 1)));
2732 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
2733 mul(matrix_elt(m
, 1, 2), matrix_elt(m
, 2, 0)));
2736 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
2737 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 0)));
2739 body
.emit(ret(add(sub(mul(matrix_elt(m
, 0, 0), f1
),
2740 mul(matrix_elt(m
, 0, 1), f2
)),
2741 mul(matrix_elt(m
, 0, 2), f3
))));
2746 ir_function_signature
*
2747 builtin_builder::_determinant_mat4()
2749 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
2750 MAKE_SIG(glsl_type::float_type
, v120
, 1, m
);
2752 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
2753 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
2754 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
2755 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
2756 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
2757 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
2758 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
2759 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
2760 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
2761 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
2762 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
2763 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
2764 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
2765 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
2766 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
2767 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
2768 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
2769 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
2770 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
2772 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)))));
2773 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)))));
2774 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)))));
2775 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)))));
2776 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)))));
2777 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)))));
2778 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)))));
2779 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)))));
2780 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)))));
2781 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)))));
2782 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)))));
2783 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)))));
2784 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)))));
2785 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)))));
2786 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)))));
2787 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)))));
2788 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)))));
2789 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)))));
2790 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)))));
2792 ir_variable
*adj_0
= body
.make_temp(glsl_type::vec4_type
, "adj_0");
2794 body
.emit(assign(adj_0
,
2795 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
2796 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
2797 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
2799 body
.emit(assign(adj_0
, neg(
2800 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
2801 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
2802 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
2804 body
.emit(assign(adj_0
,
2805 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
2806 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
2807 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
2809 body
.emit(assign(adj_0
, neg(
2810 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
2811 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
2812 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
2815 body
.emit(ret(dot(array_ref(m
, 0), adj_0
)));
2820 ir_function_signature
*
2821 builtin_builder::_inverse_mat2()
2823 ir_variable
*m
= in_var(glsl_type::mat2_type
, "m");
2824 MAKE_SIG(glsl_type::mat2_type
, v120
, 1, m
);
2826 ir_variable
*adj
= body
.make_temp(glsl_type::mat2_type
, "adj");
2827 body
.emit(assign(array_ref(adj
, 0), matrix_elt(m
, 1, 1), 1 << 0));
2828 body
.emit(assign(array_ref(adj
, 0), neg(matrix_elt(m
, 0, 1)), 1 << 1));
2829 body
.emit(assign(array_ref(adj
, 1), neg(matrix_elt(m
, 1, 0)), 1 << 0));
2830 body
.emit(assign(array_ref(adj
, 1), matrix_elt(m
, 0, 0), 1 << 1));
2832 ir_expression
*det
=
2833 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2834 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1)));
2836 body
.emit(ret(div(adj
, det
)));
2840 ir_function_signature
*
2841 builtin_builder::_inverse_mat3()
2843 ir_variable
*m
= in_var(glsl_type::mat3_type
, "m");
2844 MAKE_SIG(glsl_type::mat3_type
, v120
, 1, m
);
2846 ir_variable
*f11_22_21_12
= body
.make_temp(glsl_type::float_type
, "f11_22_21_12");
2847 ir_variable
*f10_22_20_12
= body
.make_temp(glsl_type::float_type
, "f10_22_20_12");
2848 ir_variable
*f10_21_20_11
= body
.make_temp(glsl_type::float_type
, "f10_21_20_11");
2850 body
.emit(assign(f11_22_21_12
,
2851 sub(mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 2, 2)),
2852 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 1, 2)))));
2853 body
.emit(assign(f10_22_20_12
,
2854 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 2)),
2855 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 2)))));
2856 body
.emit(assign(f10_21_20_11
,
2857 sub(mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 2, 1)),
2858 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 1, 1)))));
2860 ir_variable
*adj
= body
.make_temp(glsl_type::mat3_type
, "adj");
2861 body
.emit(assign(array_ref(adj
, 0), f11_22_21_12
, WRITEMASK_X
));
2862 body
.emit(assign(array_ref(adj
, 1), neg(f10_22_20_12
), WRITEMASK_X
));
2863 body
.emit(assign(array_ref(adj
, 2), f10_21_20_11
, WRITEMASK_X
));
2865 body
.emit(assign(array_ref(adj
, 0), neg(
2866 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 2, 2)),
2867 mul(matrix_elt(m
, 2, 1), matrix_elt(m
, 0, 2)))),
2869 body
.emit(assign(array_ref(adj
, 1),
2870 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 2)),
2871 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 2))),
2873 body
.emit(assign(array_ref(adj
, 2), neg(
2874 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 2, 1)),
2875 mul(matrix_elt(m
, 2, 0), matrix_elt(m
, 0, 1)))),
2878 body
.emit(assign(array_ref(adj
, 0),
2879 sub(mul(matrix_elt(m
, 0, 1), matrix_elt(m
, 1, 2)),
2880 mul(matrix_elt(m
, 1, 1), matrix_elt(m
, 0, 2))),
2882 body
.emit(assign(array_ref(adj
, 1), neg(
2883 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 2)),
2884 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 2)))),
2886 body
.emit(assign(array_ref(adj
, 2),
2887 sub(mul(matrix_elt(m
, 0, 0), matrix_elt(m
, 1, 1)),
2888 mul(matrix_elt(m
, 1, 0), matrix_elt(m
, 0, 1))),
2891 ir_expression
*det
=
2892 add(sub(mul(matrix_elt(m
, 0, 0), f11_22_21_12
),
2893 mul(matrix_elt(m
, 0, 1), f10_22_20_12
)),
2894 mul(matrix_elt(m
, 0, 2), f10_21_20_11
));
2896 body
.emit(ret(div(adj
, det
)));
2901 ir_function_signature
*
2902 builtin_builder::_inverse_mat4()
2904 ir_variable
*m
= in_var(glsl_type::mat4_type
, "m");
2905 MAKE_SIG(glsl_type::mat4_type
, v120
, 1, m
);
2907 ir_variable
*SubFactor00
= body
.make_temp(glsl_type::float_type
, "SubFactor00");
2908 ir_variable
*SubFactor01
= body
.make_temp(glsl_type::float_type
, "SubFactor01");
2909 ir_variable
*SubFactor02
= body
.make_temp(glsl_type::float_type
, "SubFactor02");
2910 ir_variable
*SubFactor03
= body
.make_temp(glsl_type::float_type
, "SubFactor03");
2911 ir_variable
*SubFactor04
= body
.make_temp(glsl_type::float_type
, "SubFactor04");
2912 ir_variable
*SubFactor05
= body
.make_temp(glsl_type::float_type
, "SubFactor05");
2913 ir_variable
*SubFactor06
= body
.make_temp(glsl_type::float_type
, "SubFactor06");
2914 ir_variable
*SubFactor07
= body
.make_temp(glsl_type::float_type
, "SubFactor07");
2915 ir_variable
*SubFactor08
= body
.make_temp(glsl_type::float_type
, "SubFactor08");
2916 ir_variable
*SubFactor09
= body
.make_temp(glsl_type::float_type
, "SubFactor09");
2917 ir_variable
*SubFactor10
= body
.make_temp(glsl_type::float_type
, "SubFactor10");
2918 ir_variable
*SubFactor11
= body
.make_temp(glsl_type::float_type
, "SubFactor11");
2919 ir_variable
*SubFactor12
= body
.make_temp(glsl_type::float_type
, "SubFactor12");
2920 ir_variable
*SubFactor13
= body
.make_temp(glsl_type::float_type
, "SubFactor13");
2921 ir_variable
*SubFactor14
= body
.make_temp(glsl_type::float_type
, "SubFactor14");
2922 ir_variable
*SubFactor15
= body
.make_temp(glsl_type::float_type
, "SubFactor15");
2923 ir_variable
*SubFactor16
= body
.make_temp(glsl_type::float_type
, "SubFactor16");
2924 ir_variable
*SubFactor17
= body
.make_temp(glsl_type::float_type
, "SubFactor17");
2925 ir_variable
*SubFactor18
= body
.make_temp(glsl_type::float_type
, "SubFactor18");
2927 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)))));
2928 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)))));
2929 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)))));
2930 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)))));
2931 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)))));
2932 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)))));
2933 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)))));
2934 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)))));
2935 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)))));
2936 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)))));
2937 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)))));
2938 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)))));
2939 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)))));
2940 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)))));
2941 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)))));
2942 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)))));
2943 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)))));
2944 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)))));
2945 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)))));
2947 ir_variable
*adj
= body
.make_temp(glsl_type::mat4_type
, "adj");
2948 body
.emit(assign(array_ref(adj
, 0),
2949 add(sub(mul(matrix_elt(m
, 1, 1), SubFactor00
),
2950 mul(matrix_elt(m
, 1, 2), SubFactor01
)),
2951 mul(matrix_elt(m
, 1, 3), SubFactor02
)),
2953 body
.emit(assign(array_ref(adj
, 1), neg(
2954 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor00
),
2955 mul(matrix_elt(m
, 1, 2), SubFactor03
)),
2956 mul(matrix_elt(m
, 1, 3), SubFactor04
))),
2958 body
.emit(assign(array_ref(adj
, 2),
2959 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor01
),
2960 mul(matrix_elt(m
, 1, 1), SubFactor03
)),
2961 mul(matrix_elt(m
, 1, 3), SubFactor05
)),
2963 body
.emit(assign(array_ref(adj
, 3), neg(
2964 add(sub(mul(matrix_elt(m
, 1, 0), SubFactor02
),
2965 mul(matrix_elt(m
, 1, 1), SubFactor04
)),
2966 mul(matrix_elt(m
, 1, 2), SubFactor05
))),
2969 body
.emit(assign(array_ref(adj
, 0), neg(
2970 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor00
),
2971 mul(matrix_elt(m
, 0, 2), SubFactor01
)),
2972 mul(matrix_elt(m
, 0, 3), SubFactor02
))),
2974 body
.emit(assign(array_ref(adj
, 1),
2975 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor00
),
2976 mul(matrix_elt(m
, 0, 2), SubFactor03
)),
2977 mul(matrix_elt(m
, 0, 3), SubFactor04
)),
2979 body
.emit(assign(array_ref(adj
, 2), neg(
2980 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor01
),
2981 mul(matrix_elt(m
, 0, 1), SubFactor03
)),
2982 mul(matrix_elt(m
, 0, 3), SubFactor05
))),
2984 body
.emit(assign(array_ref(adj
, 3),
2985 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor02
),
2986 mul(matrix_elt(m
, 0, 1), SubFactor04
)),
2987 mul(matrix_elt(m
, 0, 2), SubFactor05
)),
2990 body
.emit(assign(array_ref(adj
, 0),
2991 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor06
),
2992 mul(matrix_elt(m
, 0, 2), SubFactor07
)),
2993 mul(matrix_elt(m
, 0, 3), SubFactor08
)),
2995 body
.emit(assign(array_ref(adj
, 1), neg(
2996 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor06
),
2997 mul(matrix_elt(m
, 0, 2), SubFactor09
)),
2998 mul(matrix_elt(m
, 0, 3), SubFactor10
))),
3000 body
.emit(assign(array_ref(adj
, 2),
3001 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor11
),
3002 mul(matrix_elt(m
, 0, 1), SubFactor09
)),
3003 mul(matrix_elt(m
, 0, 3), SubFactor12
)),
3005 body
.emit(assign(array_ref(adj
, 3), neg(
3006 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor08
),
3007 mul(matrix_elt(m
, 0, 1), SubFactor10
)),
3008 mul(matrix_elt(m
, 0, 2), SubFactor12
))),
3011 body
.emit(assign(array_ref(adj
, 0), neg(
3012 add(sub(mul(matrix_elt(m
, 0, 1), SubFactor13
),
3013 mul(matrix_elt(m
, 0, 2), SubFactor14
)),
3014 mul(matrix_elt(m
, 0, 3), SubFactor15
))),
3016 body
.emit(assign(array_ref(adj
, 1),
3017 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor13
),
3018 mul(matrix_elt(m
, 0, 2), SubFactor16
)),
3019 mul(matrix_elt(m
, 0, 3), SubFactor17
)),
3021 body
.emit(assign(array_ref(adj
, 2), neg(
3022 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor14
),
3023 mul(matrix_elt(m
, 0, 1), SubFactor16
)),
3024 mul(matrix_elt(m
, 0, 3), SubFactor18
))),
3026 body
.emit(assign(array_ref(adj
, 3),
3027 add(sub(mul(matrix_elt(m
, 0, 0), SubFactor15
),
3028 mul(matrix_elt(m
, 0, 1), SubFactor17
)),
3029 mul(matrix_elt(m
, 0, 2), SubFactor18
)),
3032 ir_expression
*det
=
3033 add(mul(matrix_elt(m
, 0, 0), matrix_elt(adj
, 0, 0)),
3034 add(mul(matrix_elt(m
, 0, 1), matrix_elt(adj
, 1, 0)),
3035 add(mul(matrix_elt(m
, 0, 2), matrix_elt(adj
, 2, 0)),
3036 mul(matrix_elt(m
, 0, 3), matrix_elt(adj
, 3, 0)))));
3038 body
.emit(ret(div(adj
, det
)));
3044 ir_function_signature
*
3045 builtin_builder::_lessThan(builtin_available_predicate avail
,
3046 const glsl_type
*type
)
3048 return binop(ir_binop_less
, avail
,
3049 glsl_type::bvec(type
->vector_elements
), type
, type
);
3052 ir_function_signature
*
3053 builtin_builder::_lessThanEqual(builtin_available_predicate avail
,
3054 const glsl_type
*type
)
3056 return binop(ir_binop_lequal
, avail
,
3057 glsl_type::bvec(type
->vector_elements
), type
, type
);
3060 ir_function_signature
*
3061 builtin_builder::_greaterThan(builtin_available_predicate avail
,
3062 const glsl_type
*type
)
3064 return binop(ir_binop_greater
, avail
,
3065 glsl_type::bvec(type
->vector_elements
), type
, type
);
3068 ir_function_signature
*
3069 builtin_builder::_greaterThanEqual(builtin_available_predicate avail
,
3070 const glsl_type
*type
)
3072 return binop(ir_binop_gequal
, avail
,
3073 glsl_type::bvec(type
->vector_elements
), type
, type
);
3076 ir_function_signature
*
3077 builtin_builder::_equal(builtin_available_predicate avail
,
3078 const glsl_type
*type
)
3080 return binop(ir_binop_equal
, avail
,
3081 glsl_type::bvec(type
->vector_elements
), type
, type
);
3084 ir_function_signature
*
3085 builtin_builder::_notEqual(builtin_available_predicate avail
,
3086 const glsl_type
*type
)
3088 return binop(ir_binop_nequal
, avail
,
3089 glsl_type::bvec(type
->vector_elements
), type
, type
);
3092 ir_function_signature
*
3093 builtin_builder::_any(const glsl_type
*type
)
3095 return unop(always_available
, ir_unop_any
, glsl_type::bool_type
, type
);
3098 ir_function_signature
*
3099 builtin_builder::_all(const glsl_type
*type
)
3101 ir_variable
*v
= in_var(type
, "v");
3102 MAKE_SIG(glsl_type::bool_type
, always_available
, 1, v
);
3104 switch (type
->vector_elements
) {
3106 body
.emit(ret(logic_and(swizzle_x(v
), swizzle_y(v
))));
3109 body
.emit(ret(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3113 body
.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v
), swizzle_y(v
)),
3122 UNOP(not, ir_unop_logic_not
, always_available
)
3125 has_lod(const glsl_type
*sampler_type
)
3127 assert(sampler_type
->is_sampler());
3129 switch (sampler_type
->sampler_dimensionality
) {
3130 case GLSL_SAMPLER_DIM_RECT
:
3131 case GLSL_SAMPLER_DIM_BUF
:
3132 case GLSL_SAMPLER_DIM_MS
:
3139 ir_function_signature
*
3140 builtin_builder::_textureSize(builtin_available_predicate avail
,
3141 const glsl_type
*return_type
,
3142 const glsl_type
*sampler_type
)
3144 ir_variable
*s
= in_var(sampler_type
, "sampler");
3145 /* The sampler always exists; add optional lod later. */
3146 MAKE_SIG(return_type
, avail
, 1, s
);
3148 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txs
);
3149 tex
->set_sampler(new(mem_ctx
) ir_dereference_variable(s
), return_type
);
3151 if (has_lod(sampler_type
)) {
3152 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3153 sig
->parameters
.push_tail(lod
);
3154 tex
->lod_info
.lod
= var_ref(lod
);
3156 tex
->lod_info
.lod
= imm(0u);
3159 body
.emit(ret(tex
));
3164 ir_function_signature
*
3165 builtin_builder::_texture(ir_texture_opcode opcode
,
3166 builtin_available_predicate avail
,
3167 const glsl_type
*return_type
,
3168 const glsl_type
*sampler_type
,
3170 const glsl_type
*coord_type
,
3173 ir_variable
*s
= in_var(sampler_type
, "sampler");
3174 ir_variable
*P
= in_var(coord_type
, "P");
3175 /* The sampler and coordinate always exist; add optional parameters later. */
3176 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3178 ir_texture
*tex
= new(mem_ctx
) ir_texture(opcode
);
3179 tex
->set_sampler(var_ref(s
), return_type
);
3181 if (coord_size
== coord_type
->vector_elements
) {
3182 tex
->coordinate
= var_ref(P
);
3184 /* The incoming coordinate also has the projector or shadow comparitor,
3185 * so we need to swizzle those away.
3187 tex
->coordinate
= swizzle_for_size(P
, coord_size
);
3190 /* The projector is always in the last component. */
3191 if (flags
& TEX_PROJECT
)
3192 tex
->projector
= swizzle(P
, coord_type
->vector_elements
- 1, 1);
3194 /* The shadow comparitor is normally in the Z component, but a few types
3195 * have sufficiently large coordinates that it's in W.
3197 if (sampler_type
->sampler_shadow
)
3198 tex
->shadow_comparitor
= swizzle(P
, MAX2(coord_size
, SWIZZLE_Z
), 1);
3200 if (opcode
== ir_txl
) {
3201 ir_variable
*lod
= in_var(glsl_type::float_type
, "lod");
3202 sig
->parameters
.push_tail(lod
);
3203 tex
->lod_info
.lod
= var_ref(lod
);
3204 } else if (opcode
== ir_txd
) {
3205 int grad_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3206 ir_variable
*dPdx
= in_var(glsl_type::vec(grad_size
), "dPdx");
3207 ir_variable
*dPdy
= in_var(glsl_type::vec(grad_size
), "dPdy");
3208 sig
->parameters
.push_tail(dPdx
);
3209 sig
->parameters
.push_tail(dPdy
);
3210 tex
->lod_info
.grad
.dPdx
= var_ref(dPdx
);
3211 tex
->lod_info
.grad
.dPdy
= var_ref(dPdy
);
3214 if (flags
& TEX_OFFSET
) {
3215 int offset_size
= coord_size
- (sampler_type
->sampler_array
? 1 : 0);
3216 ir_variable
*offset
=
3217 new(mem_ctx
) ir_variable(glsl_type::ivec(offset_size
), "offset", ir_var_const_in
);
3218 sig
->parameters
.push_tail(offset
);
3219 tex
->offset
= var_ref(offset
);
3222 /* The "bias" parameter comes /after/ the "offset" parameter, which is
3223 * inconsistent with both textureLodOffset and textureGradOffset.
3225 if (opcode
== ir_txb
) {
3226 ir_variable
*bias
= in_var(glsl_type::float_type
, "bias");
3227 sig
->parameters
.push_tail(bias
);
3228 tex
->lod_info
.bias
= var_ref(bias
);
3231 body
.emit(ret(tex
));
3236 ir_function_signature
*
3237 builtin_builder::_textureCubeArrayShadow()
3239 ir_variable
*s
= in_var(glsl_type::samplerCubeArrayShadow_type
, "sampler");
3240 ir_variable
*P
= in_var(glsl_type::vec4_type
, "P");
3241 ir_variable
*compare
= in_var(glsl_type::float_type
, "compare");
3242 MAKE_SIG(glsl_type::float_type
, texture_cube_map_array
, 3, s
, P
, compare
);
3244 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_tex
);
3245 tex
->set_sampler(var_ref(s
), glsl_type::float_type
);
3247 tex
->coordinate
= var_ref(P
);
3248 tex
->shadow_comparitor
= var_ref(compare
);
3250 body
.emit(ret(tex
));
3255 ir_function_signature
*
3256 builtin_builder::_texelFetch(builtin_available_predicate avail
,
3257 const glsl_type
*return_type
,
3258 const glsl_type
*sampler_type
,
3259 const glsl_type
*coord_type
,
3260 const glsl_type
*offset_type
)
3262 ir_variable
*s
= in_var(sampler_type
, "sampler");
3263 ir_variable
*P
= in_var(coord_type
, "P");
3264 /* The sampler and coordinate always exist; add optional parameters later. */
3265 MAKE_SIG(return_type
, avail
, 2, s
, P
);
3267 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_txf
);
3268 tex
->coordinate
= var_ref(P
);
3269 tex
->set_sampler(var_ref(s
), return_type
);
3271 if (sampler_type
->sampler_dimensionality
== GLSL_SAMPLER_DIM_MS
) {
3272 ir_variable
*sample
= in_var(glsl_type::int_type
, "sample");
3273 sig
->parameters
.push_tail(sample
);
3274 tex
->lod_info
.sample_index
= var_ref(sample
);
3275 tex
->op
= ir_txf_ms
;
3276 } else if (has_lod(sampler_type
)) {
3277 ir_variable
*lod
= in_var(glsl_type::int_type
, "lod");
3278 sig
->parameters
.push_tail(lod
);
3279 tex
->lod_info
.lod
= var_ref(lod
);
3281 tex
->lod_info
.lod
= imm(0u);
3284 if (offset_type
!= NULL
) {
3285 ir_variable
*offset
=
3286 new(mem_ctx
) ir_variable(offset_type
, "offset", ir_var_const_in
);
3287 sig
->parameters
.push_tail(offset
);
3288 tex
->offset
= var_ref(offset
);
3291 body
.emit(ret(tex
));
3296 ir_function_signature
*
3297 builtin_builder::_EmitVertex()
3299 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3301 body
.emit(new(mem_ctx
) ir_emit_vertex());
3306 ir_function_signature
*
3307 builtin_builder::_EndPrimitive()
3309 MAKE_SIG(glsl_type::void_type
, gs_only
, 0);
3311 body
.emit(new(mem_ctx
) ir_end_primitive());
3316 ir_function_signature
*
3317 builtin_builder::_textureQueryLod(const glsl_type
*sampler_type
,
3318 const glsl_type
*coord_type
)
3320 ir_variable
*s
= in_var(sampler_type
, "sampler");
3321 ir_variable
*coord
= in_var(coord_type
, "coord");
3322 /* The sampler and coordinate always exist; add optional parameters later. */
3323 MAKE_SIG(glsl_type::vec2_type
, texture_query_lod
, 2, s
, coord
);
3325 ir_texture
*tex
= new(mem_ctx
) ir_texture(ir_lod
);
3326 tex
->coordinate
= var_ref(coord
);
3327 tex
->set_sampler(var_ref(s
), glsl_type::vec2_type
);
3329 body
.emit(ret(tex
));
3334 UNOP(dFdx
, ir_unop_dFdx
, fs_oes_derivatives
)
3335 UNOP(dFdy
, ir_unop_dFdy
, fs_oes_derivatives
)
3337 ir_function_signature
*
3338 builtin_builder::_fwidth(const glsl_type
*type
)
3340 ir_variable
*p
= in_var(type
, "p");
3341 MAKE_SIG(type
, fs_oes_derivatives
, 1, p
);
3343 body
.emit(ret(add(abs(expr(ir_unop_dFdx
, p
)), abs(expr(ir_unop_dFdy
, p
)))));
3348 ir_function_signature
*
3349 builtin_builder::_noise1(const glsl_type
*type
)
3351 return unop(v110
, ir_unop_noise
, glsl_type::float_type
, type
);
3354 ir_function_signature
*
3355 builtin_builder::_noise2(const glsl_type
*type
)
3357 ir_variable
*p
= in_var(type
, "p");
3358 MAKE_SIG(glsl_type::vec2_type
, v110
, 1, p
);
3360 ir_constant_data b_offset
;
3361 b_offset
.f
[0] = 601.0f
;
3362 b_offset
.f
[1] = 313.0f
;
3363 b_offset
.f
[2] = 29.0f
;
3364 b_offset
.f
[3] = 277.0f
;
3366 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3367 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3368 ir_variable
*t
= body
.make_temp(glsl_type::vec2_type
, "t");
3369 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3370 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3371 body
.emit(assign(t
, a
, WRITEMASK_X
));
3372 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3378 ir_function_signature
*
3379 builtin_builder::_noise3(const glsl_type
*type
)
3381 ir_variable
*p
= in_var(type
, "p");
3382 MAKE_SIG(glsl_type::vec3_type
, v110
, 1, p
);
3384 ir_constant_data b_offset
;
3385 b_offset
.f
[0] = 601.0f
;
3386 b_offset
.f
[1] = 313.0f
;
3387 b_offset
.f
[2] = 29.0f
;
3388 b_offset
.f
[3] = 277.0f
;
3390 ir_constant_data c_offset
;
3391 c_offset
.f
[0] = 1559.0f
;
3392 c_offset
.f
[1] = 113.0f
;
3393 c_offset
.f
[2] = 1861.0f
;
3394 c_offset
.f
[3] = 797.0f
;
3396 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3397 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3398 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3399 ir_variable
*t
= body
.make_temp(glsl_type::vec3_type
, "t");
3400 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3401 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, b_offset
)))));
3402 body
.emit(assign(c
, expr(ir_unop_noise
, add(p
, imm(type
, c_offset
)))));
3403 body
.emit(assign(t
, a
, WRITEMASK_X
));
3404 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3405 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3411 ir_function_signature
*
3412 builtin_builder::_noise4(const glsl_type
*type
)
3414 ir_variable
*p
= in_var(type
, "p");
3415 MAKE_SIG(glsl_type::vec4_type
, v110
, 1, p
);
3417 ir_variable
*_p
= body
.make_temp(type
, "_p");
3419 ir_constant_data p_offset
;
3420 p_offset
.f
[0] = 1559.0f
;
3421 p_offset
.f
[1] = 113.0f
;
3422 p_offset
.f
[2] = 1861.0f
;
3423 p_offset
.f
[3] = 797.0f
;
3425 body
.emit(assign(_p
, add(p
, imm(type
, p_offset
))));
3427 ir_constant_data offset
;
3428 offset
.f
[0] = 601.0f
;
3429 offset
.f
[1] = 313.0f
;
3430 offset
.f
[2] = 29.0f
;
3431 offset
.f
[3] = 277.0f
;
3433 ir_variable
*a
= body
.make_temp(glsl_type::float_type
, "a");
3434 ir_variable
*b
= body
.make_temp(glsl_type::float_type
, "b");
3435 ir_variable
*c
= body
.make_temp(glsl_type::float_type
, "c");
3436 ir_variable
*d
= body
.make_temp(glsl_type::float_type
, "d");
3437 ir_variable
*t
= body
.make_temp(glsl_type::vec4_type
, "t");
3438 body
.emit(assign(a
, expr(ir_unop_noise
, p
)));
3439 body
.emit(assign(b
, expr(ir_unop_noise
, add(p
, imm(type
, offset
)))));
3440 body
.emit(assign(c
, expr(ir_unop_noise
, _p
)));
3441 body
.emit(assign(d
, expr(ir_unop_noise
, add(_p
, imm(type
, offset
)))));
3442 body
.emit(assign(t
, a
, WRITEMASK_X
));
3443 body
.emit(assign(t
, b
, WRITEMASK_Y
));
3444 body
.emit(assign(t
, c
, WRITEMASK_Z
));
3445 body
.emit(assign(t
, d
, WRITEMASK_W
));
3451 ir_function_signature
*
3452 builtin_builder::_bitfieldExtract(const glsl_type
*type
)
3454 ir_variable
*value
= in_var(type
, "value");
3455 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3456 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3457 MAKE_SIG(type
, gpu_shader5
, 3, value
, offset
, bits
);
3459 body
.emit(ret(expr(ir_triop_bitfield_extract
, value
, offset
, bits
)));
3464 ir_function_signature
*
3465 builtin_builder::_bitfieldInsert(const glsl_type
*type
)
3467 ir_variable
*base
= in_var(type
, "base");
3468 ir_variable
*insert
= in_var(type
, "insert");
3469 ir_variable
*offset
= in_var(glsl_type::int_type
, "offset");
3470 ir_variable
*bits
= in_var(glsl_type::int_type
, "bits");
3471 MAKE_SIG(type
, gpu_shader5
, 4, base
, insert
, offset
, bits
);
3473 body
.emit(ret(bitfield_insert(base
, insert
, offset
, bits
)));
3478 UNOP(bitfieldReverse
, ir_unop_bitfield_reverse
, gpu_shader5
)
3480 ir_function_signature
*
3481 builtin_builder::_bitCount(const glsl_type
*type
)
3483 return unop(gpu_shader5
, ir_unop_bit_count
,
3484 glsl_type::ivec(type
->vector_elements
), type
);
3487 ir_function_signature
*
3488 builtin_builder::_findLSB(const glsl_type
*type
)
3490 return unop(gpu_shader5
, ir_unop_find_lsb
,
3491 glsl_type::ivec(type
->vector_elements
), type
);
3494 ir_function_signature
*
3495 builtin_builder::_findMSB(const glsl_type
*type
)
3497 return unop(gpu_shader5
, ir_unop_find_msb
,
3498 glsl_type::ivec(type
->vector_elements
), type
);
3501 ir_function_signature
*
3502 builtin_builder::_fma(const glsl_type
*type
)
3504 ir_variable
*a
= in_var(type
, "a");
3505 ir_variable
*b
= in_var(type
, "b");
3506 ir_variable
*c
= in_var(type
, "c");
3507 MAKE_SIG(type
, gpu_shader5
, 3, a
, b
, c
);
3509 body
.emit(ret(fma(a
, b
, c
)));
3515 /******************************************************************************/
3517 /* The singleton instance of builtin_builder. */
3518 static builtin_builder builtins
;
3521 * External API (exposing the built-in module to the rest of the compiler):
3525 _mesa_glsl_initialize_builtin_functions()
3527 builtins
.initialize();
3531 _mesa_glsl_release_builtin_functions()
3536 ir_function_signature
*
3537 _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state
*state
,
3538 const char *name
, exec_list
*actual_parameters
)
3540 return builtins
.find(state
, name
, actual_parameters
);