"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/compiler/glsl/builtin_functions.cpp" (16 Sep 2020, 375841 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "builtin_functions.cpp" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 20.1.5_vs_20.2.0-rc1.

    1 /*
    2  * Copyright © 2013 Intel Corporation
    3  *
    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:
   10  *
   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
   13  * Software.
   14  *
   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.
   22  */
   23 
   24 /**
   25  * \file builtin_functions.cpp
   26  *
   27  * Support for GLSL built-in functions.
   28  *
   29  * This file is split into several main components:
   30  *
   31  * 1. Availability predicates
   32  *
   33  *    A series of small functions that check whether the current shader
   34  *    supports the version/extensions required to expose a built-in.
   35  *
   36  * 2. Core builtin_builder class functionality
   37  *
   38  * 3. Lists of built-in functions
   39  *
   40  *    The builtin_builder::create_builtins() function contains lists of all
   41  *    built-in function signatures, where they're available, what types they
   42  *    take, and so on.
   43  *
   44  * 4. Implementations of built-in function signatures
   45  *
   46  *    A series of functions which create ir_function_signatures and emit IR
   47  *    via ir_builder to implement them.
   48  *
   49  * 5. External API
   50  *
   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.
   54  */
   55 
   56 
   57 /**
   58  * Unfortunately, some versions of MinGW produce bad code if this file
   59  * is compiled with -O2 or -O3.  The resulting driver will crash in random
   60  * places if the app uses GLSL.
   61  * The work-around is to disable optimizations for just this file.  Luckily,
   62  * this code is basically just executed once.
   63  *
   64  * MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug.
   65  * MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug.
   66  * MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug.
   67  * MinGW x.y.z - don't know.  Assume versions after 4.6.x are buggy
   68  */
   69 
   70 #if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR >= 407)
   71 #warning "disabling optimizations for this file to work around compiler bug"
   72 #pragma GCC optimize("O1")
   73 #endif
   74 
   75 
   76 #include <stdarg.h>
   77 #include <stdio.h>
   78 #include "main/mtypes.h"
   79 #include "main/shaderobj.h"
   80 #include "ir_builder.h"
   81 #include "glsl_parser_extras.h"
   82 #include "program/prog_instruction.h"
   83 #include <math.h>
   84 #include "builtin_functions.h"
   85 #include "util/hash_table.h"
   86 
   87 #define M_PIf   ((float) M_PI)
   88 #define M_PI_2f ((float) M_PI_2)
   89 #define M_PI_4f ((float) M_PI_4)
   90 
   91 using namespace ir_builder;
   92 
   93 /**
   94  * Availability predicates:
   95  *  @{
   96  */
   97 static bool
   98 always_available(const _mesa_glsl_parse_state *)
   99 {
  100    return true;
  101 }
  102 
  103 static bool
  104 compatibility_vs_only(const _mesa_glsl_parse_state *state)
  105 {
  106    return state->stage == MESA_SHADER_VERTEX &&
  107           (state->compat_shader || state->ARB_compatibility_enable) &&
  108           !state->es_shader;
  109 }
  110 
  111 static bool
  112 derivatives_only(const _mesa_glsl_parse_state *state)
  113 {
  114    return state->stage == MESA_SHADER_FRAGMENT ||
  115           (state->stage == MESA_SHADER_COMPUTE &&
  116            state->NV_compute_shader_derivatives_enable);
  117 }
  118 
  119 static bool
  120 gs_only(const _mesa_glsl_parse_state *state)
  121 {
  122    return state->stage == MESA_SHADER_GEOMETRY;
  123 }
  124 
  125 static bool
  126 v110(const _mesa_glsl_parse_state *state)
  127 {
  128    return !state->es_shader;
  129 }
  130 
  131 static bool
  132 v110_derivatives_only(const _mesa_glsl_parse_state *state)
  133 {
  134    return !state->es_shader &&
  135           derivatives_only(state);
  136 }
  137 
  138 static bool
  139 v120(const _mesa_glsl_parse_state *state)
  140 {
  141    return state->is_version(120, 300);
  142 }
  143 
  144 static bool
  145 v130(const _mesa_glsl_parse_state *state)
  146 {
  147    return state->is_version(130, 300);
  148 }
  149 
  150 static bool
  151 v130_desktop(const _mesa_glsl_parse_state *state)
  152 {
  153    return state->is_version(130, 0);
  154 }
  155 
  156 static bool
  157 v460_desktop(const _mesa_glsl_parse_state *state)
  158 {
  159    return state->is_version(460, 0);
  160 }
  161 
  162 static bool
  163 v130_derivatives_only(const _mesa_glsl_parse_state *state)
  164 {
  165    return state->is_version(130, 300) &&
  166           derivatives_only(state);
  167 }
  168 
  169 static bool
  170 v140_or_es3(const _mesa_glsl_parse_state *state)
  171 {
  172    return state->is_version(140, 300);
  173 }
  174 
  175 static bool
  176 v400_derivatives_only(const _mesa_glsl_parse_state *state)
  177 {
  178    return state->is_version(400, 0) &&
  179           derivatives_only(state);
  180 }
  181 
  182 static bool
  183 texture_rectangle(const _mesa_glsl_parse_state *state)
  184 {
  185    return state->ARB_texture_rectangle_enable;
  186 }
  187 
  188 static bool
  189 texture_external(const _mesa_glsl_parse_state *state)
  190 {
  191    return state->OES_EGL_image_external_enable;
  192 }
  193 
  194 static bool
  195 texture_external_es3(const _mesa_glsl_parse_state *state)
  196 {
  197    return state->OES_EGL_image_external_essl3_enable &&
  198       state->es_shader &&
  199       state->is_version(0, 300);
  200 }
  201 
  202 /** True if texturing functions with explicit LOD are allowed. */
  203 static bool
  204 lod_exists_in_stage(const _mesa_glsl_parse_state *state)
  205 {
  206    /* Texturing functions with "Lod" in their name exist:
  207     * - In the vertex shader stage (for all languages)
  208     * - In any stage for GLSL 1.30+ or GLSL ES 3.00
  209     * - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.
  210     *
  211     * Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
  212     * don't need to explicitly check state->es_shader.
  213     */
  214    return state->stage == MESA_SHADER_VERTEX ||
  215           state->is_version(130, 300) ||
  216           state->ARB_shader_texture_lod_enable ||
  217           state->EXT_gpu_shader4_enable;
  218 }
  219 
  220 static bool
  221 v110_lod(const _mesa_glsl_parse_state *state)
  222 {
  223    return !state->es_shader && lod_exists_in_stage(state);
  224 }
  225 
  226 static bool
  227 texture_buffer(const _mesa_glsl_parse_state *state)
  228 {
  229    return state->is_version(140, 320) ||
  230       state->EXT_texture_buffer_enable ||
  231       state->OES_texture_buffer_enable;
  232 }
  233 
  234 static bool
  235 shader_texture_lod(const _mesa_glsl_parse_state *state)
  236 {
  237    return state->ARB_shader_texture_lod_enable;
  238 }
  239 
  240 static bool
  241 shader_texture_lod_and_rect(const _mesa_glsl_parse_state *state)
  242 {
  243    return state->ARB_shader_texture_lod_enable &&
  244           state->ARB_texture_rectangle_enable;
  245 }
  246 
  247 static bool
  248 shader_bit_encoding(const _mesa_glsl_parse_state *state)
  249 {
  250    return state->is_version(330, 300) ||
  251           state->ARB_shader_bit_encoding_enable ||
  252           state->ARB_gpu_shader5_enable;
  253 }
  254 
  255 static bool
  256 shader_integer_mix(const _mesa_glsl_parse_state *state)
  257 {
  258    return state->is_version(450, 310) ||
  259           state->ARB_ES3_1_compatibility_enable ||
  260           (v130(state) && state->EXT_shader_integer_mix_enable);
  261 }
  262 
  263 static bool
  264 shader_packing_or_es3(const _mesa_glsl_parse_state *state)
  265 {
  266    return state->ARB_shading_language_packing_enable ||
  267           state->is_version(420, 300);
  268 }
  269 
  270 static bool
  271 shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state)
  272 {
  273    return state->ARB_shading_language_packing_enable ||
  274           state->ARB_gpu_shader5_enable ||
  275           state->is_version(400, 300);
  276 }
  277 
  278 static bool
  279 gpu_shader4(const _mesa_glsl_parse_state *state)
  280 {
  281    return state->EXT_gpu_shader4_enable;
  282 }
  283 
  284 static bool
  285 gpu_shader4_integer(const _mesa_glsl_parse_state *state)
  286 {
  287    return state->EXT_gpu_shader4_enable &&
  288           state->ctx->Extensions.EXT_texture_integer;
  289 }
  290 
  291 static bool
  292 gpu_shader4_array(const _mesa_glsl_parse_state *state)
  293 {
  294    return state->EXT_gpu_shader4_enable &&
  295           state->ctx->Extensions.EXT_texture_array;
  296 }
  297 
  298 static bool
  299 gpu_shader4_array_integer(const _mesa_glsl_parse_state *state)
  300 {
  301    return gpu_shader4_array(state) &&
  302           state->ctx->Extensions.EXT_texture_integer;
  303 }
  304 
  305 static bool
  306 gpu_shader4_rect(const _mesa_glsl_parse_state *state)
  307 {
  308    return state->EXT_gpu_shader4_enable &&
  309           state->ctx->Extensions.NV_texture_rectangle;
  310 }
  311 
  312 static bool
  313 gpu_shader4_rect_integer(const _mesa_glsl_parse_state *state)
  314 {
  315    return gpu_shader4_rect(state) &&
  316           state->ctx->Extensions.EXT_texture_integer;
  317 }
  318 
  319 static bool
  320 gpu_shader4_tbo(const _mesa_glsl_parse_state *state)
  321 {
  322    return state->EXT_gpu_shader4_enable &&
  323           state->ctx->Extensions.EXT_texture_buffer_object;
  324 }
  325 
  326 static bool
  327 gpu_shader4_tbo_integer(const _mesa_glsl_parse_state *state)
  328 {
  329    return gpu_shader4_tbo(state) &&
  330           state->ctx->Extensions.EXT_texture_integer;
  331 }
  332 
  333 static bool
  334 gpu_shader4_derivs_only(const _mesa_glsl_parse_state *state)
  335 {
  336    return state->EXT_gpu_shader4_enable &&
  337           derivatives_only(state);
  338 }
  339 
  340 static bool
  341 gpu_shader4_integer_derivs_only(const _mesa_glsl_parse_state *state)
  342 {
  343    return gpu_shader4_derivs_only(state) &&
  344           state->ctx->Extensions.EXT_texture_integer;
  345 }
  346 
  347 static bool
  348 gpu_shader4_array_derivs_only(const _mesa_glsl_parse_state *state)
  349 {
  350    return gpu_shader4_derivs_only(state) &&
  351           state->ctx->Extensions.EXT_texture_array;
  352 }
  353 
  354 static bool
  355 gpu_shader4_array_integer_derivs_only(const _mesa_glsl_parse_state *state)
  356 {
  357    return gpu_shader4_array_derivs_only(state) &&
  358           state->ctx->Extensions.EXT_texture_integer;
  359 }
  360 
  361 static bool
  362 v130_or_gpu_shader4(const _mesa_glsl_parse_state *state)
  363 {
  364    return state->is_version(130, 300) || state->EXT_gpu_shader4_enable;
  365 }
  366 
  367 static bool
  368 v130_or_gpu_shader4_and_tex_shadow_lod(const _mesa_glsl_parse_state *state)
  369 {
  370    return v130_or_gpu_shader4(state) &&
  371           state->EXT_texture_shadow_lod_enable;
  372 }
  373 
  374 static bool
  375 gpu_shader5(const _mesa_glsl_parse_state *state)
  376 {
  377    return state->is_version(400, 0) || state->ARB_gpu_shader5_enable;
  378 }
  379 
  380 static bool
  381 gpu_shader5_es(const _mesa_glsl_parse_state *state)
  382 {
  383    return state->is_version(400, 320) ||
  384           state->ARB_gpu_shader5_enable ||
  385           state->EXT_gpu_shader5_enable ||
  386           state->OES_gpu_shader5_enable;
  387 }
  388 
  389 static bool
  390 gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state *state)
  391 {
  392    return state->is_version(400, 320) ||
  393           state->ARB_gpu_shader5_enable ||
  394           state->EXT_texture_cube_map_array_enable ||
  395           state->OES_texture_cube_map_array_enable;
  396 }
  397 
  398 static bool
  399 es31_not_gs5(const _mesa_glsl_parse_state *state)
  400 {
  401    return state->is_version(0, 310) && !gpu_shader5_es(state);
  402 }
  403 
  404 static bool
  405 gpu_shader5_or_es31(const _mesa_glsl_parse_state *state)
  406 {
  407    return state->is_version(400, 310) || state->ARB_gpu_shader5_enable;
  408 }
  409 
  410 static bool
  411 shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state *state)
  412 {
  413    return state->ARB_shading_language_packing_enable ||
  414           state->ARB_gpu_shader5_enable ||
  415           state->is_version(400, 310);
  416 }
  417 
  418 static bool
  419 gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state *state)
  420 {
  421    return gpu_shader5_or_es31(state) ||
  422           state->MESA_shader_integer_functions_enable;
  423 }
  424 
  425 static bool
  426 fs_interpolate_at(const _mesa_glsl_parse_state *state)
  427 {
  428    return state->stage == MESA_SHADER_FRAGMENT &&
  429           (state->is_version(400, 320) ||
  430            state->ARB_gpu_shader5_enable ||
  431            state->OES_shader_multisample_interpolation_enable);
  432 }
  433 
  434 
  435 static bool
  436 texture_array_lod(const _mesa_glsl_parse_state *state)
  437 {
  438    return lod_exists_in_stage(state) &&
  439           (state->EXT_texture_array_enable ||
  440            (state->EXT_gpu_shader4_enable &&
  441             state->ctx->Extensions.EXT_texture_array));
  442 }
  443 
  444 static bool
  445 texture_array(const _mesa_glsl_parse_state *state)
  446 {
  447    return state->EXT_texture_array_enable ||
  448           (state->EXT_gpu_shader4_enable &&
  449            state->ctx->Extensions.EXT_texture_array);
  450 }
  451 
  452 static bool
  453 texture_array_derivs_only(const _mesa_glsl_parse_state *state)
  454 {
  455    return derivatives_only(state) &&
  456           texture_array(state);
  457 }
  458 
  459 static bool
  460 texture_multisample(const _mesa_glsl_parse_state *state)
  461 {
  462    return state->is_version(150, 310) ||
  463           state->ARB_texture_multisample_enable;
  464 }
  465 
  466 static bool
  467 texture_multisample_array(const _mesa_glsl_parse_state *state)
  468 {
  469    return state->is_version(150, 320) ||
  470           state->ARB_texture_multisample_enable ||
  471           state->OES_texture_storage_multisample_2d_array_enable;
  472 }
  473 
  474 static bool
  475 texture_samples_identical(const _mesa_glsl_parse_state *state)
  476 {
  477    return texture_multisample(state) &&
  478           state->EXT_shader_samples_identical_enable;
  479 }
  480 
  481 static bool
  482 texture_samples_identical_array(const _mesa_glsl_parse_state *state)
  483 {
  484    return texture_multisample_array(state) &&
  485           state->EXT_shader_samples_identical_enable;
  486 }
  487 
  488 static bool
  489 derivatives_texture_cube_map_array(const _mesa_glsl_parse_state *state)
  490 {
  491    return state->has_texture_cube_map_array() &&
  492           derivatives_only(state);
  493 }
  494 
  495 static bool
  496 texture_cube_map_array(const _mesa_glsl_parse_state *state)
  497 {
  498    return state->has_texture_cube_map_array();
  499 }
  500 
  501 static bool
  502 v130_or_gpu_shader4_and_tex_cube_map_array(const _mesa_glsl_parse_state *state)
  503 {
  504    return texture_cube_map_array(state) &&
  505           v130_or_gpu_shader4(state) &&
  506           state->EXT_texture_shadow_lod_enable;
  507 }
  508 
  509 static bool
  510 texture_query_levels(const _mesa_glsl_parse_state *state)
  511 {
  512    return state->is_version(430, 0) ||
  513           state->ARB_texture_query_levels_enable;
  514 }
  515 
  516 static bool
  517 texture_query_lod(const _mesa_glsl_parse_state *state)
  518 {
  519    return derivatives_only(state) &&
  520           (state->ARB_texture_query_lod_enable ||
  521            state->EXT_texture_query_lod_enable);
  522 }
  523 
  524 static bool
  525 texture_gather_cube_map_array(const _mesa_glsl_parse_state *state)
  526 {
  527    return state->is_version(400, 320) ||
  528           state->ARB_texture_gather_enable ||
  529           state->ARB_gpu_shader5_enable ||
  530           state->EXT_texture_cube_map_array_enable ||
  531           state->OES_texture_cube_map_array_enable;
  532 }
  533 
  534 static bool
  535 texture_texture4(const _mesa_glsl_parse_state *state)
  536 {
  537    return state->AMD_texture_texture4_enable;
  538 }
  539 
  540 static bool
  541 texture_gather_or_es31(const _mesa_glsl_parse_state *state)
  542 {
  543    return state->is_version(400, 310) ||
  544           state->ARB_texture_gather_enable ||
  545           state->ARB_gpu_shader5_enable;
  546 }
  547 
  548 /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
  549  * used for relaxation of const offset requirements.
  550  */
  551 static bool
  552 texture_gather_only_or_es31(const _mesa_glsl_parse_state *state)
  553 {
  554    return !state->is_version(400, 320) &&
  555           !state->ARB_gpu_shader5_enable &&
  556           !state->EXT_gpu_shader5_enable &&
  557           !state->OES_gpu_shader5_enable &&
  558           (state->ARB_texture_gather_enable ||
  559            state->is_version(0, 310));
  560 }
  561 
  562 /* Desktop GL or OES_standard_derivatives */
  563 static bool
  564 derivatives(const _mesa_glsl_parse_state *state)
  565 {
  566    return derivatives_only(state) &&
  567           (state->is_version(110, 300) ||
  568            state->OES_standard_derivatives_enable ||
  569            state->ctx->Const.AllowGLSLRelaxedES);
  570 }
  571 
  572 static bool
  573 derivative_control(const _mesa_glsl_parse_state *state)
  574 {
  575    return derivatives_only(state) &&
  576           (state->is_version(450, 0) ||
  577            state->ARB_derivative_control_enable);
  578 }
  579 
  580 static bool
  581 tex1d_lod(const _mesa_glsl_parse_state *state)
  582 {
  583    return !state->es_shader && lod_exists_in_stage(state);
  584 }
  585 
  586 /** True if sampler3D exists */
  587 static bool
  588 tex3d(const _mesa_glsl_parse_state *state)
  589 {
  590    /* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the
  591     * OES_texture_3D extension, and in GLSL ES 3.00.
  592     */
  593    return !state->es_shader ||
  594           state->OES_texture_3D_enable ||
  595           state->language_version >= 300;
  596 }
  597 
  598 static bool
  599 derivatives_tex3d(const _mesa_glsl_parse_state *state)
  600 {
  601    return (!state->es_shader || state->OES_texture_3D_enable) &&
  602           derivatives_only(state);
  603 }
  604 
  605 static bool
  606 tex3d_lod(const _mesa_glsl_parse_state *state)
  607 {
  608    return tex3d(state) && lod_exists_in_stage(state);
  609 }
  610 
  611 static bool
  612 shader_atomic_counters(const _mesa_glsl_parse_state *state)
  613 {
  614    return state->has_atomic_counters();
  615 }
  616 
  617 static bool
  618 shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)
  619 {
  620    return state->ARB_shader_atomic_counter_ops_enable;
  621 }
  622 
  623 static bool
  624 shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state *state)
  625 {
  626    return state->ARB_shader_atomic_counter_ops_enable || v460_desktop(state);
  627 }
  628 
  629 static bool
  630 shader_ballot(const _mesa_glsl_parse_state *state)
  631 {
  632    return state->ARB_shader_ballot_enable;
  633 }
  634 
  635 static bool
  636 supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state *state)
  637 {
  638    return state->ARB_fragment_shader_interlock_enable;
  639 }
  640 
  641 static bool
  642 supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state *state)
  643 {
  644    return state->NV_fragment_shader_interlock_enable;
  645 }
  646 
  647 static bool
  648 shader_clock(const _mesa_glsl_parse_state *state)
  649 {
  650    return state->ARB_shader_clock_enable;
  651 }
  652 
  653 static bool
  654 shader_clock_int64(const _mesa_glsl_parse_state *state)
  655 {
  656    return state->ARB_shader_clock_enable &&
  657           (state->ARB_gpu_shader_int64_enable ||
  658            state->AMD_gpu_shader_int64_enable);
  659 }
  660 
  661 static bool
  662 shader_storage_buffer_object(const _mesa_glsl_parse_state *state)
  663 {
  664    return state->has_shader_storage_buffer_objects();
  665 }
  666 
  667 static bool
  668 shader_trinary_minmax(const _mesa_glsl_parse_state *state)
  669 {
  670    return state->AMD_shader_trinary_minmax_enable;
  671 }
  672 
  673 static bool
  674 shader_image_load_store(const _mesa_glsl_parse_state *state)
  675 {
  676    return (state->is_version(420, 310) ||
  677            state->ARB_shader_image_load_store_enable ||
  678            state->EXT_shader_image_load_store_enable);
  679 }
  680 
  681 static bool
  682 shader_image_load_store_ext(const _mesa_glsl_parse_state *state)
  683 {
  684    return state->EXT_shader_image_load_store_enable;
  685 }
  686 
  687 static bool
  688 shader_image_atomic(const _mesa_glsl_parse_state *state)
  689 {
  690    return (state->is_version(420, 320) ||
  691            state->ARB_shader_image_load_store_enable ||
  692            state->EXT_shader_image_load_store_enable ||
  693            state->OES_shader_image_atomic_enable);
  694 }
  695 
  696 static bool
  697 shader_image_atomic_exchange_float(const _mesa_glsl_parse_state *state)
  698 {
  699    return (state->is_version(450, 320) ||
  700            state->ARB_ES3_1_compatibility_enable ||
  701            state->OES_shader_image_atomic_enable ||
  702            state->NV_shader_atomic_float_enable);
  703 }
  704 
  705 static bool
  706 shader_image_atomic_add_float(const _mesa_glsl_parse_state *state)
  707 {
  708    return state->NV_shader_atomic_float_enable;
  709 }
  710 
  711 static bool
  712 shader_image_size(const _mesa_glsl_parse_state *state)
  713 {
  714    return state->is_version(430, 310) ||
  715            state->ARB_shader_image_size_enable;
  716 }
  717 
  718 static bool
  719 shader_samples(const _mesa_glsl_parse_state *state)
  720 {
  721    return state->is_version(450, 0) ||
  722           state->ARB_shader_texture_image_samples_enable;
  723 }
  724 
  725 static bool
  726 gs_streams(const _mesa_glsl_parse_state *state)
  727 {
  728    return gpu_shader5(state) && gs_only(state);
  729 }
  730 
  731 static bool
  732 fp64(const _mesa_glsl_parse_state *state)
  733 {
  734    return state->has_double();
  735 }
  736 
  737 static bool
  738 int64(const _mesa_glsl_parse_state *state)
  739 {
  740    return state->has_int64();
  741 }
  742 
  743 static bool
  744 int64_fp64(const _mesa_glsl_parse_state *state)
  745 {
  746    return state->has_int64() && state->has_double();
  747 }
  748 
  749 static bool
  750 compute_shader(const _mesa_glsl_parse_state *state)
  751 {
  752    return state->stage == MESA_SHADER_COMPUTE;
  753 }
  754 
  755 static bool
  756 compute_shader_supported(const _mesa_glsl_parse_state *state)
  757 {
  758    return state->has_compute_shader();
  759 }
  760 
  761 static bool
  762 buffer_atomics_supported(const _mesa_glsl_parse_state *state)
  763 {
  764    return compute_shader(state) || shader_storage_buffer_object(state);
  765 }
  766 
  767 static bool
  768 barrier_supported(const _mesa_glsl_parse_state *state)
  769 {
  770    return compute_shader(state) ||
  771           state->stage == MESA_SHADER_TESS_CTRL;
  772 }
  773 
  774 static bool
  775 vote(const _mesa_glsl_parse_state *state)
  776 {
  777    return state->ARB_shader_group_vote_enable;
  778 }
  779 
  780 static bool
  781 vote_or_v460_desktop(const _mesa_glsl_parse_state *state)
  782 {
  783    return state->ARB_shader_group_vote_enable || v460_desktop(state);
  784 }
  785 
  786 static bool
  787 integer_functions_supported(const _mesa_glsl_parse_state *state)
  788 {
  789    return state->extensions->MESA_shader_integer_functions;
  790 }
  791 
  792 static bool
  793 NV_shader_atomic_float_supported(const _mesa_glsl_parse_state *state)
  794 {
  795    return state->extensions->NV_shader_atomic_float;
  796 }
  797 
  798 static bool
  799 shader_atomic_float_add(const _mesa_glsl_parse_state *state)
  800 {
  801    return state->NV_shader_atomic_float_enable;
  802 }
  803 
  804 static bool
  805 shader_atomic_float_exchange(const _mesa_glsl_parse_state *state)
  806 {
  807    return state->NV_shader_atomic_float_enable ||
  808           state->INTEL_shader_atomic_float_minmax_enable;
  809 }
  810 
  811 static bool
  812 INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state *state)
  813 {
  814    return state->extensions->INTEL_shader_atomic_float_minmax;
  815 }
  816 
  817 static bool
  818 shader_atomic_float_minmax(const _mesa_glsl_parse_state *state)
  819 {
  820    return state->INTEL_shader_atomic_float_minmax_enable;
  821 }
  822 
  823 static bool
  824 demote_to_helper_invocation(const _mesa_glsl_parse_state *state)
  825 {
  826    return state->EXT_demote_to_helper_invocation_enable;
  827 }
  828 
  829 static bool
  830 shader_integer_functions2(const _mesa_glsl_parse_state *state)
  831 {
  832    return state->INTEL_shader_integer_functions2_enable;
  833 }
  834 
  835 static bool
  836 shader_integer_functions2_int64(const _mesa_glsl_parse_state *state)
  837 {
  838    return state->INTEL_shader_integer_functions2_enable && state->has_int64();
  839 }
  840 
  841 static bool
  842 is_nir(const _mesa_glsl_parse_state *state)
  843 {
  844    return state->ctx->Const.ShaderCompilerOptions[state->stage].NirOptions;
  845 }
  846 
  847 static bool
  848 is_not_nir(const _mesa_glsl_parse_state *state)
  849 {
  850    return !is_nir(state);
  851 }
  852 
  853 /** @} */
  854 
  855 /******************************************************************************/
  856 
  857 namespace {
  858 
  859 /**
  860  * builtin_builder: A singleton object representing the core of the built-in
  861  * function module.
  862  *
  863  * It generates IR for every built-in function signature, and organizes them
  864  * into functions.
  865  */
  866 class builtin_builder {
  867 public:
  868    builtin_builder();
  869    ~builtin_builder();
  870 
  871    void initialize();
  872    void release();
  873    ir_function_signature *find(_mesa_glsl_parse_state *state,
  874                                const char *name, exec_list *actual_parameters);
  875 
  876    /**
  877     * A shader to hold all the built-in signatures; created by this module.
  878     *
  879     * This includes signatures for every built-in, regardless of version or
  880     * enabled extensions.  The availability predicate associated with each
  881     * signature allows matching_signature() to filter out the irrelevant ones.
  882     */
  883    gl_shader *shader;
  884 
  885 private:
  886    void *mem_ctx;
  887 
  888    void create_shader();
  889    void create_intrinsics();
  890    void create_builtins();
  891 
  892    /**
  893     * IR builder helpers:
  894     *
  895     * These convenience functions assist in emitting IR, but don't necessarily
  896     * fit in ir_builder itself.  Many of them rely on having a mem_ctx class
  897     * member available.
  898     */
  899    ir_variable *in_var(const glsl_type *type, const char *name);
  900    ir_variable *out_var(const glsl_type *type, const char *name);
  901    ir_constant *imm(float f, unsigned vector_elements=1);
  902    ir_constant *imm(bool b, unsigned vector_elements=1);
  903    ir_constant *imm(int i, unsigned vector_elements=1);
  904    ir_constant *imm(unsigned u, unsigned vector_elements=1);
  905    ir_constant *imm(double d, unsigned vector_elements=1);
  906    ir_constant *imm(const glsl_type *type, const ir_constant_data &);
  907    ir_dereference_variable *var_ref(ir_variable *var);
  908    ir_dereference_array *array_ref(ir_variable *var, int i);
  909    ir_swizzle *matrix_elt(ir_variable *var, int col, int row);
  910 
  911    ir_expression *asin_expr(ir_variable *x, float p0, float p1);
  912    void do_atan(ir_factory &body, const glsl_type *type, ir_variable *res, operand y_over_x);
  913 
  914    /**
  915     * Call function \param f with parameters specified as the linked
  916     * list \param params of \c ir_variable objects.  \param ret should
  917     * point to the ir_variable that will hold the function return
  918     * value, or be \c NULL if the function has void return type.
  919     */
  920    ir_call *call(ir_function *f, ir_variable *ret, exec_list params);
  921 
  922    /** Create a new function and add the given signatures. */
  923    void add_function(const char *name, ...);
  924 
  925    typedef ir_function_signature *(builtin_builder::*image_prototype_ctr)(const glsl_type *image_type,
  926                                                                           unsigned num_arguments,
  927                                                                           unsigned flags);
  928 
  929    /**
  930     * Create a new image built-in function for all known image types.
  931     * \p flags is a bitfield of \c image_function_flags flags.
  932     */
  933    void add_image_function(const char *name,
  934                            const char *intrinsic_name,
  935                            image_prototype_ctr prototype,
  936                            unsigned num_arguments,
  937                            unsigned flags,
  938                            enum ir_intrinsic_id id);
  939 
  940    /**
  941     * Create new functions for all known image built-ins and types.
  942     * If \p glsl is \c true, use the GLSL built-in names and emit code
  943     * to call into the actual compiler intrinsic.  If \p glsl is
  944     * false, emit a function prototype with no body for each image
  945     * intrinsic name.
  946     */
  947    void add_image_functions(bool glsl);
  948 
  949    ir_function_signature *new_sig(const glsl_type *return_type,
  950                                   builtin_available_predicate avail,
  951                                   int num_params, ...);
  952 
  953    /**
  954     * Function signature generators:
  955     *  @{
  956     */
  957    ir_function_signature *unop(builtin_available_predicate avail,
  958                                ir_expression_operation opcode,
  959                                const glsl_type *return_type,
  960                                const glsl_type *param_type);
  961    ir_function_signature *binop(builtin_available_predicate avail,
  962                                 ir_expression_operation opcode,
  963                                 const glsl_type *return_type,
  964                                 const glsl_type *param0_type,
  965                                 const glsl_type *param1_type,
  966                                 bool swap_operands = false);
  967 
  968 #define B0(X) ir_function_signature *_##X();
  969 #define B1(X) ir_function_signature *_##X(const glsl_type *);
  970 #define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);
  971 #define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);
  972 #define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);
  973 #define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);
  974    B1(radians)
  975    B1(degrees)
  976    B1(sin)
  977    B1(cos)
  978    B1(tan)
  979    B1(asin)
  980    B1(acos)
  981    B1(atan2)
  982    B1(atan)
  983    B1(atan2_op)
  984    B1(atan_op)
  985    B1(sinh)
  986    B1(cosh)
  987    B1(tanh)
  988    B1(asinh)
  989    B1(acosh)
  990    B1(atanh)
  991    B1(pow)
  992    B1(exp)
  993    B1(log)
  994    B1(exp2)
  995    B1(log2)
  996    BA1(sqrt)
  997    BA1(inversesqrt)
  998    BA1(abs)
  999    BA1(sign)
 1000    BA1(floor)
 1001    BA1(truncate)
 1002    BA1(trunc)
 1003    BA1(round)
 1004    BA1(roundEven)
 1005    BA1(ceil)
 1006    BA1(fract)
 1007    BA2(mod)
 1008    BA1(modf)
 1009    BA2(min)
 1010    BA2(max)
 1011    BA2(clamp)
 1012    BA2(mix_lrp)
 1013    ir_function_signature *_mix_sel(builtin_available_predicate avail,
 1014                                    const glsl_type *val_type,
 1015                                    const glsl_type *blend_type);
 1016    BA2(step)
 1017    BA2(smoothstep)
 1018    BA1(isnan)
 1019    BA1(isinf)
 1020    B1(floatBitsToInt)
 1021    B1(floatBitsToUint)
 1022    B1(intBitsToFloat)
 1023    B1(uintBitsToFloat)
 1024 
 1025    BA1(doubleBitsToInt64)
 1026    BA1(doubleBitsToUint64)
 1027    BA1(int64BitsToDouble)
 1028    BA1(uint64BitsToDouble)
 1029 
 1030    ir_function_signature *_packUnorm2x16(builtin_available_predicate avail);
 1031    ir_function_signature *_packSnorm2x16(builtin_available_predicate avail);
 1032    ir_function_signature *_packUnorm4x8(builtin_available_predicate avail);
 1033    ir_function_signature *_packSnorm4x8(builtin_available_predicate avail);
 1034    ir_function_signature *_unpackUnorm2x16(builtin_available_predicate avail);
 1035    ir_function_signature *_unpackSnorm2x16(builtin_available_predicate avail);
 1036    ir_function_signature *_unpackUnorm4x8(builtin_available_predicate avail);
 1037    ir_function_signature *_unpackSnorm4x8(builtin_available_predicate avail);
 1038    ir_function_signature *_packHalf2x16(builtin_available_predicate avail);
 1039    ir_function_signature *_unpackHalf2x16(builtin_available_predicate avail);
 1040    ir_function_signature *_packDouble2x32(builtin_available_predicate avail);
 1041    ir_function_signature *_unpackDouble2x32(builtin_available_predicate avail);
 1042    ir_function_signature *_packInt2x32(builtin_available_predicate avail);
 1043    ir_function_signature *_unpackInt2x32(builtin_available_predicate avail);
 1044    ir_function_signature *_packUint2x32(builtin_available_predicate avail);
 1045    ir_function_signature *_unpackUint2x32(builtin_available_predicate avail);
 1046 
 1047    BA1(length)
 1048    BA1(distance);
 1049    BA1(dot);
 1050    BA1(cross);
 1051    BA1(normalize);
 1052    B0(ftransform);
 1053    BA1(faceforward);
 1054    BA1(reflect);
 1055    BA1(refract);
 1056    BA1(matrixCompMult);
 1057    BA1(outerProduct);
 1058    BA1(determinant_mat2);
 1059    BA1(determinant_mat3);
 1060    BA1(determinant_mat4);
 1061    BA1(inverse_mat2);
 1062    BA1(inverse_mat3);
 1063    BA1(inverse_mat4);
 1064    BA1(transpose);
 1065    BA1(lessThan);
 1066    BA1(lessThanEqual);
 1067    BA1(greaterThan);
 1068    BA1(greaterThanEqual);
 1069    BA1(equal);
 1070    BA1(notEqual);
 1071    B1(any);
 1072    B1(all);
 1073    B1(not);
 1074    BA2(textureSize);
 1075    BA1(textureSamples);
 1076 
 1077 /** Flags to _texture() */
 1078 #define TEX_PROJECT 1
 1079 #define TEX_OFFSET  2
 1080 #define TEX_COMPONENT 4
 1081 #define TEX_OFFSET_NONCONST 8
 1082 #define TEX_OFFSET_ARRAY 16
 1083 
 1084    ir_function_signature *_texture(ir_texture_opcode opcode,
 1085                                    builtin_available_predicate avail,
 1086                                    const glsl_type *return_type,
 1087                                    const glsl_type *sampler_type,
 1088                                    const glsl_type *coord_type,
 1089                                    int flags = 0);
 1090    ir_function_signature *_textureCubeArrayShadow(ir_texture_opcode opcode,
 1091                                                   builtin_available_predicate avail,
 1092                                                   const glsl_type *x);
 1093    ir_function_signature *_texelFetch(builtin_available_predicate avail,
 1094                                       const glsl_type *return_type,
 1095                                       const glsl_type *sampler_type,
 1096                                       const glsl_type *coord_type,
 1097                                       const glsl_type *offset_type = NULL);
 1098 
 1099    B0(EmitVertex)
 1100    B0(EndPrimitive)
 1101    ir_function_signature *_EmitStreamVertex(builtin_available_predicate avail,
 1102                                             const glsl_type *stream_type);
 1103    ir_function_signature *_EndStreamPrimitive(builtin_available_predicate avail,
 1104                                               const glsl_type *stream_type);
 1105    B0(barrier)
 1106 
 1107    BA2(textureQueryLod);
 1108    BA1(textureQueryLevels);
 1109    BA2(textureSamplesIdentical);
 1110    B1(dFdx);
 1111    B1(dFdy);
 1112    B1(fwidth);
 1113    B1(dFdxCoarse);
 1114    B1(dFdyCoarse);
 1115    B1(fwidthCoarse);
 1116    B1(dFdxFine);
 1117    B1(dFdyFine);
 1118    B1(fwidthFine);
 1119    B1(noise1);
 1120    B1(noise2);
 1121    B1(noise3);
 1122    B1(noise4);
 1123 
 1124    B1(bitfieldExtract)
 1125    B1(bitfieldInsert)
 1126    B1(bitfieldReverse)
 1127    B1(bitCount)
 1128    B1(findLSB)
 1129    B1(findMSB)
 1130    BA1(countLeadingZeros)
 1131    BA1(countTrailingZeros)
 1132    BA1(fma)
 1133    B2(ldexp)
 1134    B2(frexp)
 1135    B2(dfrexp)
 1136    B1(uaddCarry)
 1137    B1(usubBorrow)
 1138    BA1(addSaturate)
 1139    BA1(subtractSaturate)
 1140    BA1(absoluteDifference)
 1141    BA1(average)
 1142    BA1(averageRounded)
 1143    B1(mulExtended)
 1144    BA1(multiply32x16)
 1145    B1(interpolateAtCentroid)
 1146    B1(interpolateAtOffset)
 1147    B1(interpolateAtSample)
 1148 
 1149    ir_function_signature *_atomic_counter_intrinsic(builtin_available_predicate avail,
 1150                                                     enum ir_intrinsic_id id);
 1151    ir_function_signature *_atomic_counter_intrinsic1(builtin_available_predicate avail,
 1152                                                      enum ir_intrinsic_id id);
 1153    ir_function_signature *_atomic_counter_intrinsic2(builtin_available_predicate avail,
 1154                                                      enum ir_intrinsic_id id);
 1155    ir_function_signature *_atomic_counter_op(const char *intrinsic,
 1156                                              builtin_available_predicate avail);
 1157    ir_function_signature *_atomic_counter_op1(const char *intrinsic,
 1158                                               builtin_available_predicate avail);
 1159    ir_function_signature *_atomic_counter_op2(const char *intrinsic,
 1160                                               builtin_available_predicate avail);
 1161 
 1162    ir_function_signature *_atomic_intrinsic2(builtin_available_predicate avail,
 1163                                              const glsl_type *type,
 1164                                              enum ir_intrinsic_id id);
 1165    ir_function_signature *_atomic_op2(const char *intrinsic,
 1166                                       builtin_available_predicate avail,
 1167                                       const glsl_type *type);
 1168    ir_function_signature *_atomic_intrinsic3(builtin_available_predicate avail,
 1169                                              const glsl_type *type,
 1170                                              enum ir_intrinsic_id id);
 1171    ir_function_signature *_atomic_op3(const char *intrinsic,
 1172                                       builtin_available_predicate avail,
 1173                                       const glsl_type *type);
 1174 
 1175    B1(min3)
 1176    B1(max3)
 1177    B1(mid3)
 1178 
 1179    ir_function_signature *_image_prototype(const glsl_type *image_type,
 1180                                            unsigned num_arguments,
 1181                                            unsigned flags);
 1182    ir_function_signature *_image_size_prototype(const glsl_type *image_type,
 1183                                                 unsigned num_arguments,
 1184                                                 unsigned flags);
 1185    ir_function_signature *_image_samples_prototype(const glsl_type *image_type,
 1186                                                    unsigned num_arguments,
 1187                                                    unsigned flags);
 1188    ir_function_signature *_image(image_prototype_ctr prototype,
 1189                                  const glsl_type *image_type,
 1190                                  const char *intrinsic_name,
 1191                                  unsigned num_arguments,
 1192                                  unsigned flags,
 1193                                  enum ir_intrinsic_id id);
 1194 
 1195    ir_function_signature *_memory_barrier_intrinsic(
 1196       builtin_available_predicate avail,
 1197       enum ir_intrinsic_id id);
 1198    ir_function_signature *_memory_barrier(const char *intrinsic_name,
 1199                                           builtin_available_predicate avail);
 1200 
 1201    ir_function_signature *_ballot_intrinsic();
 1202    ir_function_signature *_ballot();
 1203    ir_function_signature *_read_first_invocation_intrinsic(const glsl_type *type);
 1204    ir_function_signature *_read_first_invocation(const glsl_type *type);
 1205    ir_function_signature *_read_invocation_intrinsic(const glsl_type *type);
 1206    ir_function_signature *_read_invocation(const glsl_type *type);
 1207 
 1208 
 1209    ir_function_signature *_invocation_interlock_intrinsic(
 1210       builtin_available_predicate avail,
 1211       enum ir_intrinsic_id id);
 1212    ir_function_signature *_invocation_interlock(
 1213       const char *intrinsic_name,
 1214       builtin_available_predicate avail);
 1215 
 1216    ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail,
 1217                                                   const glsl_type *type);
 1218    ir_function_signature *_shader_clock(builtin_available_predicate avail,
 1219                                         const glsl_type *type);
 1220 
 1221    ir_function_signature *_vote_intrinsic(builtin_available_predicate avail,
 1222                                           enum ir_intrinsic_id id);
 1223    ir_function_signature *_vote(const char *intrinsic_name,
 1224                                 builtin_available_predicate avail);
 1225 
 1226    ir_function_signature *_helper_invocation_intrinsic();
 1227    ir_function_signature *_helper_invocation();
 1228 
 1229 #undef B0
 1230 #undef B1
 1231 #undef B2
 1232 #undef B3
 1233 #undef BA1
 1234 #undef BA2
 1235    /** @} */
 1236 };
 1237 
 1238 enum image_function_flags {
 1239    IMAGE_FUNCTION_EMIT_STUB = (1 << 0),
 1240    IMAGE_FUNCTION_RETURNS_VOID = (1 << 1),
 1241    IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE = (1 << 2),
 1242    IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE = (1 << 3),
 1243    IMAGE_FUNCTION_READ_ONLY = (1 << 4),
 1244    IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),
 1245    IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),
 1246    IMAGE_FUNCTION_MS_ONLY = (1 << 7),
 1247    IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8),
 1248    IMAGE_FUNCTION_AVAIL_ATOMIC_ADD = (1 << 9),
 1249    IMAGE_FUNCTION_EXT_ONLY = (1 << 10),
 1250    IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE = (1 << 11),
 1251 };
 1252 
 1253 } /* anonymous namespace */
 1254 
 1255 /**
 1256  * Core builtin_builder functionality:
 1257  *  @{
 1258  */
 1259 builtin_builder::builtin_builder()
 1260    : shader(NULL)
 1261 {
 1262    mem_ctx = NULL;
 1263 }
 1264 
 1265 builtin_builder::~builtin_builder()
 1266 {
 1267    ralloc_free(mem_ctx);
 1268 }
 1269 
 1270 ir_function_signature *
 1271 builtin_builder::find(_mesa_glsl_parse_state *state,
 1272                       const char *name, exec_list *actual_parameters)
 1273 {
 1274    /* The shader currently being compiled requested a built-in function;
 1275     * it needs to link against builtin_builder::shader in order to get them.
 1276     *
 1277     * Even if we don't find a matching signature, we still need to do this so
 1278     * that the "no matching signature" error will list potential candidates
 1279     * from the available built-ins.
 1280     */
 1281    state->uses_builtin_functions = true;
 1282 
 1283    ir_function *f = shader->symbols->get_function(name);
 1284    if (f == NULL)
 1285       return NULL;
 1286 
 1287    ir_function_signature *sig =
 1288       f->matching_signature(state, actual_parameters, true);
 1289    if (sig == NULL)
 1290       return NULL;
 1291 
 1292    return sig;
 1293 }
 1294 
 1295 void
 1296 builtin_builder::initialize()
 1297 {
 1298    /* If already initialized, don't do it again. */
 1299    if (mem_ctx != NULL)
 1300       return;
 1301 
 1302    glsl_type_singleton_init_or_ref();
 1303 
 1304    mem_ctx = ralloc_context(NULL);
 1305    create_shader();
 1306    create_intrinsics();
 1307    create_builtins();
 1308 }
 1309 
 1310 void
 1311 builtin_builder::release()
 1312 {
 1313    ralloc_free(mem_ctx);
 1314    mem_ctx = NULL;
 1315 
 1316    ralloc_free(shader);
 1317    shader = NULL;
 1318 
 1319    glsl_type_singleton_decref();
 1320 }
 1321 
 1322 void
 1323 builtin_builder::create_shader()
 1324 {
 1325    /* The target doesn't actually matter.  There's no target for generic
 1326     * GLSL utility code that could be linked against any stage, so just
 1327     * arbitrarily pick GL_VERTEX_SHADER.
 1328     */
 1329    shader = _mesa_new_shader(0, MESA_SHADER_VERTEX);
 1330    shader->symbols = new(mem_ctx) glsl_symbol_table;
 1331 }
 1332 
 1333 /** @} */
 1334 
 1335 /**
 1336  * Create ir_function and ir_function_signature objects for each
 1337  * intrinsic.
 1338  */
 1339 void
 1340 builtin_builder::create_intrinsics()
 1341 {
 1342    add_function("__intrinsic_atomic_read",
 1343                 _atomic_counter_intrinsic(shader_atomic_counters,
 1344                                           ir_intrinsic_atomic_counter_read),
 1345                 NULL);
 1346    add_function("__intrinsic_atomic_increment",
 1347                 _atomic_counter_intrinsic(shader_atomic_counters,
 1348                                           ir_intrinsic_atomic_counter_increment),
 1349                 NULL);
 1350    add_function("__intrinsic_atomic_predecrement",
 1351                 _atomic_counter_intrinsic(shader_atomic_counters,
 1352                                           ir_intrinsic_atomic_counter_predecrement),
 1353                 NULL);
 1354 
 1355    add_function("__intrinsic_atomic_add",
 1356                 _atomic_intrinsic2(buffer_atomics_supported,
 1357                                    glsl_type::uint_type,
 1358                                    ir_intrinsic_generic_atomic_add),
 1359                 _atomic_intrinsic2(buffer_atomics_supported,
 1360                                    glsl_type::int_type,
 1361                                    ir_intrinsic_generic_atomic_add),
 1362                 _atomic_intrinsic2(NV_shader_atomic_float_supported,
 1363                                    glsl_type::float_type,
 1364                                    ir_intrinsic_generic_atomic_add),
 1365                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1366                                            ir_intrinsic_atomic_counter_add),
 1367                 NULL);
 1368    add_function("__intrinsic_atomic_min",
 1369                 _atomic_intrinsic2(buffer_atomics_supported,
 1370                                    glsl_type::uint_type,
 1371                                    ir_intrinsic_generic_atomic_min),
 1372                 _atomic_intrinsic2(buffer_atomics_supported,
 1373                                    glsl_type::int_type,
 1374                                    ir_intrinsic_generic_atomic_min),
 1375                 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,
 1376                                    glsl_type::float_type,
 1377                                    ir_intrinsic_generic_atomic_min),
 1378                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1379                                            ir_intrinsic_atomic_counter_min),
 1380                 NULL);
 1381    add_function("__intrinsic_atomic_max",
 1382                 _atomic_intrinsic2(buffer_atomics_supported,
 1383                                    glsl_type::uint_type,
 1384                                    ir_intrinsic_generic_atomic_max),
 1385                 _atomic_intrinsic2(buffer_atomics_supported,
 1386                                    glsl_type::int_type,
 1387                                    ir_intrinsic_generic_atomic_max),
 1388                 _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,
 1389                                    glsl_type::float_type,
 1390                                    ir_intrinsic_generic_atomic_max),
 1391                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1392                                            ir_intrinsic_atomic_counter_max),
 1393                 NULL);
 1394    add_function("__intrinsic_atomic_and",
 1395                 _atomic_intrinsic2(buffer_atomics_supported,
 1396                                    glsl_type::uint_type,
 1397                                    ir_intrinsic_generic_atomic_and),
 1398                 _atomic_intrinsic2(buffer_atomics_supported,
 1399                                    glsl_type::int_type,
 1400                                    ir_intrinsic_generic_atomic_and),
 1401                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1402                                            ir_intrinsic_atomic_counter_and),
 1403                 NULL);
 1404    add_function("__intrinsic_atomic_or",
 1405                 _atomic_intrinsic2(buffer_atomics_supported,
 1406                                    glsl_type::uint_type,
 1407                                    ir_intrinsic_generic_atomic_or),
 1408                 _atomic_intrinsic2(buffer_atomics_supported,
 1409                                    glsl_type::int_type,
 1410                                    ir_intrinsic_generic_atomic_or),
 1411                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1412                                            ir_intrinsic_atomic_counter_or),
 1413                 NULL);
 1414    add_function("__intrinsic_atomic_xor",
 1415                 _atomic_intrinsic2(buffer_atomics_supported,
 1416                                    glsl_type::uint_type,
 1417                                    ir_intrinsic_generic_atomic_xor),
 1418                 _atomic_intrinsic2(buffer_atomics_supported,
 1419                                    glsl_type::int_type,
 1420                                    ir_intrinsic_generic_atomic_xor),
 1421                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1422                                            ir_intrinsic_atomic_counter_xor),
 1423                 NULL);
 1424    add_function("__intrinsic_atomic_exchange",
 1425                 _atomic_intrinsic2(buffer_atomics_supported,
 1426                                    glsl_type::uint_type,
 1427                                    ir_intrinsic_generic_atomic_exchange),
 1428                 _atomic_intrinsic2(buffer_atomics_supported,
 1429                                    glsl_type::int_type,
 1430                                    ir_intrinsic_generic_atomic_exchange),
 1431                 _atomic_intrinsic2(NV_shader_atomic_float_supported,
 1432                                    glsl_type::float_type,
 1433                                    ir_intrinsic_generic_atomic_exchange),
 1434                 _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,
 1435                                            ir_intrinsic_atomic_counter_exchange),
 1436                 NULL);
 1437    add_function("__intrinsic_atomic_comp_swap",
 1438                 _atomic_intrinsic3(buffer_atomics_supported,
 1439                                    glsl_type::uint_type,
 1440                                    ir_intrinsic_generic_atomic_comp_swap),
 1441                 _atomic_intrinsic3(buffer_atomics_supported,
 1442                                    glsl_type::int_type,
 1443                                    ir_intrinsic_generic_atomic_comp_swap),
 1444                 _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported,
 1445                                    glsl_type::float_type,
 1446                                    ir_intrinsic_generic_atomic_comp_swap),
 1447                 _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop,
 1448                                            ir_intrinsic_atomic_counter_comp_swap),
 1449                 NULL);
 1450 
 1451    add_image_functions(false);
 1452 
 1453    add_function("__intrinsic_memory_barrier",
 1454                 _memory_barrier_intrinsic(shader_image_load_store,
 1455                                           ir_intrinsic_memory_barrier),
 1456                 NULL);
 1457    add_function("__intrinsic_group_memory_barrier",
 1458                 _memory_barrier_intrinsic(compute_shader,
 1459                                           ir_intrinsic_group_memory_barrier),
 1460                 NULL);
 1461    add_function("__intrinsic_memory_barrier_atomic_counter",
 1462                 _memory_barrier_intrinsic(compute_shader_supported,
 1463                                           ir_intrinsic_memory_barrier_atomic_counter),
 1464                 NULL);
 1465    add_function("__intrinsic_memory_barrier_buffer",
 1466                 _memory_barrier_intrinsic(compute_shader_supported,
 1467                                           ir_intrinsic_memory_barrier_buffer),
 1468                 NULL);
 1469    add_function("__intrinsic_memory_barrier_image",
 1470                 _memory_barrier_intrinsic(compute_shader_supported,
 1471                                           ir_intrinsic_memory_barrier_image),
 1472                 NULL);
 1473    add_function("__intrinsic_memory_barrier_shared",
 1474                 _memory_barrier_intrinsic(compute_shader,
 1475                                           ir_intrinsic_memory_barrier_shared),
 1476                 NULL);
 1477 
 1478    add_function("__intrinsic_begin_invocation_interlock",
 1479                 _invocation_interlock_intrinsic(
 1480                    supports_arb_fragment_shader_interlock,
 1481                    ir_intrinsic_begin_invocation_interlock), NULL);
 1482 
 1483    add_function("__intrinsic_end_invocation_interlock",
 1484                 _invocation_interlock_intrinsic(
 1485                    supports_arb_fragment_shader_interlock,
 1486                    ir_intrinsic_end_invocation_interlock), NULL);
 1487 
 1488    add_function("__intrinsic_shader_clock",
 1489                 _shader_clock_intrinsic(shader_clock,
 1490                                         glsl_type::uvec2_type),
 1491                 NULL);
 1492 
 1493    add_function("__intrinsic_vote_all",
 1494                 _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_all),
 1495                 NULL);
 1496    add_function("__intrinsic_vote_any",
 1497                 _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_any),
 1498                 NULL);
 1499    add_function("__intrinsic_vote_eq",
 1500                 _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_eq),
 1501                 NULL);
 1502 
 1503    add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL);
 1504 
 1505    add_function("__intrinsic_read_invocation",
 1506                 _read_invocation_intrinsic(glsl_type::float_type),
 1507                 _read_invocation_intrinsic(glsl_type::vec2_type),
 1508                 _read_invocation_intrinsic(glsl_type::vec3_type),
 1509                 _read_invocation_intrinsic(glsl_type::vec4_type),
 1510 
 1511                 _read_invocation_intrinsic(glsl_type::int_type),
 1512                 _read_invocation_intrinsic(glsl_type::ivec2_type),
 1513                 _read_invocation_intrinsic(glsl_type::ivec3_type),
 1514                 _read_invocation_intrinsic(glsl_type::ivec4_type),
 1515 
 1516                 _read_invocation_intrinsic(glsl_type::uint_type),
 1517                 _read_invocation_intrinsic(glsl_type::uvec2_type),
 1518                 _read_invocation_intrinsic(glsl_type::uvec3_type),
 1519                 _read_invocation_intrinsic(glsl_type::uvec4_type),
 1520                 NULL);
 1521 
 1522    add_function("__intrinsic_read_first_invocation",
 1523                 _read_first_invocation_intrinsic(glsl_type::float_type),
 1524                 _read_first_invocation_intrinsic(glsl_type::vec2_type),
 1525                 _read_first_invocation_intrinsic(glsl_type::vec3_type),
 1526                 _read_first_invocation_intrinsic(glsl_type::vec4_type),
 1527 
 1528                 _read_first_invocation_intrinsic(glsl_type::int_type),
 1529                 _read_first_invocation_intrinsic(glsl_type::ivec2_type),
 1530                 _read_first_invocation_intrinsic(glsl_type::ivec3_type),
 1531                 _read_first_invocation_intrinsic(glsl_type::ivec4_type),
 1532 
 1533                 _read_first_invocation_intrinsic(glsl_type::uint_type),
 1534                 _read_first_invocation_intrinsic(glsl_type::uvec2_type),
 1535                 _read_first_invocation_intrinsic(glsl_type::uvec3_type),
 1536                 _read_first_invocation_intrinsic(glsl_type::uvec4_type),
 1537                 NULL);
 1538 
 1539    add_function("__intrinsic_helper_invocation",
 1540                 _helper_invocation_intrinsic(), NULL);
 1541 }
 1542 
 1543 /**
 1544  * Create ir_function and ir_function_signature objects for each built-in.
 1545  *
 1546  * Contains a list of every available built-in.
 1547  */
 1548 void
 1549 builtin_builder::create_builtins()
 1550 {
 1551 #define F(NAME)                                 \
 1552    add_function(#NAME,                          \
 1553                 _##NAME(glsl_type::float_type), \
 1554                 _##NAME(glsl_type::vec2_type),  \
 1555                 _##NAME(glsl_type::vec3_type),  \
 1556                 _##NAME(glsl_type::vec4_type),  \
 1557                 NULL);
 1558 
 1559 #define FD(NAME)                                 \
 1560    add_function(#NAME,                          \
 1561                 _##NAME(always_available, glsl_type::float_type), \
 1562                 _##NAME(always_available, glsl_type::vec2_type),  \
 1563                 _##NAME(always_available, glsl_type::vec3_type),  \
 1564                 _##NAME(always_available, glsl_type::vec4_type),  \
 1565                 _##NAME(fp64, glsl_type::double_type),  \
 1566                 _##NAME(fp64, glsl_type::dvec2_type),    \
 1567                 _##NAME(fp64, glsl_type::dvec3_type),     \
 1568                 _##NAME(fp64, glsl_type::dvec4_type),      \
 1569                 NULL);
 1570 
 1571 #define FD130(NAME)                                 \
 1572    add_function(#NAME,                          \
 1573                 _##NAME(v130, glsl_type::float_type), \
 1574                 _##NAME(v130, glsl_type::vec2_type),  \
 1575                 _##NAME(v130, glsl_type::vec3_type),                  \
 1576                 _##NAME(v130, glsl_type::vec4_type),  \
 1577                 _##NAME(fp64, glsl_type::double_type),  \
 1578                 _##NAME(fp64, glsl_type::dvec2_type),    \
 1579                 _##NAME(fp64, glsl_type::dvec3_type),     \
 1580                 _##NAME(fp64, glsl_type::dvec4_type),      \
 1581                 NULL);
 1582 
 1583 #define FDGS5(NAME)                                 \
 1584    add_function(#NAME,                          \
 1585                 _##NAME(gpu_shader5_es, glsl_type::float_type), \
 1586                 _##NAME(gpu_shader5_es, glsl_type::vec2_type),  \
 1587                 _##NAME(gpu_shader5_es, glsl_type::vec3_type),                  \
 1588                 _##NAME(gpu_shader5_es, glsl_type::vec4_type),  \
 1589                 _##NAME(fp64, glsl_type::double_type),  \
 1590                 _##NAME(fp64, glsl_type::dvec2_type),    \
 1591                 _##NAME(fp64, glsl_type::dvec3_type),     \
 1592                 _##NAME(fp64, glsl_type::dvec4_type),      \
 1593                 NULL);
 1594 
 1595 #define FI(NAME)                                \
 1596    add_function(#NAME,                          \
 1597                 _##NAME(glsl_type::float_type), \
 1598                 _##NAME(glsl_type::vec2_type),  \
 1599                 _##NAME(glsl_type::vec3_type),  \
 1600                 _##NAME(glsl_type::vec4_type),  \
 1601                 _##NAME(glsl_type::int_type),   \
 1602                 _##NAME(glsl_type::ivec2_type), \
 1603                 _##NAME(glsl_type::ivec3_type), \
 1604                 _##NAME(glsl_type::ivec4_type), \
 1605                 NULL);
 1606 
 1607 #define FI64(NAME)                                \
 1608    add_function(#NAME,                          \
 1609                 _##NAME(always_available, glsl_type::float_type), \
 1610                 _##NAME(always_available, glsl_type::vec2_type),  \
 1611                 _##NAME(always_available, glsl_type::vec3_type),  \
 1612                 _##NAME(always_available, glsl_type::vec4_type),  \
 1613                 _##NAME(always_available, glsl_type::int_type),   \
 1614                 _##NAME(always_available, glsl_type::ivec2_type), \
 1615                 _##NAME(always_available, glsl_type::ivec3_type), \
 1616                 _##NAME(always_available, glsl_type::ivec4_type), \
 1617                 _##NAME(fp64, glsl_type::double_type), \
 1618                 _##NAME(fp64, glsl_type::dvec2_type),  \
 1619                 _##NAME(fp64, glsl_type::dvec3_type),  \
 1620                 _##NAME(fp64, glsl_type::dvec4_type),  \
 1621                 _##NAME(int64, glsl_type::int64_t_type), \
 1622                 _##NAME(int64, glsl_type::i64vec2_type),  \
 1623                 _##NAME(int64, glsl_type::i64vec3_type),  \
 1624                 _##NAME(int64, glsl_type::i64vec4_type),  \
 1625                 NULL);
 1626 
 1627 #define FIUD_VEC(NAME)                                            \
 1628    add_function(#NAME,                                            \
 1629                 _##NAME(always_available, glsl_type::vec2_type),  \
 1630                 _##NAME(always_available, glsl_type::vec3_type),  \
 1631                 _##NAME(always_available, glsl_type::vec4_type),  \
 1632                                                                   \
 1633                 _##NAME(always_available, glsl_type::ivec2_type), \
 1634                 _##NAME(always_available, glsl_type::ivec3_type), \
 1635                 _##NAME(always_available, glsl_type::ivec4_type), \
 1636                                                                   \
 1637                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
 1638                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
 1639                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
 1640                 _##NAME(fp64, glsl_type::dvec2_type),  \
 1641                 _##NAME(fp64, glsl_type::dvec3_type),  \
 1642                 _##NAME(fp64, glsl_type::dvec4_type),  \
 1643                 _##NAME(int64, glsl_type::int64_t_type), \
 1644                 _##NAME(int64, glsl_type::i64vec2_type),  \
 1645                 _##NAME(int64, glsl_type::i64vec3_type),  \
 1646                 _##NAME(int64, glsl_type::i64vec4_type),  \
 1647                 _##NAME(int64, glsl_type::uint64_t_type), \
 1648                 _##NAME(int64, glsl_type::u64vec2_type),  \
 1649                 _##NAME(int64, glsl_type::u64vec3_type),  \
 1650                 _##NAME(int64, glsl_type::u64vec4_type),  \
 1651                 NULL);
 1652 
 1653 #define IU(NAME)                                \
 1654    add_function(#NAME,                          \
 1655                 _##NAME(glsl_type::int_type),   \
 1656                 _##NAME(glsl_type::ivec2_type), \
 1657                 _##NAME(glsl_type::ivec3_type), \
 1658                 _##NAME(glsl_type::ivec4_type), \
 1659                                                 \
 1660                 _##NAME(glsl_type::uint_type),  \
 1661                 _##NAME(glsl_type::uvec2_type), \
 1662                 _##NAME(glsl_type::uvec3_type), \
 1663                 _##NAME(glsl_type::uvec4_type), \
 1664                 NULL);
 1665 
 1666 #define FIUBD_VEC(NAME)                                           \
 1667    add_function(#NAME,                                            \
 1668                 _##NAME(always_available, glsl_type::vec2_type),  \
 1669                 _##NAME(always_available, glsl_type::vec3_type),  \
 1670                 _##NAME(always_available, glsl_type::vec4_type),  \
 1671                                                                   \
 1672                 _##NAME(always_available, glsl_type::ivec2_type), \
 1673                 _##NAME(always_available, glsl_type::ivec3_type), \
 1674                 _##NAME(always_available, glsl_type::ivec4_type), \
 1675                                                                   \
 1676                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \
 1677                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \
 1678                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \
 1679                                                                   \
 1680                 _##NAME(always_available, glsl_type::bvec2_type), \
 1681                 _##NAME(always_available, glsl_type::bvec3_type), \
 1682                 _##NAME(always_available, glsl_type::bvec4_type), \
 1683                                                                   \
 1684                 _##NAME(fp64, glsl_type::dvec2_type), \
 1685                 _##NAME(fp64, glsl_type::dvec3_type), \
 1686                 _##NAME(fp64, glsl_type::dvec4_type), \
 1687                 _##NAME(int64, glsl_type::int64_t_type), \
 1688                 _##NAME(int64, glsl_type::i64vec2_type),  \
 1689                 _##NAME(int64, glsl_type::i64vec3_type),  \
 1690                 _##NAME(int64, glsl_type::i64vec4_type),  \
 1691                 _##NAME(int64, glsl_type::uint64_t_type), \
 1692                 _##NAME(int64, glsl_type::u64vec2_type),  \
 1693                 _##NAME(int64, glsl_type::u64vec3_type),  \
 1694                 _##NAME(int64, glsl_type::u64vec4_type),  \
 1695                 NULL);
 1696 
 1697 #define FIUD2_MIXED(NAME)                                                                 \
 1698    add_function(#NAME,                                                                   \
 1699                 _##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \
 1700                 _##NAME(always_available, glsl_type::vec2_type,  glsl_type::float_type), \
 1701                 _##NAME(always_available, glsl_type::vec3_type,  glsl_type::float_type), \
 1702                 _##NAME(always_available, glsl_type::vec4_type,  glsl_type::float_type), \
 1703                                                                                          \
 1704                 _##NAME(always_available, glsl_type::vec2_type,  glsl_type::vec2_type),  \
 1705                 _##NAME(always_available, glsl_type::vec3_type,  glsl_type::vec3_type),  \
 1706                 _##NAME(always_available, glsl_type::vec4_type,  glsl_type::vec4_type),  \
 1707                                                                                          \
 1708                 _##NAME(always_available, glsl_type::int_type,   glsl_type::int_type),   \
 1709                 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type),   \
 1710                 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type),   \
 1711                 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type),   \
 1712                                                                                          \
 1713                 _##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \
 1714                 _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \
 1715                 _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \
 1716                                                                                          \
 1717                 _##NAME(v130_or_gpu_shader4, glsl_type::uint_type,  glsl_type::uint_type),  \
 1718                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uint_type),  \
 1719                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uint_type),  \
 1720                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uint_type),  \
 1721                                                                                          \
 1722                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uvec2_type), \
 1723                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uvec3_type), \
 1724                 _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uvec4_type), \
 1725                                                                                          \
 1726                 _##NAME(fp64, glsl_type::double_type, glsl_type::double_type),           \
 1727                 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type),           \
 1728                 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type),           \
 1729                 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type),           \
 1730                 _##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),           \
 1731                 _##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),           \
 1732                 _##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),           \
 1733                                                                         \
 1734                 _##NAME(int64, glsl_type::int64_t_type, glsl_type::int64_t_type),           \
 1735                 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::int64_t_type),           \
 1736                 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::int64_t_type),           \
 1737                 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::int64_t_type),           \
 1738                 _##NAME(int64, glsl_type::i64vec2_type, glsl_type::i64vec2_type),           \
 1739                 _##NAME(int64, glsl_type::i64vec3_type, glsl_type::i64vec3_type),           \
 1740                 _##NAME(int64, glsl_type::i64vec4_type, glsl_type::i64vec4_type),           \
 1741                 _##NAME(int64, glsl_type::uint64_t_type, glsl_type::uint64_t_type),           \
 1742                 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::uint64_t_type),           \
 1743                 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::uint64_t_type),           \
 1744                 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::uint64_t_type),           \
 1745                 _##NAME(int64, glsl_type::u64vec2_type, glsl_type::u64vec2_type),           \
 1746                 _##NAME(int64, glsl_type::u64vec3_type, glsl_type::u64vec3_type),           \
 1747                 _##NAME(int64, glsl_type::u64vec4_type, glsl_type::u64vec4_type),           \
 1748                 NULL);
 1749 
 1750    F(radians)
 1751    F(degrees)
 1752    F(sin)
 1753    F(cos)
 1754    F(tan)
 1755    F(asin)
 1756    F(acos)
 1757 
 1758    add_function("atan",
 1759                 _atan(glsl_type::float_type),
 1760                 _atan(glsl_type::vec2_type),
 1761                 _atan(glsl_type::vec3_type),
 1762                 _atan(glsl_type::vec4_type),
 1763                 _atan2(glsl_type::float_type),
 1764                 _atan2(glsl_type::vec2_type),
 1765                 _atan2(glsl_type::vec3_type),
 1766                 _atan2(glsl_type::vec4_type),
 1767                 _atan_op(glsl_type::float_type),
 1768                 _atan_op(glsl_type::vec2_type),
 1769                 _atan_op(glsl_type::vec3_type),
 1770                 _atan_op(glsl_type::vec4_type),
 1771                 _atan2_op(glsl_type::float_type),
 1772                 _atan2_op(glsl_type::vec2_type),
 1773                 _atan2_op(glsl_type::vec3_type),
 1774                 _atan2_op(glsl_type::vec4_type),
 1775                 NULL);
 1776 
 1777    F(sinh)
 1778    F(cosh)
 1779    F(tanh)
 1780    F(asinh)
 1781    F(acosh)
 1782    F(atanh)
 1783    F(pow)
 1784    F(exp)
 1785    F(log)
 1786    F(exp2)
 1787    F(log2)
 1788    FD(sqrt)
 1789    FD(inversesqrt)
 1790    FI64(abs)
 1791    FI64(sign)
 1792    FD(floor)
 1793    FD(trunc)
 1794    FD(round)
 1795    FD(roundEven)
 1796    FD(ceil)
 1797    FD(fract)
 1798 
 1799    add_function("truncate",
 1800                 _truncate(gpu_shader4, glsl_type::float_type),
 1801                 _truncate(gpu_shader4, glsl_type::vec2_type),
 1802                 _truncate(gpu_shader4, glsl_type::vec3_type),
 1803                 _truncate(gpu_shader4, glsl_type::vec4_type),
 1804                 NULL);
 1805 
 1806 
 1807    add_function("mod",
 1808                 _mod(always_available, glsl_type::float_type, glsl_type::float_type),
 1809                 _mod(always_available, glsl_type::vec2_type,  glsl_type::float_type),
 1810                 _mod(always_available, glsl_type::vec3_type,  glsl_type::float_type),
 1811                 _mod(always_available, glsl_type::vec4_type,  glsl_type::float_type),
 1812 
 1813                 _mod(always_available, glsl_type::vec2_type,  glsl_type::vec2_type),
 1814                 _mod(always_available, glsl_type::vec3_type,  glsl_type::vec3_type),
 1815                 _mod(always_available, glsl_type::vec4_type,  glsl_type::vec4_type),
 1816 
 1817                 _mod(fp64, glsl_type::double_type, glsl_type::double_type),
 1818                 _mod(fp64, glsl_type::dvec2_type,  glsl_type::double_type),
 1819                 _mod(fp64, glsl_type::dvec3_type,  glsl_type::double_type),
 1820                 _mod(fp64, glsl_type::dvec4_type,  glsl_type::double_type),
 1821 
 1822                 _mod(fp64, glsl_type::dvec2_type,  glsl_type::dvec2_type),
 1823                 _mod(fp64, glsl_type::dvec3_type,  glsl_type::dvec3_type),
 1824                 _mod(fp64, glsl_type::dvec4_type,  glsl_type::dvec4_type),
 1825                 NULL);
 1826 
 1827    FD(modf)
 1828 
 1829    FIUD2_MIXED(min)
 1830    FIUD2_MIXED(max)
 1831    FIUD2_MIXED(clamp)
 1832 
 1833    add_function("mix",
 1834                 _mix_lrp(always_available, glsl_type::float_type, glsl_type::float_type),
 1835                 _mix_lrp(always_available, glsl_type::vec2_type,  glsl_type::float_type),
 1836                 _mix_lrp(always_available, glsl_type::vec3_type,  glsl_type::float_type),
 1837                 _mix_lrp(always_available, glsl_type::vec4_type,  glsl_type::float_type),
 1838 
 1839                 _mix_lrp(always_available, glsl_type::vec2_type,  glsl_type::vec2_type),
 1840                 _mix_lrp(always_available, glsl_type::vec3_type,  glsl_type::vec3_type),
 1841                 _mix_lrp(always_available, glsl_type::vec4_type,  glsl_type::vec4_type),
 1842 
 1843                 _mix_lrp(fp64, glsl_type::double_type, glsl_type::double_type),
 1844                 _mix_lrp(fp64, glsl_type::dvec2_type,  glsl_type::double_type),
 1845                 _mix_lrp(fp64, glsl_type::dvec3_type,  glsl_type::double_type),
 1846                 _mix_lrp(fp64, glsl_type::dvec4_type,  glsl_type::double_type),
 1847 
 1848                 _mix_lrp(fp64, glsl_type::dvec2_type,  glsl_type::dvec2_type),
 1849                 _mix_lrp(fp64, glsl_type::dvec3_type,  glsl_type::dvec3_type),
 1850                 _mix_lrp(fp64, glsl_type::dvec4_type,  glsl_type::dvec4_type),
 1851 
 1852                 _mix_sel(v130, glsl_type::float_type, glsl_type::bool_type),
 1853                 _mix_sel(v130, glsl_type::vec2_type,  glsl_type::bvec2_type),
 1854                 _mix_sel(v130, glsl_type::vec3_type,  glsl_type::bvec3_type),
 1855                 _mix_sel(v130, glsl_type::vec4_type,  glsl_type::bvec4_type),
 1856 
 1857                 _mix_sel(fp64, glsl_type::double_type, glsl_type::bool_type),
 1858                 _mix_sel(fp64, glsl_type::dvec2_type,  glsl_type::bvec2_type),
 1859                 _mix_sel(fp64, glsl_type::dvec3_type,  glsl_type::bvec3_type),
 1860                 _mix_sel(fp64, glsl_type::dvec4_type,  glsl_type::bvec4_type),
 1861 
 1862                 _mix_sel(shader_integer_mix, glsl_type::int_type,   glsl_type::bool_type),
 1863                 _mix_sel(shader_integer_mix, glsl_type::ivec2_type, glsl_type::bvec2_type),
 1864                 _mix_sel(shader_integer_mix, glsl_type::ivec3_type, glsl_type::bvec3_type),
 1865                 _mix_sel(shader_integer_mix, glsl_type::ivec4_type, glsl_type::bvec4_type),
 1866 
 1867                 _mix_sel(shader_integer_mix, glsl_type::uint_type,  glsl_type::bool_type),
 1868                 _mix_sel(shader_integer_mix, glsl_type::uvec2_type, glsl_type::bvec2_type),
 1869                 _mix_sel(shader_integer_mix, glsl_type::uvec3_type, glsl_type::bvec3_type),
 1870                 _mix_sel(shader_integer_mix, glsl_type::uvec4_type, glsl_type::bvec4_type),
 1871 
 1872                 _mix_sel(shader_integer_mix, glsl_type::bool_type,  glsl_type::bool_type),
 1873                 _mix_sel(shader_integer_mix, glsl_type::bvec2_type, glsl_type::bvec2_type),
 1874                 _mix_sel(shader_integer_mix, glsl_type::bvec3_type, glsl_type::bvec3_type),
 1875                 _mix_sel(shader_integer_mix, glsl_type::bvec4_type, glsl_type::bvec4_type),
 1876 
 1877                 _mix_sel(int64, glsl_type::int64_t_type, glsl_type::bool_type),
 1878                 _mix_sel(int64, glsl_type::i64vec2_type, glsl_type::bvec2_type),
 1879                 _mix_sel(int64, glsl_type::i64vec3_type, glsl_type::bvec3_type),
 1880                 _mix_sel(int64, glsl_type::i64vec4_type, glsl_type::bvec4_type),
 1881 
 1882                 _mix_sel(int64, glsl_type::uint64_t_type,  glsl_type::bool_type),
 1883                 _mix_sel(int64, glsl_type::u64vec2_type, glsl_type::bvec2_type),
 1884                 _mix_sel(int64, glsl_type::u64vec3_type, glsl_type::bvec3_type),
 1885                 _mix_sel(int64, glsl_type::u64vec4_type, glsl_type::bvec4_type),
 1886                 NULL);
 1887 
 1888    add_function("step",
 1889                 _step(always_available, glsl_type::float_type, glsl_type::float_type),
 1890                 _step(always_available, glsl_type::float_type, glsl_type::vec2_type),
 1891                 _step(always_available, glsl_type::float_type, glsl_type::vec3_type),
 1892                 _step(always_available, glsl_type::float_type, glsl_type::vec4_type),
 1893 
 1894                 _step(always_available, glsl_type::vec2_type,  glsl_type::vec2_type),
 1895                 _step(always_available, glsl_type::vec3_type,  glsl_type::vec3_type),
 1896                 _step(always_available, glsl_type::vec4_type,  glsl_type::vec4_type),
 1897                 _step(fp64, glsl_type::double_type, glsl_type::double_type),
 1898                 _step(fp64, glsl_type::double_type, glsl_type::dvec2_type),
 1899                 _step(fp64, glsl_type::double_type, glsl_type::dvec3_type),
 1900                 _step(fp64, glsl_type::double_type, glsl_type::dvec4_type),
 1901 
 1902                 _step(fp64, glsl_type::dvec2_type,  glsl_type::dvec2_type),
 1903                 _step(fp64, glsl_type::dvec3_type,  glsl_type::dvec3_type),
 1904                 _step(fp64, glsl_type::dvec4_type,  glsl_type::dvec4_type),
 1905                 NULL);
 1906 
 1907    add_function("smoothstep",
 1908                 _smoothstep(always_available, glsl_type::float_type, glsl_type::float_type),
 1909                 _smoothstep(always_available, glsl_type::float_type, glsl_type::vec2_type),
 1910                 _smoothstep(always_available, glsl_type::float_type, glsl_type::vec3_type),
 1911                 _smoothstep(always_available, glsl_type::float_type, glsl_type::vec4_type),
 1912 
 1913                 _smoothstep(always_available, glsl_type::vec2_type,  glsl_type::vec2_type),
 1914                 _smoothstep(always_available, glsl_type::vec3_type,  glsl_type::vec3_type),
 1915                 _smoothstep(always_available, glsl_type::vec4_type,  glsl_type::vec4_type),
 1916                 _smoothstep(fp64, glsl_type::double_type, glsl_type::double_type),
 1917                 _smoothstep(fp64, glsl_type::double_type, glsl_type::dvec2_type),
 1918                 _smoothstep(fp64, glsl_type::double_type, glsl_type::dvec3_type),
 1919                 _smoothstep(fp64, glsl_type::double_type, glsl_type::dvec4_type),
 1920 
 1921                 _smoothstep(fp64, glsl_type::dvec2_type,  glsl_type::dvec2_type),
 1922                 _smoothstep(fp64, glsl_type::dvec3_type,  glsl_type::dvec3_type),
 1923                 _smoothstep(fp64, glsl_type::dvec4_type,  glsl_type::dvec4_type),
 1924                 NULL);
 1925 
 1926    FD130(isnan)
 1927    FD130(isinf)
 1928 
 1929    F(floatBitsToInt)
 1930    F(floatBitsToUint)
 1931    add_function("intBitsToFloat",
 1932                 _intBitsToFloat(glsl_type::int_type),
 1933                 _intBitsToFloat(glsl_type::ivec2_type),
 1934                 _intBitsToFloat(glsl_type::ivec3_type),
 1935                 _intBitsToFloat(glsl_type::ivec4_type),
 1936                 NULL);
 1937    add_function("uintBitsToFloat",
 1938                 _uintBitsToFloat(glsl_type::uint_type),
 1939                 _uintBitsToFloat(glsl_type::uvec2_type),
 1940                 _uintBitsToFloat(glsl_type::uvec3_type),
 1941                 _uintBitsToFloat(glsl_type::uvec4_type),
 1942                 NULL);
 1943 
 1944    add_function("doubleBitsToInt64",
 1945                 _doubleBitsToInt64(int64_fp64, glsl_type::double_type),
 1946                 _doubleBitsToInt64(int64_fp64, glsl_type::dvec2_type),
 1947                 _doubleBitsToInt64(int64_fp64, glsl_type::dvec3_type),
 1948                 _doubleBitsToInt64(int64_fp64, glsl_type::dvec4_type),
 1949                 NULL);
 1950 
 1951    add_function("doubleBitsToUint64",
 1952                 _doubleBitsToUint64(int64_fp64, glsl_type::double_type),
 1953                 _doubleBitsToUint64(int64_fp64, glsl_type::dvec2_type),
 1954                 _doubleBitsToUint64(int64_fp64, glsl_type::dvec3_type),
 1955                 _doubleBitsToUint64(int64_fp64, glsl_type::dvec4_type),
 1956                 NULL);
 1957 
 1958    add_function("int64BitsToDouble",
 1959                 _int64BitsToDouble(int64_fp64, glsl_type::int64_t_type),
 1960                 _int64BitsToDouble(int64_fp64, glsl_type::i64vec2_type),
 1961                 _int64BitsToDouble(int64_fp64, glsl_type::i64vec3_type),
 1962                 _int64BitsToDouble(int64_fp64, glsl_type::i64vec4_type),
 1963                 NULL);
 1964 
 1965    add_function("uint64BitsToDouble",
 1966                 _uint64BitsToDouble(int64_fp64, glsl_type::uint64_t_type),
 1967                 _uint64BitsToDouble(int64_fp64, glsl_type::u64vec2_type),
 1968                 _uint64BitsToDouble(int64_fp64, glsl_type::u64vec3_type),
 1969                 _uint64BitsToDouble(int64_fp64, glsl_type::u64vec4_type),
 1970                 NULL);
 1971 
 1972    add_function("packUnorm2x16",   _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5),   NULL);
 1973    add_function("packSnorm2x16",   _packSnorm2x16(shader_packing_or_es3),                  NULL);
 1974    add_function("packUnorm4x8",    _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5),   NULL);
 1975    add_function("packSnorm4x8",    _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5),   NULL);
 1976    add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
 1977    add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3),                NULL);
 1978    add_function("unpackUnorm4x8",  _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
 1979    add_function("unpackSnorm4x8",  _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
 1980    add_function("packHalf2x16",    _packHalf2x16(shader_packing_or_es3),                   NULL);
 1981    add_function("unpackHalf2x16",  _unpackHalf2x16(shader_packing_or_es3),                 NULL);
 1982    add_function("packDouble2x32",    _packDouble2x32(fp64),                   NULL);
 1983    add_function("unpackDouble2x32",  _unpackDouble2x32(fp64),                 NULL);
 1984 
 1985    add_function("packInt2x32",     _packInt2x32(int64),                    NULL);
 1986    add_function("unpackInt2x32",   _unpackInt2x32(int64),                  NULL);
 1987    add_function("packUint2x32",    _packUint2x32(int64),                   NULL);
 1988    add_function("unpackUint2x32",  _unpackUint2x32(int64),                 NULL);
 1989 
 1990    FD(length)
 1991    FD(distance)
 1992    FD(dot)
 1993 
 1994    add_function("cross", _cross(always_available, glsl_type::vec3_type),
 1995                 _cross(fp64, glsl_type::dvec3_type), NULL);
 1996 
 1997    FD(normalize)
 1998    add_function("ftransform", _ftransform(), NULL);
 1999    FD(faceforward)
 2000    FD(reflect)
 2001    FD(refract)
 2002    // ...
 2003    add_function("matrixCompMult",
 2004                 _matrixCompMult(always_available, glsl_type::mat2_type),
 2005                 _matrixCompMult(always_available, glsl_type::mat3_type),
 2006                 _matrixCompMult(always_available, glsl_type::mat4_type),
 2007                 _matrixCompMult(always_available, glsl_type::mat2x3_type),
 2008                 _matrixCompMult(always_available, glsl_type::mat2x4_type),
 2009                 _matrixCompMult(always_available, glsl_type::mat3x2_type),
 2010                 _matrixCompMult(always_available, glsl_type::mat3x4_type),
 2011                 _matrixCompMult(always_available, glsl_type::mat4x2_type),
 2012                 _matrixCompMult(always_available, glsl_type::mat4x3_type),
 2013                 _matrixCompMult(fp64, glsl_type::dmat2_type),
 2014                 _matrixCompMult(fp64, glsl_type::dmat3_type),
 2015                 _matrixCompMult(fp64, glsl_type::dmat4_type),
 2016                 _matrixCompMult(fp64, glsl_type::dmat2x3_type),
 2017                 _matrixCompMult(fp64, glsl_type::dmat2x4_type),
 2018                 _matrixCompMult(fp64, glsl_type::dmat3x2_type),
 2019                 _matrixCompMult(fp64, glsl_type::dmat3x4_type),
 2020                 _matrixCompMult(fp64, glsl_type::dmat4x2_type),
 2021                 _matrixCompMult(fp64, glsl_type::dmat4x3_type),
 2022                 NULL);
 2023    add_function("outerProduct",
 2024                 _outerProduct(v120, glsl_type::mat2_type),
 2025                 _outerProduct(v120, glsl_type::mat3_type),
 2026                 _outerProduct(v120, glsl_type::mat4_type),
 2027                 _outerProduct(v120, glsl_type::mat2x3_type),
 2028                 _outerProduct(v120, glsl_type::mat2x4_type),
 2029                 _outerProduct(v120, glsl_type::mat3x2_type),
 2030                 _outerProduct(v120, glsl_type::mat3x4_type),
 2031                 _outerProduct(v120, glsl_type::mat4x2_type),
 2032                 _outerProduct(v120, glsl_type::mat4x3_type),
 2033                 _outerProduct(fp64, glsl_type::dmat2_type),
 2034                 _outerProduct(fp64, glsl_type::dmat3_type),
 2035                 _outerProduct(fp64, glsl_type::dmat4_type),
 2036                 _outerProduct(fp64, glsl_type::dmat2x3_type),
 2037                 _outerProduct(fp64, glsl_type::dmat2x4_type),
 2038                 _outerProduct(fp64, glsl_type::dmat3x2_type),
 2039                 _outerProduct(fp64, glsl_type::dmat3x4_type),
 2040                 _outerProduct(fp64, glsl_type::dmat4x2_type),
 2041                 _outerProduct(fp64, glsl_type::dmat4x3_type),
 2042                 NULL);
 2043    add_function("determinant",
 2044                 _determinant_mat2(v120, glsl_type::mat2_type),
 2045                 _determinant_mat3(v120, glsl_type::mat3_type),
 2046                 _determinant_mat4(v120, glsl_type::mat4_type),
 2047                 _determinant_mat2(fp64, glsl_type::dmat2_type),
 2048                 _determinant_mat3(fp64, glsl_type::dmat3_type),
 2049                 _determinant_mat4(fp64, glsl_type::dmat4_type),
 2050 
 2051                 NULL);
 2052    add_function("inverse",
 2053                 _inverse_mat2(v140_or_es3, glsl_type::mat2_type),
 2054                 _inverse_mat3(v140_or_es3, glsl_type::mat3_type),
 2055                 _inverse_mat4(v140_or_es3, glsl_type::mat4_type),
 2056                 _inverse_mat2(fp64, glsl_type::dmat2_type),
 2057                 _inverse_mat3(fp64, glsl_type::dmat3_type),
 2058                 _inverse_mat4(fp64, glsl_type::dmat4_type),
 2059                 NULL);
 2060    add_function("transpose",
 2061                 _transpose(v120, glsl_type::mat2_type),
 2062                 _transpose(v120, glsl_type::mat3_type),
 2063                 _transpose(v120, glsl_type::mat4_type),
 2064                 _transpose(v120, glsl_type::mat2x3_type),
 2065                 _transpose(v120, glsl_type::mat2x4_type),
 2066                 _transpose(v120, glsl_type::mat3x2_type),
 2067                 _transpose(v120, glsl_type::mat3x4_type),
 2068                 _transpose(v120, glsl_type::mat4x2_type),
 2069                 _transpose(v120, glsl_type::mat4x3_type),
 2070                 _transpose(fp64, glsl_type::dmat2_type),
 2071                 _transpose(fp64, glsl_type::dmat3_type),
 2072                 _transpose(fp64, glsl_type::dmat4_type),
 2073                 _transpose(fp64, glsl_type::dmat2x3_type),
 2074                 _transpose(fp64, glsl_type::dmat2x4_type),
 2075                 _transpose(fp64, glsl_type::dmat3x2_type),
 2076                 _transpose(fp64, glsl_type::dmat3x4_type),
 2077                 _transpose(fp64, glsl_type::dmat4x2_type),
 2078                 _transpose(fp64, glsl_type::dmat4x3_type),
 2079                 NULL);
 2080    FIUD_VEC(lessThan)
 2081    FIUD_VEC(lessThanEqual)
 2082    FIUD_VEC(greaterThan)
 2083    FIUD_VEC(greaterThanEqual)
 2084    FIUBD_VEC(notEqual)
 2085    FIUBD_VEC(equal)
 2086 
 2087    add_function("any",
 2088                 _any(glsl_type::bvec2_type),
 2089                 _any(glsl_type::bvec3_type),
 2090                 _any(glsl_type::bvec4_type),
 2091                 NULL);
 2092 
 2093    add_function("all",
 2094                 _all(glsl_type::bvec2_type),
 2095                 _all(glsl_type::bvec3_type),
 2096                 _all(glsl_type::bvec4_type),
 2097                 NULL);
 2098 
 2099    add_function("not",
 2100                 _not(glsl_type::bvec2_type),
 2101                 _not(glsl_type::bvec3_type),
 2102                 _not(glsl_type::bvec4_type),
 2103                 NULL);
 2104 
 2105    add_function("textureSize",
 2106                 _textureSize(v130, glsl_type::int_type,   glsl_type::sampler1D_type),
 2107                 _textureSize(v130, glsl_type::int_type,   glsl_type::isampler1D_type),
 2108                 _textureSize(v130, glsl_type::int_type,   glsl_type::usampler1D_type),
 2109 
 2110                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2D_type),
 2111                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler2D_type),
 2112                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler2D_type),
 2113 
 2114                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler3D_type),
 2115                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::isampler3D_type),
 2116                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::usampler3D_type),
 2117 
 2118                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::samplerCube_type),
 2119                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isamplerCube_type),
 2120                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usamplerCube_type),
 2121 
 2122                 _textureSize(v130, glsl_type::int_type,   glsl_type::sampler1DShadow_type),
 2123                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DShadow_type),
 2124                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::samplerCubeShadow_type),
 2125 
 2126                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler1DArray_type),
 2127                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler1DArray_type),
 2128                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler1DArray_type),
 2129                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler2DArray_type),
 2130                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::isampler2DArray_type),
 2131                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::usampler2DArray_type),
 2132 
 2133                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler1DArrayShadow_type),
 2134                 _textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler2DArrayShadow_type),
 2135 
 2136                 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::samplerCubeArray_type),
 2137                 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::isamplerCubeArray_type),
 2138                 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::usamplerCubeArray_type),
 2139                 _textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::samplerCubeArrayShadow_type),
 2140 
 2141                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DRect_type),
 2142                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler2DRect_type),
 2143                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler2DRect_type),
 2144                 _textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DRectShadow_type),
 2145 
 2146                 _textureSize(texture_buffer, glsl_type::int_type,   glsl_type::samplerBuffer_type),
 2147                 _textureSize(texture_buffer, glsl_type::int_type,   glsl_type::isamplerBuffer_type),
 2148                 _textureSize(texture_buffer, glsl_type::int_type,   glsl_type::usamplerBuffer_type),
 2149                 _textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::sampler2DMS_type),
 2150                 _textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::isampler2DMS_type),
 2151                 _textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::usampler2DMS_type),
 2152 
 2153                 _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::sampler2DMSArray_type),
 2154                 _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::isampler2DMSArray_type),
 2155                 _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::usampler2DMSArray_type),
 2156 
 2157                 _textureSize(texture_external_es3, glsl_type::ivec2_type, glsl_type::samplerExternalOES_type),
 2158                 NULL);
 2159 
 2160    add_function("textureSize1D",
 2161                 _textureSize(gpu_shader4, glsl_type::int_type,   glsl_type::sampler1D_type),
 2162                 _textureSize(gpu_shader4_integer, glsl_type::int_type,   glsl_type::isampler1D_type),
 2163                 _textureSize(gpu_shader4_integer, glsl_type::int_type,   glsl_type::usampler1D_type),
 2164                 NULL);
 2165 
 2166    add_function("textureSize2D",
 2167                 _textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::sampler2D_type),
 2168                 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isampler2D_type),
 2169                 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usampler2D_type),
 2170                 NULL);
 2171 
 2172    add_function("textureSize3D",
 2173                 _textureSize(gpu_shader4, glsl_type::ivec3_type, glsl_type::sampler3D_type),
 2174                 _textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::isampler3D_type),
 2175                 _textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::usampler3D_type),
 2176                 NULL);
 2177 
 2178    add_function("textureSizeCube",
 2179                 _textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::samplerCube_type),
 2180                 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isamplerCube_type),
 2181                 _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usamplerCube_type),
 2182                 NULL);
 2183 
 2184    add_function("textureSize1DArray",
 2185                 _textureSize(gpu_shader4_array,         glsl_type::ivec2_type, glsl_type::sampler1DArray_type),
 2186                 _textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::isampler1DArray_type),
 2187                 _textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::usampler1DArray_type),
 2188                 NULL);
 2189 
 2190    add_function("textureSize2DArray",
 2191                 _textureSize(gpu_shader4_array,         glsl_type::ivec3_type, glsl_type::sampler2DArray_type),
 2192                 _textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::isampler2DArray_type),
 2193                 _textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::usampler2DArray_type),
 2194                 NULL);
 2195 
 2196    add_function("textureSize2DRect",
 2197                 _textureSize(gpu_shader4_rect,         glsl_type::ivec2_type, glsl_type::sampler2DRect_type),
 2198                 _textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::isampler2DRect_type),
 2199                 _textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::usampler2DRect_type),
 2200                 NULL);
 2201 
 2202    add_function("textureSizeBuffer",
 2203                 _textureSize(gpu_shader4_tbo,         glsl_type::int_type,   glsl_type::samplerBuffer_type),
 2204                 _textureSize(gpu_shader4_tbo_integer, glsl_type::int_type,   glsl_type::isamplerBuffer_type),
 2205                 _textureSize(gpu_shader4_tbo_integer, glsl_type::int_type,   glsl_type::usamplerBuffer_type),
 2206                 NULL);
 2207 
 2208    add_function("textureSamples",
 2209                 _textureSamples(shader_samples, glsl_type::sampler2DMS_type),
 2210                 _textureSamples(shader_samples, glsl_type::isampler2DMS_type),
 2211                 _textureSamples(shader_samples, glsl_type::usampler2DMS_type),
 2212 
 2213                 _textureSamples(shader_samples, glsl_type::sampler2DMSArray_type),
 2214                 _textureSamples(shader_samples, glsl_type::isampler2DMSArray_type),
 2215                 _textureSamples(shader_samples, glsl_type::usampler2DMSArray_type),
 2216                 NULL);
 2217 
 2218    add_function("texture",
 2219                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type),
 2220                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
 2221                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
 2222 
 2223                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type),
 2224                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
 2225                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
 2226 
 2227                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type),
 2228                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
 2229                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
 2230 
 2231                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::samplerCube_type,  glsl_type::vec3_type),
 2232                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
 2233                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
 2234 
 2235                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type,   glsl_type::vec3_type),
 2236                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type,   glsl_type::vec3_type),
 2237                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 2238 
 2239                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type),
 2240                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 2241                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 2242 
 2243                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type),
 2244                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 2245                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 2246 
 2247                 _texture(ir_tex, texture_cube_map_array, glsl_type::vec4_type,  glsl_type::samplerCubeArray_type,  glsl_type::vec4_type),
 2248                 _texture(ir_tex, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
 2249                 _texture(ir_tex, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
 2250 
 2251                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 2252                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 2253                 /* samplerCubeArrayShadow is special; it has an extra parameter
 2254                  * for the shadow comparator since there is no vec5 type.
 2255                  */
 2256                 _textureCubeArrayShadow(ir_tex, texture_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
 2257 
 2258                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec2_type),
 2259                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
 2260                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
 2261 
 2262                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
 2263 
 2264                 _texture(ir_tex, texture_external_es3, glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::vec2_type),
 2265 
 2266                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type),
 2267                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
 2268                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
 2269 
 2270                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type),
 2271                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
 2272                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
 2273 
 2274                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type),
 2275                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
 2276                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
 2277 
 2278                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::samplerCube_type,  glsl_type::vec3_type),
 2279                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
 2280                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
 2281 
 2282                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type,   glsl_type::vec3_type),
 2283                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type,   glsl_type::vec3_type),
 2284                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 2285 
 2286                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type),
 2287                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 2288                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 2289 
 2290                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type),
 2291                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 2292                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 2293 
 2294                 _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::vec4_type,  glsl_type::samplerCubeArray_type,  glsl_type::vec4_type),
 2295                 _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
 2296                 _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
 2297 
 2298                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 2299                 _texture(ir_tex, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 2300                 _texture(ir_txb, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 2301 
 2302                 _textureCubeArrayShadow(ir_tex, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
 2303                 _textureCubeArrayShadow(ir_txb, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
 2304                 NULL);
 2305 
 2306    add_function("textureLod",
 2307                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type),
 2308                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
 2309                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
 2310 
 2311                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type),
 2312                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
 2313                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
 2314 
 2315                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type),
 2316                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
 2317                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
 2318 
 2319                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::samplerCube_type,  glsl_type::vec3_type),
 2320                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
 2321                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
 2322 
 2323                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
 2324                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
 2325 
 2326                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type),
 2327                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 2328                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 2329 
 2330                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type),
 2331                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 2332                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 2333 
 2334                 _texture(ir_txl, texture_cube_map_array, glsl_type::vec4_type,  glsl_type::samplerCubeArray_type,  glsl_type::vec4_type),
 2335                 _texture(ir_txl, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
 2336                 _texture(ir_txl, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
 2337 
 2338                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 2339                 _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 2340                 _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 2341                 _textureCubeArrayShadow(ir_txl, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),
 2342                 NULL);
 2343 
 2344    add_function("textureOffset",
 2345                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2346                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2347                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2348 
 2349                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2350                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2351                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2352 
 2353                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 2354                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2355                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2356 
 2357                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec2_type, TEX_OFFSET),
 2358                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 2359                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 2360 
 2361                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2362 
 2363                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2364                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2365 
 2366                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 2367                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2368                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2369 
 2370                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 2371                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2372                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2373 
 2374                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2375                 /* The next one was forgotten in GLSL 1.30 spec. It's from
 2376                  * EXT_gpu_shader4 originally. It was added in 4.30 with the
 2377                  * wrong syntax. This was corrected in 4.40. 4.30 indicates
 2378                  * that it was intended to be included previously, so allow it
 2379                  * in 1.30.
 2380                  */
 2381                 _texture(ir_tex, v130_desktop, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 2382 
 2383                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2384                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2385                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2386 
 2387                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2388                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2389                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2390 
 2391                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 2392                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2393                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2394 
 2395                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2396                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2397 
 2398                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 2399                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2400                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2401 
 2402                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 2403                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2404                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2405 
 2406                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2407                 _texture(ir_tex, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 2408                 _texture(ir_txb, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 2409                 NULL);
 2410 
 2411    add_function("texture1DOffset",
 2412                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2413                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2414                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2415                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2416                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2417                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2418                 NULL);
 2419 
 2420    add_function("texture2DOffset",
 2421                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2422                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2423                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2424                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2425                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2426                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2427                 NULL);
 2428 
 2429    add_function("texture3DOffset",
 2430                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 2431                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2432                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2433                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 2434                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2435                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2436                 NULL);
 2437 
 2438    add_function("texture2DRectOffset",
 2439                 _texture(ir_tex, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec2_type, TEX_OFFSET),
 2440                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 2441                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 2442                 NULL);
 2443 
 2444    add_function("shadow2DRectOffset",
 2445                 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2446                 NULL);
 2447 
 2448    add_function("shadow1DOffset",
 2449                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2450                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2451                 NULL);
 2452 
 2453    add_function("shadow2DOffset",
 2454                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2455                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2456                 NULL);
 2457 
 2458    add_function("texture1DArrayOffset",
 2459                 _texture(ir_tex, gpu_shader4_array,                     glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 2460                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2461                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2462                 _texture(ir_txb, gpu_shader4_array_derivs_only,         glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 2463                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2464                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2465                 NULL);
 2466 
 2467    add_function("texture2DArrayOffset",
 2468                 _texture(ir_tex, gpu_shader4_array,                     glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 2469                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2470                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2471                 _texture(ir_txb, gpu_shader4_array_derivs_only,         glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 2472                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2473                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2474                 NULL);
 2475 
 2476    add_function("shadow1DArrayOffset",
 2477                 _texture(ir_tex, gpu_shader4_array,             glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2478                 _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2479                 NULL);
 2480 
 2481    add_function("shadow2DArrayOffset",
 2482                 _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 2483                 NULL);
 2484 
 2485    add_function("textureProj",
 2486                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT),
 2487                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 2488                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 2489                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2490                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 2491                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 2492 
 2493                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT),
 2494                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 2495                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 2496                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2497                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 2498                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 2499 
 2500                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2501                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 2502                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 2503 
 2504                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2505                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2506 
 2507                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec3_type, TEX_PROJECT),
 2508                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 2509                 _texture(ir_tex, texture_external_es3, glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),
 2510                 _texture(ir_tex, texture_external_es3, glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),
 2511 
 2512                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 2513                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec4_type, TEX_PROJECT),
 2514                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 2515                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 2516 
 2517                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2518 
 2519                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT),
 2520                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 2521                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 2522                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2523                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 2524                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 2525 
 2526                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT),
 2527                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 2528                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 2529                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2530                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 2531                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 2532 
 2533                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2534                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 2535                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 2536 
 2537                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2538                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2539                 NULL);
 2540 
 2541    add_function("texelFetch",
 2542                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::int_type),
 2543                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type),
 2544                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type),
 2545 
 2546                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::ivec2_type),
 2547                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type),
 2548                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type),
 2549 
 2550                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::ivec3_type),
 2551                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type),
 2552                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type),
 2553 
 2554                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::ivec2_type),
 2555                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type),
 2556                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type),
 2557 
 2558                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::ivec2_type),
 2559                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type),
 2560                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type),
 2561 
 2562                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::ivec3_type),
 2563                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type),
 2564                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type),
 2565 
 2566                 _texelFetch(texture_buffer, glsl_type::vec4_type,  glsl_type::samplerBuffer_type,  glsl_type::int_type),
 2567                 _texelFetch(texture_buffer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type),
 2568                 _texelFetch(texture_buffer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type),
 2569 
 2570                 _texelFetch(texture_multisample, glsl_type::vec4_type,  glsl_type::sampler2DMS_type,  glsl_type::ivec2_type),
 2571                 _texelFetch(texture_multisample, glsl_type::ivec4_type, glsl_type::isampler2DMS_type, glsl_type::ivec2_type),
 2572                 _texelFetch(texture_multisample, glsl_type::uvec4_type, glsl_type::usampler2DMS_type, glsl_type::ivec2_type),
 2573 
 2574                 _texelFetch(texture_multisample_array, glsl_type::vec4_type,  glsl_type::sampler2DMSArray_type,  glsl_type::ivec3_type),
 2575                 _texelFetch(texture_multisample_array, glsl_type::ivec4_type, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),
 2576                 _texelFetch(texture_multisample_array, glsl_type::uvec4_type, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),
 2577 
 2578                 _texelFetch(texture_external_es3, glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::ivec2_type),
 2579 
 2580                 NULL);
 2581 
 2582    add_function("texelFetch1D",
 2583                 _texelFetch(gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::int_type),
 2584                 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type),
 2585                 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type),
 2586                 NULL);
 2587 
 2588    add_function("texelFetch2D",
 2589                 _texelFetch(gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::ivec2_type),
 2590                 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type),
 2591                 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type),
 2592                 NULL);
 2593 
 2594    add_function("texelFetch3D",
 2595                 _texelFetch(gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::ivec3_type),
 2596                 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type),
 2597                 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type),
 2598                 NULL);
 2599 
 2600    add_function("texelFetch2DRect",
 2601                 _texelFetch(gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::ivec2_type),
 2602                 _texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type),
 2603                 _texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type),
 2604                 NULL);
 2605 
 2606    add_function("texelFetch1DArray",
 2607                 _texelFetch(gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::ivec2_type),
 2608                 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type),
 2609                 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type),
 2610                 NULL);
 2611 
 2612    add_function("texelFetch2DArray",
 2613                 _texelFetch(gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::ivec3_type),
 2614                 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type),
 2615                 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type),
 2616                 NULL);
 2617 
 2618    add_function("texelFetchBuffer",
 2619                 _texelFetch(gpu_shader4_tbo,         glsl_type::vec4_type,  glsl_type::samplerBuffer_type,  glsl_type::int_type),
 2620                 _texelFetch(gpu_shader4_tbo_integer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type),
 2621                 _texelFetch(gpu_shader4_tbo_integer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type),
 2622                 NULL);
 2623 
 2624    add_function("texelFetchOffset",
 2625                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::int_type, glsl_type::int_type),
 2626                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),
 2627                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type),
 2628 
 2629                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::ivec2_type, glsl_type::ivec2_type),
 2630                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2631                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2632 
 2633                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::ivec3_type, glsl_type::ivec3_type),
 2634                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
 2635                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
 2636 
 2637                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::ivec2_type, glsl_type::ivec2_type),
 2638                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2639                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2640 
 2641                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::ivec2_type, glsl_type::int_type),
 2642                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
 2643                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
 2644 
 2645                 _texelFetch(v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::ivec3_type, glsl_type::ivec2_type),
 2646                 _texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
 2647                 _texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
 2648 
 2649                 NULL);
 2650 
 2651    add_function("texelFetch1DOffset",
 2652                 _texelFetch(gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::int_type, glsl_type::int_type),
 2653                 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),
 2654                 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type),
 2655                 NULL);
 2656 
 2657    add_function("texelFetch2DOffset",
 2658                 _texelFetch(gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::ivec2_type, glsl_type::ivec2_type),
 2659                 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2660                 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2661                 NULL);
 2662 
 2663    add_function("texelFetch3DOffset",
 2664                 _texelFetch(gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::ivec3_type, glsl_type::ivec3_type),
 2665                 _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
 2666                 _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
 2667                 NULL);
 2668 
 2669    add_function("texelFetch2DRectOffset",
 2670                 _texelFetch(gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::ivec2_type, glsl_type::ivec2_type),
 2671                 _texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2672                 _texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
 2673                 NULL);
 2674 
 2675    add_function("texelFetch1DArrayOffset",
 2676                 _texelFetch(gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::ivec2_type, glsl_type::int_type),
 2677                 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
 2678                 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),
 2679                 NULL);
 2680 
 2681    add_function("texelFetch2DArrayOffset",
 2682                 _texelFetch(gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::ivec3_type, glsl_type::ivec2_type),
 2683                 _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
 2684                 _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),
 2685                 NULL);
 2686 
 2687    add_function("textureProjOffset",
 2688                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2689                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2690                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2691                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2692                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2693                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2694 
 2695                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2696                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2697                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2698                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2699                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2700                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2701 
 2702                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2703                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2704                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2705 
 2706                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2707                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2708 
 2709                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2710                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2711                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2712                 _texture(ir_tex, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2713                 _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2714                 _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2715 
 2716                 _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2717 
 2718                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2719                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2720                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2721                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2722                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2723                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2724 
 2725                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2726                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2727                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2728                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2729                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2730                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2731 
 2732                 _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2733                 _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2734                 _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2735 
 2736                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2737                 _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2738                 NULL);
 2739 
 2740    add_function("texture1DProjOffset",
 2741                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2742                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2743                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2744                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2745                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2746                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2747                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2748                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2749                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2750                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2751                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2752                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2753                 NULL);
 2754 
 2755    add_function("texture2DProjOffset",
 2756                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2757                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2758                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2759                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2760                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2761                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2762                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2763                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2764                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2765                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2766                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2767                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2768                 NULL);
 2769 
 2770    add_function("texture3DProjOffset",
 2771                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2772                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2773                 _texture(ir_tex, gpu_shader4_integer,     glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2774                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2775                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2776                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2777                 NULL);
 2778 
 2779    add_function("shadow1DProjOffset",
 2780                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2781                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2782                 NULL);
 2783 
 2784    add_function("shadow2DProjOffset",
 2785                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2786                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2787                 NULL);
 2788 
 2789    add_function("texture2DRectProjOffset",
 2790                 _texture(ir_tex, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2791                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2792                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2793                 _texture(ir_tex, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2794                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2795                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2796                 NULL);
 2797 
 2798    add_function("shadow2DRectProjOffset",
 2799                 _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2800                 NULL);
 2801 
 2802    add_function("textureLodOffset",
 2803                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2804                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2805                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2806 
 2807                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2808                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2809                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2810 
 2811                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 2812                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2813                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2814 
 2815                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2816                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2817 
 2818                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 2819                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2820                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2821 
 2822                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 2823                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2824                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2825 
 2826                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2827                 _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 2828                 NULL);
 2829 
 2830    add_function("texture1DLodOffset",
 2831                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2832                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2833                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2834                 NULL);
 2835 
 2836    add_function("texture2DLodOffset",
 2837                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2838                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2839                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 2840                 NULL);
 2841 
 2842    add_function("texture3DLodOffset",
 2843                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 2844                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2845                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 2846                 NULL);
 2847 
 2848    add_function("shadow1DLodOffset",
 2849                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2850                 NULL);
 2851 
 2852    add_function("shadow2DLodOffset",
 2853                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2854                 NULL);
 2855 
 2856    add_function("texture1DArrayLodOffset",
 2857                 _texture(ir_txl, gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 2858                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2859                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 2860                 NULL);
 2861 
 2862    add_function("texture2DArrayLodOffset",
 2863                 _texture(ir_txl, gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 2864                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2865                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 2866                 NULL);
 2867 
 2868    add_function("shadow1DArrayLodOffset",
 2869                 _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 2870                 NULL);
 2871 
 2872    add_function("textureProjLod",
 2873                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT),
 2874                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 2875                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 2876                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2877                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 2878                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 2879 
 2880                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT),
 2881                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 2882                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 2883                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2884                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 2885                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 2886 
 2887                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT),
 2888                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 2889                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 2890 
 2891                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2892                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 2893                 NULL);
 2894 
 2895    add_function("textureProjLodOffset",
 2896                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2897                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2898                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2899                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2900                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2901                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2902 
 2903                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2904                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2905                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2906                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2907                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2908                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2909 
 2910                 _texture(ir_txl, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2911                 _texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2912                 _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2913 
 2914                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2915                 _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2916                 NULL);
 2917 
 2918    add_function("texture1DProjLodOffset",
 2919                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2920                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2921                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 2922                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2923                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2924                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2925                 NULL);
 2926 
 2927    add_function("texture2DProjLodOffset",
 2928                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2929                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2930                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 2931                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2932                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2933                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2934                 NULL);
 2935 
 2936    add_function("texture3DProjLodOffset",
 2937                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2938                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2939                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2940                 NULL);
 2941 
 2942    add_function("shadow1DProjLodOffset",
 2943                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2944                 NULL);
 2945 
 2946    add_function("shadow2DProjLodOffset",
 2947                 _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 2948                 NULL);
 2949 
 2950    add_function("textureGrad",
 2951                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type),
 2952                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),
 2953                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),
 2954 
 2955                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type),
 2956                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
 2957                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
 2958 
 2959                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type),
 2960                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
 2961                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
 2962 
 2963                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::samplerCube_type,  glsl_type::vec3_type),
 2964                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
 2965                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
 2966 
 2967                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec2_type),
 2968                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
 2969                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
 2970 
 2971                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
 2972 
 2973                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type,   glsl_type::vec3_type),
 2974                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type,   glsl_type::vec3_type),
 2975                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 2976 
 2977                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type),
 2978                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 2979                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 2980 
 2981                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type),
 2982                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 2983                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 2984 
 2985                 _texture(ir_txd, texture_cube_map_array, glsl_type::vec4_type,  glsl_type::samplerCubeArray_type,  glsl_type::vec4_type),
 2986                 _texture(ir_txd, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
 2987                 _texture(ir_txd, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
 2988 
 2989                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 2990                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 2991                 NULL);
 2992 
 2993    add_function("textureGradOffset",
 2994                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 2995                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2996                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 2997 
 2998                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 2999                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 3000                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 3001 
 3002                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 3003                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 3004                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 3005 
 3006                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec2_type, TEX_OFFSET),
 3007                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 3008                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 3009 
 3010                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3011 
 3012                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3013                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3014 
 3015                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 3016                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 3017                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 3018 
 3019                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 3020                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 3021                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 3022 
 3023                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3024                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 3025                 NULL);
 3026 
 3027    add_function("texture1DGradOffset",
 3028                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::float_type, TEX_OFFSET),
 3029                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),
 3030                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),
 3031                 NULL);
 3032 
 3033    add_function("texture2DGradOffset",
 3034                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec2_type, TEX_OFFSET),
 3035                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 3036                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
 3037                 NULL);
 3038 
 3039    add_function("texture3DGradOffset",
 3040                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec3_type, TEX_OFFSET),
 3041                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 3042                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),
 3043                 NULL);
 3044 
 3045    add_function("texture2DRectGradOffset",
 3046                 _texture(ir_txd, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec2_type, TEX_OFFSET),
 3047                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 3048                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),
 3049                 NULL);
 3050 
 3051    add_function("shadow2DRectGradOffset",
 3052                 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3053                 NULL);
 3054 
 3055    add_function("shadow1DGradOffset",
 3056                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3057                 NULL);
 3058 
 3059    add_function("shadow2DGradOffset",
 3060                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3061                 NULL);
 3062 
 3063    add_function("texture1DArrayGradOffset",
 3064                 _texture(ir_txd, gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler1DArray_type,  glsl_type::vec2_type, TEX_OFFSET),
 3065                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 3066                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),
 3067                 NULL);
 3068 
 3069    add_function("texture2DArrayGradOffset",
 3070                 _texture(ir_txd, gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler2DArray_type,  glsl_type::vec3_type, TEX_OFFSET),
 3071                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 3072                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
 3073                 NULL);
 3074 
 3075    add_function("shadow1DArrayGradOffset",
 3076                 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
 3077                 NULL);
 3078 
 3079    add_function("shadow2DArrayGradOffset",
 3080                 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),
 3081                 NULL);
 3082 
 3083    add_function("textureProjGrad",
 3084                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT),
 3085                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3086                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3087                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT),
 3088                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3089                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3090 
 3091                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT),
 3092                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3093                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3094                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT),
 3095                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3096                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3097 
 3098                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT),
 3099                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3100                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3101 
 3102                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec3_type, TEX_PROJECT),
 3103                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3104                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3105                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec4_type, TEX_PROJECT),
 3106                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3107                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3108 
 3109                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3110 
 3111                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3112                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3113                 NULL);
 3114 
 3115    add_function("textureProjGradOffset",
 3116                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 3117                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 3118                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 3119                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3120                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3121                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3122 
 3123                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3124                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3125                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3126                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3127                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3128                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3129 
 3130                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3131                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3132                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3133 
 3134                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3135                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3136                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3137                 _texture(ir_txd, v130, glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3138                 _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3139                 _texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3140 
 3141                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3142 
 3143                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3144                 _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3145                 NULL);
 3146 
 3147    add_function("texture1DProjGradOffset",
 3148                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 3149                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 3150                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),
 3151                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3152                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3153                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3154                 NULL);
 3155 
 3156    add_function("texture2DProjGradOffset",
 3157                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3158                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3159                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3160                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3161                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3162                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3163                 NULL);
 3164 
 3165    add_function("texture3DProjGradOffset",
 3166                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3167                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3168                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3169                 NULL);
 3170 
 3171    add_function("texture2DRectProjGradOffset",
 3172                 _texture(ir_txd, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3173                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3174                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),
 3175                 _texture(ir_txd, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type,  glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3176                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3177                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3178                 NULL);
 3179 
 3180    add_function("shadow2DRectProjGradOffset",
 3181                 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3182                 NULL);
 3183 
 3184    add_function("shadow1DProjGradOffset",
 3185                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3186                 NULL);
 3187 
 3188    add_function("shadow2DProjGradOffset",
 3189                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),
 3190                 NULL);
 3191 
 3192    add_function("EmitVertex",   _EmitVertex(),   NULL);
 3193    add_function("EndPrimitive", _EndPrimitive(), NULL);
 3194    add_function("EmitStreamVertex",
 3195                 _EmitStreamVertex(gs_streams, glsl_type::uint_type),
 3196                 _EmitStreamVertex(gs_streams, glsl_type::int_type),
 3197                 NULL);
 3198    add_function("EndStreamPrimitive",
 3199                 _EndStreamPrimitive(gs_streams, glsl_type::uint_type),
 3200                 _EndStreamPrimitive(gs_streams, glsl_type::int_type),
 3201                 NULL);
 3202    add_function("barrier", _barrier(), NULL);
 3203 
 3204    add_function("textureQueryLOD",
 3205                 _textureQueryLod(texture_query_lod, glsl_type::sampler1D_type,  glsl_type::float_type),
 3206                 _textureQueryLod(texture_query_lod, glsl_type::isampler1D_type, glsl_type::float_type),
 3207                 _textureQueryLod(texture_query_lod, glsl_type::usampler1D_type, glsl_type::float_type),
 3208 
 3209                 _textureQueryLod(texture_query_lod, glsl_type::sampler2D_type,  glsl_type::vec2_type),
 3210                 _textureQueryLod(texture_query_lod, glsl_type::isampler2D_type, glsl_type::vec2_type),
 3211                 _textureQueryLod(texture_query_lod, glsl_type::usampler2D_type, glsl_type::vec2_type),
 3212 
 3213                 _textureQueryLod(texture_query_lod, glsl_type::sampler3D_type,  glsl_type::vec3_type),
 3214                 _textureQueryLod(texture_query_lod, glsl_type::isampler3D_type, glsl_type::vec3_type),
 3215                 _textureQueryLod(texture_query_lod, glsl_type::usampler3D_type, glsl_type::vec3_type),
 3216 
 3217                 _textureQueryLod(texture_query_lod, glsl_type::samplerCube_type,  glsl_type::vec3_type),
 3218                 _textureQueryLod(texture_query_lod, glsl_type::isamplerCube_type, glsl_type::vec3_type),
 3219                 _textureQueryLod(texture_query_lod, glsl_type::usamplerCube_type, glsl_type::vec3_type),
 3220 
 3221                 _textureQueryLod(texture_query_lod, glsl_type::sampler1DArray_type,  glsl_type::float_type),
 3222                 _textureQueryLod(texture_query_lod, glsl_type::isampler1DArray_type, glsl_type::float_type),
 3223                 _textureQueryLod(texture_query_lod, glsl_type::usampler1DArray_type, glsl_type::float_type),
 3224 
 3225                 _textureQueryLod(texture_query_lod, glsl_type::sampler2DArray_type,  glsl_type::vec2_type),
 3226                 _textureQueryLod(texture_query_lod, glsl_type::isampler2DArray_type, glsl_type::vec2_type),
 3227                 _textureQueryLod(texture_query_lod, glsl_type::usampler2DArray_type, glsl_type::vec2_type),
 3228 
 3229                 _textureQueryLod(texture_query_lod, glsl_type::samplerCubeArray_type,  glsl_type::vec3_type),
 3230                 _textureQueryLod(texture_query_lod, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type),
 3231                 _textureQueryLod(texture_query_lod, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type),
 3232 
 3233                 _textureQueryLod(texture_query_lod, glsl_type::sampler1DShadow_type, glsl_type::float_type),
 3234                 _textureQueryLod(texture_query_lod, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
 3235                 _textureQueryLod(texture_query_lod, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
 3236                 _textureQueryLod(texture_query_lod, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type),
 3237                 _textureQueryLod(texture_query_lod, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type),
 3238                 _textureQueryLod(texture_query_lod, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type),
 3239                 NULL);
 3240 
 3241    add_function("textureQueryLod",
 3242                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1D_type,  glsl_type::float_type),
 3243                 _textureQueryLod(v400_derivatives_only, glsl_type::isampler1D_type, glsl_type::float_type),
 3244                 _textureQueryLod(v400_derivatives_only, glsl_type::usampler1D_type, glsl_type::float_type),
 3245 
 3246                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2D_type,  glsl_type::vec2_type),
 3247                 _textureQueryLod(v400_derivatives_only, glsl_type::isampler2D_type, glsl_type::vec2_type),
 3248                 _textureQueryLod(v400_derivatives_only, glsl_type::usampler2D_type, glsl_type::vec2_type),
 3249 
 3250                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler3D_type,  glsl_type::vec3_type),
 3251                 _textureQueryLod(v400_derivatives_only, glsl_type::isampler3D_type, glsl_type::vec3_type),
 3252                 _textureQueryLod(v400_derivatives_only, glsl_type::usampler3D_type, glsl_type::vec3_type),
 3253 
 3254                 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCube_type,  glsl_type::vec3_type),
 3255                 _textureQueryLod(v400_derivatives_only, glsl_type::isamplerCube_type, glsl_type::vec3_type),
 3256                 _textureQueryLod(v400_derivatives_only, glsl_type::usamplerCube_type, glsl_type::vec3_type),
 3257 
 3258                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArray_type,  glsl_type::float_type),
 3259                 _textureQueryLod(v400_derivatives_only, glsl_type::isampler1DArray_type, glsl_type::float_type),
 3260                 _textureQueryLod(v400_derivatives_only, glsl_type::usampler1DArray_type, glsl_type::float_type),
 3261 
 3262                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArray_type,  glsl_type::vec2_type),
 3263                 _textureQueryLod(v400_derivatives_only, glsl_type::isampler2DArray_type, glsl_type::vec2_type),
 3264                 _textureQueryLod(v400_derivatives_only, glsl_type::usampler2DArray_type, glsl_type::vec2_type),
 3265 
 3266                 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArray_type,  glsl_type::vec3_type),
 3267                 _textureQueryLod(v400_derivatives_only, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type),
 3268                 _textureQueryLod(v400_derivatives_only, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type),
 3269 
 3270                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DShadow_type, glsl_type::float_type),
 3271                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
 3272                 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
 3273                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type),
 3274                 _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type),
 3275                 _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type),
 3276                 NULL);
 3277 
 3278    add_function("textureQueryLevels",
 3279                 _textureQueryLevels(texture_query_levels, glsl_type::sampler1D_type),
 3280                 _textureQueryLevels(texture_query_levels, glsl_type::sampler2D_type),
 3281                 _textureQueryLevels(texture_query_levels, glsl_type::sampler3D_type),
 3282                 _textureQueryLevels(texture_query_levels, glsl_type::samplerCube_type),
 3283                 _textureQueryLevels(texture_query_levels, glsl_type::sampler1DArray_type),
 3284                 _textureQueryLevels(texture_query_levels, glsl_type::sampler2DArray_type),
 3285                 _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArray_type),
 3286                 _textureQueryLevels(texture_query_levels, glsl_type::sampler1DShadow_type),
 3287                 _textureQueryLevels(texture_query_levels, glsl_type::sampler2DShadow_type),
 3288                 _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeShadow_type),
 3289                 _textureQueryLevels(texture_query_levels, glsl_type::sampler1DArrayShadow_type),
 3290                 _textureQueryLevels(texture_query_levels, glsl_type::sampler2DArrayShadow_type),
 3291                 _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArrayShadow_type),
 3292 
 3293                 _textureQueryLevels(texture_query_levels, glsl_type::isampler1D_type),
 3294                 _textureQueryLevels(texture_query_levels, glsl_type::isampler2D_type),
 3295                 _textureQueryLevels(texture_query_levels, glsl_type::isampler3D_type),
 3296                 _textureQueryLevels(texture_query_levels, glsl_type::isamplerCube_type),
 3297                 _textureQueryLevels(texture_query_levels, glsl_type::isampler1DArray_type),
 3298                 _textureQueryLevels(texture_query_levels, glsl_type::isampler2DArray_type),
 3299                 _textureQueryLevels(texture_query_levels, glsl_type::isamplerCubeArray_type),
 3300 
 3301                 _textureQueryLevels(texture_query_levels, glsl_type::usampler1D_type),
 3302                 _textureQueryLevels(texture_query_levels, glsl_type::usampler2D_type),
 3303                 _textureQueryLevels(texture_query_levels, glsl_type::usampler3D_type),
 3304                 _textureQueryLevels(texture_query_levels, glsl_type::usamplerCube_type),
 3305                 _textureQueryLevels(texture_query_levels, glsl_type::usampler1DArray_type),
 3306                 _textureQueryLevels(texture_query_levels, glsl_type::usampler2DArray_type),
 3307                 _textureQueryLevels(texture_query_levels, glsl_type::usamplerCubeArray_type),
 3308 
 3309                 NULL);
 3310 
 3311    add_function("textureSamplesIdenticalEXT",
 3312                 _textureSamplesIdentical(texture_samples_identical, glsl_type::sampler2DMS_type,  glsl_type::ivec2_type),
 3313                 _textureSamplesIdentical(texture_samples_identical, glsl_type::isampler2DMS_type, glsl_type::ivec2_type),
 3314                 _textureSamplesIdentical(texture_samples_identical, glsl_type::usampler2DMS_type, glsl_type::ivec2_type),
 3315 
 3316                 _textureSamplesIdentical(texture_samples_identical_array, glsl_type::sampler2DMSArray_type,  glsl_type::ivec3_type),
 3317                 _textureSamplesIdentical(texture_samples_identical_array, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),
 3318                 _textureSamplesIdentical(texture_samples_identical_array, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),
 3319                 NULL);
 3320 
 3321    add_function("texture1D",
 3322                 _texture(ir_tex, v110,                      glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::float_type),
 3323                 _texture(ir_txb, v110_derivatives_only,     glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::float_type),
 3324                 _texture(ir_tex, gpu_shader4_integer,               glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::float_type),
 3325                 _texture(ir_txb, gpu_shader4_integer_derivs_only,   glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::float_type),
 3326                 _texture(ir_tex, gpu_shader4_integer,               glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::float_type),
 3327                 _texture(ir_txb, gpu_shader4_integer_derivs_only,   glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::float_type),
 3328                 NULL);
 3329 
 3330    add_function("texture1DArray",
 3331                 _texture(ir_tex, texture_array,           glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
 3332                 _texture(ir_txb, texture_array_derivs_only,glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
 3333                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 3334                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 3335                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 3336                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 3337                 NULL);
 3338 
 3339    add_function("texture1DProj",
 3340                 _texture(ir_tex, v110,                  glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3341                 _texture(ir_tex, v110,                  glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3342                 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3343                 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3344                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3345                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3346                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3347                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3348                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3349                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3350                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3351                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3352                 NULL);
 3353 
 3354    add_function("texture1DLod",
 3355                 _texture(ir_txl, tex1d_lod, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::float_type),
 3356                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::float_type),
 3357                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::float_type),
 3358                 NULL);
 3359 
 3360    add_function("texture1DArrayLod",
 3361                 _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
 3362                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 3363                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 3364                 NULL);
 3365 
 3366    add_function("texture1DProjLod",
 3367                 _texture(ir_txl, tex1d_lod, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3368                 _texture(ir_txl, tex1d_lod, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3369                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3370                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3371                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3372                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3373                 NULL);
 3374 
 3375    add_function("texture2D",
 3376                 _texture(ir_tex, always_available,        glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec2_type),
 3377                 _texture(ir_txb, derivatives_only,        glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec2_type),
 3378                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec2_type),
 3379                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec2_type),
 3380                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec2_type),
 3381                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec2_type),
 3382                 _texture(ir_tex, texture_external,        glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::vec2_type),
 3383                 NULL);
 3384 
 3385    add_function("texture2DArray",
 3386                 _texture(ir_tex, texture_array,           glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
 3387                 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
 3388                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 3389                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 3390                 _texture(ir_tex, gpu_shader4_array_integer,             glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 3391                 _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 3392                 NULL);
 3393 
 3394    add_function("texture2DProj",
 3395                 _texture(ir_tex, always_available,        glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3396                 _texture(ir_tex, always_available,        glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3397                 _texture(ir_txb, derivatives_only,        glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3398                 _texture(ir_txb, derivatives_only,        glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3399                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3400                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3401                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3402                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3403                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3404                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3405                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3406                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3407                 _texture(ir_tex, texture_external,        glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),
 3408                 _texture(ir_tex, texture_external,        glsl_type::vec4_type,  glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),
 3409                 NULL);
 3410 
 3411    add_function("texture2DLod",
 3412                 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec2_type),
 3413                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec2_type),
 3414                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec2_type),
 3415                 NULL);
 3416 
 3417    add_function("texture2DArrayLod",
 3418                 _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
 3419                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 3420                 _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 3421                 NULL);
 3422 
 3423    add_function("texture2DProjLod",
 3424                 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3425                 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3426                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3427                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3428                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3429                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3430                 NULL);
 3431 
 3432    add_function("texture3D",
 3433                 _texture(ir_tex, tex3d,                   glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec3_type),
 3434                 _texture(ir_txb, derivatives_tex3d,       glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec3_type),
 3435                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
 3436                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),
 3437                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
 3438                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),
 3439                 NULL);
 3440 
 3441    add_function("texture3DProj",
 3442                 _texture(ir_tex, tex3d,                   glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3443                 _texture(ir_txb, derivatives_tex3d,       glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3444                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3445                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3446                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3447                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3448                 NULL);
 3449 
 3450    add_function("texture3DLod",
 3451                 _texture(ir_txl, tex3d_lod, glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec3_type),
 3452                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler3D_type, glsl_type::vec3_type),
 3453                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler3D_type, glsl_type::vec3_type),
 3454                 NULL);
 3455 
 3456    add_function("texture3DProjLod",
 3457                 _texture(ir_txl, tex3d_lod, glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3458                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3459                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3460                 NULL);
 3461 
 3462    add_function("textureCube",
 3463                 _texture(ir_tex, always_available,        glsl_type::vec4_type,  glsl_type::samplerCube_type, glsl_type::vec3_type),
 3464                 _texture(ir_txb, derivatives_only,        glsl_type::vec4_type,  glsl_type::samplerCube_type, glsl_type::vec3_type),
 3465                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::ivec4_type,  glsl_type::isamplerCube_type, glsl_type::vec3_type),
 3466                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type,  glsl_type::isamplerCube_type, glsl_type::vec3_type),
 3467                 _texture(ir_tex, gpu_shader4_integer,             glsl_type::uvec4_type,  glsl_type::usamplerCube_type, glsl_type::vec3_type),
 3468                 _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type,  glsl_type::usamplerCube_type, glsl_type::vec3_type),
 3469                 NULL);
 3470 
 3471    add_function("textureCubeLod",
 3472                 _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type,  glsl_type::samplerCube_type, glsl_type::vec3_type),
 3473                 _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isamplerCube_type, glsl_type::vec3_type),
 3474                 _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usamplerCube_type, glsl_type::vec3_type),
 3475                 NULL);
 3476 
 3477    add_function("texture2DRect",
 3478                 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec2_type),
 3479                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type,  glsl_type::isampler2DRect_type, glsl_type::vec2_type),
 3480                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type,  glsl_type::usampler2DRect_type, glsl_type::vec2_type),
 3481                 NULL);
 3482 
 3483    add_function("texture2DRectProj",
 3484                 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3485                 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3486                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type,  glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3487                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type,  glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3488                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type,  glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3489                 _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type,  glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3490                 NULL);
 3491 
 3492    add_function("shadow1D",
 3493                 _texture(ir_tex, v110,                  glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
 3494                 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
 3495                 NULL);
 3496 
 3497    add_function("shadow1DArray",
 3498                 _texture(ir_tex, texture_array,    glsl_type::vec4_type,  glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 3499                 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type,  glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 3500                 NULL);
 3501 
 3502    add_function("shadow2D",
 3503                 _texture(ir_tex, v110,                  glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
 3504                 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
 3505                 NULL);
 3506 
 3507    add_function("shadow2DArray",
 3508                 _texture(ir_tex, texture_array,    glsl_type::vec4_type,  glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 3509                 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type,  glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 3510                 NULL);
 3511 
 3512    add_function("shadow1DProj",
 3513                 _texture(ir_tex, v110,                  glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3514                 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3515                 NULL);
 3516 
 3517    add_function("shadow2DArray",
 3518                 _texture(ir_tex, texture_array,    glsl_type::vec4_type,  glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 3519                 _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type,  glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 3520                 NULL);
 3521 
 3522    add_function("shadowCube",
 3523                 _texture(ir_tex, gpu_shader4,             glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 3524                 _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 3525                 NULL);
 3526 
 3527    add_function("shadow2DProj",
 3528                 _texture(ir_tex, v110,                  glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3529                 _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3530                 NULL);
 3531 
 3532    add_function("shadow1DLod",
 3533                 _texture(ir_txl, v110_lod, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
 3534                 NULL);
 3535 
 3536    add_function("shadow2DLod",
 3537                 _texture(ir_txl, v110_lod, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
 3538                 NULL);
 3539 
 3540    add_function("shadow1DArrayLod",
 3541                 _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 3542                 NULL);
 3543 
 3544    add_function("shadow1DProjLod",
 3545                 _texture(ir_txl, v110_lod, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3546                 NULL);
 3547 
 3548    add_function("shadow2DProjLod",
 3549                 _texture(ir_txl, v110_lod, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3550                 NULL);
 3551 
 3552    add_function("shadow2DRect",
 3553                 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type,  glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
 3554                 NULL);
 3555 
 3556    add_function("shadow2DRectProj",
 3557                 _texture(ir_tex, texture_rectangle, glsl_type::vec4_type,  glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3558                 NULL);
 3559 
 3560    add_function("texture1DGradARB",
 3561                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::float_type),
 3562                 NULL);
 3563 
 3564    add_function("texture1DProjGradARB",
 3565                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3566                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3567                 NULL);
 3568 
 3569    add_function("texture2DGradARB",
 3570                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec2_type),
 3571                 NULL);
 3572 
 3573    add_function("texture2DProjGradARB",
 3574                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3575                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3576                 NULL);
 3577 
 3578    add_function("texture3DGradARB",
 3579                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec3_type),
 3580                 NULL);
 3581 
 3582    add_function("texture3DProjGradARB",
 3583                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3584                 NULL);
 3585 
 3586    add_function("textureCubeGradARB",
 3587                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::samplerCube_type, glsl_type::vec3_type),
 3588                 NULL);
 3589 
 3590    add_function("shadow1DGradARB",
 3591                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
 3592                 NULL);
 3593 
 3594    add_function("shadow1DProjGradARB",
 3595                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3596                 NULL);
 3597 
 3598    add_function("shadow2DGradARB",
 3599                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
 3600                 NULL);
 3601 
 3602    add_function("shadow2DProjGradARB",
 3603                 _texture(ir_txd, shader_texture_lod, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3604                 NULL);
 3605 
 3606    add_function("texture2DRectGradARB",
 3607                 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec2_type),
 3608                 NULL);
 3609 
 3610    add_function("texture2DRectProjGradARB",
 3611                 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3612                 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3613                 NULL);
 3614 
 3615    add_function("shadow2DRectGradARB",
 3616                 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type,  glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
 3617                 NULL);
 3618 
 3619    add_function("shadow2DRectProjGradARB",
 3620                 _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type,  glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3621                 NULL);
 3622 
 3623    add_function("texture4",
 3624                 _texture(ir_tg4, texture_texture4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
 3625                 NULL);
 3626 
 3627    add_function("texture1DGrad",
 3628                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::float_type),
 3629                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::float_type),
 3630                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::float_type),
 3631                 NULL);
 3632 
 3633    add_function("texture1DProjGrad",
 3634                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3635                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3636                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3637                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3638                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),
 3639                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),
 3640                 NULL);
 3641 
 3642    add_function("texture1DArrayGrad",
 3643                 _texture(ir_txd, gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler1DArray_type, glsl_type::vec2_type),
 3644                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type,  glsl_type::isampler1DArray_type, glsl_type::vec2_type),
 3645                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type,  glsl_type::usampler1DArray_type, glsl_type::vec2_type),
 3646                 NULL);
 3647 
 3648    add_function("texture2DGrad",
 3649                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec2_type),
 3650                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec2_type),
 3651                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec2_type),
 3652                 NULL);
 3653 
 3654    add_function("texture2DProjGrad",
 3655                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3656                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3657                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3658                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3659                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),
 3660                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),
 3661                 NULL);
 3662 
 3663    add_function("texture2DArrayGrad",
 3664                 _texture(ir_txd, gpu_shader4_array,         glsl_type::vec4_type,  glsl_type::sampler2DArray_type, glsl_type::vec3_type),
 3665                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type,  glsl_type::isampler2DArray_type, glsl_type::vec3_type),
 3666                 _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type,  glsl_type::usampler2DArray_type, glsl_type::vec3_type),
 3667                 NULL);
 3668 
 3669    add_function("texture3DGrad",
 3670                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec3_type),
 3671                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler3D_type, glsl_type::vec3_type),
 3672                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler3D_type, glsl_type::vec3_type),
 3673                 NULL);
 3674 
 3675    add_function("texture3DProjGrad",
 3676                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3677                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3678                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),
 3679                 NULL);
 3680 
 3681    add_function("textureCubeGrad",
 3682                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::samplerCube_type, glsl_type::vec3_type),
 3683                 _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type,  glsl_type::isamplerCube_type, glsl_type::vec3_type),
 3684                 _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type,  glsl_type::usamplerCube_type, glsl_type::vec3_type),
 3685                 NULL);
 3686 
 3687    add_function("shadow1DGrad",
 3688                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec3_type),
 3689                 NULL);
 3690 
 3691    add_function("shadow1DProjGrad",
 3692                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3693                 NULL);
 3694 
 3695    add_function("shadow1DArrayGrad",
 3696                 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type,  glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
 3697                 NULL);
 3698 
 3699    add_function("shadow2DGrad",
 3700                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec3_type),
 3701                 NULL);
 3702 
 3703    add_function("shadow2DProjGrad",
 3704                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3705                 NULL);
 3706 
 3707    add_function("shadow2DArrayGrad",
 3708                 _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type,  glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),
 3709                 NULL);
 3710 
 3711    add_function("texture2DRectGrad",
 3712                 _texture(ir_txd, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec2_type),
 3713                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type,  glsl_type::isampler2DRect_type, glsl_type::vec2_type),
 3714                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type,  glsl_type::usampler2DRect_type, glsl_type::vec2_type),
 3715                 NULL);
 3716 
 3717    add_function("texture2DRectProjGrad",
 3718                 _texture(ir_txd, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3719                 _texture(ir_txd, gpu_shader4_rect,         glsl_type::vec4_type,  glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3720                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type,  glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3721                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type,  glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3722                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type,  glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),
 3723                 _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type,  glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),
 3724                 NULL);
 3725 
 3726    add_function("shadow2DRectGrad",
 3727                 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type,  glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),
 3728                 NULL);
 3729 
 3730    add_function("shadow2DRectProjGrad",
 3731                 _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type,  glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),
 3732                 NULL);
 3733 
 3734    add_function("shadowCubeGrad",
 3735                 _texture(ir_txd, gpu_shader4, glsl_type::vec4_type,  glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),
 3736                 NULL);
 3737 
 3738    add_function("textureGather",
 3739                 _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type