Path: blob/21.2-virgl/src/compiler/glsl/builtin_functions.cpp
4547 views
/*1* Copyright © 2013 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223/**24* \file builtin_functions.cpp25*26* Support for GLSL built-in functions.27*28* This file is split into several main components:29*30* 1. Availability predicates31*32* A series of small functions that check whether the current shader33* supports the version/extensions required to expose a built-in.34*35* 2. Core builtin_builder class functionality36*37* 3. Lists of built-in functions38*39* The builtin_builder::create_builtins() function contains lists of all40* built-in function signatures, where they're available, what types they41* take, and so on.42*43* 4. Implementations of built-in function signatures44*45* A series of functions which create ir_function_signatures and emit IR46* via ir_builder to implement them.47*48* 5. External API49*50* A few functions the rest of the compiler can use to interact with the51* built-in function module. For example, searching for a built-in by52* name and parameters.53*/545556/**57* Unfortunately, some versions of MinGW produce bad code if this file58* is compiled with -O2 or -O3. The resulting driver will crash in random59* places if the app uses GLSL.60* The work-around is to disable optimizations for just this file. Luckily,61* this code is basically just executed once.62*63* MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug.64* MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug.65* MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug.66* MinGW 7.3.0 (in Ubuntu 18.04) does not have this bug. Assume versions before 7.3.x are buggy67*/6869#if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR < 703)70#warning "disabling optimizations for this file to work around compiler bug"71#pragma GCC optimize("O1")72#endif737475#include <stdarg.h>76#include <stdio.h>77#include "main/mtypes.h"78#include "main/shaderobj.h"79#include "ir_builder.h"80#include "glsl_parser_extras.h"81#include "program/prog_instruction.h"82#include <math.h>83#include "builtin_functions.h"84#include "util/hash_table.h"8586#define M_PIf ((float) M_PI)87#define M_PI_2f ((float) M_PI_2)88#define M_PI_4f ((float) M_PI_4)8990using namespace ir_builder;9192static mtx_t builtins_lock = _MTX_INITIALIZER_NP;9394/**95* Availability predicates:96* @{97*/98static bool99always_available(const _mesa_glsl_parse_state *)100{101return true;102}103104static bool105compatibility_vs_only(const _mesa_glsl_parse_state *state)106{107return state->stage == MESA_SHADER_VERTEX &&108(state->compat_shader || state->ARB_compatibility_enable) &&109!state->es_shader;110}111112static bool113derivatives_only(const _mesa_glsl_parse_state *state)114{115return state->stage == MESA_SHADER_FRAGMENT ||116(state->stage == MESA_SHADER_COMPUTE &&117state->NV_compute_shader_derivatives_enable);118}119120static bool121gs_only(const _mesa_glsl_parse_state *state)122{123return state->stage == MESA_SHADER_GEOMETRY;124}125126/* For texture functions moved to compat profile in GLSL 4.20 */127static bool128deprecated_texture(const _mesa_glsl_parse_state *state)129{130return state->compat_shader || !state->is_version(420, 0);131}132133static bool134deprecated_texture_derivatives_only(const _mesa_glsl_parse_state *state)135{136return deprecated_texture(state) && derivatives_only(state);137}138139static bool140v110(const _mesa_glsl_parse_state *state)141{142return !state->es_shader;143}144145static bool146v110_deprecated_texture(const _mesa_glsl_parse_state *state)147{148return !state->es_shader && deprecated_texture(state);149}150151static bool152v110_derivatives_only_deprecated_texture(const _mesa_glsl_parse_state *state)153{154return v110_deprecated_texture(state) &&155derivatives_only(state);156}157158static bool159v120(const _mesa_glsl_parse_state *state)160{161return state->is_version(120, 300);162}163164static bool165v130(const _mesa_glsl_parse_state *state)166{167return state->is_version(130, 300);168}169170static bool171v130_desktop(const _mesa_glsl_parse_state *state)172{173return state->is_version(130, 0);174}175176static bool177v460_desktop(const _mesa_glsl_parse_state *state)178{179return state->is_version(460, 0);180}181182static bool183v130_derivatives_only(const _mesa_glsl_parse_state *state)184{185return state->is_version(130, 300) &&186derivatives_only(state);187}188189static bool190v140_or_es3(const _mesa_glsl_parse_state *state)191{192return state->is_version(140, 300);193}194195static bool196v400_derivatives_only(const _mesa_glsl_parse_state *state)197{198return state->is_version(400, 0) &&199derivatives_only(state);200}201202static bool203texture_rectangle(const _mesa_glsl_parse_state *state)204{205return state->ARB_texture_rectangle_enable;206}207208static bool209texture_external(const _mesa_glsl_parse_state *state)210{211return state->OES_EGL_image_external_enable;212}213214static bool215texture_external_es3(const _mesa_glsl_parse_state *state)216{217return state->OES_EGL_image_external_essl3_enable &&218state->es_shader &&219state->is_version(0, 300);220}221222/** True if texturing functions with explicit LOD are allowed. */223static bool224lod_exists_in_stage(const _mesa_glsl_parse_state *state)225{226/* Texturing functions with "Lod" in their name exist:227* - In the vertex shader stage (for all languages)228* - In any stage for GLSL 1.30+ or GLSL ES 3.00229* - In any stage for desktop GLSL with ARB_shader_texture_lod enabled.230*231* Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we232* don't need to explicitly check state->es_shader.233*/234return state->stage == MESA_SHADER_VERTEX ||235state->is_version(130, 300) ||236state->ARB_shader_texture_lod_enable ||237state->EXT_gpu_shader4_enable;238}239240static bool241lod_deprecated_texture(const _mesa_glsl_parse_state *state)242{243return deprecated_texture(state) && lod_exists_in_stage(state);244}245246static bool247v110_lod_deprecated_texture(const _mesa_glsl_parse_state *state)248{249return !state->es_shader && lod_deprecated_texture(state);250}251252static bool253texture_buffer(const _mesa_glsl_parse_state *state)254{255return state->is_version(140, 320) ||256state->EXT_texture_buffer_enable ||257state->OES_texture_buffer_enable;258}259260static bool261shader_texture_lod(const _mesa_glsl_parse_state *state)262{263return state->ARB_shader_texture_lod_enable;264}265266static bool267shader_texture_lod_and_rect(const _mesa_glsl_parse_state *state)268{269return state->ARB_shader_texture_lod_enable &&270state->ARB_texture_rectangle_enable;271}272273static bool274shader_bit_encoding(const _mesa_glsl_parse_state *state)275{276return state->is_version(330, 300) ||277state->ARB_shader_bit_encoding_enable ||278state->ARB_gpu_shader5_enable;279}280281static bool282shader_integer_mix(const _mesa_glsl_parse_state *state)283{284return state->is_version(450, 310) ||285state->ARB_ES3_1_compatibility_enable ||286(v130(state) && state->EXT_shader_integer_mix_enable);287}288289static bool290shader_packing_or_es3(const _mesa_glsl_parse_state *state)291{292return state->ARB_shading_language_packing_enable ||293state->is_version(420, 300);294}295296static bool297shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state)298{299return state->ARB_shading_language_packing_enable ||300state->ARB_gpu_shader5_enable ||301state->is_version(400, 300);302}303304static bool305gpu_shader4(const _mesa_glsl_parse_state *state)306{307return state->EXT_gpu_shader4_enable;308}309310static bool311gpu_shader4_integer(const _mesa_glsl_parse_state *state)312{313return state->EXT_gpu_shader4_enable &&314state->ctx->Extensions.EXT_texture_integer;315}316317static bool318gpu_shader4_array(const _mesa_glsl_parse_state *state)319{320return state->EXT_gpu_shader4_enable &&321state->ctx->Extensions.EXT_texture_array;322}323324static bool325gpu_shader4_array_integer(const _mesa_glsl_parse_state *state)326{327return gpu_shader4_array(state) &&328state->ctx->Extensions.EXT_texture_integer;329}330331static bool332gpu_shader4_rect(const _mesa_glsl_parse_state *state)333{334return state->EXT_gpu_shader4_enable &&335state->ctx->Extensions.NV_texture_rectangle;336}337338static bool339gpu_shader4_rect_integer(const _mesa_glsl_parse_state *state)340{341return gpu_shader4_rect(state) &&342state->ctx->Extensions.EXT_texture_integer;343}344345static bool346gpu_shader4_tbo(const _mesa_glsl_parse_state *state)347{348return state->EXT_gpu_shader4_enable &&349state->ctx->Extensions.EXT_texture_buffer_object;350}351352static bool353gpu_shader4_tbo_integer(const _mesa_glsl_parse_state *state)354{355return gpu_shader4_tbo(state) &&356state->ctx->Extensions.EXT_texture_integer;357}358359static bool360gpu_shader4_derivs_only(const _mesa_glsl_parse_state *state)361{362return state->EXT_gpu_shader4_enable &&363derivatives_only(state);364}365366static bool367gpu_shader4_integer_derivs_only(const _mesa_glsl_parse_state *state)368{369return gpu_shader4_derivs_only(state) &&370state->ctx->Extensions.EXT_texture_integer;371}372373static bool374gpu_shader4_array_derivs_only(const _mesa_glsl_parse_state *state)375{376return gpu_shader4_derivs_only(state) &&377state->ctx->Extensions.EXT_texture_array;378}379380static bool381gpu_shader4_array_integer_derivs_only(const _mesa_glsl_parse_state *state)382{383return gpu_shader4_array_derivs_only(state) &&384state->ctx->Extensions.EXT_texture_integer;385}386387static bool388v130_or_gpu_shader4(const _mesa_glsl_parse_state *state)389{390return state->is_version(130, 300) || state->EXT_gpu_shader4_enable;391}392393static bool394v130_or_gpu_shader4_and_tex_shadow_lod(const _mesa_glsl_parse_state *state)395{396return v130_or_gpu_shader4(state) &&397state->EXT_texture_shadow_lod_enable;398}399400static bool401gpu_shader5(const _mesa_glsl_parse_state *state)402{403return state->is_version(400, 0) || state->ARB_gpu_shader5_enable;404}405406static bool407gpu_shader5_es(const _mesa_glsl_parse_state *state)408{409return state->is_version(400, 320) ||410state->ARB_gpu_shader5_enable ||411state->EXT_gpu_shader5_enable ||412state->OES_gpu_shader5_enable;413}414415static bool416gpu_shader5_or_OES_texture_cube_map_array(const _mesa_glsl_parse_state *state)417{418return state->is_version(400, 320) ||419state->ARB_gpu_shader5_enable ||420state->EXT_texture_cube_map_array_enable ||421state->OES_texture_cube_map_array_enable;422}423424static bool425es31_not_gs5(const _mesa_glsl_parse_state *state)426{427return state->is_version(0, 310) && !gpu_shader5_es(state);428}429430static bool431gpu_shader5_or_es31(const _mesa_glsl_parse_state *state)432{433return state->is_version(400, 310) || state->ARB_gpu_shader5_enable;434}435436static bool437shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state *state)438{439return state->ARB_shading_language_packing_enable ||440state->ARB_gpu_shader5_enable ||441state->is_version(400, 310);442}443444static bool445gpu_shader5_or_es31_or_integer_functions(const _mesa_glsl_parse_state *state)446{447return gpu_shader5_or_es31(state) ||448state->MESA_shader_integer_functions_enable;449}450451static bool452fs_interpolate_at(const _mesa_glsl_parse_state *state)453{454return state->stage == MESA_SHADER_FRAGMENT &&455(state->is_version(400, 320) ||456state->ARB_gpu_shader5_enable ||457state->OES_shader_multisample_interpolation_enable);458}459460461static bool462texture_array_lod(const _mesa_glsl_parse_state *state)463{464return lod_exists_in_stage(state) &&465(state->EXT_texture_array_enable ||466(state->EXT_gpu_shader4_enable &&467state->ctx->Extensions.EXT_texture_array));468}469470static bool471texture_array(const _mesa_glsl_parse_state *state)472{473return state->EXT_texture_array_enable ||474(state->EXT_gpu_shader4_enable &&475state->ctx->Extensions.EXT_texture_array);476}477478static bool479texture_array_derivs_only(const _mesa_glsl_parse_state *state)480{481return derivatives_only(state) &&482texture_array(state);483}484485static bool486texture_multisample(const _mesa_glsl_parse_state *state)487{488return state->is_version(150, 310) ||489state->ARB_texture_multisample_enable;490}491492static bool493texture_multisample_array(const _mesa_glsl_parse_state *state)494{495return state->is_version(150, 320) ||496state->ARB_texture_multisample_enable ||497state->OES_texture_storage_multisample_2d_array_enable;498}499500static bool501texture_samples_identical(const _mesa_glsl_parse_state *state)502{503return texture_multisample(state) &&504state->EXT_shader_samples_identical_enable;505}506507static bool508texture_samples_identical_array(const _mesa_glsl_parse_state *state)509{510return texture_multisample_array(state) &&511state->EXT_shader_samples_identical_enable;512}513514static bool515derivatives_texture_cube_map_array(const _mesa_glsl_parse_state *state)516{517return state->has_texture_cube_map_array() &&518derivatives_only(state);519}520521static bool522texture_cube_map_array(const _mesa_glsl_parse_state *state)523{524return state->has_texture_cube_map_array();525}526527static bool528v130_or_gpu_shader4_and_tex_cube_map_array(const _mesa_glsl_parse_state *state)529{530return texture_cube_map_array(state) &&531v130_or_gpu_shader4(state) &&532state->EXT_texture_shadow_lod_enable;533}534535static bool536texture_query_levels(const _mesa_glsl_parse_state *state)537{538return state->is_version(430, 0) ||539state->ARB_texture_query_levels_enable;540}541542static bool543texture_query_lod(const _mesa_glsl_parse_state *state)544{545return derivatives_only(state) &&546(state->ARB_texture_query_lod_enable ||547state->EXT_texture_query_lod_enable);548}549550static bool551texture_gather_cube_map_array(const _mesa_glsl_parse_state *state)552{553return state->is_version(400, 320) ||554state->ARB_texture_gather_enable ||555state->ARB_gpu_shader5_enable ||556state->EXT_texture_cube_map_array_enable ||557state->OES_texture_cube_map_array_enable;558}559560static bool561texture_texture4(const _mesa_glsl_parse_state *state)562{563return state->AMD_texture_texture4_enable;564}565566static bool567texture_gather_or_es31(const _mesa_glsl_parse_state *state)568{569return state->is_version(400, 310) ||570state->ARB_texture_gather_enable ||571state->ARB_gpu_shader5_enable;572}573574/* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.575* used for relaxation of const offset requirements.576*/577static bool578texture_gather_only_or_es31(const _mesa_glsl_parse_state *state)579{580return !state->is_version(400, 320) &&581!state->ARB_gpu_shader5_enable &&582!state->EXT_gpu_shader5_enable &&583!state->OES_gpu_shader5_enable &&584(state->ARB_texture_gather_enable ||585state->is_version(0, 310));586}587588/* Desktop GL or OES_standard_derivatives */589static bool590derivatives(const _mesa_glsl_parse_state *state)591{592return derivatives_only(state) &&593(state->is_version(110, 300) ||594state->OES_standard_derivatives_enable ||595state->ctx->Const.AllowGLSLRelaxedES);596}597598static bool599derivative_control(const _mesa_glsl_parse_state *state)600{601return derivatives_only(state) &&602(state->is_version(450, 0) ||603state->ARB_derivative_control_enable);604}605606/** True if sampler3D exists */607static bool608tex3d(const _mesa_glsl_parse_state *state)609{610/* sampler3D exists in all desktop GLSL versions, GLSL ES 1.00 with the611* OES_texture_3D extension, and in GLSL ES 3.00.612*/613return (!state->es_shader ||614state->OES_texture_3D_enable ||615state->language_version >= 300) && deprecated_texture(state);616}617618static bool619derivatives_tex3d(const _mesa_glsl_parse_state *state)620{621return (!state->es_shader || state->OES_texture_3D_enable) &&622derivatives_only(state) && deprecated_texture(state);623}624625static bool626tex3d_lod(const _mesa_glsl_parse_state *state)627{628return tex3d(state) && lod_exists_in_stage(state);629}630631static bool632shader_atomic_counters(const _mesa_glsl_parse_state *state)633{634return state->has_atomic_counters();635}636637static bool638shader_atomic_counter_ops(const _mesa_glsl_parse_state *state)639{640return state->ARB_shader_atomic_counter_ops_enable;641}642643static bool644shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state *state)645{646return state->ARB_shader_atomic_counter_ops_enable || v460_desktop(state);647}648649static bool650shader_ballot(const _mesa_glsl_parse_state *state)651{652return state->ARB_shader_ballot_enable;653}654655static bool656supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state *state)657{658return state->ARB_fragment_shader_interlock_enable;659}660661static bool662supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state *state)663{664return state->NV_fragment_shader_interlock_enable;665}666667static bool668shader_clock(const _mesa_glsl_parse_state *state)669{670return state->ARB_shader_clock_enable;671}672673static bool674shader_clock_int64(const _mesa_glsl_parse_state *state)675{676return state->ARB_shader_clock_enable &&677(state->ARB_gpu_shader_int64_enable ||678state->AMD_gpu_shader_int64_enable);679}680681static bool682shader_storage_buffer_object(const _mesa_glsl_parse_state *state)683{684return state->has_shader_storage_buffer_objects();685}686687static bool688shader_trinary_minmax(const _mesa_glsl_parse_state *state)689{690return state->AMD_shader_trinary_minmax_enable;691}692693static bool694shader_image_load_store(const _mesa_glsl_parse_state *state)695{696return (state->is_version(420, 310) ||697state->ARB_shader_image_load_store_enable ||698state->EXT_shader_image_load_store_enable);699}700701static bool702shader_image_load_store_ext(const _mesa_glsl_parse_state *state)703{704return state->EXT_shader_image_load_store_enable;705}706707static bool708shader_image_atomic(const _mesa_glsl_parse_state *state)709{710return (state->is_version(420, 320) ||711state->ARB_shader_image_load_store_enable ||712state->EXT_shader_image_load_store_enable ||713state->OES_shader_image_atomic_enable);714}715716static bool717shader_image_atomic_exchange_float(const _mesa_glsl_parse_state *state)718{719return (state->is_version(450, 320) ||720state->ARB_ES3_1_compatibility_enable ||721state->OES_shader_image_atomic_enable ||722state->NV_shader_atomic_float_enable);723}724725static bool726shader_image_atomic_add_float(const _mesa_glsl_parse_state *state)727{728return state->NV_shader_atomic_float_enable;729}730731static bool732shader_image_size(const _mesa_glsl_parse_state *state)733{734return state->is_version(430, 310) ||735state->ARB_shader_image_size_enable;736}737738static bool739shader_samples(const _mesa_glsl_parse_state *state)740{741return state->is_version(450, 0) ||742state->ARB_shader_texture_image_samples_enable;743}744745static bool746gs_streams(const _mesa_glsl_parse_state *state)747{748return gpu_shader5(state) && gs_only(state);749}750751static bool752fp64(const _mesa_glsl_parse_state *state)753{754return state->has_double();755}756757static bool758int64_avail(const _mesa_glsl_parse_state *state)759{760return state->has_int64();761}762763static bool764int64_fp64(const _mesa_glsl_parse_state *state)765{766return state->has_int64() && state->has_double();767}768769static bool770compute_shader(const _mesa_glsl_parse_state *state)771{772return state->stage == MESA_SHADER_COMPUTE;773}774775static bool776compute_shader_supported(const _mesa_glsl_parse_state *state)777{778return state->has_compute_shader();779}780781static bool782buffer_atomics_supported(const _mesa_glsl_parse_state *state)783{784return compute_shader(state) || shader_storage_buffer_object(state);785}786787static bool788buffer_int64_atomics_supported(const _mesa_glsl_parse_state *state)789{790return state->NV_shader_atomic_int64_enable &&791buffer_atomics_supported(state);792}793794static bool795barrier_supported(const _mesa_glsl_parse_state *state)796{797return compute_shader(state) ||798state->stage == MESA_SHADER_TESS_CTRL;799}800801static bool802vote(const _mesa_glsl_parse_state *state)803{804return state->ARB_shader_group_vote_enable;805}806807static bool808vote_ext(const _mesa_glsl_parse_state *state)809{810return state->EXT_shader_group_vote_enable;811}812813static bool814vote_or_v460_desktop(const _mesa_glsl_parse_state *state)815{816return state->EXT_shader_group_vote_enable || state->ARB_shader_group_vote_enable || v460_desktop(state);817}818819static bool820integer_functions_supported(const _mesa_glsl_parse_state *state)821{822return state->extensions->MESA_shader_integer_functions;823}824825static bool826NV_shader_atomic_float_supported(const _mesa_glsl_parse_state *state)827{828return state->extensions->NV_shader_atomic_float;829}830831static bool832shader_atomic_float_add(const _mesa_glsl_parse_state *state)833{834return state->NV_shader_atomic_float_enable;835}836837static bool838shader_atomic_float_exchange(const _mesa_glsl_parse_state *state)839{840return state->NV_shader_atomic_float_enable ||841state->INTEL_shader_atomic_float_minmax_enable;842}843844static bool845INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state *state)846{847return state->extensions->INTEL_shader_atomic_float_minmax;848}849850static bool851shader_atomic_float_minmax(const _mesa_glsl_parse_state *state)852{853return state->INTEL_shader_atomic_float_minmax_enable;854}855856static bool857demote_to_helper_invocation(const _mesa_glsl_parse_state *state)858{859return state->EXT_demote_to_helper_invocation_enable;860}861862static bool863shader_integer_functions2(const _mesa_glsl_parse_state *state)864{865return state->INTEL_shader_integer_functions2_enable;866}867868static bool869shader_integer_functions2_int64(const _mesa_glsl_parse_state *state)870{871return state->INTEL_shader_integer_functions2_enable && state->has_int64();872}873874static bool875is_nir(const _mesa_glsl_parse_state *state)876{877return state->ctx->Const.ShaderCompilerOptions[state->stage].NirOptions;878}879880static bool881is_not_nir(const _mesa_glsl_parse_state *state)882{883return !is_nir(state);884}885886/** @} */887888/******************************************************************************/889890namespace {891892/**893* builtin_builder: A singleton object representing the core of the built-in894* function module.895*896* It generates IR for every built-in function signature, and organizes them897* into functions.898*/899class builtin_builder {900public:901builtin_builder();902~builtin_builder();903904void initialize();905void release();906ir_function_signature *find(_mesa_glsl_parse_state *state,907const char *name, exec_list *actual_parameters);908909/**910* A shader to hold all the built-in signatures; created by this module.911*912* This includes signatures for every built-in, regardless of version or913* enabled extensions. The availability predicate associated with each914* signature allows matching_signature() to filter out the irrelevant ones.915*/916gl_shader *shader;917918private:919void *mem_ctx;920921void create_shader();922void create_intrinsics();923void create_builtins();924925/**926* IR builder helpers:927*928* These convenience functions assist in emitting IR, but don't necessarily929* fit in ir_builder itself. Many of them rely on having a mem_ctx class930* member available.931*/932ir_variable *in_var(const glsl_type *type, const char *name);933ir_variable *out_var(const glsl_type *type, const char *name);934ir_constant *imm(float f, unsigned vector_elements=1);935ir_constant *imm(bool b, unsigned vector_elements=1);936ir_constant *imm(int i, unsigned vector_elements=1);937ir_constant *imm(unsigned u, unsigned vector_elements=1);938ir_constant *imm(double d, unsigned vector_elements=1);939ir_constant *imm(const glsl_type *type, const ir_constant_data &);940ir_dereference_variable *var_ref(ir_variable *var);941ir_dereference_array *array_ref(ir_variable *var, int i);942ir_swizzle *matrix_elt(ir_variable *var, int col, int row);943944ir_expression *asin_expr(ir_variable *x, float p0, float p1);945void do_atan(ir_factory &body, const glsl_type *type, ir_variable *res, operand y_over_x);946947/**948* Call function \param f with parameters specified as the linked949* list \param params of \c ir_variable objects. \param ret should950* point to the ir_variable that will hold the function return951* value, or be \c NULL if the function has void return type.952*/953ir_call *call(ir_function *f, ir_variable *ret, exec_list params);954955/** Create a new function and add the given signatures. */956void add_function(const char *name, ...);957958typedef ir_function_signature *(builtin_builder::*image_prototype_ctr)(const glsl_type *image_type,959unsigned num_arguments,960unsigned flags);961962/**963* Create a new image built-in function for all known image types.964* \p flags is a bitfield of \c image_function_flags flags.965*/966void add_image_function(const char *name,967const char *intrinsic_name,968image_prototype_ctr prototype,969unsigned num_arguments,970unsigned flags,971enum ir_intrinsic_id id);972973/**974* Create new functions for all known image built-ins and types.975* If \p glsl is \c true, use the GLSL built-in names and emit code976* to call into the actual compiler intrinsic. If \p glsl is977* false, emit a function prototype with no body for each image978* intrinsic name.979*/980void add_image_functions(bool glsl);981982ir_function_signature *new_sig(const glsl_type *return_type,983builtin_available_predicate avail,984int num_params, ...);985986/**987* Function signature generators:988* @{989*/990ir_function_signature *unop(builtin_available_predicate avail,991ir_expression_operation opcode,992const glsl_type *return_type,993const glsl_type *param_type);994ir_function_signature *binop(builtin_available_predicate avail,995ir_expression_operation opcode,996const glsl_type *return_type,997const glsl_type *param0_type,998const glsl_type *param1_type,999bool swap_operands = false);10001001#define B0(X) ir_function_signature *_##X();1002#define B1(X) ir_function_signature *_##X(const glsl_type *);1003#define B2(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *);1004#define B3(X) ir_function_signature *_##X(const glsl_type *, const glsl_type *, const glsl_type *);1005#define BA1(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *);1006#define BA2(X) ir_function_signature *_##X(builtin_available_predicate, const glsl_type *, const glsl_type *);1007B1(radians)1008B1(degrees)1009B1(sin)1010B1(cos)1011B1(tan)1012B1(asin)1013B1(acos)1014B1(atan2)1015B1(atan)1016B1(atan2_op)1017B1(atan_op)1018B1(sinh)1019B1(cosh)1020B1(tanh)1021B1(asinh)1022B1(acosh)1023B1(atanh)1024B1(pow)1025B1(exp)1026B1(log)1027B1(exp2)1028B1(log2)1029BA1(sqrt)1030BA1(inversesqrt)1031BA1(abs)1032BA1(sign)1033BA1(floor)1034BA1(truncate)1035BA1(trunc)1036BA1(round)1037BA1(roundEven)1038BA1(ceil)1039BA1(fract)1040BA2(mod)1041BA1(modf)1042BA2(min)1043BA2(max)1044BA2(clamp)1045BA2(mix_lrp)1046ir_function_signature *_mix_sel(builtin_available_predicate avail,1047const glsl_type *val_type,1048const glsl_type *blend_type);1049BA2(step)1050BA2(smoothstep)1051BA1(isnan)1052BA1(isinf)1053B1(floatBitsToInt)1054B1(floatBitsToUint)1055B1(intBitsToFloat)1056B1(uintBitsToFloat)10571058BA1(doubleBitsToInt64)1059BA1(doubleBitsToUint64)1060BA1(int64BitsToDouble)1061BA1(uint64BitsToDouble)10621063ir_function_signature *_packUnorm2x16(builtin_available_predicate avail);1064ir_function_signature *_packSnorm2x16(builtin_available_predicate avail);1065ir_function_signature *_packUnorm4x8(builtin_available_predicate avail);1066ir_function_signature *_packSnorm4x8(builtin_available_predicate avail);1067ir_function_signature *_unpackUnorm2x16(builtin_available_predicate avail);1068ir_function_signature *_unpackSnorm2x16(builtin_available_predicate avail);1069ir_function_signature *_unpackUnorm4x8(builtin_available_predicate avail);1070ir_function_signature *_unpackSnorm4x8(builtin_available_predicate avail);1071ir_function_signature *_packHalf2x16(builtin_available_predicate avail);1072ir_function_signature *_unpackHalf2x16(builtin_available_predicate avail);1073ir_function_signature *_packDouble2x32(builtin_available_predicate avail);1074ir_function_signature *_unpackDouble2x32(builtin_available_predicate avail);1075ir_function_signature *_packInt2x32(builtin_available_predicate avail);1076ir_function_signature *_unpackInt2x32(builtin_available_predicate avail);1077ir_function_signature *_packUint2x32(builtin_available_predicate avail);1078ir_function_signature *_unpackUint2x32(builtin_available_predicate avail);10791080BA1(length)1081BA1(distance);1082BA1(dot);1083BA1(cross);1084BA1(normalize);1085B0(ftransform);1086BA1(faceforward);1087BA1(reflect);1088BA1(refract);1089BA1(matrixCompMult);1090BA1(outerProduct);1091BA1(determinant_mat2);1092BA1(determinant_mat3);1093BA1(determinant_mat4);1094BA1(inverse_mat2);1095BA1(inverse_mat3);1096BA1(inverse_mat4);1097BA1(transpose);1098BA1(lessThan);1099BA1(lessThanEqual);1100BA1(greaterThan);1101BA1(greaterThanEqual);1102BA1(equal);1103BA1(notEqual);1104B1(any);1105B1(all);1106B1(not);1107BA2(textureSize);1108BA1(textureSamples);11091110/** Flags to _texture() */1111#define TEX_PROJECT 11112#define TEX_OFFSET 21113#define TEX_COMPONENT 41114#define TEX_OFFSET_NONCONST 81115#define TEX_OFFSET_ARRAY 1611161117ir_function_signature *_texture(ir_texture_opcode opcode,1118builtin_available_predicate avail,1119const glsl_type *return_type,1120const glsl_type *sampler_type,1121const glsl_type *coord_type,1122int flags = 0);1123ir_function_signature *_textureCubeArrayShadow(ir_texture_opcode opcode,1124builtin_available_predicate avail,1125const glsl_type *x);1126ir_function_signature *_texelFetch(builtin_available_predicate avail,1127const glsl_type *return_type,1128const glsl_type *sampler_type,1129const glsl_type *coord_type,1130const glsl_type *offset_type = NULL);11311132B0(EmitVertex)1133B0(EndPrimitive)1134ir_function_signature *_EmitStreamVertex(builtin_available_predicate avail,1135const glsl_type *stream_type);1136ir_function_signature *_EndStreamPrimitive(builtin_available_predicate avail,1137const glsl_type *stream_type);1138B0(barrier)11391140BA2(textureQueryLod);1141BA1(textureQueryLevels);1142BA2(textureSamplesIdentical);1143B1(dFdx);1144B1(dFdy);1145B1(fwidth);1146B1(dFdxCoarse);1147B1(dFdyCoarse);1148B1(fwidthCoarse);1149B1(dFdxFine);1150B1(dFdyFine);1151B1(fwidthFine);1152B1(noise1);1153B1(noise2);1154B1(noise3);1155B1(noise4);11561157B1(bitfieldExtract)1158B1(bitfieldInsert)1159B1(bitfieldReverse)1160B1(bitCount)1161B1(findLSB)1162B1(findMSB)1163BA1(countLeadingZeros)1164BA1(countTrailingZeros)1165BA1(fma)1166B2(ldexp)1167B2(frexp)1168B2(dfrexp)1169B1(uaddCarry)1170B1(usubBorrow)1171BA1(addSaturate)1172BA1(subtractSaturate)1173BA1(absoluteDifference)1174BA1(average)1175BA1(averageRounded)1176B1(mulExtended)1177BA1(multiply32x16)1178B1(interpolateAtCentroid)1179B1(interpolateAtOffset)1180B1(interpolateAtSample)11811182ir_function_signature *_atomic_counter_intrinsic(builtin_available_predicate avail,1183enum ir_intrinsic_id id);1184ir_function_signature *_atomic_counter_intrinsic1(builtin_available_predicate avail,1185enum ir_intrinsic_id id);1186ir_function_signature *_atomic_counter_intrinsic2(builtin_available_predicate avail,1187enum ir_intrinsic_id id);1188ir_function_signature *_atomic_counter_op(const char *intrinsic,1189builtin_available_predicate avail);1190ir_function_signature *_atomic_counter_op1(const char *intrinsic,1191builtin_available_predicate avail);1192ir_function_signature *_atomic_counter_op2(const char *intrinsic,1193builtin_available_predicate avail);11941195ir_function_signature *_atomic_intrinsic2(builtin_available_predicate avail,1196const glsl_type *type,1197enum ir_intrinsic_id id);1198ir_function_signature *_atomic_op2(const char *intrinsic,1199builtin_available_predicate avail,1200const glsl_type *type);1201ir_function_signature *_atomic_intrinsic3(builtin_available_predicate avail,1202const glsl_type *type,1203enum ir_intrinsic_id id);1204ir_function_signature *_atomic_op3(const char *intrinsic,1205builtin_available_predicate avail,1206const glsl_type *type);12071208B1(min3)1209B1(max3)1210B1(mid3)12111212ir_function_signature *_image_prototype(const glsl_type *image_type,1213unsigned num_arguments,1214unsigned flags);1215ir_function_signature *_image_size_prototype(const glsl_type *image_type,1216unsigned num_arguments,1217unsigned flags);1218ir_function_signature *_image_samples_prototype(const glsl_type *image_type,1219unsigned num_arguments,1220unsigned flags);1221ir_function_signature *_image(image_prototype_ctr prototype,1222const glsl_type *image_type,1223const char *intrinsic_name,1224unsigned num_arguments,1225unsigned flags,1226enum ir_intrinsic_id id);12271228ir_function_signature *_memory_barrier_intrinsic(1229builtin_available_predicate avail,1230enum ir_intrinsic_id id);1231ir_function_signature *_memory_barrier(const char *intrinsic_name,1232builtin_available_predicate avail);12331234ir_function_signature *_ballot_intrinsic();1235ir_function_signature *_ballot();1236ir_function_signature *_read_first_invocation_intrinsic(const glsl_type *type);1237ir_function_signature *_read_first_invocation(const glsl_type *type);1238ir_function_signature *_read_invocation_intrinsic(const glsl_type *type);1239ir_function_signature *_read_invocation(const glsl_type *type);124012411242ir_function_signature *_invocation_interlock_intrinsic(1243builtin_available_predicate avail,1244enum ir_intrinsic_id id);1245ir_function_signature *_invocation_interlock(1246const char *intrinsic_name,1247builtin_available_predicate avail);12481249ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail,1250const glsl_type *type);1251ir_function_signature *_shader_clock(builtin_available_predicate avail,1252const glsl_type *type);12531254ir_function_signature *_vote_intrinsic(builtin_available_predicate avail,1255enum ir_intrinsic_id id);1256ir_function_signature *_vote(const char *intrinsic_name,1257builtin_available_predicate avail);12581259ir_function_signature *_helper_invocation_intrinsic();1260ir_function_signature *_helper_invocation();12611262#undef B01263#undef B11264#undef B21265#undef B31266#undef BA11267#undef BA21268/** @} */1269};12701271enum image_function_flags {1272IMAGE_FUNCTION_EMIT_STUB = (1 << 0),1273IMAGE_FUNCTION_RETURNS_VOID = (1 << 1),1274IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE = (1 << 2),1275IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE = (1 << 3),1276IMAGE_FUNCTION_READ_ONLY = (1 << 4),1277IMAGE_FUNCTION_WRITE_ONLY = (1 << 5),1278IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6),1279IMAGE_FUNCTION_MS_ONLY = (1 << 7),1280IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8),1281IMAGE_FUNCTION_AVAIL_ATOMIC_ADD = (1 << 9),1282IMAGE_FUNCTION_EXT_ONLY = (1 << 10),1283IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE = (1 << 11),1284};12851286} /* anonymous namespace */12871288/**1289* Core builtin_builder functionality:1290* @{1291*/1292builtin_builder::builtin_builder()1293: shader(NULL)1294{1295mem_ctx = NULL;1296}12971298builtin_builder::~builtin_builder()1299{1300mtx_lock(&builtins_lock);13011302ralloc_free(mem_ctx);1303mem_ctx = NULL;13041305ralloc_free(shader);1306shader = NULL;13071308mtx_unlock(&builtins_lock);1309}13101311ir_function_signature *1312builtin_builder::find(_mesa_glsl_parse_state *state,1313const char *name, exec_list *actual_parameters)1314{1315/* The shader currently being compiled requested a built-in function;1316* it needs to link against builtin_builder::shader in order to get them.1317*1318* Even if we don't find a matching signature, we still need to do this so1319* that the "no matching signature" error will list potential candidates1320* from the available built-ins.1321*/1322state->uses_builtin_functions = true;13231324ir_function *f = shader->symbols->get_function(name);1325if (f == NULL)1326return NULL;13271328ir_function_signature *sig =1329f->matching_signature(state, actual_parameters, true);1330if (sig == NULL)1331return NULL;13321333return sig;1334}13351336void1337builtin_builder::initialize()1338{1339/* If already initialized, don't do it again. */1340if (mem_ctx != NULL)1341return;13421343glsl_type_singleton_init_or_ref();13441345mem_ctx = ralloc_context(NULL);1346create_shader();1347create_intrinsics();1348create_builtins();1349}13501351void1352builtin_builder::release()1353{1354ralloc_free(mem_ctx);1355mem_ctx = NULL;13561357ralloc_free(shader);1358shader = NULL;13591360glsl_type_singleton_decref();1361}13621363void1364builtin_builder::create_shader()1365{1366/* The target doesn't actually matter. There's no target for generic1367* GLSL utility code that could be linked against any stage, so just1368* arbitrarily pick GL_VERTEX_SHADER.1369*/1370shader = _mesa_new_shader(0, MESA_SHADER_VERTEX);1371shader->symbols = new(mem_ctx) glsl_symbol_table;1372}13731374/** @} */13751376/**1377* Create ir_function and ir_function_signature objects for each1378* intrinsic.1379*/1380void1381builtin_builder::create_intrinsics()1382{1383add_function("__intrinsic_atomic_read",1384_atomic_counter_intrinsic(shader_atomic_counters,1385ir_intrinsic_atomic_counter_read),1386NULL);1387add_function("__intrinsic_atomic_increment",1388_atomic_counter_intrinsic(shader_atomic_counters,1389ir_intrinsic_atomic_counter_increment),1390NULL);1391add_function("__intrinsic_atomic_predecrement",1392_atomic_counter_intrinsic(shader_atomic_counters,1393ir_intrinsic_atomic_counter_predecrement),1394NULL);13951396add_function("__intrinsic_atomic_add",1397_atomic_intrinsic2(buffer_atomics_supported,1398glsl_type::uint_type,1399ir_intrinsic_generic_atomic_add),1400_atomic_intrinsic2(buffer_atomics_supported,1401glsl_type::int_type,1402ir_intrinsic_generic_atomic_add),1403_atomic_intrinsic2(NV_shader_atomic_float_supported,1404glsl_type::float_type,1405ir_intrinsic_generic_atomic_add),1406_atomic_intrinsic2(buffer_int64_atomics_supported,1407glsl_type::int64_t_type,1408ir_intrinsic_generic_atomic_add),1409_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1410ir_intrinsic_atomic_counter_add),1411NULL);1412add_function("__intrinsic_atomic_min",1413_atomic_intrinsic2(buffer_atomics_supported,1414glsl_type::uint_type,1415ir_intrinsic_generic_atomic_min),1416_atomic_intrinsic2(buffer_atomics_supported,1417glsl_type::int_type,1418ir_intrinsic_generic_atomic_min),1419_atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,1420glsl_type::float_type,1421ir_intrinsic_generic_atomic_min),1422_atomic_intrinsic2(buffer_int64_atomics_supported,1423glsl_type::uint64_t_type,1424ir_intrinsic_generic_atomic_min),1425_atomic_intrinsic2(buffer_int64_atomics_supported,1426glsl_type::int64_t_type,1427ir_intrinsic_generic_atomic_min),1428_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1429ir_intrinsic_atomic_counter_min),1430NULL);1431add_function("__intrinsic_atomic_max",1432_atomic_intrinsic2(buffer_atomics_supported,1433glsl_type::uint_type,1434ir_intrinsic_generic_atomic_max),1435_atomic_intrinsic2(buffer_atomics_supported,1436glsl_type::int_type,1437ir_intrinsic_generic_atomic_max),1438_atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported,1439glsl_type::float_type,1440ir_intrinsic_generic_atomic_max),1441_atomic_intrinsic2(buffer_int64_atomics_supported,1442glsl_type::uint64_t_type,1443ir_intrinsic_generic_atomic_max),1444_atomic_intrinsic2(buffer_int64_atomics_supported,1445glsl_type::int64_t_type,1446ir_intrinsic_generic_atomic_max),1447_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1448ir_intrinsic_atomic_counter_max),1449NULL);1450add_function("__intrinsic_atomic_and",1451_atomic_intrinsic2(buffer_atomics_supported,1452glsl_type::uint_type,1453ir_intrinsic_generic_atomic_and),1454_atomic_intrinsic2(buffer_atomics_supported,1455glsl_type::int_type,1456ir_intrinsic_generic_atomic_and),1457_atomic_intrinsic2(buffer_int64_atomics_supported,1458glsl_type::uint64_t_type,1459ir_intrinsic_generic_atomic_and),1460_atomic_intrinsic2(buffer_int64_atomics_supported,1461glsl_type::int64_t_type,1462ir_intrinsic_generic_atomic_and),1463_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1464ir_intrinsic_atomic_counter_and),1465NULL);1466add_function("__intrinsic_atomic_or",1467_atomic_intrinsic2(buffer_atomics_supported,1468glsl_type::uint_type,1469ir_intrinsic_generic_atomic_or),1470_atomic_intrinsic2(buffer_atomics_supported,1471glsl_type::int_type,1472ir_intrinsic_generic_atomic_or),1473_atomic_intrinsic2(buffer_int64_atomics_supported,1474glsl_type::uint64_t_type,1475ir_intrinsic_generic_atomic_or),1476_atomic_intrinsic2(buffer_int64_atomics_supported,1477glsl_type::int64_t_type,1478ir_intrinsic_generic_atomic_or),1479_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1480ir_intrinsic_atomic_counter_or),1481NULL);1482add_function("__intrinsic_atomic_xor",1483_atomic_intrinsic2(buffer_atomics_supported,1484glsl_type::uint_type,1485ir_intrinsic_generic_atomic_xor),1486_atomic_intrinsic2(buffer_atomics_supported,1487glsl_type::int_type,1488ir_intrinsic_generic_atomic_xor),1489_atomic_intrinsic2(buffer_int64_atomics_supported,1490glsl_type::uint64_t_type,1491ir_intrinsic_generic_atomic_xor),1492_atomic_intrinsic2(buffer_int64_atomics_supported,1493glsl_type::int64_t_type,1494ir_intrinsic_generic_atomic_xor),1495_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1496ir_intrinsic_atomic_counter_xor),1497NULL);1498add_function("__intrinsic_atomic_exchange",1499_atomic_intrinsic2(buffer_atomics_supported,1500glsl_type::uint_type,1501ir_intrinsic_generic_atomic_exchange),1502_atomic_intrinsic2(buffer_atomics_supported,1503glsl_type::int_type,1504ir_intrinsic_generic_atomic_exchange),1505_atomic_intrinsic2(buffer_int64_atomics_supported,1506glsl_type::int64_t_type,1507ir_intrinsic_generic_atomic_exchange),1508_atomic_intrinsic2(NV_shader_atomic_float_supported,1509glsl_type::float_type,1510ir_intrinsic_generic_atomic_exchange),1511_atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop,1512ir_intrinsic_atomic_counter_exchange),1513NULL);1514add_function("__intrinsic_atomic_comp_swap",1515_atomic_intrinsic3(buffer_atomics_supported,1516glsl_type::uint_type,1517ir_intrinsic_generic_atomic_comp_swap),1518_atomic_intrinsic3(buffer_atomics_supported,1519glsl_type::int_type,1520ir_intrinsic_generic_atomic_comp_swap),1521_atomic_intrinsic3(buffer_int64_atomics_supported,1522glsl_type::int64_t_type,1523ir_intrinsic_generic_atomic_comp_swap),1524_atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported,1525glsl_type::float_type,1526ir_intrinsic_generic_atomic_comp_swap),1527_atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop,1528ir_intrinsic_atomic_counter_comp_swap),1529NULL);15301531add_image_functions(false);15321533add_function("__intrinsic_memory_barrier",1534_memory_barrier_intrinsic(shader_image_load_store,1535ir_intrinsic_memory_barrier),1536NULL);1537add_function("__intrinsic_group_memory_barrier",1538_memory_barrier_intrinsic(compute_shader,1539ir_intrinsic_group_memory_barrier),1540NULL);1541add_function("__intrinsic_memory_barrier_atomic_counter",1542_memory_barrier_intrinsic(compute_shader_supported,1543ir_intrinsic_memory_barrier_atomic_counter),1544NULL);1545add_function("__intrinsic_memory_barrier_buffer",1546_memory_barrier_intrinsic(compute_shader_supported,1547ir_intrinsic_memory_barrier_buffer),1548NULL);1549add_function("__intrinsic_memory_barrier_image",1550_memory_barrier_intrinsic(compute_shader_supported,1551ir_intrinsic_memory_barrier_image),1552NULL);1553add_function("__intrinsic_memory_barrier_shared",1554_memory_barrier_intrinsic(compute_shader,1555ir_intrinsic_memory_barrier_shared),1556NULL);15571558add_function("__intrinsic_begin_invocation_interlock",1559_invocation_interlock_intrinsic(1560supports_arb_fragment_shader_interlock,1561ir_intrinsic_begin_invocation_interlock), NULL);15621563add_function("__intrinsic_end_invocation_interlock",1564_invocation_interlock_intrinsic(1565supports_arb_fragment_shader_interlock,1566ir_intrinsic_end_invocation_interlock), NULL);15671568add_function("__intrinsic_shader_clock",1569_shader_clock_intrinsic(shader_clock,1570glsl_type::uvec2_type),1571NULL);15721573add_function("__intrinsic_vote_all",1574_vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_all),1575NULL);1576add_function("__intrinsic_vote_any",1577_vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_any),1578NULL);1579add_function("__intrinsic_vote_eq",1580_vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_eq),1581NULL);15821583add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL);15841585add_function("__intrinsic_read_invocation",1586_read_invocation_intrinsic(glsl_type::float_type),1587_read_invocation_intrinsic(glsl_type::vec2_type),1588_read_invocation_intrinsic(glsl_type::vec3_type),1589_read_invocation_intrinsic(glsl_type::vec4_type),15901591_read_invocation_intrinsic(glsl_type::int_type),1592_read_invocation_intrinsic(glsl_type::ivec2_type),1593_read_invocation_intrinsic(glsl_type::ivec3_type),1594_read_invocation_intrinsic(glsl_type::ivec4_type),15951596_read_invocation_intrinsic(glsl_type::uint_type),1597_read_invocation_intrinsic(glsl_type::uvec2_type),1598_read_invocation_intrinsic(glsl_type::uvec3_type),1599_read_invocation_intrinsic(glsl_type::uvec4_type),1600NULL);16011602add_function("__intrinsic_read_first_invocation",1603_read_first_invocation_intrinsic(glsl_type::float_type),1604_read_first_invocation_intrinsic(glsl_type::vec2_type),1605_read_first_invocation_intrinsic(glsl_type::vec3_type),1606_read_first_invocation_intrinsic(glsl_type::vec4_type),16071608_read_first_invocation_intrinsic(glsl_type::int_type),1609_read_first_invocation_intrinsic(glsl_type::ivec2_type),1610_read_first_invocation_intrinsic(glsl_type::ivec3_type),1611_read_first_invocation_intrinsic(glsl_type::ivec4_type),16121613_read_first_invocation_intrinsic(glsl_type::uint_type),1614_read_first_invocation_intrinsic(glsl_type::uvec2_type),1615_read_first_invocation_intrinsic(glsl_type::uvec3_type),1616_read_first_invocation_intrinsic(glsl_type::uvec4_type),1617NULL);16181619add_function("__intrinsic_helper_invocation",1620_helper_invocation_intrinsic(), NULL);1621}16221623/**1624* Create ir_function and ir_function_signature objects for each built-in.1625*1626* Contains a list of every available built-in.1627*/1628void1629builtin_builder::create_builtins()1630{1631#define F(NAME) \1632add_function(#NAME, \1633_##NAME(glsl_type::float_type), \1634_##NAME(glsl_type::vec2_type), \1635_##NAME(glsl_type::vec3_type), \1636_##NAME(glsl_type::vec4_type), \1637NULL);16381639#define FD(NAME) \1640add_function(#NAME, \1641_##NAME(always_available, glsl_type::float_type), \1642_##NAME(always_available, glsl_type::vec2_type), \1643_##NAME(always_available, glsl_type::vec3_type), \1644_##NAME(always_available, glsl_type::vec4_type), \1645_##NAME(fp64, glsl_type::double_type), \1646_##NAME(fp64, glsl_type::dvec2_type), \1647_##NAME(fp64, glsl_type::dvec3_type), \1648_##NAME(fp64, glsl_type::dvec4_type), \1649NULL);16501651#define FD130(NAME) \1652add_function(#NAME, \1653_##NAME(v130, glsl_type::float_type), \1654_##NAME(v130, glsl_type::vec2_type), \1655_##NAME(v130, glsl_type::vec3_type), \1656_##NAME(v130, glsl_type::vec4_type), \1657_##NAME(fp64, glsl_type::double_type), \1658_##NAME(fp64, glsl_type::dvec2_type), \1659_##NAME(fp64, glsl_type::dvec3_type), \1660_##NAME(fp64, glsl_type::dvec4_type), \1661NULL);16621663#define FD130GS4(NAME) \1664add_function(#NAME, \1665_##NAME(v130_or_gpu_shader4, glsl_type::float_type), \1666_##NAME(v130_or_gpu_shader4, glsl_type::vec2_type), \1667_##NAME(v130_or_gpu_shader4, glsl_type::vec3_type), \1668_##NAME(v130_or_gpu_shader4, glsl_type::vec4_type), \1669_##NAME(fp64, glsl_type::double_type), \1670_##NAME(fp64, glsl_type::dvec2_type), \1671_##NAME(fp64, glsl_type::dvec3_type), \1672_##NAME(fp64, glsl_type::dvec4_type), \1673NULL);16741675#define FDGS5(NAME) \1676add_function(#NAME, \1677_##NAME(gpu_shader5_es, glsl_type::float_type), \1678_##NAME(gpu_shader5_es, glsl_type::vec2_type), \1679_##NAME(gpu_shader5_es, glsl_type::vec3_type), \1680_##NAME(gpu_shader5_es, glsl_type::vec4_type), \1681_##NAME(fp64, glsl_type::double_type), \1682_##NAME(fp64, glsl_type::dvec2_type), \1683_##NAME(fp64, glsl_type::dvec3_type), \1684_##NAME(fp64, glsl_type::dvec4_type), \1685NULL);16861687#define FI(NAME) \1688add_function(#NAME, \1689_##NAME(glsl_type::float_type), \1690_##NAME(glsl_type::vec2_type), \1691_##NAME(glsl_type::vec3_type), \1692_##NAME(glsl_type::vec4_type), \1693_##NAME(glsl_type::int_type), \1694_##NAME(glsl_type::ivec2_type), \1695_##NAME(glsl_type::ivec3_type), \1696_##NAME(glsl_type::ivec4_type), \1697NULL);16981699#define FI64(NAME) \1700add_function(#NAME, \1701_##NAME(always_available, glsl_type::float_type), \1702_##NAME(always_available, glsl_type::vec2_type), \1703_##NAME(always_available, glsl_type::vec3_type), \1704_##NAME(always_available, glsl_type::vec4_type), \1705_##NAME(always_available, glsl_type::int_type), \1706_##NAME(always_available, glsl_type::ivec2_type), \1707_##NAME(always_available, glsl_type::ivec3_type), \1708_##NAME(always_available, glsl_type::ivec4_type), \1709_##NAME(fp64, glsl_type::double_type), \1710_##NAME(fp64, glsl_type::dvec2_type), \1711_##NAME(fp64, glsl_type::dvec3_type), \1712_##NAME(fp64, glsl_type::dvec4_type), \1713_##NAME(int64_avail, glsl_type::int64_t_type), \1714_##NAME(int64_avail, glsl_type::i64vec2_type), \1715_##NAME(int64_avail, glsl_type::i64vec3_type), \1716_##NAME(int64_avail, glsl_type::i64vec4_type), \1717NULL);17181719#define FIUD_VEC(NAME) \1720add_function(#NAME, \1721_##NAME(always_available, glsl_type::vec2_type), \1722_##NAME(always_available, glsl_type::vec3_type), \1723_##NAME(always_available, glsl_type::vec4_type), \1724\1725_##NAME(always_available, glsl_type::ivec2_type), \1726_##NAME(always_available, glsl_type::ivec3_type), \1727_##NAME(always_available, glsl_type::ivec4_type), \1728\1729_##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \1730_##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \1731_##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \1732_##NAME(fp64, glsl_type::dvec2_type), \1733_##NAME(fp64, glsl_type::dvec3_type), \1734_##NAME(fp64, glsl_type::dvec4_type), \1735_##NAME(int64_avail, glsl_type::int64_t_type), \1736_##NAME(int64_avail, glsl_type::i64vec2_type), \1737_##NAME(int64_avail, glsl_type::i64vec3_type), \1738_##NAME(int64_avail, glsl_type::i64vec4_type), \1739_##NAME(int64_avail, glsl_type::uint64_t_type), \1740_##NAME(int64_avail, glsl_type::u64vec2_type), \1741_##NAME(int64_avail, glsl_type::u64vec3_type), \1742_##NAME(int64_avail, glsl_type::u64vec4_type), \1743NULL);17441745#define IU(NAME) \1746add_function(#NAME, \1747_##NAME(glsl_type::int_type), \1748_##NAME(glsl_type::ivec2_type), \1749_##NAME(glsl_type::ivec3_type), \1750_##NAME(glsl_type::ivec4_type), \1751\1752_##NAME(glsl_type::uint_type), \1753_##NAME(glsl_type::uvec2_type), \1754_##NAME(glsl_type::uvec3_type), \1755_##NAME(glsl_type::uvec4_type), \1756NULL);17571758#define FIUBD_VEC(NAME) \1759add_function(#NAME, \1760_##NAME(always_available, glsl_type::vec2_type), \1761_##NAME(always_available, glsl_type::vec3_type), \1762_##NAME(always_available, glsl_type::vec4_type), \1763\1764_##NAME(always_available, glsl_type::ivec2_type), \1765_##NAME(always_available, glsl_type::ivec3_type), \1766_##NAME(always_available, glsl_type::ivec4_type), \1767\1768_##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \1769_##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \1770_##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \1771\1772_##NAME(always_available, glsl_type::bvec2_type), \1773_##NAME(always_available, glsl_type::bvec3_type), \1774_##NAME(always_available, glsl_type::bvec4_type), \1775\1776_##NAME(fp64, glsl_type::dvec2_type), \1777_##NAME(fp64, glsl_type::dvec3_type), \1778_##NAME(fp64, glsl_type::dvec4_type), \1779_##NAME(int64_avail, glsl_type::int64_t_type), \1780_##NAME(int64_avail, glsl_type::i64vec2_type), \1781_##NAME(int64_avail, glsl_type::i64vec3_type), \1782_##NAME(int64_avail, glsl_type::i64vec4_type), \1783_##NAME(int64_avail, glsl_type::uint64_t_type), \1784_##NAME(int64_avail, glsl_type::u64vec2_type), \1785_##NAME(int64_avail, glsl_type::u64vec3_type), \1786_##NAME(int64_avail, glsl_type::u64vec4_type), \1787NULL);17881789#define FIUD2_MIXED(NAME) \1790add_function(#NAME, \1791_##NAME(always_available, glsl_type::float_type, glsl_type::float_type), \1792_##NAME(always_available, glsl_type::vec2_type, glsl_type::float_type), \1793_##NAME(always_available, glsl_type::vec3_type, glsl_type::float_type), \1794_##NAME(always_available, glsl_type::vec4_type, glsl_type::float_type), \1795\1796_##NAME(always_available, glsl_type::vec2_type, glsl_type::vec2_type), \1797_##NAME(always_available, glsl_type::vec3_type, glsl_type::vec3_type), \1798_##NAME(always_available, glsl_type::vec4_type, glsl_type::vec4_type), \1799\1800_##NAME(always_available, glsl_type::int_type, glsl_type::int_type), \1801_##NAME(always_available, glsl_type::ivec2_type, glsl_type::int_type), \1802_##NAME(always_available, glsl_type::ivec3_type, glsl_type::int_type), \1803_##NAME(always_available, glsl_type::ivec4_type, glsl_type::int_type), \1804\1805_##NAME(always_available, glsl_type::ivec2_type, glsl_type::ivec2_type), \1806_##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \1807_##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \1808\1809_##NAME(v130_or_gpu_shader4, glsl_type::uint_type, glsl_type::uint_type), \1810_##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uint_type), \1811_##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uint_type), \1812_##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uint_type), \1813\1814_##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uvec2_type), \1815_##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uvec3_type), \1816_##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uvec4_type), \1817\1818_##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \1819_##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \1820_##NAME(fp64, glsl_type::dvec3_type, glsl_type::double_type), \1821_##NAME(fp64, glsl_type::dvec4_type, glsl_type::double_type), \1822_##NAME(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type), \1823_##NAME(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type), \1824_##NAME(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type), \1825\1826_##NAME(int64_avail, glsl_type::int64_t_type, glsl_type::int64_t_type), \1827_##NAME(int64_avail, glsl_type::i64vec2_type, glsl_type::int64_t_type), \1828_##NAME(int64_avail, glsl_type::i64vec3_type, glsl_type::int64_t_type), \1829_##NAME(int64_avail, glsl_type::i64vec4_type, glsl_type::int64_t_type), \1830_##NAME(int64_avail, glsl_type::i64vec2_type, glsl_type::i64vec2_type), \1831_##NAME(int64_avail, glsl_type::i64vec3_type, glsl_type::i64vec3_type), \1832_##NAME(int64_avail, glsl_type::i64vec4_type, glsl_type::i64vec4_type), \1833_##NAME(int64_avail, glsl_type::uint64_t_type, glsl_type::uint64_t_type), \1834_##NAME(int64_avail, glsl_type::u64vec2_type, glsl_type::uint64_t_type), \1835_##NAME(int64_avail, glsl_type::u64vec3_type, glsl_type::uint64_t_type), \1836_##NAME(int64_avail, glsl_type::u64vec4_type, glsl_type::uint64_t_type), \1837_##NAME(int64_avail, glsl_type::u64vec2_type, glsl_type::u64vec2_type), \1838_##NAME(int64_avail, glsl_type::u64vec3_type, glsl_type::u64vec3_type), \1839_##NAME(int64_avail, glsl_type::u64vec4_type, glsl_type::u64vec4_type), \1840NULL);18411842F(radians)1843F(degrees)1844F(sin)1845F(cos)1846F(tan)1847F(asin)1848F(acos)18491850add_function("atan",1851_atan(glsl_type::float_type),1852_atan(glsl_type::vec2_type),1853_atan(glsl_type::vec3_type),1854_atan(glsl_type::vec4_type),1855_atan2(glsl_type::float_type),1856_atan2(glsl_type::vec2_type),1857_atan2(glsl_type::vec3_type),1858_atan2(glsl_type::vec4_type),1859_atan_op(glsl_type::float_type),1860_atan_op(glsl_type::vec2_type),1861_atan_op(glsl_type::vec3_type),1862_atan_op(glsl_type::vec4_type),1863_atan2_op(glsl_type::float_type),1864_atan2_op(glsl_type::vec2_type),1865_atan2_op(glsl_type::vec3_type),1866_atan2_op(glsl_type::vec4_type),1867NULL);18681869F(sinh)1870F(cosh)1871F(tanh)1872F(asinh)1873F(acosh)1874F(atanh)1875F(pow)1876F(exp)1877F(log)1878F(exp2)1879F(log2)1880FD(sqrt)1881FD(inversesqrt)1882FI64(abs)1883FI64(sign)1884FD(floor)1885FD130(trunc)1886FD130GS4(round)1887FD130(roundEven)1888FD(ceil)1889FD(fract)18901891add_function("truncate",1892_truncate(gpu_shader4, glsl_type::float_type),1893_truncate(gpu_shader4, glsl_type::vec2_type),1894_truncate(gpu_shader4, glsl_type::vec3_type),1895_truncate(gpu_shader4, glsl_type::vec4_type),1896NULL);189718981899add_function("mod",1900_mod(always_available, glsl_type::float_type, glsl_type::float_type),1901_mod(always_available, glsl_type::vec2_type, glsl_type::float_type),1902_mod(always_available, glsl_type::vec3_type, glsl_type::float_type),1903_mod(always_available, glsl_type::vec4_type, glsl_type::float_type),19041905_mod(always_available, glsl_type::vec2_type, glsl_type::vec2_type),1906_mod(always_available, glsl_type::vec3_type, glsl_type::vec3_type),1907_mod(always_available, glsl_type::vec4_type, glsl_type::vec4_type),19081909_mod(fp64, glsl_type::double_type, glsl_type::double_type),1910_mod(fp64, glsl_type::dvec2_type, glsl_type::double_type),1911_mod(fp64, glsl_type::dvec3_type, glsl_type::double_type),1912_mod(fp64, glsl_type::dvec4_type, glsl_type::double_type),19131914_mod(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),1915_mod(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),1916_mod(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),1917NULL);19181919FD130(modf)19201921FIUD2_MIXED(min)1922FIUD2_MIXED(max)1923FIUD2_MIXED(clamp)19241925add_function("mix",1926_mix_lrp(always_available, glsl_type::float_type, glsl_type::float_type),1927_mix_lrp(always_available, glsl_type::vec2_type, glsl_type::float_type),1928_mix_lrp(always_available, glsl_type::vec3_type, glsl_type::float_type),1929_mix_lrp(always_available, glsl_type::vec4_type, glsl_type::float_type),19301931_mix_lrp(always_available, glsl_type::vec2_type, glsl_type::vec2_type),1932_mix_lrp(always_available, glsl_type::vec3_type, glsl_type::vec3_type),1933_mix_lrp(always_available, glsl_type::vec4_type, glsl_type::vec4_type),19341935_mix_lrp(fp64, glsl_type::double_type, glsl_type::double_type),1936_mix_lrp(fp64, glsl_type::dvec2_type, glsl_type::double_type),1937_mix_lrp(fp64, glsl_type::dvec3_type, glsl_type::double_type),1938_mix_lrp(fp64, glsl_type::dvec4_type, glsl_type::double_type),19391940_mix_lrp(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),1941_mix_lrp(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),1942_mix_lrp(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),19431944_mix_sel(v130, glsl_type::float_type, glsl_type::bool_type),1945_mix_sel(v130, glsl_type::vec2_type, glsl_type::bvec2_type),1946_mix_sel(v130, glsl_type::vec3_type, glsl_type::bvec3_type),1947_mix_sel(v130, glsl_type::vec4_type, glsl_type::bvec4_type),19481949_mix_sel(fp64, glsl_type::double_type, glsl_type::bool_type),1950_mix_sel(fp64, glsl_type::dvec2_type, glsl_type::bvec2_type),1951_mix_sel(fp64, glsl_type::dvec3_type, glsl_type::bvec3_type),1952_mix_sel(fp64, glsl_type::dvec4_type, glsl_type::bvec4_type),19531954_mix_sel(shader_integer_mix, glsl_type::int_type, glsl_type::bool_type),1955_mix_sel(shader_integer_mix, glsl_type::ivec2_type, glsl_type::bvec2_type),1956_mix_sel(shader_integer_mix, glsl_type::ivec3_type, glsl_type::bvec3_type),1957_mix_sel(shader_integer_mix, glsl_type::ivec4_type, glsl_type::bvec4_type),19581959_mix_sel(shader_integer_mix, glsl_type::uint_type, glsl_type::bool_type),1960_mix_sel(shader_integer_mix, glsl_type::uvec2_type, glsl_type::bvec2_type),1961_mix_sel(shader_integer_mix, glsl_type::uvec3_type, glsl_type::bvec3_type),1962_mix_sel(shader_integer_mix, glsl_type::uvec4_type, glsl_type::bvec4_type),19631964_mix_sel(shader_integer_mix, glsl_type::bool_type, glsl_type::bool_type),1965_mix_sel(shader_integer_mix, glsl_type::bvec2_type, glsl_type::bvec2_type),1966_mix_sel(shader_integer_mix, glsl_type::bvec3_type, glsl_type::bvec3_type),1967_mix_sel(shader_integer_mix, glsl_type::bvec4_type, glsl_type::bvec4_type),19681969_mix_sel(int64_avail, glsl_type::int64_t_type, glsl_type::bool_type),1970_mix_sel(int64_avail, glsl_type::i64vec2_type, glsl_type::bvec2_type),1971_mix_sel(int64_avail, glsl_type::i64vec3_type, glsl_type::bvec3_type),1972_mix_sel(int64_avail, glsl_type::i64vec4_type, glsl_type::bvec4_type),19731974_mix_sel(int64_avail, glsl_type::uint64_t_type, glsl_type::bool_type),1975_mix_sel(int64_avail, glsl_type::u64vec2_type, glsl_type::bvec2_type),1976_mix_sel(int64_avail, glsl_type::u64vec3_type, glsl_type::bvec3_type),1977_mix_sel(int64_avail, glsl_type::u64vec4_type, glsl_type::bvec4_type),1978NULL);19791980add_function("step",1981_step(always_available, glsl_type::float_type, glsl_type::float_type),1982_step(always_available, glsl_type::float_type, glsl_type::vec2_type),1983_step(always_available, glsl_type::float_type, glsl_type::vec3_type),1984_step(always_available, glsl_type::float_type, glsl_type::vec4_type),19851986_step(always_available, glsl_type::vec2_type, glsl_type::vec2_type),1987_step(always_available, glsl_type::vec3_type, glsl_type::vec3_type),1988_step(always_available, glsl_type::vec4_type, glsl_type::vec4_type),1989_step(fp64, glsl_type::double_type, glsl_type::double_type),1990_step(fp64, glsl_type::double_type, glsl_type::dvec2_type),1991_step(fp64, glsl_type::double_type, glsl_type::dvec3_type),1992_step(fp64, glsl_type::double_type, glsl_type::dvec4_type),19931994_step(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),1995_step(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),1996_step(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),1997NULL);19981999add_function("smoothstep",2000_smoothstep(always_available, glsl_type::float_type, glsl_type::float_type),2001_smoothstep(always_available, glsl_type::float_type, glsl_type::vec2_type),2002_smoothstep(always_available, glsl_type::float_type, glsl_type::vec3_type),2003_smoothstep(always_available, glsl_type::float_type, glsl_type::vec4_type),20042005_smoothstep(always_available, glsl_type::vec2_type, glsl_type::vec2_type),2006_smoothstep(always_available, glsl_type::vec3_type, glsl_type::vec3_type),2007_smoothstep(always_available, glsl_type::vec4_type, glsl_type::vec4_type),2008_smoothstep(fp64, glsl_type::double_type, glsl_type::double_type),2009_smoothstep(fp64, glsl_type::double_type, glsl_type::dvec2_type),2010_smoothstep(fp64, glsl_type::double_type, glsl_type::dvec3_type),2011_smoothstep(fp64, glsl_type::double_type, glsl_type::dvec4_type),20122013_smoothstep(fp64, glsl_type::dvec2_type, glsl_type::dvec2_type),2014_smoothstep(fp64, glsl_type::dvec3_type, glsl_type::dvec3_type),2015_smoothstep(fp64, glsl_type::dvec4_type, glsl_type::dvec4_type),2016NULL);20172018FD130(isnan)2019FD130(isinf)20202021F(floatBitsToInt)2022F(floatBitsToUint)2023add_function("intBitsToFloat",2024_intBitsToFloat(glsl_type::int_type),2025_intBitsToFloat(glsl_type::ivec2_type),2026_intBitsToFloat(glsl_type::ivec3_type),2027_intBitsToFloat(glsl_type::ivec4_type),2028NULL);2029add_function("uintBitsToFloat",2030_uintBitsToFloat(glsl_type::uint_type),2031_uintBitsToFloat(glsl_type::uvec2_type),2032_uintBitsToFloat(glsl_type::uvec3_type),2033_uintBitsToFloat(glsl_type::uvec4_type),2034NULL);20352036add_function("doubleBitsToInt64",2037_doubleBitsToInt64(int64_fp64, glsl_type::double_type),2038_doubleBitsToInt64(int64_fp64, glsl_type::dvec2_type),2039_doubleBitsToInt64(int64_fp64, glsl_type::dvec3_type),2040_doubleBitsToInt64(int64_fp64, glsl_type::dvec4_type),2041NULL);20422043add_function("doubleBitsToUint64",2044_doubleBitsToUint64(int64_fp64, glsl_type::double_type),2045_doubleBitsToUint64(int64_fp64, glsl_type::dvec2_type),2046_doubleBitsToUint64(int64_fp64, glsl_type::dvec3_type),2047_doubleBitsToUint64(int64_fp64, glsl_type::dvec4_type),2048NULL);20492050add_function("int64BitsToDouble",2051_int64BitsToDouble(int64_fp64, glsl_type::int64_t_type),2052_int64BitsToDouble(int64_fp64, glsl_type::i64vec2_type),2053_int64BitsToDouble(int64_fp64, glsl_type::i64vec3_type),2054_int64BitsToDouble(int64_fp64, glsl_type::i64vec4_type),2055NULL);20562057add_function("uint64BitsToDouble",2058_uint64BitsToDouble(int64_fp64, glsl_type::uint64_t_type),2059_uint64BitsToDouble(int64_fp64, glsl_type::u64vec2_type),2060_uint64BitsToDouble(int64_fp64, glsl_type::u64vec3_type),2061_uint64BitsToDouble(int64_fp64, glsl_type::u64vec4_type),2062NULL);20632064add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);2065add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3), NULL);2066add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);2067add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);2068add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);2069add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3), NULL);2070add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);2071add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);2072add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3), NULL);2073add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3), NULL);2074add_function("packDouble2x32", _packDouble2x32(fp64), NULL);2075add_function("unpackDouble2x32", _unpackDouble2x32(fp64), NULL);20762077add_function("packInt2x32", _packInt2x32(int64_avail), NULL);2078add_function("unpackInt2x32", _unpackInt2x32(int64_avail), NULL);2079add_function("packUint2x32", _packUint2x32(int64_avail), NULL);2080add_function("unpackUint2x32", _unpackUint2x32(int64_avail), NULL);20812082FD(length)2083FD(distance)2084FD(dot)20852086add_function("cross", _cross(always_available, glsl_type::vec3_type),2087_cross(fp64, glsl_type::dvec3_type), NULL);20882089FD(normalize)2090add_function("ftransform", _ftransform(), NULL);2091FD(faceforward)2092FD(reflect)2093FD(refract)2094// ...2095add_function("matrixCompMult",2096_matrixCompMult(always_available, glsl_type::mat2_type),2097_matrixCompMult(always_available, glsl_type::mat3_type),2098_matrixCompMult(always_available, glsl_type::mat4_type),2099_matrixCompMult(always_available, glsl_type::mat2x3_type),2100_matrixCompMult(always_available, glsl_type::mat2x4_type),2101_matrixCompMult(always_available, glsl_type::mat3x2_type),2102_matrixCompMult(always_available, glsl_type::mat3x4_type),2103_matrixCompMult(always_available, glsl_type::mat4x2_type),2104_matrixCompMult(always_available, glsl_type::mat4x3_type),2105_matrixCompMult(fp64, glsl_type::dmat2_type),2106_matrixCompMult(fp64, glsl_type::dmat3_type),2107_matrixCompMult(fp64, glsl_type::dmat4_type),2108_matrixCompMult(fp64, glsl_type::dmat2x3_type),2109_matrixCompMult(fp64, glsl_type::dmat2x4_type),2110_matrixCompMult(fp64, glsl_type::dmat3x2_type),2111_matrixCompMult(fp64, glsl_type::dmat3x4_type),2112_matrixCompMult(fp64, glsl_type::dmat4x2_type),2113_matrixCompMult(fp64, glsl_type::dmat4x3_type),2114NULL);2115add_function("outerProduct",2116_outerProduct(v120, glsl_type::mat2_type),2117_outerProduct(v120, glsl_type::mat3_type),2118_outerProduct(v120, glsl_type::mat4_type),2119_outerProduct(v120, glsl_type::mat2x3_type),2120_outerProduct(v120, glsl_type::mat2x4_type),2121_outerProduct(v120, glsl_type::mat3x2_type),2122_outerProduct(v120, glsl_type::mat3x4_type),2123_outerProduct(v120, glsl_type::mat4x2_type),2124_outerProduct(v120, glsl_type::mat4x3_type),2125_outerProduct(fp64, glsl_type::dmat2_type),2126_outerProduct(fp64, glsl_type::dmat3_type),2127_outerProduct(fp64, glsl_type::dmat4_type),2128_outerProduct(fp64, glsl_type::dmat2x3_type),2129_outerProduct(fp64, glsl_type::dmat2x4_type),2130_outerProduct(fp64, glsl_type::dmat3x2_type),2131_outerProduct(fp64, glsl_type::dmat3x4_type),2132_outerProduct(fp64, glsl_type::dmat4x2_type),2133_outerProduct(fp64, glsl_type::dmat4x3_type),2134NULL);2135add_function("determinant",2136_determinant_mat2(v120, glsl_type::mat2_type),2137_determinant_mat3(v120, glsl_type::mat3_type),2138_determinant_mat4(v120, glsl_type::mat4_type),2139_determinant_mat2(fp64, glsl_type::dmat2_type),2140_determinant_mat3(fp64, glsl_type::dmat3_type),2141_determinant_mat4(fp64, glsl_type::dmat4_type),21422143NULL);2144add_function("inverse",2145_inverse_mat2(v140_or_es3, glsl_type::mat2_type),2146_inverse_mat3(v140_or_es3, glsl_type::mat3_type),2147_inverse_mat4(v140_or_es3, glsl_type::mat4_type),2148_inverse_mat2(fp64, glsl_type::dmat2_type),2149_inverse_mat3(fp64, glsl_type::dmat3_type),2150_inverse_mat4(fp64, glsl_type::dmat4_type),2151NULL);2152add_function("transpose",2153_transpose(v120, glsl_type::mat2_type),2154_transpose(v120, glsl_type::mat3_type),2155_transpose(v120, glsl_type::mat4_type),2156_transpose(v120, glsl_type::mat2x3_type),2157_transpose(v120, glsl_type::mat2x4_type),2158_transpose(v120, glsl_type::mat3x2_type),2159_transpose(v120, glsl_type::mat3x4_type),2160_transpose(v120, glsl_type::mat4x2_type),2161_transpose(v120, glsl_type::mat4x3_type),2162_transpose(fp64, glsl_type::dmat2_type),2163_transpose(fp64, glsl_type::dmat3_type),2164_transpose(fp64, glsl_type::dmat4_type),2165_transpose(fp64, glsl_type::dmat2x3_type),2166_transpose(fp64, glsl_type::dmat2x4_type),2167_transpose(fp64, glsl_type::dmat3x2_type),2168_transpose(fp64, glsl_type::dmat3x4_type),2169_transpose(fp64, glsl_type::dmat4x2_type),2170_transpose(fp64, glsl_type::dmat4x3_type),2171NULL);2172FIUD_VEC(lessThan)2173FIUD_VEC(lessThanEqual)2174FIUD_VEC(greaterThan)2175FIUD_VEC(greaterThanEqual)2176FIUBD_VEC(notEqual)2177FIUBD_VEC(equal)21782179add_function("any",2180_any(glsl_type::bvec2_type),2181_any(glsl_type::bvec3_type),2182_any(glsl_type::bvec4_type),2183NULL);21842185add_function("all",2186_all(glsl_type::bvec2_type),2187_all(glsl_type::bvec3_type),2188_all(glsl_type::bvec4_type),2189NULL);21902191add_function("not",2192_not(glsl_type::bvec2_type),2193_not(glsl_type::bvec3_type),2194_not(glsl_type::bvec4_type),2195NULL);21962197add_function("textureSize",2198_textureSize(v130, glsl_type::int_type, glsl_type::sampler1D_type),2199_textureSize(v130, glsl_type::int_type, glsl_type::isampler1D_type),2200_textureSize(v130, glsl_type::int_type, glsl_type::usampler1D_type),22012202_textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2D_type),2203_textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler2D_type),2204_textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler2D_type),22052206_textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler3D_type),2207_textureSize(v130, glsl_type::ivec3_type, glsl_type::isampler3D_type),2208_textureSize(v130, glsl_type::ivec3_type, glsl_type::usampler3D_type),22092210_textureSize(v130, glsl_type::ivec2_type, glsl_type::samplerCube_type),2211_textureSize(v130, glsl_type::ivec2_type, glsl_type::isamplerCube_type),2212_textureSize(v130, glsl_type::ivec2_type, glsl_type::usamplerCube_type),22132214_textureSize(v130, glsl_type::int_type, glsl_type::sampler1DShadow_type),2215_textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DShadow_type),2216_textureSize(v130, glsl_type::ivec2_type, glsl_type::samplerCubeShadow_type),22172218_textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler1DArray_type),2219_textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler1DArray_type),2220_textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler1DArray_type),2221_textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler2DArray_type),2222_textureSize(v130, glsl_type::ivec3_type, glsl_type::isampler2DArray_type),2223_textureSize(v130, glsl_type::ivec3_type, glsl_type::usampler2DArray_type),22242225_textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler1DArrayShadow_type),2226_textureSize(v130, glsl_type::ivec3_type, glsl_type::sampler2DArrayShadow_type),22272228_textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::samplerCubeArray_type),2229_textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::isamplerCubeArray_type),2230_textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::usamplerCubeArray_type),2231_textureSize(texture_cube_map_array, glsl_type::ivec3_type, glsl_type::samplerCubeArrayShadow_type),22322233_textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DRect_type),2234_textureSize(v130, glsl_type::ivec2_type, glsl_type::isampler2DRect_type),2235_textureSize(v130, glsl_type::ivec2_type, glsl_type::usampler2DRect_type),2236_textureSize(v130, glsl_type::ivec2_type, glsl_type::sampler2DRectShadow_type),22372238_textureSize(texture_buffer, glsl_type::int_type, glsl_type::samplerBuffer_type),2239_textureSize(texture_buffer, glsl_type::int_type, glsl_type::isamplerBuffer_type),2240_textureSize(texture_buffer, glsl_type::int_type, glsl_type::usamplerBuffer_type),2241_textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::sampler2DMS_type),2242_textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::isampler2DMS_type),2243_textureSize(texture_multisample, glsl_type::ivec2_type, glsl_type::usampler2DMS_type),22442245_textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::sampler2DMSArray_type),2246_textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::isampler2DMSArray_type),2247_textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::usampler2DMSArray_type),22482249_textureSize(texture_external_es3, glsl_type::ivec2_type, glsl_type::samplerExternalOES_type),2250NULL);22512252add_function("textureSize1D",2253_textureSize(gpu_shader4, glsl_type::int_type, glsl_type::sampler1D_type),2254_textureSize(gpu_shader4_integer, glsl_type::int_type, glsl_type::isampler1D_type),2255_textureSize(gpu_shader4_integer, glsl_type::int_type, glsl_type::usampler1D_type),2256NULL);22572258add_function("textureSize2D",2259_textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::sampler2D_type),2260_textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isampler2D_type),2261_textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usampler2D_type),2262NULL);22632264add_function("textureSize3D",2265_textureSize(gpu_shader4, glsl_type::ivec3_type, glsl_type::sampler3D_type),2266_textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::isampler3D_type),2267_textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::usampler3D_type),2268NULL);22692270add_function("textureSizeCube",2271_textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::samplerCube_type),2272_textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isamplerCube_type),2273_textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usamplerCube_type),2274NULL);22752276add_function("textureSize1DArray",2277_textureSize(gpu_shader4_array, glsl_type::ivec2_type, glsl_type::sampler1DArray_type),2278_textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::isampler1DArray_type),2279_textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::usampler1DArray_type),2280NULL);22812282add_function("textureSize2DArray",2283_textureSize(gpu_shader4_array, glsl_type::ivec3_type, glsl_type::sampler2DArray_type),2284_textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::isampler2DArray_type),2285_textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::usampler2DArray_type),2286NULL);22872288add_function("textureSize2DRect",2289_textureSize(gpu_shader4_rect, glsl_type::ivec2_type, glsl_type::sampler2DRect_type),2290_textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::isampler2DRect_type),2291_textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::usampler2DRect_type),2292NULL);22932294add_function("textureSizeBuffer",2295_textureSize(gpu_shader4_tbo, glsl_type::int_type, glsl_type::samplerBuffer_type),2296_textureSize(gpu_shader4_tbo_integer, glsl_type::int_type, glsl_type::isamplerBuffer_type),2297_textureSize(gpu_shader4_tbo_integer, glsl_type::int_type, glsl_type::usamplerBuffer_type),2298NULL);22992300add_function("textureSamples",2301_textureSamples(shader_samples, glsl_type::sampler2DMS_type),2302_textureSamples(shader_samples, glsl_type::isampler2DMS_type),2303_textureSamples(shader_samples, glsl_type::usampler2DMS_type),23042305_textureSamples(shader_samples, glsl_type::sampler2DMSArray_type),2306_textureSamples(shader_samples, glsl_type::isampler2DMSArray_type),2307_textureSamples(shader_samples, glsl_type::usampler2DMSArray_type),2308NULL);23092310add_function("texture",2311_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),2312_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),2313_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),23142315_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),2316_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),2317_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),23182319_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),2320_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),2321_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),23222323_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),2324_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),2325_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),23262327_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),2328_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),2329_texture(ir_tex, v130, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),23302331_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),2332_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),2333_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),23342335_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),2336_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),2337_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),23382339_texture(ir_tex, texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),2340_texture(ir_tex, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),2341_texture(ir_tex, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),23422343_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),2344_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),2345/* samplerCubeArrayShadow is special; it has an extra parameter2346* for the shadow comparator since there is no vec5 type.2347*/2348_textureCubeArrayShadow(ir_tex, texture_cube_map_array, glsl_type::samplerCubeArrayShadow_type),23492350_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),2351_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),2352_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),23532354_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),23552356_texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type),23572358_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),2359_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),2360_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),23612362_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),2363_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),2364_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),23652366_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),2367_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),2368_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),23692370_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),2371_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),2372_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),23732374_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),2375_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),2376_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),23772378_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),2379_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),2380_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),23812382_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),2383_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),2384_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),23852386_texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),2387_texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),2388_texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),23892390_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),2391_texture(ir_tex, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),2392_texture(ir_txb, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),23932394_textureCubeArrayShadow(ir_tex, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),2395_textureCubeArrayShadow(ir_txb, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),2396NULL);23972398add_function("textureLod",2399_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),2400_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),2401_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),24022403_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),2404_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),2405_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),24062407_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),2408_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),2409_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),24102411_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),2412_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),2413_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),24142415_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),2416_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),24172418_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),2419_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),2420_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),24212422_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),2423_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),2424_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),24252426_texture(ir_txl, texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),2427_texture(ir_txl, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),2428_texture(ir_txl, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),24292430_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),2431_texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),2432_texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),2433_textureCubeArrayShadow(ir_txl, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type),2434NULL);24352436add_function("textureOffset",2437_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),2438_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),2439_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),24402441_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2442_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2443_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),24442445_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2446_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2447_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),24482449_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),2450_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),2451_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),24522453_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),24542455_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2456_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),24572458_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2459_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2460_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),24612462_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2463_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2464_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),24652466_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),2467/* The next one was forgotten in GLSL 1.30 spec. It's from2468* EXT_gpu_shader4 originally. It was added in 4.30 with the2469* wrong syntax. This was corrected in 4.40. 4.30 indicates2470* that it was intended to be included previously, so allow it2471* in 1.30.2472*/2473_texture(ir_tex, v130_desktop, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),24742475_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),2476_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),2477_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),24782479_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2480_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2481_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),24822483_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2484_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2485_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),24862487_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2488_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),24892490_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2491_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2492_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),24932494_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2495_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2496_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),24972498_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),2499_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),2500_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),2501NULL);25022503add_function("texture1DOffset",2504_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),2505_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),2506_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),2507_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),2508_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),2509_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),2510NULL);25112512add_function("texture2DOffset",2513_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2514_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2515_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2516_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2517_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2518_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2519NULL);25202521add_function("texture3DOffset",2522_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2523_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2524_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2525_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2526_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2527_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2528NULL);25292530add_function("texture2DRectOffset",2531_texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),2532_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),2533_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),2534NULL);25352536add_function("shadow2DRectOffset",2537_texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),2538NULL);25392540add_function("shadow1DOffset",2541_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2542_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2543NULL);25442545add_function("shadow2DOffset",2546_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2547_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2548NULL);25492550add_function("texture1DArrayOffset",2551_texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2552_texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2553_texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2554_texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2555_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2556_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2557NULL);25582559add_function("texture2DArrayOffset",2560_texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2561_texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2562_texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2563_texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2564_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2565_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2566NULL);25672568add_function("shadow1DArrayOffset",2569_texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),2570_texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),2571NULL);25722573add_function("shadow2DArrayOffset",2574_texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),2575NULL);25762577add_function("textureProj",2578_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2579_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2580_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2581_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),2582_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),2583_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),25842585_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2586_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2587_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2588_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),2589_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),2590_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),25912592_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),2593_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),2594_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),25952596_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),2597_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),25982599_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),2600_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),2601_texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),2602_texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),26032604_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),2605_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),2606_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),2607_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),26082609_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),26102611_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2612_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2613_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2614_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),2615_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),2616_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),26172618_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2619_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2620_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2621_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),2622_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),2623_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),26242625_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),2626_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),2627_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),26282629_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),2630_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),2631NULL);26322633add_function("texelFetch",2634_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type),2635_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type),2636_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type),26372638_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type),2639_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type),2640_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type),26412642_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type),2643_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type),2644_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type),26452646_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type),2647_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type),2648_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type),26492650_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type),2651_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type),2652_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type),26532654_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type),2655_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type),2656_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type),26572658_texelFetch(texture_buffer, glsl_type::vec4_type, glsl_type::samplerBuffer_type, glsl_type::int_type),2659_texelFetch(texture_buffer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type),2660_texelFetch(texture_buffer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type),26612662_texelFetch(texture_multisample, glsl_type::vec4_type, glsl_type::sampler2DMS_type, glsl_type::ivec2_type),2663_texelFetch(texture_multisample, glsl_type::ivec4_type, glsl_type::isampler2DMS_type, glsl_type::ivec2_type),2664_texelFetch(texture_multisample, glsl_type::uvec4_type, glsl_type::usampler2DMS_type, glsl_type::ivec2_type),26652666_texelFetch(texture_multisample_array, glsl_type::vec4_type, glsl_type::sampler2DMSArray_type, glsl_type::ivec3_type),2667_texelFetch(texture_multisample_array, glsl_type::ivec4_type, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),2668_texelFetch(texture_multisample_array, glsl_type::uvec4_type, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),26692670_texelFetch(texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::ivec2_type),26712672NULL);26732674add_function("texelFetch1D",2675_texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type),2676_texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type),2677_texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type),2678NULL);26792680add_function("texelFetch2D",2681_texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type),2682_texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type),2683_texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type),2684NULL);26852686add_function("texelFetch3D",2687_texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type),2688_texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type),2689_texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type),2690NULL);26912692add_function("texelFetch2DRect",2693_texelFetch(gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type),2694_texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type),2695_texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type),2696NULL);26972698add_function("texelFetch1DArray",2699_texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type),2700_texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type),2701_texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type),2702NULL);27032704add_function("texelFetch2DArray",2705_texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type),2706_texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type),2707_texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type),2708NULL);27092710add_function("texelFetchBuffer",2711_texelFetch(gpu_shader4_tbo, glsl_type::vec4_type, glsl_type::samplerBuffer_type, glsl_type::int_type),2712_texelFetch(gpu_shader4_tbo_integer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type),2713_texelFetch(gpu_shader4_tbo_integer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type),2714NULL);27152716add_function("texelFetchOffset",2717_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type, glsl_type::int_type),2718_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),2719_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type),27202721_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2722_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2723_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),27242725_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),2726_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),2727_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),27282729_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2730_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2731_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),27322733_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),2734_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),2735_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),27362737_texelFetch(v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),2738_texelFetch(v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),2739_texelFetch(v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),27402741NULL);27422743add_function("texelFetch1DOffset",2744_texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type, glsl_type::int_type),2745_texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type),2746_texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type),2747NULL);27482749add_function("texelFetch2DOffset",2750_texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2751_texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2752_texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2753NULL);27542755add_function("texelFetch3DOffset",2756_texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),2757_texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),2758_texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type),2759NULL);27602761add_function("texelFetch2DRectOffset",2762_texelFetch(gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2763_texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2764_texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type),2765NULL);27662767add_function("texelFetch1DArrayOffset",2768_texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),2769_texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),2770_texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type),2771NULL);27722773add_function("texelFetch2DArrayOffset",2774_texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),2775_texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),2776_texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type),2777NULL);27782779add_function("textureProjOffset",2780_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2781_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2782_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2783_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2784_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2785_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),27862787_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2788_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2789_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2790_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2791_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2792_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),27932794_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2795_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2796_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),27972798_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2799_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),28002801_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2802_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2803_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2804_texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2805_texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2806_texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),28072808_texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),28092810_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2811_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2812_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2813_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2814_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2815_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),28162817_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2818_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2819_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2820_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2821_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2822_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),28232824_texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2825_texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2826_texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),28272828_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2829_texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2830NULL);28312832add_function("texture1DProjOffset",2833_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2834_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2835_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2836_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2837_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2838_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2839_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2840_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2841_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2842_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2843_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2844_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2845NULL);28462847add_function("texture2DProjOffset",2848_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2849_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2850_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2851_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2852_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2853_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2854_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2855_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2856_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2857_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2858_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2859_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2860NULL);28612862add_function("texture3DProjOffset",2863_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2864_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2865_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2866_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2867_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2868_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2869NULL);28702871add_function("shadow1DProjOffset",2872_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2873_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2874NULL);28752876add_function("shadow2DProjOffset",2877_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2878_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2879NULL);28802881add_function("texture2DRectProjOffset",2882_texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2883_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2884_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2885_texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2886_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2887_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2888NULL);28892890add_function("shadow2DRectProjOffset",2891_texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2892NULL);28932894add_function("textureLodOffset",2895_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),2896_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),2897_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),28982899_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2900_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2901_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),29022903_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2904_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2905_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),29062907_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2908_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),29092910_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2911_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2912_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),29132914_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2915_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2916_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),29172918_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),2919_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),2920NULL);29212922add_function("texture1DLodOffset",2923_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),2924_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),2925_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),2926NULL);29272928add_function("texture2DLodOffset",2929_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2930_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2931_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),2932NULL);29332934add_function("texture3DLodOffset",2935_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2936_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2937_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),2938NULL);29392940add_function("shadow1DLodOffset",2941_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2942NULL);29432944add_function("shadow2DLodOffset",2945_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),2946NULL);29472948add_function("texture1DArrayLodOffset",2949_texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2950_texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2951_texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),2952NULL);29532954add_function("texture2DArrayLodOffset",2955_texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2956_texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2957_texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),2958NULL);29592960add_function("shadow1DArrayLodOffset",2961_texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),2962NULL);29632964add_function("textureProjLod",2965_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2966_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2967_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),2968_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),2969_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),2970_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),29712972_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2973_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2974_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),2975_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),2976_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),2977_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),29782979_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),2980_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),2981_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),29822983_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),2984_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),2985NULL);29862987add_function("textureProjLodOffset",2988_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2989_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2990_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),2991_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2992_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2993_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),29942995_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2996_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2997_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),2998_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),2999_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3000_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),30013002_texture(ir_txl, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3003_texture(ir_txl, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3004_texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),30053006_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3007_texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3008NULL);30093010add_function("texture1DProjLodOffset",3011_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3012_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3013_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3014_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3015_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3016_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3017NULL);30183019add_function("texture2DProjLodOffset",3020_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3021_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3022_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3023_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3024_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3025_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3026NULL);30273028add_function("texture3DProjLodOffset",3029_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3030_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3031_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3032NULL);30333034add_function("shadow1DProjLodOffset",3035_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3036NULL);30373038add_function("shadow2DProjLodOffset",3039_texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3040NULL);30413042add_function("textureGrad",3043_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),3044_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),3045_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),30463047_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3048_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),3049_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),30503051_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),3052_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),3053_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),30543055_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3056_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),3057_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),30583059_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),3060_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),3061_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),30623063_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),30643065_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),3066_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),3067_texture(ir_txd, v130, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),30683069_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),3070_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),3071_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),30723073_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),3074_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),3075_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),30763077_texture(ir_txd, texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),3078_texture(ir_txd, texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),3079_texture(ir_txd, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),30803081_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),3082_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),3083NULL);30843085add_function("textureGradOffset",3086_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),3087_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),3088_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),30893090_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3091_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3092_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),30933094_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),3095_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),3096_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),30973098_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),3099_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),3100_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),31013102_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),31033104_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),3105_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),31063107_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),3108_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),3109_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),31103111_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3112_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3113_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),31143115_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),3116_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),3117NULL);31183119add_function("texture1DGradOffset",3120_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET),3121_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET),3122_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET),3123NULL);31243125add_function("texture2DGradOffset",3126_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3127_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3128_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3129NULL);31303131add_function("texture3DGradOffset",3132_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET),3133_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET),3134_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET),3135NULL);31363137add_function("texture2DRectGradOffset",3138_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),3139_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),3140_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET),3141NULL);31423143add_function("shadow2DRectGradOffset",3144_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET),3145NULL);31463147add_function("shadow1DGradOffset",3148_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET),3149NULL);31503151add_function("shadow2DGradOffset",3152_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET),3153NULL);31543155add_function("texture1DArrayGradOffset",3156_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),3157_texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),3158_texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET),3159NULL);31603161add_function("texture2DArrayGradOffset",3162_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3163_texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3164_texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3165NULL);31663167add_function("shadow1DArrayGradOffset",3168_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),3169NULL);31703171add_function("shadow2DArrayGradOffset",3172_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET),3173NULL);31743175add_function("textureProjGrad",3176_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3177_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3178_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3179_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3180_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3181_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),31823183_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3184_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3185_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3186_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3187_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3188_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),31893190_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3191_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3192_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),31933194_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3195_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3196_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3197_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3198_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3199_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),32003201_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),32023203_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3204_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3205NULL);32063207add_function("textureProjGradOffset",3208_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3209_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3210_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3211_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3212_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3213_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),32143215_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3216_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3217_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3218_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3219_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3220_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),32213222_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3223_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3224_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),32253226_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3227_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3228_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3229_texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3230_texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3231_texture(ir_txd, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),32323233_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),32343235_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3236_texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3237NULL);32383239add_function("texture1DProjGradOffset",3240_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3241_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3242_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET),3243_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3244_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3245_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3246NULL);32473248add_function("texture2DProjGradOffset",3249_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3250_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3251_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3252_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3253_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3254_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3255NULL);32563257add_function("texture3DProjGradOffset",3258_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3259_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3260_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3261NULL);32623263add_function("texture2DRectProjGradOffset",3264_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3265_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3266_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET),3267_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3268_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3269_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3270NULL);32713272add_function("shadow2DRectProjGradOffset",3273_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3274NULL);32753276add_function("shadow1DProjGradOffset",3277_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3278NULL);32793280add_function("shadow2DProjGradOffset",3281_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET),3282NULL);32833284add_function("EmitVertex", _EmitVertex(), NULL);3285add_function("EndPrimitive", _EndPrimitive(), NULL);3286add_function("EmitStreamVertex",3287_EmitStreamVertex(gs_streams, glsl_type::uint_type),3288_EmitStreamVertex(gs_streams, glsl_type::int_type),3289NULL);3290add_function("EndStreamPrimitive",3291_EndStreamPrimitive(gs_streams, glsl_type::uint_type),3292_EndStreamPrimitive(gs_streams, glsl_type::int_type),3293NULL);3294add_function("barrier", _barrier(), NULL);32953296add_function("textureQueryLOD",3297_textureQueryLod(texture_query_lod, glsl_type::sampler1D_type, glsl_type::float_type),3298_textureQueryLod(texture_query_lod, glsl_type::isampler1D_type, glsl_type::float_type),3299_textureQueryLod(texture_query_lod, glsl_type::usampler1D_type, glsl_type::float_type),33003301_textureQueryLod(texture_query_lod, glsl_type::sampler2D_type, glsl_type::vec2_type),3302_textureQueryLod(texture_query_lod, glsl_type::isampler2D_type, glsl_type::vec2_type),3303_textureQueryLod(texture_query_lod, glsl_type::usampler2D_type, glsl_type::vec2_type),33043305_textureQueryLod(texture_query_lod, glsl_type::sampler3D_type, glsl_type::vec3_type),3306_textureQueryLod(texture_query_lod, glsl_type::isampler3D_type, glsl_type::vec3_type),3307_textureQueryLod(texture_query_lod, glsl_type::usampler3D_type, glsl_type::vec3_type),33083309_textureQueryLod(texture_query_lod, glsl_type::samplerCube_type, glsl_type::vec3_type),3310_textureQueryLod(texture_query_lod, glsl_type::isamplerCube_type, glsl_type::vec3_type),3311_textureQueryLod(texture_query_lod, glsl_type::usamplerCube_type, glsl_type::vec3_type),33123313_textureQueryLod(texture_query_lod, glsl_type::sampler1DArray_type, glsl_type::float_type),3314_textureQueryLod(texture_query_lod, glsl_type::isampler1DArray_type, glsl_type::float_type),3315_textureQueryLod(texture_query_lod, glsl_type::usampler1DArray_type, glsl_type::float_type),33163317_textureQueryLod(texture_query_lod, glsl_type::sampler2DArray_type, glsl_type::vec2_type),3318_textureQueryLod(texture_query_lod, glsl_type::isampler2DArray_type, glsl_type::vec2_type),3319_textureQueryLod(texture_query_lod, glsl_type::usampler2DArray_type, glsl_type::vec2_type),33203321_textureQueryLod(texture_query_lod, glsl_type::samplerCubeArray_type, glsl_type::vec3_type),3322_textureQueryLod(texture_query_lod, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type),3323_textureQueryLod(texture_query_lod, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type),33243325_textureQueryLod(texture_query_lod, glsl_type::sampler1DShadow_type, glsl_type::float_type),3326_textureQueryLod(texture_query_lod, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),3327_textureQueryLod(texture_query_lod, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),3328_textureQueryLod(texture_query_lod, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type),3329_textureQueryLod(texture_query_lod, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type),3330_textureQueryLod(texture_query_lod, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type),3331NULL);33323333add_function("textureQueryLod",3334_textureQueryLod(v400_derivatives_only, glsl_type::sampler1D_type, glsl_type::float_type),3335_textureQueryLod(v400_derivatives_only, glsl_type::isampler1D_type, glsl_type::float_type),3336_textureQueryLod(v400_derivatives_only, glsl_type::usampler1D_type, glsl_type::float_type),33373338_textureQueryLod(v400_derivatives_only, glsl_type::sampler2D_type, glsl_type::vec2_type),3339_textureQueryLod(v400_derivatives_only, glsl_type::isampler2D_type, glsl_type::vec2_type),3340_textureQueryLod(v400_derivatives_only, glsl_type::usampler2D_type, glsl_type::vec2_type),33413342_textureQueryLod(v400_derivatives_only, glsl_type::sampler3D_type, glsl_type::vec3_type),3343_textureQueryLod(v400_derivatives_only, glsl_type::isampler3D_type, glsl_type::vec3_type),3344_textureQueryLod(v400_derivatives_only, glsl_type::usampler3D_type, glsl_type::vec3_type),33453346_textureQueryLod(v400_derivatives_only, glsl_type::samplerCube_type, glsl_type::vec3_type),3347_textureQueryLod(v400_derivatives_only, glsl_type::isamplerCube_type, glsl_type::vec3_type),3348_textureQueryLod(v400_derivatives_only, glsl_type::usamplerCube_type, glsl_type::vec3_type),33493350_textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArray_type, glsl_type::float_type),3351_textureQueryLod(v400_derivatives_only, glsl_type::isampler1DArray_type, glsl_type::float_type),3352_textureQueryLod(v400_derivatives_only, glsl_type::usampler1DArray_type, glsl_type::float_type),33533354_textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArray_type, glsl_type::vec2_type),3355_textureQueryLod(v400_derivatives_only, glsl_type::isampler2DArray_type, glsl_type::vec2_type),3356_textureQueryLod(v400_derivatives_only, glsl_type::usampler2DArray_type, glsl_type::vec2_type),33573358_textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArray_type, glsl_type::vec3_type),3359_textureQueryLod(v400_derivatives_only, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type),3360_textureQueryLod(v400_derivatives_only, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type),33613362_textureQueryLod(v400_derivatives_only, glsl_type::sampler1DShadow_type, glsl_type::float_type),3363_textureQueryLod(v400_derivatives_only, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),3364_textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),3365_textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type),3366_textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type),3367_textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type),3368NULL);33693370add_function("textureQueryLevels",3371_textureQueryLevels(texture_query_levels, glsl_type::sampler1D_type),3372_textureQueryLevels(texture_query_levels, glsl_type::sampler2D_type),3373_textureQueryLevels(texture_query_levels, glsl_type::sampler3D_type),3374_textureQueryLevels(texture_query_levels, glsl_type::samplerCube_type),3375_textureQueryLevels(texture_query_levels, glsl_type::sampler1DArray_type),3376_textureQueryLevels(texture_query_levels, glsl_type::sampler2DArray_type),3377_textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArray_type),3378_textureQueryLevels(texture_query_levels, glsl_type::sampler1DShadow_type),3379_textureQueryLevels(texture_query_levels, glsl_type::sampler2DShadow_type),3380_textureQueryLevels(texture_query_levels, glsl_type::samplerCubeShadow_type),3381_textureQueryLevels(texture_query_levels, glsl_type::sampler1DArrayShadow_type),3382_textureQueryLevels(texture_query_levels, glsl_type::sampler2DArrayShadow_type),3383_textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArrayShadow_type),33843385_textureQueryLevels(texture_query_levels, glsl_type::isampler1D_type),3386_textureQueryLevels(texture_query_levels, glsl_type::isampler2D_type),3387_textureQueryLevels(texture_query_levels, glsl_type::isampler3D_type),3388_textureQueryLevels(texture_query_levels, glsl_type::isamplerCube_type),3389_textureQueryLevels(texture_query_levels, glsl_type::isampler1DArray_type),3390_textureQueryLevels(texture_query_levels, glsl_type::isampler2DArray_type),3391_textureQueryLevels(texture_query_levels, glsl_type::isamplerCubeArray_type),33923393_textureQueryLevels(texture_query_levels, glsl_type::usampler1D_type),3394_textureQueryLevels(texture_query_levels, glsl_type::usampler2D_type),3395_textureQueryLevels(texture_query_levels, glsl_type::usampler3D_type),3396_textureQueryLevels(texture_query_levels, glsl_type::usamplerCube_type),3397_textureQueryLevels(texture_query_levels, glsl_type::usampler1DArray_type),3398_textureQueryLevels(texture_query_levels, glsl_type::usampler2DArray_type),3399_textureQueryLevels(texture_query_levels, glsl_type::usamplerCubeArray_type),34003401NULL);34023403add_function("textureSamplesIdenticalEXT",3404_textureSamplesIdentical(texture_samples_identical, glsl_type::sampler2DMS_type, glsl_type::ivec2_type),3405_textureSamplesIdentical(texture_samples_identical, glsl_type::isampler2DMS_type, glsl_type::ivec2_type),3406_textureSamplesIdentical(texture_samples_identical, glsl_type::usampler2DMS_type, glsl_type::ivec2_type),34073408_textureSamplesIdentical(texture_samples_identical_array, glsl_type::sampler2DMSArray_type, glsl_type::ivec3_type),3409_textureSamplesIdentical(texture_samples_identical_array, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type),3410_textureSamplesIdentical(texture_samples_identical_array, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type),3411NULL);34123413add_function("texture1D",3414_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),3415_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),3416_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),3417_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),3418_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),3419_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),3420NULL);34213422add_function("texture1DArray",3423_texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),3424_texture(ir_txb, texture_array_derivs_only,glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),3425_texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),3426_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),3427_texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),3428_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),3429NULL);34303431add_function("texture1DProj",3432_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3433_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3434_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3435_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3436_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3437_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3438_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3439_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3440_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3441_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3442_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3443_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3444NULL);34453446add_function("texture1DLod",3447_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),3448_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),3449_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),3450NULL);34513452add_function("texture1DArrayLod",3453_texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),3454_texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),3455_texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),3456NULL);34573458add_function("texture1DProjLod",3459_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3460_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3461_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3462_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3463_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3464_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3465NULL);34663467add_function("texture2D",3468_texture(ir_tex, deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3469_texture(ir_txb, deprecated_texture_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3470_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),3471_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),3472_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),3473_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),3474_texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type),3475NULL);34763477add_function("texture2DArray",3478_texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),3479_texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),3480_texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),3481_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),3482_texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),3483_texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),3484NULL);34853486add_function("texture2DProj",3487_texture(ir_tex, deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3488_texture(ir_tex, deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3489_texture(ir_txb, deprecated_texture_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3490_texture(ir_txb, deprecated_texture_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3491_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3492_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3493_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3494_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3495_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3496_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3497_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3498_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3499_texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT),3500_texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT),3501NULL);35023503add_function("texture2DLod",3504_texture(ir_txl, lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3505_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),3506_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),3507NULL);35083509add_function("texture2DArrayLod",3510_texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),3511_texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),3512_texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),3513NULL);35143515add_function("texture2DProjLod",3516_texture(ir_txl, lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3517_texture(ir_txl, lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3518_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3519_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3520_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3521_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3522NULL);35233524add_function("texture3D",3525_texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),3526_texture(ir_txb, derivatives_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),3527_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),3528_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),3529_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),3530_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),3531NULL);35323533add_function("texture3DProj",3534_texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3535_texture(ir_txb, derivatives_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3536_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3537_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3538_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3539_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3540NULL);35413542add_function("texture3DLod",3543_texture(ir_txl, tex3d_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),3544_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),3545_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),3546NULL);35473548add_function("texture3DProjLod",3549_texture(ir_txl, tex3d_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3550_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3551_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3552NULL);35533554add_function("textureCube",3555_texture(ir_tex, deprecated_texture, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3556_texture(ir_txb, deprecated_texture_derivatives_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3557_texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),3558_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),3559_texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),3560_texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),3561NULL);35623563add_function("textureCubeLod",3564_texture(ir_txl, lod_deprecated_texture, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3565_texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),3566_texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),3567NULL);35683569add_function("texture2DRect",3570_texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),3571_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),3572_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),3573NULL);35743575add_function("texture2DRectProj",3576_texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3577_texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3578_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3579_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3580_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3581_texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3582NULL);35833584add_function("shadow1D",3585_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),3586_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),3587NULL);35883589add_function("shadow1DArray",3590_texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),3591_texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),3592NULL);35933594add_function("shadow2D",3595_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),3596_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),3597NULL);35983599add_function("shadow2DArray",3600_texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),3601_texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),3602NULL);36033604add_function("shadow1DProj",3605_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3606_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3607NULL);36083609add_function("shadow2DArray",3610_texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),3611_texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),3612NULL);36133614add_function("shadowCube",3615_texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),3616_texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),3617NULL);36183619add_function("shadow2DProj",3620_texture(ir_tex, v110_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3621_texture(ir_txb, v110_derivatives_only_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3622NULL);36233624add_function("shadow1DLod",3625_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),3626NULL);36273628add_function("shadow2DLod",3629_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),3630NULL);36313632add_function("shadow1DArrayLod",3633_texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),3634NULL);36353636add_function("shadow1DProjLod",3637_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3638NULL);36393640add_function("shadow2DProjLod",3641_texture(ir_txl, v110_lod_deprecated_texture, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3642NULL);36433644add_function("shadow2DRect",3645_texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),3646NULL);36473648add_function("shadow2DRectProj",3649_texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),3650NULL);36513652add_function("texture1DGradARB",3653_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),3654NULL);36553656add_function("texture1DProjGradARB",3657_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3658_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3659NULL);36603661add_function("texture2DGradARB",3662_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3663NULL);36643665add_function("texture2DProjGradARB",3666_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3667_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3668NULL);36693670add_function("texture3DGradARB",3671_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),3672NULL);36733674add_function("texture3DProjGradARB",3675_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3676NULL);36773678add_function("textureCubeGradARB",3679_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3680NULL);36813682add_function("shadow1DGradARB",3683_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),3684NULL);36853686add_function("shadow1DProjGradARB",3687_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3688NULL);36893690add_function("shadow2DGradARB",3691_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),3692NULL);36933694add_function("shadow2DProjGradARB",3695_texture(ir_txd, shader_texture_lod, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3696NULL);36973698add_function("texture2DRectGradARB",3699_texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),3700NULL);37013702add_function("texture2DRectProjGradARB",3703_texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3704_texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3705NULL);37063707add_function("shadow2DRectGradARB",3708_texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),3709NULL);37103711add_function("shadow2DRectProjGradARB",3712_texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),3713NULL);37143715add_function("texture4",3716_texture(ir_tg4, texture_texture4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3717NULL);37183719add_function("texture1DGrad",3720_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type),3721_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type),3722_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type),3723NULL);37243725add_function("texture1DProjGrad",3726_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3727_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3728_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3729_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3730_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT),3731_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT),3732NULL);37333734add_function("texture1DArrayGrad",3735_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),3736_texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type),3737_texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type),3738NULL);37393740add_function("texture2DGrad",3741_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3742_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),3743_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),3744NULL);37453746add_function("texture2DProjGrad",3747_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3748_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3749_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3750_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3751_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT),3752_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT),3753NULL);37543755add_function("texture2DArrayGrad",3756_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),3757_texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),3758_texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),3759NULL);37603761add_function("texture3DGrad",3762_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type),3763_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type),3764_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type),3765NULL);37663767add_function("texture3DProjGrad",3768_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3769_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3770_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT),3771NULL);37723773add_function("textureCubeGrad",3774_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3775_texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),3776_texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),3777NULL);37783779add_function("shadow1DGrad",3780_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type),3781NULL);37823783add_function("shadow1DProjGrad",3784_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3785NULL);37863787add_function("shadow1DArrayGrad",3788_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),3789NULL);37903791add_function("shadow2DGrad",3792_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type),3793NULL);37943795add_function("shadow2DProjGrad",3796_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT),3797NULL);37983799add_function("shadow2DArrayGrad",3800_texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type),3801NULL);38023803add_function("texture2DRectGrad",3804_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),3805_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),3806_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),3807NULL);38083809add_function("texture2DRectProjGrad",3810_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3811_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3812_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3813_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3814_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT),3815_texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT),3816NULL);38173818add_function("shadow2DRectGrad",3819_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type),3820NULL);38213822add_function("shadow2DRectProjGrad",3823_texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT),3824NULL);38253826add_function("shadowCubeGrad",3827_texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type),3828NULL);38293830add_function("textureGather",3831_texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),3832_texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),3833_texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),38343835_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),3836_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),3837_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),38383839_texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),3840_texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),3841_texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),38423843_texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),3844_texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),3845_texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),38463847_texture(ir_tg4, texture_gather_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),3848_texture(ir_tg4, texture_gather_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),3849_texture(ir_tg4, texture_gather_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),38503851_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),3852_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),3853_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),38543855_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),3856_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),3857_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),38583859_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),3860_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),3861_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),38623863_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),3864_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),3865_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),38663867_texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),3868_texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),3869_texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),38703871_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),3872_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type),3873_texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),3874_texture(ir_tg4, gpu_shader5_or_OES_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec4_type),3875_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type),3876NULL);38773878add_function("textureGatherOffset",3879_texture(ir_tg4, texture_gather_only_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3880_texture(ir_tg4, texture_gather_only_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),3881_texture(ir_tg4, texture_gather_only_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),38823883_texture(ir_tg4, texture_gather_only_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3884_texture(ir_tg4, texture_gather_only_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),3885_texture(ir_tg4, texture_gather_only_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),38863887_texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),3888_texture(ir_tg4, es31_not_gs5, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),3889_texture(ir_tg4, es31_not_gs5, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),38903891_texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),3892_texture(ir_tg4, es31_not_gs5, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),3893_texture(ir_tg4, es31_not_gs5, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),38943895_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),3896_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),3897_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),38983899_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),3900_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),3901_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),39023903_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),3904_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),3905_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),39063907_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),3908_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),3909_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),39103911_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),3912_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),3913_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),39143915_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),3916_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),3917_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST | TEX_COMPONENT),39183919_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),3920_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),3921_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),39223923_texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET),3924_texture(ir_tg4, es31_not_gs5, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),3925NULL);39263927add_function("textureGatherOffsets",3928_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),3929_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),3930_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),39313932_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),3933_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),3934_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),39353936_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),3937_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),3938_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),39393940_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),3941_texture(ir_tg4, gpu_shader5_es, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),3942_texture(ir_tg4, gpu_shader5_es, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),39433944_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),3945_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),3946_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),39473948_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),3949_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),3950_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY | TEX_COMPONENT),39513952_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),3953_texture(ir_tg4, gpu_shader5_es, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET_ARRAY),3954_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY),3955NULL);39563957F(dFdx)3958F(dFdy)3959F(fwidth)3960F(dFdxCoarse)3961F(dFdyCoarse)3962F(fwidthCoarse)3963F(dFdxFine)3964F(dFdyFine)3965F(fwidthFine)3966F(noise1)3967F(noise2)3968F(noise3)3969F(noise4)39703971IU(bitfieldExtract)3972IU(bitfieldInsert)3973IU(bitfieldReverse)3974IU(bitCount)3975IU(findLSB)3976IU(findMSB)3977FDGS5(fma)39783979add_function("ldexp",3980_ldexp(glsl_type::float_type, glsl_type::int_type),3981_ldexp(glsl_type::vec2_type, glsl_type::ivec2_type),3982_ldexp(glsl_type::vec3_type, glsl_type::ivec3_type),3983_ldexp(glsl_type::vec4_type, glsl_type::ivec4_type),3984_ldexp(glsl_type::double_type, glsl_type::int_type),3985_ldexp(glsl_type::dvec2_type, glsl_type::ivec2_type),3986_ldexp(glsl_type::dvec3_type, glsl_type::ivec3_type),3987_ldexp(glsl_type::dvec4_type, glsl_type::ivec4_type),3988NULL);39893990add_function("frexp",3991_frexp(glsl_type::float_type, glsl_type::int_type),3992_frexp(glsl_type::vec2_type, glsl_type::ivec2_type),3993_frexp(glsl_type::vec3_type, glsl_type::ivec3_type),3994_frexp(glsl_type::vec4_type, glsl_type::ivec4_type),3995_dfrexp(glsl_type::double_type, glsl_type::int_type),3996_dfrexp(glsl_type::dvec2_type, glsl_type::ivec2_type),3997_dfrexp(glsl_type::dvec3_type, glsl_type::ivec3_type),3998_dfrexp(glsl_type::dvec4_type, glsl_type::ivec4_type),3999NULL);4000add_function("uaddCarry",4001_uaddCarry(glsl_type::uint_type),4002_uaddCarry(glsl_type::uvec2_type),4003_uaddCarry(glsl_type::uvec3_type),4004_uaddCarry(glsl_type::uvec4_type),4005NULL);4006add_function("usubBorrow",4007_usubBorrow(glsl_type::uint_type),4008_usubBorrow(glsl_type::uvec2_type),4009_usubBorrow(glsl_type::uvec3_type),4010_usubBorrow(glsl_type::uvec4_type),4011NULL);4012add_function("imulExtended",4013_mulExtended(glsl_type::int_type),4014_mulExtended(glsl_type::ivec2_type),4015_mulExtended(glsl_type::ivec3_type),4016_mulExtended(glsl_type::ivec4_type),4017NULL);4018add_function("umulExtended",4019_mulExtended(glsl_type::uint_type),4020_mulExtended(glsl_type::uvec2_type),4021_mulExtended(glsl_type::uvec3_type),4022_mulExtended(glsl_type::uvec4_type),4023NULL);4024add_function("interpolateAtCentroid",4025_interpolateAtCentroid(glsl_type::float_type),4026_interpolateAtCentroid(glsl_type::vec2_type),4027_interpolateAtCentroid(glsl_type::vec3_type),4028_interpolateAtCentroid(glsl_type::vec4_type),4029NULL);4030add_function("interpolateAtOffset",4031_interpolateAtOffset(glsl_type::float_type),4032_interpolateAtOffset(glsl_type::vec2_type),4033_interpolateAtOffset(glsl_type::vec3_type),4034_interpolateAtOffset(glsl_type::vec4_type),4035NULL);4036add_function("interpolateAtSample",4037_interpolateAtSample(glsl_type::float_type),4038_interpolateAtSample(glsl_type::vec2_type),4039_interpolateAtSample(glsl_type::vec3_type),4040_interpolateAtSample(glsl_type::vec4_type),4041NULL);40424043add_function("atomicCounter",4044_atomic_counter_op("__intrinsic_atomic_read",4045shader_atomic_counters),4046NULL);4047add_function("atomicCounterIncrement",4048_atomic_counter_op("__intrinsic_atomic_increment",4049shader_atomic_counters),4050NULL);4051add_function("atomicCounterDecrement",4052_atomic_counter_op("__intrinsic_atomic_predecrement",4053shader_atomic_counters),4054NULL);40554056add_function("atomicCounterAddARB",4057_atomic_counter_op1("__intrinsic_atomic_add",4058shader_atomic_counter_ops),4059NULL);4060add_function("atomicCounterSubtractARB",4061_atomic_counter_op1("__intrinsic_atomic_sub",4062shader_atomic_counter_ops),4063NULL);4064add_function("atomicCounterMinARB",4065_atomic_counter_op1("__intrinsic_atomic_min",4066shader_atomic_counter_ops),4067NULL);4068add_function("atomicCounterMaxARB",4069_atomic_counter_op1("__intrinsic_atomic_max",4070shader_atomic_counter_ops),4071NULL);4072add_function("atomicCounterAndARB",4073_atomic_counter_op1("__intrinsic_atomic_and",4074shader_atomic_counter_ops),4075NULL);4076add_function("atomicCounterOrARB",4077_atomic_counter_op1("__intrinsic_atomic_or",4078shader_atomic_counter_ops),4079NULL);4080add_function("atomicCounterXorARB",4081_atomic_counter_op1("__intrinsic_atomic_xor",4082shader_atomic_counter_ops),4083NULL);4084add_function("atomicCounterExchangeARB",4085_atomic_counter_op1("__intrinsic_atomic_exchange",4086shader_atomic_counter_ops),4087NULL);4088add_function("atomicCounterCompSwapARB",4089_atomic_counter_op2("__intrinsic_atomic_comp_swap",4090shader_atomic_counter_ops),4091NULL);40924093add_function("atomicCounterAdd",4094_atomic_counter_op1("__intrinsic_atomic_add",4095v460_desktop),4096NULL);4097add_function("atomicCounterSubtract",4098_atomic_counter_op1("__intrinsic_atomic_sub",4099v460_desktop),4100NULL);4101add_function("atomicCounterMin",4102_atomic_counter_op1("__intrinsic_atomic_min",4103v460_desktop),4104NULL);4105add_function("atomicCounterMax",4106_atomic_counter_op1("__intrinsic_atomic_max",4107v460_desktop),4108NULL);4109add_function("atomicCounterAnd",4110_atomic_counter_op1("__intrinsic_atomic_and",4111v460_desktop),4112NULL);4113add_function("atomicCounterOr",4114_atomic_counter_op1("__intrinsic_atomic_or",4115v460_desktop),4116NULL);4117add_function("atomicCounterXor",4118_atomic_counter_op1("__intrinsic_atomic_xor",4119v460_desktop),4120NULL);4121add_function("atomicCounterExchange",4122_atomic_counter_op1("__intrinsic_atomic_exchange",4123v460_desktop),4124NULL);4125add_function("atomicCounterCompSwap",4126_atomic_counter_op2("__intrinsic_atomic_comp_swap",4127v460_desktop),4128NULL);41294130add_function("atomicAdd",4131_atomic_op2("__intrinsic_atomic_add",4132buffer_atomics_supported,4133glsl_type::uint_type),4134_atomic_op2("__intrinsic_atomic_add",4135buffer_atomics_supported,4136glsl_type::int_type),4137_atomic_op2("__intrinsic_atomic_add",4138shader_atomic_float_add,4139glsl_type::float_type),4140_atomic_op2("__intrinsic_atomic_add",4141buffer_int64_atomics_supported,4142glsl_type::int64_t_type),4143NULL);4144add_function("atomicMin",4145_atomic_op2("__intrinsic_atomic_min",4146buffer_atomics_supported,4147glsl_type::uint_type),4148_atomic_op2("__intrinsic_atomic_min",4149buffer_atomics_supported,4150glsl_type::int_type),4151_atomic_op2("__intrinsic_atomic_min",4152shader_atomic_float_minmax,4153glsl_type::float_type),4154_atomic_op2("__intrinsic_atomic_min",4155buffer_int64_atomics_supported,4156glsl_type::uint64_t_type),4157_atomic_op2("__intrinsic_atomic_min",4158buffer_int64_atomics_supported,4159glsl_type::int64_t_type),4160NULL);4161add_function("atomicMax",4162_atomic_op2("__intrinsic_atomic_max",4163buffer_atomics_supported,4164glsl_type::uint_type),4165_atomic_op2("__intrinsic_atomic_max",4166buffer_atomics_supported,4167glsl_type::int_type),4168_atomic_op2("__intrinsic_atomic_max",4169shader_atomic_float_minmax,4170glsl_type::float_type),4171_atomic_op2("__intrinsic_atomic_max",4172buffer_int64_atomics_supported,4173glsl_type::uint64_t_type),4174_atomic_op2("__intrinsic_atomic_max",4175buffer_int64_atomics_supported,4176glsl_type::int64_t_type),4177NULL);4178add_function("atomicAnd",4179_atomic_op2("__intrinsic_atomic_and",4180buffer_atomics_supported,4181glsl_type::uint_type),4182_atomic_op2("__intrinsic_atomic_and",4183buffer_atomics_supported,4184glsl_type::int_type),4185_atomic_op2("__intrinsic_atomic_and",4186buffer_int64_atomics_supported,4187glsl_type::uint64_t_type),4188_atomic_op2("__intrinsic_atomic_and",4189buffer_int64_atomics_supported,4190glsl_type::int64_t_type),4191NULL);4192add_function("atomicOr",4193_atomic_op2("__intrinsic_atomic_or",4194buffer_atomics_supported,4195glsl_type::uint_type),4196_atomic_op2("__intrinsic_atomic_or",4197buffer_atomics_supported,4198glsl_type::int_type),4199_atomic_op2("__intrinsic_atomic_or",4200buffer_int64_atomics_supported,4201glsl_type::uint64_t_type),4202_atomic_op2("__intrinsic_atomic_or",4203buffer_int64_atomics_supported,4204glsl_type::int64_t_type),4205NULL);4206add_function("atomicXor",4207_atomic_op2("__intrinsic_atomic_xor",4208buffer_atomics_supported,4209glsl_type::uint_type),4210_atomic_op2("__intrinsic_atomic_xor",4211buffer_atomics_supported,4212glsl_type::int_type),4213_atomic_op2("__intrinsic_atomic_xor",4214buffer_int64_atomics_supported,4215glsl_type::uint64_t_type),4216_atomic_op2("__intrinsic_atomic_xor",4217buffer_int64_atomics_supported,4218glsl_type::int64_t_type),4219NULL);4220add_function("atomicExchange",4221_atomic_op2("__intrinsic_atomic_exchange",4222buffer_atomics_supported,4223glsl_type::uint_type),4224_atomic_op2("__intrinsic_atomic_exchange",4225buffer_atomics_supported,4226glsl_type::int_type),4227_atomic_op2("__intrinsic_atomic_exchange",4228buffer_int64_atomics_supported,4229glsl_type::int64_t_type),4230_atomic_op2("__intrinsic_atomic_exchange",4231shader_atomic_float_exchange,4232glsl_type::float_type),4233NULL);4234add_function("atomicCompSwap",4235_atomic_op3("__intrinsic_atomic_comp_swap",4236buffer_atomics_supported,4237glsl_type::uint_type),4238_atomic_op3("__intrinsic_atomic_comp_swap",4239buffer_atomics_supported,4240glsl_type::int_type),4241_atomic_op3("__intrinsic_atomic_comp_swap",4242buffer_int64_atomics_supported,4243glsl_type::int64_t_type),4244_atomic_op3("__intrinsic_atomic_comp_swap",4245shader_atomic_float_minmax,4246glsl_type::float_type),4247NULL);42484249add_function("min3",4250_min3(glsl_type::float_type),4251_min3(glsl_type::vec2_type),4252_min3(glsl_type::vec3_type),4253_min3(glsl_type::vec4_type),42544255_min3(glsl_type::int_type),4256_min3(glsl_type::ivec2_type),4257_min3(glsl_type::ivec3_type),4258_min3(glsl_type::ivec4_type),42594260_min3(glsl_type::uint_type),4261_min3(glsl_type::uvec2_type),4262_min3(glsl_type::uvec3_type),4263_min3(glsl_type::uvec4_type),4264NULL);42654266add_function("max3",4267_max3(glsl_type::float_type),4268_max3(glsl_type::vec2_type),4269_max3(glsl_type::vec3_type),4270_max3(glsl_type::vec4_type),42714272_max3(glsl_type::int_type),4273_max3(glsl_type::ivec2_type),4274_max3(glsl_type::ivec3_type),4275_max3(glsl_type::ivec4_type),42764277_max3(glsl_type::uint_type),4278_max3(glsl_type::uvec2_type),4279_max3(glsl_type::uvec3_type),4280_max3(glsl_type::uvec4_type),4281NULL);42824283add_function("mid3",4284_mid3(glsl_type::float_type),4285_mid3(glsl_type::vec2_type),4286_mid3(glsl_type::vec3_type),4287_mid3(glsl_type::vec4_type),42884289_mid3(glsl_type::int_type),4290_mid3(glsl_type::ivec2_type),4291_mid3(glsl_type::ivec3_type),4292_mid3(glsl_type::ivec4_type),42934294_mid3(glsl_type::uint_type),4295_mid3(glsl_type::uvec2_type),4296_mid3(glsl_type::uvec3_type),4297_mid3(glsl_type::uvec4_type),4298NULL);42994300add_image_functions(true);43014302add_function("memoryBarrier",4303_memory_barrier("__intrinsic_memory_barrier",4304shader_image_load_store),4305NULL);4306add_function("groupMemoryBarrier",4307_memory_barrier("__intrinsic_group_memory_barrier",4308compute_shader),4309NULL);4310add_function("memoryBarrierAtomicCounter",4311_memory_barrier("__intrinsic_memory_barrier_atomic_counter",4312compute_shader_supported),4313NULL);4314add_function("memoryBarrierBuffer",4315_memory_barrier("__intrinsic_memory_barrier_buffer",4316compute_shader_supported),4317NULL);4318add_function("memoryBarrierImage",4319_memory_barrier("__intrinsic_memory_barrier_image",4320compute_shader_supported),4321NULL);4322add_function("memoryBarrierShared",4323_memory_barrier("__intrinsic_memory_barrier_shared",4324compute_shader),4325NULL);43264327add_function("ballotARB", _ballot(), NULL);43284329add_function("readInvocationARB",4330_read_invocation(glsl_type::float_type),4331_read_invocation(glsl_type::vec2_type),4332_read_invocation(glsl_type::vec3_type),4333_read_invocation(glsl_type::vec4_type),43344335_read_invocation(glsl_type::int_type),4336_read_invocation(glsl_type::ivec2_type),4337_read_invocation(glsl_type::ivec3_type),4338_read_invocation(glsl_type::ivec4_type),43394340_read_invocation(glsl_type::uint_type),4341_read_invocation(glsl_type::uvec2_type),4342_read_invocation(glsl_type::uvec3_type),4343_read_invocation(glsl_type::uvec4_type),4344NULL);43454346add_function("readFirstInvocationARB",4347_read_first_invocation(glsl_type::float_type),4348_read_first_invocation(glsl_type::vec2_type),4349_read_first_invocation(glsl_type::vec3_type),4350_read_first_invocation(glsl_type::vec4_type),43514352_read_first_invocation(glsl_type::int_type),4353_read_first_invocation(glsl_type::ivec2_type),4354_read_first_invocation(glsl_type::ivec3_type),4355_read_first_invocation(glsl_type::ivec4_type),43564357_read_first_invocation(glsl_type::uint_type),4358_read_first_invocation(glsl_type::uvec2_type),4359_read_first_invocation(glsl_type::uvec3_type),4360_read_first_invocation(glsl_type::uvec4_type),4361NULL);43624363add_function("clock2x32ARB",4364_shader_clock(shader_clock,4365glsl_type::uvec2_type),4366NULL);43674368add_function("clockARB",4369_shader_clock(shader_clock_int64,4370glsl_type::uint64_t_type),4371NULL);43724373add_function("beginInvocationInterlockARB",4374_invocation_interlock(4375"__intrinsic_begin_invocation_interlock",4376supports_arb_fragment_shader_interlock),4377NULL);43784379add_function("endInvocationInterlockARB",4380_invocation_interlock(4381"__intrinsic_end_invocation_interlock",4382supports_arb_fragment_shader_interlock),4383NULL);43844385add_function("beginInvocationInterlockNV",4386_invocation_interlock(4387"__intrinsic_begin_invocation_interlock",4388supports_nv_fragment_shader_interlock),4389NULL);43904391add_function("endInvocationInterlockNV",4392_invocation_interlock(4393"__intrinsic_end_invocation_interlock",4394supports_nv_fragment_shader_interlock),4395NULL);43964397add_function("anyInvocationARB",4398_vote("__intrinsic_vote_any", vote),4399NULL);44004401add_function("allInvocationsARB",4402_vote("__intrinsic_vote_all", vote),4403NULL);44044405add_function("allInvocationsEqualARB",4406_vote("__intrinsic_vote_eq", vote),4407NULL);44084409add_function("anyInvocationEXT",4410_vote("__intrinsic_vote_any", vote_ext),4411NULL);44124413add_function("allInvocationsEXT",4414_vote("__intrinsic_vote_all", vote_ext),4415NULL);44164417add_function("allInvocationsEqualEXT",4418_vote("__intrinsic_vote_eq", vote_ext),4419NULL);44204421add_function("anyInvocation",4422_vote("__intrinsic_vote_any", v460_desktop),4423NULL);44244425add_function("allInvocations",4426_vote("__intrinsic_vote_all", v460_desktop),4427NULL);44284429add_function("allInvocationsEqual",4430_vote("__intrinsic_vote_eq", v460_desktop),4431NULL);44324433add_function("helperInvocationEXT", _helper_invocation(), NULL);44344435add_function("__builtin_idiv64",4436generate_ir::idiv64(mem_ctx, integer_functions_supported),4437NULL);44384439add_function("__builtin_imod64",4440generate_ir::imod64(mem_ctx, integer_functions_supported),4441NULL);44424443add_function("__builtin_sign64",4444generate_ir::sign64(mem_ctx, integer_functions_supported),4445NULL);44464447add_function("__builtin_udiv64",4448generate_ir::udiv64(mem_ctx, integer_functions_supported),4449NULL);44504451add_function("__builtin_umod64",4452generate_ir::umod64(mem_ctx, integer_functions_supported),4453NULL);44544455add_function("__builtin_umul64",4456generate_ir::umul64(mem_ctx, integer_functions_supported),4457NULL);44584459add_function("countLeadingZeros",4460_countLeadingZeros(shader_integer_functions2,4461glsl_type::uint_type),4462_countLeadingZeros(shader_integer_functions2,4463glsl_type::uvec2_type),4464_countLeadingZeros(shader_integer_functions2,4465glsl_type::uvec3_type),4466_countLeadingZeros(shader_integer_functions2,4467glsl_type::uvec4_type),4468NULL);44694470add_function("countTrailingZeros",4471_countTrailingZeros(shader_integer_functions2,4472glsl_type::uint_type),4473_countTrailingZeros(shader_integer_functions2,4474glsl_type::uvec2_type),4475_countTrailingZeros(shader_integer_functions2,4476glsl_type::uvec3_type),4477_countTrailingZeros(shader_integer_functions2,4478glsl_type::uvec4_type),4479NULL);44804481add_function("absoluteDifference",4482_absoluteDifference(shader_integer_functions2,4483glsl_type::int_type),4484_absoluteDifference(shader_integer_functions2,4485glsl_type::ivec2_type),4486_absoluteDifference(shader_integer_functions2,4487glsl_type::ivec3_type),4488_absoluteDifference(shader_integer_functions2,4489glsl_type::ivec4_type),4490_absoluteDifference(shader_integer_functions2,4491glsl_type::uint_type),4492_absoluteDifference(shader_integer_functions2,4493glsl_type::uvec2_type),4494_absoluteDifference(shader_integer_functions2,4495glsl_type::uvec3_type),4496_absoluteDifference(shader_integer_functions2,4497glsl_type::uvec4_type),44984499_absoluteDifference(shader_integer_functions2_int64,4500glsl_type::int64_t_type),4501_absoluteDifference(shader_integer_functions2_int64,4502glsl_type::i64vec2_type),4503_absoluteDifference(shader_integer_functions2_int64,4504glsl_type::i64vec3_type),4505_absoluteDifference(shader_integer_functions2_int64,4506glsl_type::i64vec4_type),4507_absoluteDifference(shader_integer_functions2_int64,4508glsl_type::uint64_t_type),4509_absoluteDifference(shader_integer_functions2_int64,4510glsl_type::u64vec2_type),4511_absoluteDifference(shader_integer_functions2_int64,4512glsl_type::u64vec3_type),4513_absoluteDifference(shader_integer_functions2_int64,4514glsl_type::u64vec4_type),4515NULL);45164517add_function("addSaturate",4518_addSaturate(shader_integer_functions2,4519glsl_type::int_type),4520_addSaturate(shader_integer_functions2,4521glsl_type::ivec2_type),4522_addSaturate(shader_integer_functions2,4523glsl_type::ivec3_type),4524_addSaturate(shader_integer_functions2,4525glsl_type::ivec4_type),4526_addSaturate(shader_integer_functions2,4527glsl_type::uint_type),4528_addSaturate(shader_integer_functions2,4529glsl_type::uvec2_type),4530_addSaturate(shader_integer_functions2,4531glsl_type::uvec3_type),4532_addSaturate(shader_integer_functions2,4533glsl_type::uvec4_type),45344535_addSaturate(shader_integer_functions2_int64,4536glsl_type::int64_t_type),4537_addSaturate(shader_integer_functions2_int64,4538glsl_type::i64vec2_type),4539_addSaturate(shader_integer_functions2_int64,4540glsl_type::i64vec3_type),4541_addSaturate(shader_integer_functions2_int64,4542glsl_type::i64vec4_type),4543_addSaturate(shader_integer_functions2_int64,4544glsl_type::uint64_t_type),4545_addSaturate(shader_integer_functions2_int64,4546glsl_type::u64vec2_type),4547_addSaturate(shader_integer_functions2_int64,4548glsl_type::u64vec3_type),4549_addSaturate(shader_integer_functions2_int64,4550glsl_type::u64vec4_type),4551NULL);45524553add_function("average",4554_average(shader_integer_functions2,4555glsl_type::int_type),4556_average(shader_integer_functions2,4557glsl_type::ivec2_type),4558_average(shader_integer_functions2,4559glsl_type::ivec3_type),4560_average(shader_integer_functions2,4561glsl_type::ivec4_type),4562_average(shader_integer_functions2,4563glsl_type::uint_type),4564_average(shader_integer_functions2,4565glsl_type::uvec2_type),4566_average(shader_integer_functions2,4567glsl_type::uvec3_type),4568_average(shader_integer_functions2,4569glsl_type::uvec4_type),45704571_average(shader_integer_functions2_int64,4572glsl_type::int64_t_type),4573_average(shader_integer_functions2_int64,4574glsl_type::i64vec2_type),4575_average(shader_integer_functions2_int64,4576glsl_type::i64vec3_type),4577_average(shader_integer_functions2_int64,4578glsl_type::i64vec4_type),4579_average(shader_integer_functions2_int64,4580glsl_type::uint64_t_type),4581_average(shader_integer_functions2_int64,4582glsl_type::u64vec2_type),4583_average(shader_integer_functions2_int64,4584glsl_type::u64vec3_type),4585_average(shader_integer_functions2_int64,4586glsl_type::u64vec4_type),4587NULL);45884589add_function("averageRounded",4590_averageRounded(shader_integer_functions2,4591glsl_type::int_type),4592_averageRounded(shader_integer_functions2,4593glsl_type::ivec2_type),4594_averageRounded(shader_integer_functions2,4595glsl_type::ivec3_type),4596_averageRounded(shader_integer_functions2,4597glsl_type::ivec4_type),4598_averageRounded(shader_integer_functions2,4599glsl_type::uint_type),4600_averageRounded(shader_integer_functions2,4601glsl_type::uvec2_type),4602_averageRounded(shader_integer_functions2,4603glsl_type::uvec3_type),4604_averageRounded(shader_integer_functions2,4605glsl_type::uvec4_type),46064607_averageRounded(shader_integer_functions2_int64,4608glsl_type::int64_t_type),4609_averageRounded(shader_integer_functions2_int64,4610glsl_type::i64vec2_type),4611_averageRounded(shader_integer_functions2_int64,4612glsl_type::i64vec3_type),4613_averageRounded(shader_integer_functions2_int64,4614glsl_type::i64vec4_type),4615_averageRounded(shader_integer_functions2_int64,4616glsl_type::uint64_t_type),4617_averageRounded(shader_integer_functions2_int64,4618glsl_type::u64vec2_type),4619_averageRounded(shader_integer_functions2_int64,4620glsl_type::u64vec3_type),4621_averageRounded(shader_integer_functions2_int64,4622glsl_type::u64vec4_type),4623NULL);46244625add_function("subtractSaturate",4626_subtractSaturate(shader_integer_functions2,4627glsl_type::int_type),4628_subtractSaturate(shader_integer_functions2,4629glsl_type::ivec2_type),4630_subtractSaturate(shader_integer_functions2,4631glsl_type::ivec3_type),4632_subtractSaturate(shader_integer_functions2,4633glsl_type::ivec4_type),4634_subtractSaturate(shader_integer_functions2,4635glsl_type::uint_type),4636_subtractSaturate(shader_integer_functions2,4637glsl_type::uvec2_type),4638_subtractSaturate(shader_integer_functions2,4639glsl_type::uvec3_type),4640_subtractSaturate(shader_integer_functions2,4641glsl_type::uvec4_type),46424643_subtractSaturate(shader_integer_functions2_int64,4644glsl_type::int64_t_type),4645_subtractSaturate(shader_integer_functions2_int64,4646glsl_type::i64vec2_type),4647_subtractSaturate(shader_integer_functions2_int64,4648glsl_type::i64vec3_type),4649_subtractSaturate(shader_integer_functions2_int64,4650glsl_type::i64vec4_type),4651_subtractSaturate(shader_integer_functions2_int64,4652glsl_type::uint64_t_type),4653_subtractSaturate(shader_integer_functions2_int64,4654glsl_type::u64vec2_type),4655_subtractSaturate(shader_integer_functions2_int64,4656glsl_type::u64vec3_type),4657_subtractSaturate(shader_integer_functions2_int64,4658glsl_type::u64vec4_type),4659NULL);46604661add_function("multiply32x16",4662_multiply32x16(shader_integer_functions2,4663glsl_type::int_type),4664_multiply32x16(shader_integer_functions2,4665glsl_type::ivec2_type),4666_multiply32x16(shader_integer_functions2,4667glsl_type::ivec3_type),4668_multiply32x16(shader_integer_functions2,4669glsl_type::ivec4_type),4670_multiply32x16(shader_integer_functions2,4671glsl_type::uint_type),4672_multiply32x16(shader_integer_functions2,4673glsl_type::uvec2_type),4674_multiply32x16(shader_integer_functions2,4675glsl_type::uvec3_type),4676_multiply32x16(shader_integer_functions2,4677glsl_type::uvec4_type),4678NULL);46794680#undef F4681#undef FI4682#undef FIUD_VEC4683#undef FIUBD_VEC4684#undef FIU2_MIXED4685}46864687void4688builtin_builder::add_function(const char *name, ...)4689{4690va_list ap;46914692ir_function *f = new(mem_ctx) ir_function(name);46934694va_start(ap, name);4695while (true) {4696ir_function_signature *sig = va_arg(ap, ir_function_signature *);4697if (sig == NULL)4698break;46994700if (false) {4701exec_list stuff;4702stuff.push_tail(sig);4703validate_ir_tree(&stuff);4704}47054706f->add_signature(sig);4707}4708va_end(ap);47094710shader->symbols->add_function(f);4711}47124713void4714builtin_builder::add_image_function(const char *name,4715const char *intrinsic_name,4716image_prototype_ctr prototype,4717unsigned num_arguments,4718unsigned flags,4719enum ir_intrinsic_id intrinsic_id)4720{4721static const glsl_type *const types[] = {4722glsl_type::image1D_type,4723glsl_type::image2D_type,4724glsl_type::image3D_type,4725glsl_type::image2DRect_type,4726glsl_type::imageCube_type,4727glsl_type::imageBuffer_type,4728glsl_type::image1DArray_type,4729glsl_type::image2DArray_type,4730glsl_type::imageCubeArray_type,4731glsl_type::image2DMS_type,4732glsl_type::image2DMSArray_type,4733glsl_type::iimage1D_type,4734glsl_type::iimage2D_type,4735glsl_type::iimage3D_type,4736glsl_type::iimage2DRect_type,4737glsl_type::iimageCube_type,4738glsl_type::iimageBuffer_type,4739glsl_type::iimage1DArray_type,4740glsl_type::iimage2DArray_type,4741glsl_type::iimageCubeArray_type,4742glsl_type::iimage2DMS_type,4743glsl_type::iimage2DMSArray_type,4744glsl_type::uimage1D_type,4745glsl_type::uimage2D_type,4746glsl_type::uimage3D_type,4747glsl_type::uimage2DRect_type,4748glsl_type::uimageCube_type,4749glsl_type::uimageBuffer_type,4750glsl_type::uimage1DArray_type,4751glsl_type::uimage2DArray_type,4752glsl_type::uimageCubeArray_type,4753glsl_type::uimage2DMS_type,4754glsl_type::uimage2DMSArray_type4755};47564757ir_function *f = new(mem_ctx) ir_function(name);47584759for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) {4760if (types[i]->sampled_type == GLSL_TYPE_FLOAT && !(flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE))4761continue;4762if (types[i]->sampled_type == GLSL_TYPE_INT && !(flags & IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE))4763continue;4764if ((types[i]->sampler_dimensionality != GLSL_SAMPLER_DIM_MS) && (flags & IMAGE_FUNCTION_MS_ONLY))4765continue;4766f->add_signature(_image(prototype, types[i], intrinsic_name,4767num_arguments, flags, intrinsic_id));4768}4769shader->symbols->add_function(f);4770}47714772void4773builtin_builder::add_image_functions(bool glsl)4774{4775const unsigned flags = (glsl ? IMAGE_FUNCTION_EMIT_STUB : 0);47764777add_image_function(glsl ? "imageLoad" : "__intrinsic_image_load",4778"__intrinsic_image_load",4779&builtin_builder::_image_prototype, 0,4780(flags | IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE |4781IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |4782IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |4783IMAGE_FUNCTION_READ_ONLY),4784ir_intrinsic_image_load);47854786add_image_function(glsl ? "imageStore" : "__intrinsic_image_store",4787"__intrinsic_image_store",4788&builtin_builder::_image_prototype, 1,4789(flags | IMAGE_FUNCTION_RETURNS_VOID |4790IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE |4791IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |4792IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |4793IMAGE_FUNCTION_WRITE_ONLY),4794ir_intrinsic_image_store);47954796const unsigned atom_flags = flags | IMAGE_FUNCTION_AVAIL_ATOMIC;47974798add_image_function(glsl ? "imageAtomicAdd" : "__intrinsic_image_atomic_add",4799"__intrinsic_image_atomic_add",4800&builtin_builder::_image_prototype, 1,4801(flags | IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |4802IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |4803IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE),4804ir_intrinsic_image_atomic_add);48054806add_image_function(glsl ? "imageAtomicMin" : "__intrinsic_image_atomic_min",4807"__intrinsic_image_atomic_min",4808&builtin_builder::_image_prototype, 1,4809atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4810ir_intrinsic_image_atomic_min);48114812add_image_function(glsl ? "imageAtomicMax" : "__intrinsic_image_atomic_max",4813"__intrinsic_image_atomic_max",4814&builtin_builder::_image_prototype, 1,4815atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4816ir_intrinsic_image_atomic_max);48174818add_image_function(glsl ? "imageAtomicAnd" : "__intrinsic_image_atomic_and",4819"__intrinsic_image_atomic_and",4820&builtin_builder::_image_prototype, 1,4821atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4822ir_intrinsic_image_atomic_and);48234824add_image_function(glsl ? "imageAtomicOr" : "__intrinsic_image_atomic_or",4825"__intrinsic_image_atomic_or",4826&builtin_builder::_image_prototype, 1,4827atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4828ir_intrinsic_image_atomic_or);48294830add_image_function(glsl ? "imageAtomicXor" : "__intrinsic_image_atomic_xor",4831"__intrinsic_image_atomic_xor",4832&builtin_builder::_image_prototype, 1,4833atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4834ir_intrinsic_image_atomic_xor);48354836add_image_function((glsl ? "imageAtomicExchange" :4837"__intrinsic_image_atomic_exchange"),4838"__intrinsic_image_atomic_exchange",4839&builtin_builder::_image_prototype, 1,4840(flags | IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |4841IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |4842IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE),4843ir_intrinsic_image_atomic_exchange);48444845add_image_function((glsl ? "imageAtomicCompSwap" :4846"__intrinsic_image_atomic_comp_swap"),4847"__intrinsic_image_atomic_comp_swap",4848&builtin_builder::_image_prototype, 2,4849atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4850ir_intrinsic_image_atomic_comp_swap);48514852add_image_function(glsl ? "imageSize" : "__intrinsic_image_size",4853"__intrinsic_image_size",4854&builtin_builder::_image_size_prototype, 1,4855flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |4856IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE,4857ir_intrinsic_image_size);48584859add_image_function(glsl ? "imageSamples" : "__intrinsic_image_samples",4860"__intrinsic_image_samples",4861&builtin_builder::_image_samples_prototype, 1,4862flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE |4863IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE |4864IMAGE_FUNCTION_MS_ONLY,4865ir_intrinsic_image_samples);48664867/* EXT_shader_image_load_store */4868add_image_function(glsl ? "imageAtomicIncWrap" : "__intrinsic_image_atomic_inc_wrap",4869"__intrinsic_image_atomic_inc_wrap",4870&builtin_builder::_image_prototype, 1,4871(atom_flags | IMAGE_FUNCTION_EXT_ONLY),4872ir_intrinsic_image_atomic_inc_wrap);4873add_image_function(glsl ? "imageAtomicDecWrap" : "__intrinsic_image_atomic_dec_wrap",4874"__intrinsic_image_atomic_dec_wrap",4875&builtin_builder::_image_prototype, 1,4876(atom_flags | IMAGE_FUNCTION_EXT_ONLY),4877ir_intrinsic_image_atomic_dec_wrap);4878}48794880ir_variable *4881builtin_builder::in_var(const glsl_type *type, const char *name)4882{4883return new(mem_ctx) ir_variable(type, name, ir_var_function_in);4884}48854886ir_variable *4887builtin_builder::out_var(const glsl_type *type, const char *name)4888{4889return new(mem_ctx) ir_variable(type, name, ir_var_function_out);4890}48914892ir_constant *4893builtin_builder::imm(bool b, unsigned vector_elements)4894{4895return new(mem_ctx) ir_constant(b, vector_elements);4896}48974898ir_constant *4899builtin_builder::imm(float f, unsigned vector_elements)4900{4901return new(mem_ctx) ir_constant(f, vector_elements);4902}49034904ir_constant *4905builtin_builder::imm(int i, unsigned vector_elements)4906{4907return new(mem_ctx) ir_constant(i, vector_elements);4908}49094910ir_constant *4911builtin_builder::imm(unsigned u, unsigned vector_elements)4912{4913return new(mem_ctx) ir_constant(u, vector_elements);4914}49154916ir_constant *4917builtin_builder::imm(double d, unsigned vector_elements)4918{4919return new(mem_ctx) ir_constant(d, vector_elements);4920}49214922ir_constant *4923builtin_builder::imm(const glsl_type *type, const ir_constant_data &data)4924{4925return new(mem_ctx) ir_constant(type, &data);4926}49274928#define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val)49294930ir_dereference_variable *4931builtin_builder::var_ref(ir_variable *var)4932{4933return new(mem_ctx) ir_dereference_variable(var);4934}49354936ir_dereference_array *4937builtin_builder::array_ref(ir_variable *var, int idx)4938{4939return new(mem_ctx) ir_dereference_array(var, imm(idx));4940}49414942/** Return an element of a matrix */4943ir_swizzle *4944builtin_builder::matrix_elt(ir_variable *var, int column, int row)4945{4946return swizzle(array_ref(var, column), row, 1);4947}49484949/**4950* Implementations of built-in functions:4951* @{4952*/4953ir_function_signature *4954builtin_builder::new_sig(const glsl_type *return_type,4955builtin_available_predicate avail,4956int num_params,4957...)4958{4959va_list ap;49604961ir_function_signature *sig =4962new(mem_ctx) ir_function_signature(return_type, avail);49634964exec_list plist;4965va_start(ap, num_params);4966for (int i = 0; i < num_params; i++) {4967plist.push_tail(va_arg(ap, ir_variable *));4968}4969va_end(ap);49704971sig->replace_parameters(&plist);4972return sig;4973}49744975#define MAKE_SIG(return_type, avail, ...) \4976ir_function_signature *sig = \4977new_sig(return_type, avail, __VA_ARGS__); \4978ir_factory body(&sig->body, mem_ctx); \4979sig->is_defined = true;49804981#define MAKE_INTRINSIC(return_type, id, avail, ...) \4982ir_function_signature *sig = \4983new_sig(return_type, avail, __VA_ARGS__); \4984sig->intrinsic_id = id;49854986ir_function_signature *4987builtin_builder::unop(builtin_available_predicate avail,4988ir_expression_operation opcode,4989const glsl_type *return_type,4990const glsl_type *param_type)4991{4992ir_variable *x = in_var(param_type, "x");4993MAKE_SIG(return_type, avail, 1, x);4994body.emit(ret(expr(opcode, x)));4995return sig;4996}49974998#define UNOP(NAME, OPCODE, AVAIL) \4999ir_function_signature * \5000builtin_builder::_##NAME(const glsl_type *type) \5001{ \5002return unop(&AVAIL, OPCODE, type, type); \5003}50045005#define UNOPA(NAME, OPCODE) \5006ir_function_signature * \5007builtin_builder::_##NAME(builtin_available_predicate avail, const glsl_type *type) \5008{ \5009return unop(avail, OPCODE, type, type); \5010}50115012ir_function_signature *5013builtin_builder::binop(builtin_available_predicate avail,5014ir_expression_operation opcode,5015const glsl_type *return_type,5016const glsl_type *param0_type,5017const glsl_type *param1_type,5018bool swap_operands)5019{5020ir_variable *x = in_var(param0_type, "x");5021ir_variable *y = in_var(param1_type, "y");5022MAKE_SIG(return_type, avail, 2, x, y);50235024if (swap_operands)5025body.emit(ret(expr(opcode, y, x)));5026else5027body.emit(ret(expr(opcode, x, y)));50285029return sig;5030}50315032#define BINOP(NAME, OPCODE, AVAIL) \5033ir_function_signature * \5034builtin_builder::_##NAME(const glsl_type *return_type, \5035const glsl_type *param0_type, \5036const glsl_type *param1_type) \5037{ \5038return binop(&AVAIL, OPCODE, return_type, param0_type, param1_type); \5039}50405041/**5042* Angle and Trigonometry Functions @{5043*/50445045ir_function_signature *5046builtin_builder::_radians(const glsl_type *type)5047{5048ir_variable *degrees = in_var(type, "degrees");5049MAKE_SIG(type, always_available, 1, degrees);5050body.emit(ret(mul(degrees, imm(0.0174532925f))));5051return sig;5052}50535054ir_function_signature *5055builtin_builder::_degrees(const glsl_type *type)5056{5057ir_variable *radians = in_var(type, "radians");5058MAKE_SIG(type, always_available, 1, radians);5059body.emit(ret(mul(radians, imm(57.29578f))));5060return sig;5061}50625063UNOP(sin, ir_unop_sin, always_available)5064UNOP(cos, ir_unop_cos, always_available)50655066ir_function_signature *5067builtin_builder::_tan(const glsl_type *type)5068{5069ir_variable *theta = in_var(type, "theta");5070MAKE_SIG(type, always_available, 1, theta);5071body.emit(ret(div(sin(theta), cos(theta))));5072return sig;5073}50745075ir_expression *5076builtin_builder::asin_expr(ir_variable *x, float p0, float p1)5077{5078return mul(sign(x),5079sub(imm(M_PI_2f),5080mul(sqrt(sub(imm(1.0f), abs(x))),5081add(imm(M_PI_2f),5082mul(abs(x),5083add(imm(M_PI_4f - 1.0f),5084mul(abs(x),5085add(imm(p0),5086mul(abs(x), imm(p1))))))))));5087}50885089/**5090* Generate a ir_call to a function with a set of parameters5091*5092* The input \c params can either be a list of \c ir_variable or a list of5093* \c ir_dereference_variable. In the latter case, all nodes will be removed5094* from \c params and used directly as the parameters to the generated5095* \c ir_call.5096*/5097ir_call *5098builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params)5099{5100exec_list actual_params;51015102foreach_in_list_safe(ir_instruction, ir, ¶ms) {5103ir_dereference_variable *d = ir->as_dereference_variable();5104if (d != NULL) {5105d->remove();5106actual_params.push_tail(d);5107} else {5108ir_variable *var = ir->as_variable();5109assert(var != NULL);5110actual_params.push_tail(var_ref(var));5111}5112}51135114ir_function_signature *sig =5115f->exact_matching_signature(NULL, &actual_params);5116if (!sig)5117return NULL;51185119ir_dereference_variable *deref =5120(sig->return_type->is_void() ? NULL : var_ref(ret));51215122return new(mem_ctx) ir_call(sig, deref, &actual_params);5123}51245125ir_function_signature *5126builtin_builder::_asin(const glsl_type *type)5127{5128ir_variable *x = in_var(type, "x");5129MAKE_SIG(type, always_available, 1, x);51305131body.emit(ret(asin_expr(x, 0.086566724f, -0.03102955f)));51325133return sig;5134}51355136ir_function_signature *5137builtin_builder::_acos(const glsl_type *type)5138{5139ir_variable *x = in_var(type, "x");5140MAKE_SIG(type, always_available, 1, x);51415142body.emit(ret(sub(imm(M_PI_2f), asin_expr(x, 0.08132463f, -0.02363318f))));51435144return sig;5145}51465147ir_function_signature *5148builtin_builder::_atan2(const glsl_type *type)5149{5150const unsigned n = type->vector_elements;5151ir_variable *y = in_var(type, "y");5152ir_variable *x = in_var(type, "x");5153MAKE_SIG(type, is_not_nir, 2, y, x);51545155/* If we're on the left half-plane rotate the coordinates Ï€/2 clock-wise5156* for the y=0 discontinuity to end up aligned with the vertical5157* discontinuity of atan(s/t) along t=0. This also makes sure that we5158* don't attempt to divide by zero along the vertical line, which may give5159* unspecified results on non-GLSL 4.1-capable hardware.5160*/5161ir_variable *flip = body.make_temp(glsl_type::bvec(n), "flip");5162body.emit(assign(flip, gequal(imm(0.0f, n), x)));5163ir_variable *s = body.make_temp(type, "s");5164body.emit(assign(s, csel(flip, abs(x), y)));5165ir_variable *t = body.make_temp(type, "t");5166body.emit(assign(t, csel(flip, y, abs(x))));51675168/* If the magnitude of the denominator exceeds some huge value, scale down5169* the arguments in order to prevent the reciprocal operation from flushing5170* its result to zero, which would cause precision problems, and for s5171* infinite would cause us to return a NaN instead of the correct finite5172* value.5173*5174* If fmin and fmax are respectively the smallest and largest positive5175* normalized floating point values representable by the implementation,5176* the constants below should be in agreement with:5177*5178* huge <= 1 / fmin5179* scale <= 1 / fmin / fmax (for |t| >= huge)5180*5181* In addition scale should be a negative power of two in order to avoid5182* loss of precision. The values chosen below should work for most usual5183* floating point representations with at least the dynamic range of ATI's5184* 24-bit representation.5185*/5186ir_constant *huge = imm(1e18f, n);5187ir_variable *scale = body.make_temp(type, "scale");5188body.emit(assign(scale, csel(gequal(abs(t), huge),5189imm(0.25f, n), imm(1.0f, n))));5190ir_variable *rcp_scaled_t = body.make_temp(type, "rcp_scaled_t");5191body.emit(assign(rcp_scaled_t, rcp(mul(t, scale))));5192ir_expression *s_over_t = mul(mul(s, scale), rcp_scaled_t);51935194/* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily5195* that ∞/∞ = 1) in order to comply with the rather artificial rules5196* inherited from IEEE 754-2008, namely:5197*5198* "atan2(±∞, −∞) is ±3Ï€/45199* atan2(±∞, +∞) is ±π/4"5200*5201* Note that this is inconsistent with the rules for the neighborhood of5202* zero that are based on iterated limits:5203*5204* "atan2(±0, −0) is ±π5205* atan2(±0, +0) is ±0"5206*5207* but GLSL specifically allows implementations to deviate from IEEE rules5208* at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as5209* well).5210*/5211ir_expression *tan = csel(equal(abs(x), abs(y)),5212imm(1.0f, n), abs(s_over_t));52135214/* Calculate the arctangent and fix up the result if we had flipped the5215* coordinate system.5216*/5217ir_variable *arc = body.make_temp(type, "arc");5218do_atan(body, type, arc, tan);5219body.emit(assign(arc, add(arc, mul(b2f(flip), imm(M_PI_2f)))));52205221/* Rather convoluted calculation of the sign of the result. When x < 0 we5222* cannot use fsign because we need to be able to distinguish between5223* negative and positive zero. Unfortunately we cannot use bitwise5224* arithmetic tricks either because of back-ends without integer support.5225* When x >= 0 rcp_scaled_t will always be non-negative so this won't be5226* able to distinguish between negative and positive zero, but we don't5227* care because atan2 is continuous along the whole positive y = 05228* half-line, so it won't affect the result significantly.5229*/5230body.emit(ret(csel(less(min2(y, rcp_scaled_t), imm(0.0f, n)),5231neg(arc), arc)));52325233return sig;5234}52355236void5237builtin_builder::do_atan(ir_factory &body, const glsl_type *type, ir_variable *res, operand y_over_x)5238{5239/*5240* range-reduction, first step:5241*5242* / y_over_x if |y_over_x| <= 1.0;5243* x = <5244* \ 1.0 / y_over_x otherwise5245*/5246ir_variable *x = body.make_temp(type, "atan_x");5247body.emit(assign(x, div(min2(abs(y_over_x),5248imm(1.0f)),5249max2(abs(y_over_x),5250imm(1.0f)))));52515252/*5253* approximate atan by evaluating polynomial:5254*5255* x * 0.9999793128310355 - x^3 * 0.3326756418091246 +5256* x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +5257* x^9 * 0.0536813784310406 - x^11 * 0.01213232131734445258*/5259ir_variable *tmp = body.make_temp(type, "atan_tmp");5260body.emit(assign(tmp, mul(x, x)));5261body.emit(assign(tmp, mul(add(mul(sub(mul(add(mul(sub(mul(add(mul(imm(-0.0121323213173444f),5262tmp),5263imm(0.0536813784310406f)),5264tmp),5265imm(0.1173503194786851f)),5266tmp),5267imm(0.1938924977115610f)),5268tmp),5269imm(0.3326756418091246f)),5270tmp),5271imm(0.9999793128310355f)),5272x)));52735274/* range-reduction fixup */5275body.emit(assign(tmp, add(tmp,5276mul(b2f(greater(abs(y_over_x),5277imm(1.0f, type->components()))),5278add(mul(tmp,5279imm(-2.0f)),5280imm(M_PI_2f))))));52815282/* sign fixup */5283body.emit(assign(res, mul(tmp, sign(y_over_x))));5284}52855286ir_function_signature *5287builtin_builder::_atan(const glsl_type *type)5288{5289ir_variable *y_over_x = in_var(type, "y_over_x");5290MAKE_SIG(type, is_not_nir, 1, y_over_x);52915292ir_variable *tmp = body.make_temp(type, "tmp");5293do_atan(body, type, tmp, y_over_x);5294body.emit(ret(tmp));52955296return sig;5297}52985299ir_function_signature *5300builtin_builder::_sinh(const glsl_type *type)5301{5302ir_variable *x = in_var(type, "x");5303MAKE_SIG(type, v130, 1, x);53045305/* 0.5 * (e^x - e^(-x)) */5306body.emit(ret(mul(imm(0.5f), sub(exp(x), exp(neg(x))))));53075308return sig;5309}53105311ir_function_signature *5312builtin_builder::_cosh(const glsl_type *type)5313{5314ir_variable *x = in_var(type, "x");5315MAKE_SIG(type, v130, 1, x);53165317/* 0.5 * (e^x + e^(-x)) */5318body.emit(ret(mul(imm(0.5f), add(exp(x), exp(neg(x))))));53195320return sig;5321}53225323ir_function_signature *5324builtin_builder::_tanh(const glsl_type *type)5325{5326ir_variable *x = in_var(type, "x");5327MAKE_SIG(type, v130, 1, x);53285329/* Clamp x to [-10, +10] to avoid precision problems.5330* When x > 10, e^(-x) is so small relative to e^x that it gets flushed to5331* zero in the computation e^x + e^(-x). The same happens in the other5332* direction when x < -10.5333*/5334ir_variable *t = body.make_temp(type, "tmp");5335body.emit(assign(t, min2(max2(x, imm(-10.0f)), imm(10.0f))));53365337/* (e^x - e^(-x)) / (e^x + e^(-x)) */5338body.emit(ret(div(sub(exp(t), exp(neg(t))),5339add(exp(t), exp(neg(t))))));53405341return sig;5342}53435344ir_function_signature *5345builtin_builder::_asinh(const glsl_type *type)5346{5347ir_variable *x = in_var(type, "x");5348MAKE_SIG(type, v130, 1, x);53495350body.emit(ret(mul(sign(x), log(add(abs(x), sqrt(add(mul(x, x),5351imm(1.0f))))))));5352return sig;5353}53545355ir_function_signature *5356builtin_builder::_acosh(const glsl_type *type)5357{5358ir_variable *x = in_var(type, "x");5359MAKE_SIG(type, v130, 1, x);53605361body.emit(ret(log(add(x, sqrt(sub(mul(x, x), imm(1.0f)))))));5362return sig;5363}53645365ir_function_signature *5366builtin_builder::_atanh(const glsl_type *type)5367{5368ir_variable *x = in_var(type, "x");5369MAKE_SIG(type, v130, 1, x);53705371body.emit(ret(mul(imm(0.5f), log(div(add(imm(1.0f), x),5372sub(imm(1.0f), x))))));5373return sig;5374}5375/** @} */53765377/**5378* Exponential Functions @{5379*/53805381ir_function_signature *5382builtin_builder::_pow(const glsl_type *type)5383{5384return binop(always_available, ir_binop_pow, type, type, type);5385}53865387UNOP(exp, ir_unop_exp, always_available)5388UNOP(log, ir_unop_log, always_available)5389UNOP(exp2, ir_unop_exp2, always_available)5390UNOP(log2, ir_unop_log2, always_available)5391UNOP(atan_op, ir_unop_atan, is_nir)5392UNOPA(sqrt, ir_unop_sqrt)5393UNOPA(inversesqrt, ir_unop_rsq)53945395/** @} */53965397UNOPA(abs, ir_unop_abs)5398UNOPA(sign, ir_unop_sign)5399UNOPA(floor, ir_unop_floor)5400UNOPA(truncate, ir_unop_trunc)5401UNOPA(trunc, ir_unop_trunc)5402UNOPA(round, ir_unop_round_even)5403UNOPA(roundEven, ir_unop_round_even)5404UNOPA(ceil, ir_unop_ceil)5405UNOPA(fract, ir_unop_fract)54065407ir_function_signature *5408builtin_builder::_mod(builtin_available_predicate avail,5409const glsl_type *x_type, const glsl_type *y_type)5410{5411return binop(avail, ir_binop_mod, x_type, x_type, y_type);5412}54135414ir_function_signature *5415builtin_builder::_modf(builtin_available_predicate avail, const glsl_type *type)5416{5417ir_variable *x = in_var(type, "x");5418ir_variable *i = out_var(type, "i");5419MAKE_SIG(type, avail, 2, x, i);54205421ir_variable *t = body.make_temp(type, "t");5422body.emit(assign(t, expr(ir_unop_trunc, x)));5423body.emit(assign(i, t));5424body.emit(ret(sub(x, t)));54255426return sig;5427}54285429ir_function_signature *5430builtin_builder::_min(builtin_available_predicate avail,5431const glsl_type *x_type, const glsl_type *y_type)5432{5433return binop(avail, ir_binop_min, x_type, x_type, y_type);5434}54355436ir_function_signature *5437builtin_builder::_max(builtin_available_predicate avail,5438const glsl_type *x_type, const glsl_type *y_type)5439{5440return binop(avail, ir_binop_max, x_type, x_type, y_type);5441}54425443ir_function_signature *5444builtin_builder::_clamp(builtin_available_predicate avail,5445const glsl_type *val_type, const glsl_type *bound_type)5446{5447ir_variable *x = in_var(val_type, "x");5448ir_variable *minVal = in_var(bound_type, "minVal");5449ir_variable *maxVal = in_var(bound_type, "maxVal");5450MAKE_SIG(val_type, avail, 3, x, minVal, maxVal);54515452body.emit(ret(clamp(x, minVal, maxVal)));54535454return sig;5455}54565457ir_function_signature *5458builtin_builder::_mix_lrp(builtin_available_predicate avail, const glsl_type *val_type, const glsl_type *blend_type)5459{5460ir_variable *x = in_var(val_type, "x");5461ir_variable *y = in_var(val_type, "y");5462ir_variable *a = in_var(blend_type, "a");5463MAKE_SIG(val_type, avail, 3, x, y, a);54645465body.emit(ret(lrp(x, y, a)));54665467return sig;5468}54695470ir_function_signature *5471builtin_builder::_mix_sel(builtin_available_predicate avail,5472const glsl_type *val_type,5473const glsl_type *blend_type)5474{5475ir_variable *x = in_var(val_type, "x");5476ir_variable *y = in_var(val_type, "y");5477ir_variable *a = in_var(blend_type, "a");5478MAKE_SIG(val_type, avail, 3, x, y, a);54795480/* csel matches the ternary operator in that a selector of true choses the5481* first argument. This differs from mix(x, y, false) which choses the5482* second argument (to remain consistent with the interpolating version of5483* mix() which takes a blend factor from 0.0 to 1.0 where 0.0 is only x.5484*5485* To handle the behavior mismatch, reverse the x and y arguments.5486*/5487body.emit(ret(csel(a, y, x)));54885489return sig;5490}54915492ir_function_signature *5493builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_type, const glsl_type *x_type)5494{5495ir_variable *edge = in_var(edge_type, "edge");5496ir_variable *x = in_var(x_type, "x");5497MAKE_SIG(x_type, avail, 2, edge, x);54985499ir_variable *t = body.make_temp(x_type, "t");5500if (x_type->vector_elements == 1) {5501/* Both are floats */5502if (edge_type->is_double())5503body.emit(assign(t, f2d(b2f(gequal(x, edge)))));5504else5505body.emit(assign(t, b2f(gequal(x, edge))));5506} else if (edge_type->vector_elements == 1) {5507/* x is a vector but edge is a float */5508for (int i = 0; i < x_type->vector_elements; i++) {5509if (edge_type->is_double())5510body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), edge))), 1 << i));5511else5512body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), edge)), 1 << i));5513}5514} else {5515/* Both are vectors */5516for (int i = 0; i < x_type->vector_elements; i++) {5517if (edge_type->is_double())5518body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1)))),55191 << i));5520else5521body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1))),55221 << i));55235524}5525}5526body.emit(ret(t));55275528return sig;5529}55305531ir_function_signature *5532builtin_builder::_smoothstep(builtin_available_predicate avail, const glsl_type *edge_type, const glsl_type *x_type)5533{5534ir_variable *edge0 = in_var(edge_type, "edge0");5535ir_variable *edge1 = in_var(edge_type, "edge1");5536ir_variable *x = in_var(x_type, "x");5537MAKE_SIG(x_type, avail, 3, edge0, edge1, x);55385539/* From the GLSL 1.10 specification:5540*5541* genType t;5542* t = clamp((x - edge0) / (edge1 - edge0), 0, 1);5543* return t * t * (3 - 2 * t);5544*/55455546ir_variable *t = body.make_temp(x_type, "t");5547body.emit(assign(t, clamp(div(sub(x, edge0), sub(edge1, edge0)),5548IMM_FP(x_type, 0.0), IMM_FP(x_type, 1.0))));55495550body.emit(ret(mul(t, mul(t, sub(IMM_FP(x_type, 3.0), mul(IMM_FP(x_type, 2.0), t))))));55515552return sig;5553}55545555ir_function_signature *5556builtin_builder::_isnan(builtin_available_predicate avail, const glsl_type *type)5557{5558ir_variable *x = in_var(type, "x");5559MAKE_SIG(glsl_type::bvec(type->vector_elements), avail, 1, x);55605561body.emit(ret(nequal(x, x)));55625563return sig;5564}55655566ir_function_signature *5567builtin_builder::_isinf(builtin_available_predicate avail, const glsl_type *type)5568{5569ir_variable *x = in_var(type, "x");5570MAKE_SIG(glsl_type::bvec(type->vector_elements), avail, 1, x);55715572ir_constant_data infinities;5573for (int i = 0; i < type->vector_elements; i++) {5574switch (type->base_type) {5575case GLSL_TYPE_FLOAT:5576infinities.f[i] = INFINITY;5577break;5578case GLSL_TYPE_DOUBLE:5579infinities.d[i] = INFINITY;5580break;5581default:5582unreachable("unknown type");5583}5584}55855586body.emit(ret(equal(abs(x), imm(type, infinities))));55875588return sig;5589}55905591ir_function_signature *5592builtin_builder::_atan2_op(const glsl_type *x_type)5593{5594return binop(is_nir, ir_binop_atan2, x_type, x_type, x_type);5595}55965597ir_function_signature *5598builtin_builder::_floatBitsToInt(const glsl_type *type)5599{5600ir_variable *x = in_var(type, "x");5601MAKE_SIG(glsl_type::ivec(type->vector_elements), shader_bit_encoding, 1, x);5602body.emit(ret(bitcast_f2i(x)));5603return sig;5604}56055606ir_function_signature *5607builtin_builder::_floatBitsToUint(const glsl_type *type)5608{5609ir_variable *x = in_var(type, "x");5610MAKE_SIG(glsl_type::uvec(type->vector_elements), shader_bit_encoding, 1, x);5611body.emit(ret(bitcast_f2u(x)));5612return sig;5613}56145615ir_function_signature *5616builtin_builder::_intBitsToFloat(const glsl_type *type)5617{5618ir_variable *x = in_var(type, "x");5619MAKE_SIG(glsl_type::vec(type->vector_elements), shader_bit_encoding, 1, x);5620body.emit(ret(bitcast_i2f(x)));5621return sig;5622}56235624ir_function_signature *5625builtin_builder::_uintBitsToFloat(const glsl_type *type)5626{5627ir_variable *x = in_var(type, "x");5628MAKE_SIG(glsl_type::vec(type->vector_elements), shader_bit_encoding, 1, x);5629body.emit(ret(bitcast_u2f(x)));5630return sig;5631}56325633ir_function_signature *5634builtin_builder::_doubleBitsToInt64(builtin_available_predicate avail, const glsl_type *type)5635{5636ir_variable *x = in_var(type, "x");5637MAKE_SIG(glsl_type::i64vec(type->vector_elements), avail, 1, x);5638body.emit(ret(bitcast_d2i64(x)));5639return sig;5640}56415642ir_function_signature *5643builtin_builder::_doubleBitsToUint64(builtin_available_predicate avail, const glsl_type *type)5644{5645ir_variable *x = in_var(type, "x");5646MAKE_SIG(glsl_type::u64vec(type->vector_elements), avail, 1, x);5647body.emit(ret(bitcast_d2u64(x)));5648return sig;5649}56505651ir_function_signature *5652builtin_builder::_int64BitsToDouble(builtin_available_predicate avail, const glsl_type *type)5653{5654ir_variable *x = in_var(type, "x");5655MAKE_SIG(glsl_type::dvec(type->vector_elements), avail, 1, x);5656body.emit(ret(bitcast_i642d(x)));5657return sig;5658}56595660ir_function_signature *5661builtin_builder::_uint64BitsToDouble(builtin_available_predicate avail, const glsl_type *type)5662{5663ir_variable *x = in_var(type, "x");5664MAKE_SIG(glsl_type::dvec(type->vector_elements), avail, 1, x);5665body.emit(ret(bitcast_u642d(x)));5666return sig;5667}56685669ir_function_signature *5670builtin_builder::_packUnorm2x16(builtin_available_predicate avail)5671{5672ir_variable *v = in_var(glsl_type::vec2_type, "v");5673MAKE_SIG(glsl_type::uint_type, avail, 1, v);5674body.emit(ret(expr(ir_unop_pack_unorm_2x16, v)));5675return sig;5676}56775678ir_function_signature *5679builtin_builder::_packSnorm2x16(builtin_available_predicate avail)5680{5681ir_variable *v = in_var(glsl_type::vec2_type, "v");5682MAKE_SIG(glsl_type::uint_type, avail, 1, v);5683body.emit(ret(expr(ir_unop_pack_snorm_2x16, v)));5684return sig;5685}56865687ir_function_signature *5688builtin_builder::_packUnorm4x8(builtin_available_predicate avail)5689{5690ir_variable *v = in_var(glsl_type::vec4_type, "v");5691MAKE_SIG(glsl_type::uint_type, avail, 1, v);5692body.emit(ret(expr(ir_unop_pack_unorm_4x8, v)));5693return sig;5694}56955696ir_function_signature *5697builtin_builder::_packSnorm4x8(builtin_available_predicate avail)5698{5699ir_variable *v = in_var(glsl_type::vec4_type, "v");5700MAKE_SIG(glsl_type::uint_type, avail, 1, v);5701body.emit(ret(expr(ir_unop_pack_snorm_4x8, v)));5702return sig;5703}57045705ir_function_signature *5706builtin_builder::_unpackUnorm2x16(builtin_available_predicate avail)5707{5708ir_variable *p = in_var(glsl_type::uint_type, "p");5709MAKE_SIG(glsl_type::vec2_type, avail, 1, p);5710body.emit(ret(expr(ir_unop_unpack_unorm_2x16, p)));5711return sig;5712}57135714ir_function_signature *5715builtin_builder::_unpackSnorm2x16(builtin_available_predicate avail)5716{5717ir_variable *p = in_var(glsl_type::uint_type, "p");5718MAKE_SIG(glsl_type::vec2_type, avail, 1, p);5719body.emit(ret(expr(ir_unop_unpack_snorm_2x16, p)));5720return sig;5721}572257235724ir_function_signature *5725builtin_builder::_unpackUnorm4x8(builtin_available_predicate avail)5726{5727ir_variable *p = in_var(glsl_type::uint_type, "p");5728MAKE_SIG(glsl_type::vec4_type, avail, 1, p);5729body.emit(ret(expr(ir_unop_unpack_unorm_4x8, p)));5730return sig;5731}57325733ir_function_signature *5734builtin_builder::_unpackSnorm4x8(builtin_available_predicate avail)5735{5736ir_variable *p = in_var(glsl_type::uint_type, "p");5737MAKE_SIG(glsl_type::vec4_type, avail, 1, p);5738body.emit(ret(expr(ir_unop_unpack_snorm_4x8, p)));5739return sig;5740}57415742ir_function_signature *5743builtin_builder::_packHalf2x16(builtin_available_predicate avail)5744{5745ir_variable *v = in_var(glsl_type::vec2_type, "v");5746MAKE_SIG(glsl_type::uint_type, avail, 1, v);5747body.emit(ret(expr(ir_unop_pack_half_2x16, v)));5748return sig;5749}57505751ir_function_signature *5752builtin_builder::_unpackHalf2x16(builtin_available_predicate avail)5753{5754ir_variable *p = in_var(glsl_type::uint_type, "p");5755MAKE_SIG(glsl_type::vec2_type, avail, 1, p);5756body.emit(ret(expr(ir_unop_unpack_half_2x16, p)));5757return sig;5758}57595760ir_function_signature *5761builtin_builder::_packDouble2x32(builtin_available_predicate avail)5762{5763ir_variable *v = in_var(glsl_type::uvec2_type, "v");5764MAKE_SIG(glsl_type::double_type, avail, 1, v);5765body.emit(ret(expr(ir_unop_pack_double_2x32, v)));5766return sig;5767}57685769ir_function_signature *5770builtin_builder::_unpackDouble2x32(builtin_available_predicate avail)5771{5772ir_variable *p = in_var(glsl_type::double_type, "p");5773MAKE_SIG(glsl_type::uvec2_type, avail, 1, p);5774body.emit(ret(expr(ir_unop_unpack_double_2x32, p)));5775return sig;5776}57775778ir_function_signature *5779builtin_builder::_packInt2x32(builtin_available_predicate avail)5780{5781ir_variable *v = in_var(glsl_type::ivec2_type, "v");5782MAKE_SIG(glsl_type::int64_t_type, avail, 1, v);5783body.emit(ret(expr(ir_unop_pack_int_2x32, v)));5784return sig;5785}57865787ir_function_signature *5788builtin_builder::_unpackInt2x32(builtin_available_predicate avail)5789{5790ir_variable *p = in_var(glsl_type::int64_t_type, "p");5791MAKE_SIG(glsl_type::ivec2_type, avail, 1, p);5792body.emit(ret(expr(ir_unop_unpack_int_2x32, p)));5793return sig;5794}57955796ir_function_signature *5797builtin_builder::_packUint2x32(builtin_available_predicate avail)5798{5799ir_variable *v = in_var(glsl_type::uvec2_type, "v");5800MAKE_SIG(glsl_type::uint64_t_type, avail, 1, v);5801body.emit(ret(expr(ir_unop_pack_uint_2x32, v)));5802return sig;5803}58045805ir_function_signature *5806builtin_builder::_unpackUint2x32(builtin_available_predicate avail)5807{5808ir_variable *p = in_var(glsl_type::uint64_t_type, "p");5809MAKE_SIG(glsl_type::uvec2_type, avail, 1, p);5810body.emit(ret(expr(ir_unop_unpack_uint_2x32, p)));5811return sig;5812}58135814ir_function_signature *5815builtin_builder::_length(builtin_available_predicate avail, const glsl_type *type)5816{5817ir_variable *x = in_var(type, "x");5818MAKE_SIG(type->get_base_type(), avail, 1, x);58195820body.emit(ret(sqrt(dot(x, x))));58215822return sig;5823}58245825ir_function_signature *5826builtin_builder::_distance(builtin_available_predicate avail, const glsl_type *type)5827{5828ir_variable *p0 = in_var(type, "p0");5829ir_variable *p1 = in_var(type, "p1");5830MAKE_SIG(type->get_base_type(), avail, 2, p0, p1);58315832if (type->vector_elements == 1) {5833body.emit(ret(abs(sub(p0, p1))));5834} else {5835ir_variable *p = body.make_temp(type, "p");5836body.emit(assign(p, sub(p0, p1)));5837body.emit(ret(sqrt(dot(p, p))));5838}58395840return sig;5841}58425843ir_function_signature *5844builtin_builder::_dot(builtin_available_predicate avail, const glsl_type *type)5845{5846if (type->vector_elements == 1)5847return binop(avail, ir_binop_mul, type, type, type);58485849return binop(avail, ir_binop_dot,5850type->get_base_type(), type, type);5851}58525853ir_function_signature *5854builtin_builder::_cross(builtin_available_predicate avail, const glsl_type *type)5855{5856ir_variable *a = in_var(type, "a");5857ir_variable *b = in_var(type, "b");5858MAKE_SIG(type, avail, 2, a, b);58595860int yzx = MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X, 0);5861int zxy = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_X, SWIZZLE_Y, 0);58625863body.emit(ret(sub(mul(swizzle(a, yzx, 3), swizzle(b, zxy, 3)),5864mul(swizzle(a, zxy, 3), swizzle(b, yzx, 3)))));58655866return sig;5867}58685869ir_function_signature *5870builtin_builder::_normalize(builtin_available_predicate avail, const glsl_type *type)5871{5872ir_variable *x = in_var(type, "x");5873MAKE_SIG(type, avail, 1, x);58745875if (type->vector_elements == 1) {5876body.emit(ret(sign(x)));5877} else {5878body.emit(ret(mul(x, rsq(dot(x, x)))));5879}58805881return sig;5882}58835884ir_function_signature *5885builtin_builder::_ftransform()5886{5887MAKE_SIG(glsl_type::vec4_type, compatibility_vs_only, 0);58885889/* ftransform() refers to global variables, and is always emitted5890* directly by ast_function.cpp. Just emit a prototype here so we5891* can recognize calls to it.5892*/5893return sig;5894}58955896ir_function_signature *5897builtin_builder::_faceforward(builtin_available_predicate avail, const glsl_type *type)5898{5899ir_variable *N = in_var(type, "N");5900ir_variable *I = in_var(type, "I");5901ir_variable *Nref = in_var(type, "Nref");5902MAKE_SIG(type, avail, 3, N, I, Nref);59035904body.emit(if_tree(less(dot(Nref, I), IMM_FP(type, 0.0)),5905ret(N), ret(neg(N))));59065907return sig;5908}59095910ir_function_signature *5911builtin_builder::_reflect(builtin_available_predicate avail, const glsl_type *type)5912{5913ir_variable *I = in_var(type, "I");5914ir_variable *N = in_var(type, "N");5915MAKE_SIG(type, avail, 2, I, N);59165917/* I - 2 * dot(N, I) * N */5918body.emit(ret(sub(I, mul(IMM_FP(type, 2.0), mul(dot(N, I), N)))));59195920return sig;5921}59225923ir_function_signature *5924builtin_builder::_refract(builtin_available_predicate avail, const glsl_type *type)5925{5926ir_variable *I = in_var(type, "I");5927ir_variable *N = in_var(type, "N");5928ir_variable *eta = in_var(type->get_base_type(), "eta");5929MAKE_SIG(type, avail, 3, I, N, eta);59305931ir_variable *n_dot_i = body.make_temp(type->get_base_type(), "n_dot_i");5932body.emit(assign(n_dot_i, dot(N, I)));59335934/* From the GLSL 1.10 specification:5935* k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))5936* if (k < 0.0)5937* return genType(0.0)5938* else5939* return eta * I - (eta * dot(N, I) + sqrt(k)) * N5940*/5941ir_variable *k = body.make_temp(type->get_base_type(), "k");5942body.emit(assign(k, sub(IMM_FP(type, 1.0),5943mul(eta, mul(eta, sub(IMM_FP(type, 1.0),5944mul(n_dot_i, n_dot_i)))))));5945body.emit(if_tree(less(k, IMM_FP(type, 0.0)),5946ret(ir_constant::zero(mem_ctx, type)),5947ret(sub(mul(eta, I),5948mul(add(mul(eta, n_dot_i), sqrt(k)), N)))));59495950return sig;5951}59525953ir_function_signature *5954builtin_builder::_matrixCompMult(builtin_available_predicate avail, const glsl_type *type)5955{5956ir_variable *x = in_var(type, "x");5957ir_variable *y = in_var(type, "y");5958MAKE_SIG(type, avail, 2, x, y);59595960ir_variable *z = body.make_temp(type, "z");5961for (int i = 0; i < type->matrix_columns; i++) {5962body.emit(assign(array_ref(z, i), mul(array_ref(x, i), array_ref(y, i))));5963}5964body.emit(ret(z));59655966return sig;5967}59685969ir_function_signature *5970builtin_builder::_outerProduct(builtin_available_predicate avail, const glsl_type *type)5971{5972ir_variable *c;5973ir_variable *r;59745975if (type->is_double()) {5976r = in_var(glsl_type::dvec(type->matrix_columns), "r");5977c = in_var(glsl_type::dvec(type->vector_elements), "c");5978} else {5979r = in_var(glsl_type::vec(type->matrix_columns), "r");5980c = in_var(glsl_type::vec(type->vector_elements), "c");5981}5982MAKE_SIG(type, avail, 2, c, r);59835984ir_variable *m = body.make_temp(type, "m");5985for (int i = 0; i < type->matrix_columns; i++) {5986body.emit(assign(array_ref(m, i), mul(c, swizzle(r, i, 1))));5987}5988body.emit(ret(m));59895990return sig;5991}59925993ir_function_signature *5994builtin_builder::_transpose(builtin_available_predicate avail, const glsl_type *orig_type)5995{5996const glsl_type *transpose_type =5997glsl_type::get_instance(orig_type->base_type,5998orig_type->matrix_columns,5999orig_type->vector_elements);60006001ir_variable *m = in_var(orig_type, "m");6002MAKE_SIG(transpose_type, avail, 1, m);60036004ir_variable *t = body.make_temp(transpose_type, "t");6005for (int i = 0; i < orig_type->matrix_columns; i++) {6006for (int j = 0; j < orig_type->vector_elements; j++) {6007body.emit(assign(array_ref(t, j),6008matrix_elt(m, i, j),60091 << i));6010}6011}6012body.emit(ret(t));60136014return sig;6015}60166017ir_function_signature *6018builtin_builder::_determinant_mat2(builtin_available_predicate avail, const glsl_type *type)6019{6020ir_variable *m = in_var(type, "m");6021MAKE_SIG(type->get_base_type(), avail, 1, m);60226023body.emit(ret(sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),6024mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1)))));60256026return sig;6027}60286029ir_function_signature *6030builtin_builder::_determinant_mat3(builtin_available_predicate avail, const glsl_type *type)6031{6032ir_variable *m = in_var(type, "m");6033MAKE_SIG(type->get_base_type(), avail, 1, m);60346035ir_expression *f1 =6036sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)),6037mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 1)));60386039ir_expression *f2 =6040sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)),6041mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 0)));60426043ir_expression *f3 =6044sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)),6045mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 0)));60466047body.emit(ret(add(sub(mul(matrix_elt(m, 0, 0), f1),6048mul(matrix_elt(m, 0, 1), f2)),6049mul(matrix_elt(m, 0, 2), f3))));60506051return sig;6052}60536054ir_function_signature *6055builtin_builder::_determinant_mat4(builtin_available_predicate avail, const glsl_type *type)6056{6057ir_variable *m = in_var(type, "m");6058const glsl_type *btype = type->get_base_type();6059MAKE_SIG(btype, avail, 1, m);60606061ir_variable *SubFactor00 = body.make_temp(btype, "SubFactor00");6062ir_variable *SubFactor01 = body.make_temp(btype, "SubFactor01");6063ir_variable *SubFactor02 = body.make_temp(btype, "SubFactor02");6064ir_variable *SubFactor03 = body.make_temp(btype, "SubFactor03");6065ir_variable *SubFactor04 = body.make_temp(btype, "SubFactor04");6066ir_variable *SubFactor05 = body.make_temp(btype, "SubFactor05");6067ir_variable *SubFactor06 = body.make_temp(btype, "SubFactor06");6068ir_variable *SubFactor07 = body.make_temp(btype, "SubFactor07");6069ir_variable *SubFactor08 = body.make_temp(btype, "SubFactor08");6070ir_variable *SubFactor09 = body.make_temp(btype, "SubFactor09");6071ir_variable *SubFactor10 = body.make_temp(btype, "SubFactor10");6072ir_variable *SubFactor11 = body.make_temp(btype, "SubFactor11");6073ir_variable *SubFactor12 = body.make_temp(btype, "SubFactor12");6074ir_variable *SubFactor13 = body.make_temp(btype, "SubFactor13");6075ir_variable *SubFactor14 = body.make_temp(btype, "SubFactor14");6076ir_variable *SubFactor15 = body.make_temp(btype, "SubFactor15");6077ir_variable *SubFactor16 = body.make_temp(btype, "SubFactor16");6078ir_variable *SubFactor17 = body.make_temp(btype, "SubFactor17");6079ir_variable *SubFactor18 = body.make_temp(btype, "SubFactor18");60806081body.emit(assign(SubFactor00, sub(mul(matrix_elt(m, 2, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 2, 3)))));6082body.emit(assign(SubFactor01, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 3)))));6083body.emit(assign(SubFactor02, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 2)))));6084body.emit(assign(SubFactor03, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 3)))));6085body.emit(assign(SubFactor04, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 2)))));6086body.emit(assign(SubFactor05, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 1)))));6087body.emit(assign(SubFactor06, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 1, 3)))));6088body.emit(assign(SubFactor07, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));6089body.emit(assign(SubFactor08, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 2)))));6090body.emit(assign(SubFactor09, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 3)))));6091body.emit(assign(SubFactor10, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 2)))));6092body.emit(assign(SubFactor11, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));6093body.emit(assign(SubFactor12, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 1)))));6094body.emit(assign(SubFactor13, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 2), matrix_elt(m, 1, 3)))));6095body.emit(assign(SubFactor14, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 3)))));6096body.emit(assign(SubFactor15, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 2)))));6097body.emit(assign(SubFactor16, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 3)))));6098body.emit(assign(SubFactor17, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 2)))));6099body.emit(assign(SubFactor18, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 1)))));61006101ir_variable *adj_0 = body.make_temp(btype == glsl_type::float_type ? glsl_type::vec4_type : glsl_type::dvec4_type, "adj_0");61026103body.emit(assign(adj_0,6104add(sub(mul(matrix_elt(m, 1, 1), SubFactor00),6105mul(matrix_elt(m, 1, 2), SubFactor01)),6106mul(matrix_elt(m, 1, 3), SubFactor02)),6107WRITEMASK_X));6108body.emit(assign(adj_0, neg(6109add(sub(mul(matrix_elt(m, 1, 0), SubFactor00),6110mul(matrix_elt(m, 1, 2), SubFactor03)),6111mul(matrix_elt(m, 1, 3), SubFactor04))),6112WRITEMASK_Y));6113body.emit(assign(adj_0,6114add(sub(mul(matrix_elt(m, 1, 0), SubFactor01),6115mul(matrix_elt(m, 1, 1), SubFactor03)),6116mul(matrix_elt(m, 1, 3), SubFactor05)),6117WRITEMASK_Z));6118body.emit(assign(adj_0, neg(6119add(sub(mul(matrix_elt(m, 1, 0), SubFactor02),6120mul(matrix_elt(m, 1, 1), SubFactor04)),6121mul(matrix_elt(m, 1, 2), SubFactor05))),6122WRITEMASK_W));61236124body.emit(ret(dot(array_ref(m, 0), adj_0)));61256126return sig;6127}61286129ir_function_signature *6130builtin_builder::_inverse_mat2(builtin_available_predicate avail, const glsl_type *type)6131{6132ir_variable *m = in_var(type, "m");6133MAKE_SIG(type, avail, 1, m);61346135ir_variable *adj = body.make_temp(type, "adj");6136body.emit(assign(array_ref(adj, 0), matrix_elt(m, 1, 1), 1 << 0));6137body.emit(assign(array_ref(adj, 0), neg(matrix_elt(m, 0, 1)), 1 << 1));6138body.emit(assign(array_ref(adj, 1), neg(matrix_elt(m, 1, 0)), 1 << 0));6139body.emit(assign(array_ref(adj, 1), matrix_elt(m, 0, 0), 1 << 1));61406141ir_expression *det =6142sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),6143mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1)));61446145body.emit(ret(div(adj, det)));6146return sig;6147}61486149ir_function_signature *6150builtin_builder::_inverse_mat3(builtin_available_predicate avail, const glsl_type *type)6151{6152ir_variable *m = in_var(type, "m");6153const glsl_type *btype = type->get_base_type();6154MAKE_SIG(type, avail, 1, m);61556156ir_variable *f11_22_21_12 = body.make_temp(btype, "f11_22_21_12");6157ir_variable *f10_22_20_12 = body.make_temp(btype, "f10_22_20_12");6158ir_variable *f10_21_20_11 = body.make_temp(btype, "f10_21_20_11");61596160body.emit(assign(f11_22_21_12,6161sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)),6162mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 2)))));6163body.emit(assign(f10_22_20_12,6164sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)),6165mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 2)))));6166body.emit(assign(f10_21_20_11,6167sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)),6168mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 1)))));61696170ir_variable *adj = body.make_temp(type, "adj");6171body.emit(assign(array_ref(adj, 0), f11_22_21_12, WRITEMASK_X));6172body.emit(assign(array_ref(adj, 1), neg(f10_22_20_12), WRITEMASK_X));6173body.emit(assign(array_ref(adj, 2), f10_21_20_11, WRITEMASK_X));61746175body.emit(assign(array_ref(adj, 0), neg(6176sub(mul(matrix_elt(m, 0, 1), matrix_elt(m, 2, 2)),6177mul(matrix_elt(m, 2, 1), matrix_elt(m, 0, 2)))),6178WRITEMASK_Y));6179body.emit(assign(array_ref(adj, 1),6180sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 2, 2)),6181mul(matrix_elt(m, 2, 0), matrix_elt(m, 0, 2))),6182WRITEMASK_Y));6183body.emit(assign(array_ref(adj, 2), neg(6184sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 2, 1)),6185mul(matrix_elt(m, 2, 0), matrix_elt(m, 0, 1)))),6186WRITEMASK_Y));61876188body.emit(assign(array_ref(adj, 0),6189sub(mul(matrix_elt(m, 0, 1), matrix_elt(m, 1, 2)),6190mul(matrix_elt(m, 1, 1), matrix_elt(m, 0, 2))),6191WRITEMASK_Z));6192body.emit(assign(array_ref(adj, 1), neg(6193sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 2)),6194mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 2)))),6195WRITEMASK_Z));6196body.emit(assign(array_ref(adj, 2),6197sub(mul(matrix_elt(m, 0, 0), matrix_elt(m, 1, 1)),6198mul(matrix_elt(m, 1, 0), matrix_elt(m, 0, 1))),6199WRITEMASK_Z));62006201ir_expression *det =6202add(sub(mul(matrix_elt(m, 0, 0), f11_22_21_12),6203mul(matrix_elt(m, 0, 1), f10_22_20_12)),6204mul(matrix_elt(m, 0, 2), f10_21_20_11));62056206body.emit(ret(div(adj, det)));62076208return sig;6209}62106211ir_function_signature *6212builtin_builder::_inverse_mat4(builtin_available_predicate avail, const glsl_type *type)6213{6214ir_variable *m = in_var(type, "m");6215const glsl_type *btype = type->get_base_type();6216MAKE_SIG(type, avail, 1, m);62176218ir_variable *SubFactor00 = body.make_temp(btype, "SubFactor00");6219ir_variable *SubFactor01 = body.make_temp(btype, "SubFactor01");6220ir_variable *SubFactor02 = body.make_temp(btype, "SubFactor02");6221ir_variable *SubFactor03 = body.make_temp(btype, "SubFactor03");6222ir_variable *SubFactor04 = body.make_temp(btype, "SubFactor04");6223ir_variable *SubFactor05 = body.make_temp(btype, "SubFactor05");6224ir_variable *SubFactor06 = body.make_temp(btype, "SubFactor06");6225ir_variable *SubFactor07 = body.make_temp(btype, "SubFactor07");6226ir_variable *SubFactor08 = body.make_temp(btype, "SubFactor08");6227ir_variable *SubFactor09 = body.make_temp(btype, "SubFactor09");6228ir_variable *SubFactor10 = body.make_temp(btype, "SubFactor10");6229ir_variable *SubFactor11 = body.make_temp(btype, "SubFactor11");6230ir_variable *SubFactor12 = body.make_temp(btype, "SubFactor12");6231ir_variable *SubFactor13 = body.make_temp(btype, "SubFactor13");6232ir_variable *SubFactor14 = body.make_temp(btype, "SubFactor14");6233ir_variable *SubFactor15 = body.make_temp(btype, "SubFactor15");6234ir_variable *SubFactor16 = body.make_temp(btype, "SubFactor16");6235ir_variable *SubFactor17 = body.make_temp(btype, "SubFactor17");6236ir_variable *SubFactor18 = body.make_temp(btype, "SubFactor18");62376238body.emit(assign(SubFactor00, sub(mul(matrix_elt(m, 2, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 2, 3)))));6239body.emit(assign(SubFactor01, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 3)))));6240body.emit(assign(SubFactor02, sub(mul(matrix_elt(m, 2, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 2, 2)))));6241body.emit(assign(SubFactor03, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 3)))));6242body.emit(assign(SubFactor04, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 2)))));6243body.emit(assign(SubFactor05, sub(mul(matrix_elt(m, 2, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 2, 1)))));6244body.emit(assign(SubFactor06, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 2), matrix_elt(m, 1, 3)))));6245body.emit(assign(SubFactor07, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));6246body.emit(assign(SubFactor08, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 2)))));6247body.emit(assign(SubFactor09, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 3)))));6248body.emit(assign(SubFactor10, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 2)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 2)))));6249body.emit(assign(SubFactor11, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 3, 3)), mul(matrix_elt(m, 3, 1), matrix_elt(m, 1, 3)))));6250body.emit(assign(SubFactor12, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 3, 1)), mul(matrix_elt(m, 3, 0), matrix_elt(m, 1, 1)))));6251body.emit(assign(SubFactor13, sub(mul(matrix_elt(m, 1, 2), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 2), matrix_elt(m, 1, 3)))));6252body.emit(assign(SubFactor14, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 3)))));6253body.emit(assign(SubFactor15, sub(mul(matrix_elt(m, 1, 1), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 1), matrix_elt(m, 1, 2)))));6254body.emit(assign(SubFactor16, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 3)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 3)))));6255body.emit(assign(SubFactor17, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 2)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 2)))));6256body.emit(assign(SubFactor18, sub(mul(matrix_elt(m, 1, 0), matrix_elt(m, 2, 1)), mul(matrix_elt(m, 2, 0), matrix_elt(m, 1, 1)))));62576258ir_variable *adj = body.make_temp(btype == glsl_type::float_type ? glsl_type::mat4_type : glsl_type::dmat4_type, "adj");6259body.emit(assign(array_ref(adj, 0),6260add(sub(mul(matrix_elt(m, 1, 1), SubFactor00),6261mul(matrix_elt(m, 1, 2), SubFactor01)),6262mul(matrix_elt(m, 1, 3), SubFactor02)),6263WRITEMASK_X));6264body.emit(assign(array_ref(adj, 1), neg(6265add(sub(mul(matrix_elt(m, 1, 0), SubFactor00),6266mul(matrix_elt(m, 1, 2), SubFactor03)),6267mul(matrix_elt(m, 1, 3), SubFactor04))),6268WRITEMASK_X));6269body.emit(assign(array_ref(adj, 2),6270add(sub(mul(matrix_elt(m, 1, 0), SubFactor01),6271mul(matrix_elt(m, 1, 1), SubFactor03)),6272mul(matrix_elt(m, 1, 3), SubFactor05)),6273WRITEMASK_X));6274body.emit(assign(array_ref(adj, 3), neg(6275add(sub(mul(matrix_elt(m, 1, 0), SubFactor02),6276mul(matrix_elt(m, 1, 1), SubFactor04)),6277mul(matrix_elt(m, 1, 2), SubFactor05))),6278WRITEMASK_X));62796280body.emit(assign(array_ref(adj, 0), neg(6281add(sub(mul(matrix_elt(m, 0, 1), SubFactor00),6282mul(matrix_elt(m, 0, 2), SubFactor01)),6283mul(matrix_elt(m, 0, 3), SubFactor02))),6284WRITEMASK_Y));6285body.emit(assign(array_ref(adj, 1),6286add(sub(mul(matrix_elt(m, 0, 0), SubFactor00),6287mul(matrix_elt(m, 0, 2), SubFactor03)),6288mul(matrix_elt(m, 0, 3), SubFactor04)),6289WRITEMASK_Y));6290body.emit(assign(array_ref(adj, 2), neg(6291add(sub(mul(matrix_elt(m, 0, 0), SubFactor01),6292mul(matrix_elt(m, 0, 1), SubFactor03)),6293mul(matrix_elt(m, 0, 3), SubFactor05))),6294WRITEMASK_Y));6295body.emit(assign(array_ref(adj, 3),6296add(sub(mul(matrix_elt(m, 0, 0), SubFactor02),6297mul(matrix_elt(m, 0, 1), SubFactor04)),6298mul(matrix_elt(m, 0, 2), SubFactor05)),6299WRITEMASK_Y));63006301body.emit(assign(array_ref(adj, 0),6302add(sub(mul(matrix_elt(m, 0, 1), SubFactor06),6303mul(matrix_elt(m, 0, 2), SubFactor07)),6304mul(matrix_elt(m, 0, 3), SubFactor08)),6305WRITEMASK_Z));6306body.emit(assign(array_ref(adj, 1), neg(6307add(sub(mul(matrix_elt(m, 0, 0), SubFactor06),6308mul(matrix_elt(m, 0, 2), SubFactor09)),6309mul(matrix_elt(m, 0, 3), SubFactor10))),6310WRITEMASK_Z));6311body.emit(assign(array_ref(adj, 2),6312add(sub(mul(matrix_elt(m, 0, 0), SubFactor11),6313mul(matrix_elt(m, 0, 1), SubFactor09)),6314mul(matrix_elt(m, 0, 3), SubFactor12)),6315WRITEMASK_Z));6316body.emit(assign(array_ref(adj, 3), neg(6317add(sub(mul(matrix_elt(m, 0, 0), SubFactor08),6318mul(matrix_elt(m, 0, 1), SubFactor10)),6319mul(matrix_elt(m, 0, 2), SubFactor12))),6320WRITEMASK_Z));63216322body.emit(assign(array_ref(adj, 0), neg(6323add(sub(mul(matrix_elt(m, 0, 1), SubFactor13),6324mul(matrix_elt(m, 0, 2), SubFactor14)),6325mul(matrix_elt(m, 0, 3), SubFactor15))),6326WRITEMASK_W));6327body.emit(assign(array_ref(adj, 1),6328add(sub(mul(matrix_elt(m, 0, 0), SubFactor13),6329mul(matrix_elt(m, 0, 2), SubFactor16)),6330mul(matrix_elt(m, 0, 3), SubFactor17)),6331WRITEMASK_W));6332body.emit(assign(array_ref(adj, 2), neg(6333add(sub(mul(matrix_elt(m, 0, 0), SubFactor14),6334mul(matrix_elt(m, 0, 1), SubFactor16)),6335mul(matrix_elt(m, 0, 3), SubFactor18))),6336WRITEMASK_W));6337body.emit(assign(array_ref(adj, 3),6338add(sub(mul(matrix_elt(m, 0, 0), SubFactor15),6339mul(matrix_elt(m, 0, 1), SubFactor17)),6340mul(matrix_elt(m, 0, 2), SubFactor18)),6341WRITEMASK_W));63426343ir_expression *det =6344add(mul(matrix_elt(m, 0, 0), matrix_elt(adj, 0, 0)),6345add(mul(matrix_elt(m, 0, 1), matrix_elt(adj, 1, 0)),6346add(mul(matrix_elt(m, 0, 2), matrix_elt(adj, 2, 0)),6347mul(matrix_elt(m, 0, 3), matrix_elt(adj, 3, 0)))));63486349body.emit(ret(div(adj, det)));63506351return sig;6352}635363546355ir_function_signature *6356builtin_builder::_lessThan(builtin_available_predicate avail,6357const glsl_type *type)6358{6359return binop(avail, ir_binop_less,6360glsl_type::bvec(type->vector_elements), type, type);6361}63626363ir_function_signature *6364builtin_builder::_lessThanEqual(builtin_available_predicate avail,6365const glsl_type *type)6366{6367return binop(avail, ir_binop_gequal,6368glsl_type::bvec(type->vector_elements), type, type,6369true);6370}63716372ir_function_signature *6373builtin_builder::_greaterThan(builtin_available_predicate avail,6374const glsl_type *type)6375{6376return binop(avail, ir_binop_less,6377glsl_type::bvec(type->vector_elements), type, type,6378true);6379}63806381ir_function_signature *6382builtin_builder::_greaterThanEqual(builtin_available_predicate avail,6383const glsl_type *type)6384{6385return binop(avail, ir_binop_gequal,6386glsl_type::bvec(type->vector_elements), type, type);6387}63886389ir_function_signature *6390builtin_builder::_equal(builtin_available_predicate avail,6391const glsl_type *type)6392{6393return binop(avail, ir_binop_equal,6394glsl_type::bvec(type->vector_elements), type, type);6395}63966397ir_function_signature *6398builtin_builder::_notEqual(builtin_available_predicate avail,6399const glsl_type *type)6400{6401return binop(avail, ir_binop_nequal,6402glsl_type::bvec(type->vector_elements), type, type);6403}64046405ir_function_signature *6406builtin_builder::_any(const glsl_type *type)6407{6408ir_variable *v = in_var(type, "v");6409MAKE_SIG(glsl_type::bool_type, always_available, 1, v);64106411const unsigned vec_elem = v->type->vector_elements;6412body.emit(ret(expr(ir_binop_any_nequal, v, imm(false, vec_elem))));64136414return sig;6415}64166417ir_function_signature *6418builtin_builder::_all(const glsl_type *type)6419{6420ir_variable *v = in_var(type, "v");6421MAKE_SIG(glsl_type::bool_type, always_available, 1, v);64226423const unsigned vec_elem = v->type->vector_elements;6424body.emit(ret(expr(ir_binop_all_equal, v, imm(true, vec_elem))));64256426return sig;6427}64286429UNOP(not, ir_unop_logic_not, always_available)64306431static bool6432has_lod(const glsl_type *sampler_type)6433{6434assert(sampler_type->is_sampler());64356436switch (sampler_type->sampler_dimensionality) {6437case GLSL_SAMPLER_DIM_RECT:6438case GLSL_SAMPLER_DIM_BUF:6439case GLSL_SAMPLER_DIM_MS:6440return false;6441default:6442return true;6443}6444}64456446ir_function_signature *6447builtin_builder::_textureSize(builtin_available_predicate avail,6448const glsl_type *return_type,6449const glsl_type *sampler_type)6450{6451ir_variable *s = in_var(sampler_type, "sampler");6452/* The sampler always exists; add optional lod later. */6453MAKE_SIG(return_type, avail, 1, s);64546455ir_texture *tex = new(mem_ctx) ir_texture(ir_txs);6456tex->set_sampler(new(mem_ctx) ir_dereference_variable(s), return_type);64576458if (has_lod(sampler_type)) {6459ir_variable *lod = in_var(glsl_type::int_type, "lod");6460sig->parameters.push_tail(lod);6461tex->lod_info.lod = var_ref(lod);6462} else {6463tex->lod_info.lod = imm(0u);6464}64656466body.emit(ret(tex));64676468return sig;6469}64706471ir_function_signature *6472builtin_builder::_textureSamples(builtin_available_predicate avail,6473const glsl_type *sampler_type)6474{6475ir_variable *s = in_var(sampler_type, "sampler");6476MAKE_SIG(glsl_type::int_type, avail, 1, s);64776478ir_texture *tex = new(mem_ctx) ir_texture(ir_texture_samples);6479tex->set_sampler(new(mem_ctx) ir_dereference_variable(s), glsl_type::int_type);6480body.emit(ret(tex));64816482return sig;6483}64846485ir_function_signature *6486builtin_builder::_texture(ir_texture_opcode opcode,6487builtin_available_predicate avail,6488const glsl_type *return_type,6489const glsl_type *sampler_type,6490const glsl_type *coord_type,6491int flags)6492{6493ir_variable *s = in_var(sampler_type, "sampler");6494ir_variable *P = in_var(coord_type, "P");6495/* The sampler and coordinate always exist; add optional parameters later. */6496MAKE_SIG(return_type, avail, 2, s, P);64976498ir_texture *tex = new(mem_ctx) ir_texture(opcode);6499tex->set_sampler(var_ref(s), return_type);65006501const int coord_size = sampler_type->coordinate_components();65026503if (coord_size == coord_type->vector_elements) {6504tex->coordinate = var_ref(P);6505} else {6506/* The incoming coordinate also has the projector or shadow comparator,6507* so we need to swizzle those away.6508*/6509tex->coordinate = swizzle_for_size(P, coord_size);6510}65116512/* The projector is always in the last component. */6513if (flags & TEX_PROJECT)6514tex->projector = swizzle(P, coord_type->vector_elements - 1, 1);65156516if (sampler_type->sampler_shadow) {6517if (opcode == ir_tg4) {6518/* gather has refz as a separate parameter, immediately after the6519* coordinate6520*/6521ir_variable *refz = in_var(glsl_type::float_type, "refz");6522sig->parameters.push_tail(refz);6523tex->shadow_comparator = var_ref(refz);6524} else {6525/* The shadow comparator is normally in the Z component, but a few types6526* have sufficiently large coordinates that it's in W.6527*/6528tex->shadow_comparator = swizzle(P, MAX2(coord_size, SWIZZLE_Z), 1);6529}6530}65316532if (opcode == ir_txl) {6533ir_variable *lod = in_var(glsl_type::float_type, "lod");6534sig->parameters.push_tail(lod);6535tex->lod_info.lod = var_ref(lod);6536} else if (opcode == ir_txd) {6537int grad_size = coord_size - (sampler_type->sampler_array ? 1 : 0);6538ir_variable *dPdx = in_var(glsl_type::vec(grad_size), "dPdx");6539ir_variable *dPdy = in_var(glsl_type::vec(grad_size), "dPdy");6540sig->parameters.push_tail(dPdx);6541sig->parameters.push_tail(dPdy);6542tex->lod_info.grad.dPdx = var_ref(dPdx);6543tex->lod_info.grad.dPdy = var_ref(dPdy);6544}65456546if (flags & (TEX_OFFSET | TEX_OFFSET_NONCONST)) {6547int offset_size = coord_size - (sampler_type->sampler_array ? 1 : 0);6548ir_variable *offset =6549new(mem_ctx) ir_variable(glsl_type::ivec(offset_size), "offset",6550(flags & TEX_OFFSET) ? ir_var_const_in : ir_var_function_in);6551sig->parameters.push_tail(offset);6552tex->offset = var_ref(offset);6553}65546555if (flags & TEX_OFFSET_ARRAY) {6556ir_variable *offsets =6557new(mem_ctx) ir_variable(glsl_type::get_array_instance(glsl_type::ivec2_type, 4),6558"offsets", ir_var_const_in);6559sig->parameters.push_tail(offsets);6560tex->offset = var_ref(offsets);6561}65626563if (opcode == ir_tg4) {6564if (flags & TEX_COMPONENT) {6565ir_variable *component =6566new(mem_ctx) ir_variable(glsl_type::int_type, "comp", ir_var_const_in);6567sig->parameters.push_tail(component);6568tex->lod_info.component = var_ref(component);6569}6570else {6571tex->lod_info.component = imm(0);6572}6573}65746575/* The "bias" parameter comes /after/ the "offset" parameter, which is6576* inconsistent with both textureLodOffset and textureGradOffset.6577*/6578if (opcode == ir_txb) {6579ir_variable *bias = in_var(glsl_type::float_type, "bias");6580sig->parameters.push_tail(bias);6581tex->lod_info.bias = var_ref(bias);6582}65836584body.emit(ret(tex));65856586return sig;6587}65886589ir_function_signature *6590builtin_builder::_textureCubeArrayShadow(ir_texture_opcode opcode,6591builtin_available_predicate avail,6592const glsl_type *sampler_type)6593{6594ir_variable *s = in_var(sampler_type, "sampler");6595ir_variable *P = in_var(glsl_type::vec4_type, "P");6596ir_variable *compare = in_var(glsl_type::float_type, "compare");6597MAKE_SIG(glsl_type::float_type, avail, 3, s, P, compare);65986599ir_texture *tex = new(mem_ctx) ir_texture(opcode);6600tex->set_sampler(var_ref(s), glsl_type::float_type);66016602tex->coordinate = var_ref(P);6603tex->shadow_comparator = var_ref(compare);66046605if (opcode == ir_txb) {6606ir_variable *bias = in_var(glsl_type::float_type, "bias");6607sig->parameters.push_tail(bias);6608tex->lod_info.bias = var_ref(bias);6609}66106611if (opcode == ir_txl) {6612ir_variable *lod = in_var(glsl_type::float_type, "lod");6613sig->parameters.push_tail(lod);6614tex->lod_info.lod = var_ref(lod);6615}66166617body.emit(ret(tex));66186619return sig;6620}66216622ir_function_signature *6623builtin_builder::_texelFetch(builtin_available_predicate avail,6624const glsl_type *return_type,6625const glsl_type *sampler_type,6626const glsl_type *coord_type,6627const glsl_type *offset_type)6628{6629ir_variable *s = in_var(sampler_type, "sampler");6630ir_variable *P = in_var(coord_type, "P");6631/* The sampler and coordinate always exist; add optional parameters later. */6632MAKE_SIG(return_type, avail, 2, s, P);66336634ir_texture *tex = new(mem_ctx) ir_texture(ir_txf);6635tex->coordinate = var_ref(P);6636tex->set_sampler(var_ref(s), return_type);66376638if (sampler_type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS) {6639ir_variable *sample = in_var(glsl_type::int_type, "sample");6640sig->parameters.push_tail(sample);6641tex->lod_info.sample_index = var_ref(sample);6642tex->op = ir_txf_ms;6643} else if (has_lod(sampler_type)) {6644ir_variable *lod = in_var(glsl_type::int_type, "lod");6645sig->parameters.push_tail(lod);6646tex->lod_info.lod = var_ref(lod);6647} else {6648tex->lod_info.lod = imm(0u);6649}66506651if (offset_type != NULL) {6652ir_variable *offset =6653new(mem_ctx) ir_variable(offset_type, "offset", ir_var_const_in);6654sig->parameters.push_tail(offset);6655tex->offset = var_ref(offset);6656}66576658body.emit(ret(tex));66596660return sig;6661}66626663ir_function_signature *6664builtin_builder::_EmitVertex()6665{6666MAKE_SIG(glsl_type::void_type, gs_only, 0);66676668ir_rvalue *stream = new(mem_ctx) ir_constant(0, 1);6669body.emit(new(mem_ctx) ir_emit_vertex(stream));66706671return sig;6672}66736674ir_function_signature *6675builtin_builder::_EmitStreamVertex(builtin_available_predicate avail,6676const glsl_type *stream_type)6677{6678/* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:6679*6680* "Emit the current values of output variables to the current output6681* primitive on stream stream. The argument to stream must be a constant6682* integral expression."6683*/6684ir_variable *stream =6685new(mem_ctx) ir_variable(stream_type, "stream", ir_var_const_in);66866687MAKE_SIG(glsl_type::void_type, avail, 1, stream);66886689body.emit(new(mem_ctx) ir_emit_vertex(var_ref(stream)));66906691return sig;6692}66936694ir_function_signature *6695builtin_builder::_EndPrimitive()6696{6697MAKE_SIG(glsl_type::void_type, gs_only, 0);66986699ir_rvalue *stream = new(mem_ctx) ir_constant(0, 1);6700body.emit(new(mem_ctx) ir_end_primitive(stream));67016702return sig;6703}67046705ir_function_signature *6706builtin_builder::_EndStreamPrimitive(builtin_available_predicate avail,6707const glsl_type *stream_type)6708{6709/* Section 8.12 (Geometry Shader Functions) of the GLSL 4.0 spec says:6710*6711* "Completes the current output primitive on stream stream and starts6712* a new one. The argument to stream must be a constant integral6713* expression."6714*/6715ir_variable *stream =6716new(mem_ctx) ir_variable(stream_type, "stream", ir_var_const_in);67176718MAKE_SIG(glsl_type::void_type, avail, 1, stream);67196720body.emit(new(mem_ctx) ir_end_primitive(var_ref(stream)));67216722return sig;6723}67246725ir_function_signature *6726builtin_builder::_barrier()6727{6728MAKE_SIG(glsl_type::void_type, barrier_supported, 0);67296730body.emit(new(mem_ctx) ir_barrier());6731return sig;6732}67336734ir_function_signature *6735builtin_builder::_textureQueryLod(builtin_available_predicate avail,6736const glsl_type *sampler_type,6737const glsl_type *coord_type)6738{6739ir_variable *s = in_var(sampler_type, "sampler");6740ir_variable *coord = in_var(coord_type, "coord");6741/* The sampler and coordinate always exist; add optional parameters later. */6742MAKE_SIG(glsl_type::vec2_type, avail, 2, s, coord);67436744ir_texture *tex = new(mem_ctx) ir_texture(ir_lod);6745tex->coordinate = var_ref(coord);6746tex->set_sampler(var_ref(s), glsl_type::vec2_type);67476748body.emit(ret(tex));67496750return sig;6751}67526753ir_function_signature *6754builtin_builder::_textureQueryLevels(builtin_available_predicate avail,6755const glsl_type *sampler_type)6756{6757ir_variable *s = in_var(sampler_type, "sampler");6758const glsl_type *return_type = glsl_type::int_type;6759MAKE_SIG(return_type, avail, 1, s);67606761ir_texture *tex = new(mem_ctx) ir_texture(ir_query_levels);6762tex->set_sampler(var_ref(s), return_type);67636764body.emit(ret(tex));67656766return sig;6767}67686769ir_function_signature *6770builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail,6771const glsl_type *sampler_type,6772const glsl_type *coord_type)6773{6774ir_variable *s = in_var(sampler_type, "sampler");6775ir_variable *P = in_var(coord_type, "P");6776const glsl_type *return_type = glsl_type::bool_type;6777MAKE_SIG(return_type, avail, 2, s, P);67786779ir_texture *tex = new(mem_ctx) ir_texture(ir_samples_identical);6780tex->coordinate = var_ref(P);6781tex->set_sampler(var_ref(s), return_type);67826783body.emit(ret(tex));67846785return sig;6786}67876788UNOP(dFdx, ir_unop_dFdx, derivatives)6789UNOP(dFdxCoarse, ir_unop_dFdx_coarse, derivative_control)6790UNOP(dFdxFine, ir_unop_dFdx_fine, derivative_control)6791UNOP(dFdy, ir_unop_dFdy, derivatives)6792UNOP(dFdyCoarse, ir_unop_dFdy_coarse, derivative_control)6793UNOP(dFdyFine, ir_unop_dFdy_fine, derivative_control)67946795ir_function_signature *6796builtin_builder::_fwidth(const glsl_type *type)6797{6798ir_variable *p = in_var(type, "p");6799MAKE_SIG(type, derivatives, 1, p);68006801body.emit(ret(add(abs(expr(ir_unop_dFdx, p)), abs(expr(ir_unop_dFdy, p)))));68026803return sig;6804}68056806ir_function_signature *6807builtin_builder::_fwidthCoarse(const glsl_type *type)6808{6809ir_variable *p = in_var(type, "p");6810MAKE_SIG(type, derivative_control, 1, p);68116812body.emit(ret(add(abs(expr(ir_unop_dFdx_coarse, p)),6813abs(expr(ir_unop_dFdy_coarse, p)))));68146815return sig;6816}68176818ir_function_signature *6819builtin_builder::_fwidthFine(const glsl_type *type)6820{6821ir_variable *p = in_var(type, "p");6822MAKE_SIG(type, derivative_control, 1, p);68236824body.emit(ret(add(abs(expr(ir_unop_dFdx_fine, p)),6825abs(expr(ir_unop_dFdy_fine, p)))));68266827return sig;6828}68296830ir_function_signature *6831builtin_builder::_noise1(const glsl_type *type)6832{6833/* From the GLSL 4.60 specification:6834*6835* "The noise functions noise1, noise2, noise3, and noise4 have been6836* deprecated starting with version 4.4 of GLSL. When not generating6837* SPIR-V they are defined to return the value 0.0 or a vector whose6838* components are all 0.0. When generating SPIR-V the noise functions6839* are not declared and may not be used."6840*6841* In earlier versions of the GLSL specification attempt to define some6842* sort of statistical noise function. However, the function's6843* characteristics have always been such that always returning 0 is6844* valid and Mesa has always returned 0 for noise on most drivers.6845*/6846ir_variable *p = in_var(type, "p");6847MAKE_SIG(glsl_type::float_type, v110, 1, p);6848body.emit(ret(imm(glsl_type::float_type, ir_constant_data())));6849return sig;6850}68516852ir_function_signature *6853builtin_builder::_noise2(const glsl_type *type)6854{6855/* See builtin_builder::_noise1 */6856ir_variable *p = in_var(type, "p");6857MAKE_SIG(glsl_type::vec2_type, v110, 1, p);6858body.emit(ret(imm(glsl_type::vec2_type, ir_constant_data())));6859return sig;6860}68616862ir_function_signature *6863builtin_builder::_noise3(const glsl_type *type)6864{6865/* See builtin_builder::_noise1 */6866ir_variable *p = in_var(type, "p");6867MAKE_SIG(glsl_type::vec3_type, v110, 1, p);6868body.emit(ret(imm(glsl_type::vec3_type, ir_constant_data())));6869return sig;6870}68716872ir_function_signature *6873builtin_builder::_noise4(const glsl_type *type)6874{6875/* See builtin_builder::_noise1 */6876ir_variable *p = in_var(type, "p");6877MAKE_SIG(glsl_type::vec4_type, v110, 1, p);6878body.emit(ret(imm(glsl_type::vec4_type, ir_constant_data())));6879return sig;6880}68816882ir_function_signature *6883builtin_builder::_bitfieldExtract(const glsl_type *type)6884{6885bool is_uint = type->base_type == GLSL_TYPE_UINT;6886ir_variable *value = in_var(type, "value");6887ir_variable *offset = in_var(glsl_type::int_type, "offset");6888ir_variable *bits = in_var(glsl_type::int_type, "bits");6889MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 3, value, offset,6890bits);68916892operand cast_offset = is_uint ? i2u(offset) : operand(offset);6893operand cast_bits = is_uint ? i2u(bits) : operand(bits);68946895body.emit(ret(expr(ir_triop_bitfield_extract, value,6896swizzle(cast_offset, SWIZZLE_XXXX, type->vector_elements),6897swizzle(cast_bits, SWIZZLE_XXXX, type->vector_elements))));68986899return sig;6900}69016902ir_function_signature *6903builtin_builder::_bitfieldInsert(const glsl_type *type)6904{6905bool is_uint = type->base_type == GLSL_TYPE_UINT;6906ir_variable *base = in_var(type, "base");6907ir_variable *insert = in_var(type, "insert");6908ir_variable *offset = in_var(glsl_type::int_type, "offset");6909ir_variable *bits = in_var(glsl_type::int_type, "bits");6910MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 4, base, insert,6911offset, bits);69126913operand cast_offset = is_uint ? i2u(offset) : operand(offset);6914operand cast_bits = is_uint ? i2u(bits) : operand(bits);69156916body.emit(ret(bitfield_insert(base, insert,6917swizzle(cast_offset, SWIZZLE_XXXX, type->vector_elements),6918swizzle(cast_bits, SWIZZLE_XXXX, type->vector_elements))));69196920return sig;6921}69226923UNOP(bitfieldReverse, ir_unop_bitfield_reverse, gpu_shader5_or_es31_or_integer_functions)69246925ir_function_signature *6926builtin_builder::_bitCount(const glsl_type *type)6927{6928return unop(gpu_shader5_or_es31_or_integer_functions, ir_unop_bit_count,6929glsl_type::ivec(type->vector_elements), type);6930}69316932ir_function_signature *6933builtin_builder::_findLSB(const glsl_type *type)6934{6935return unop(gpu_shader5_or_es31_or_integer_functions, ir_unop_find_lsb,6936glsl_type::ivec(type->vector_elements), type);6937}69386939ir_function_signature *6940builtin_builder::_findMSB(const glsl_type *type)6941{6942return unop(gpu_shader5_or_es31_or_integer_functions, ir_unop_find_msb,6943glsl_type::ivec(type->vector_elements), type);6944}69456946ir_function_signature *6947builtin_builder::_countLeadingZeros(builtin_available_predicate avail,6948const glsl_type *type)6949{6950return unop(avail, ir_unop_clz,6951glsl_type::uvec(type->vector_elements), type);6952}69536954ir_function_signature *6955builtin_builder::_countTrailingZeros(builtin_available_predicate avail,6956const glsl_type *type)6957{6958ir_variable *a = in_var(type, "a");6959MAKE_SIG(glsl_type::uvec(type->vector_elements), avail, 1, a);69606961body.emit(ret(ir_builder::min2(6962ir_builder::i2u(ir_builder::expr(ir_unop_find_lsb, a)),6963imm(32u))));69646965return sig;6966}69676968ir_function_signature *6969builtin_builder::_fma(builtin_available_predicate avail, const glsl_type *type)6970{6971ir_variable *a = in_var(type, "a");6972ir_variable *b = in_var(type, "b");6973ir_variable *c = in_var(type, "c");6974MAKE_SIG(type, avail, 3, a, b, c);69756976body.emit(ret(ir_builder::fma(a, b, c)));69776978return sig;6979}69806981ir_function_signature *6982builtin_builder::_ldexp(const glsl_type *x_type, const glsl_type *exp_type)6983{6984return binop(x_type->is_double() ? fp64 : gpu_shader5_or_es31_or_integer_functions,6985ir_binop_ldexp, x_type, x_type, exp_type);6986}69876988ir_function_signature *6989builtin_builder::_dfrexp(const glsl_type *x_type, const glsl_type *exp_type)6990{6991ir_variable *x = in_var(x_type, "x");6992ir_variable *exponent = out_var(exp_type, "exp");6993MAKE_SIG(x_type, fp64, 2, x, exponent);69946995body.emit(assign(exponent, expr(ir_unop_frexp_exp, x)));69966997body.emit(ret(expr(ir_unop_frexp_sig, x)));6998return sig;6999}70007001ir_function_signature *7002builtin_builder::_frexp(const glsl_type *x_type, const glsl_type *exp_type)7003{7004ir_variable *x = in_var(x_type, "x");7005ir_variable *exponent = out_var(exp_type, "exp");7006MAKE_SIG(x_type, gpu_shader5_or_es31_or_integer_functions, 2, x, exponent);70077008const unsigned vec_elem = x_type->vector_elements;7009const glsl_type *bvec = glsl_type::get_instance(GLSL_TYPE_BOOL, vec_elem, 1);7010const glsl_type *uvec = glsl_type::get_instance(GLSL_TYPE_UINT, vec_elem, 1);70117012/* Single-precision floating-point values are stored as7013* 1 sign bit;7014* 8 exponent bits;7015* 23 mantissa bits.7016*7017* An exponent shift of 23 will shift the mantissa out, leaving only the7018* exponent and sign bit (which itself may be zero, if the absolute value7019* was taken before the bitcast and shift.7020*/7021ir_constant *exponent_shift = imm(23);7022ir_constant *exponent_bias = imm(-126, vec_elem);70237024ir_constant *sign_mantissa_mask = imm(0x807fffffu, vec_elem);70257026/* Exponent of floating-point values in the range [0.5, 1.0). */7027ir_constant *exponent_value = imm(0x3f000000u, vec_elem);70287029ir_variable *is_not_zero = body.make_temp(bvec, "is_not_zero");7030body.emit(assign(is_not_zero, nequal(abs(x), imm(0.0f, vec_elem))));70317032/* Since abs(x) ensures that the sign bit is zero, we don't need to bitcast7033* to unsigned integers to ensure that 1 bits aren't shifted in.7034*/7035body.emit(assign(exponent, rshift(bitcast_f2i(abs(x)), exponent_shift)));7036body.emit(assign(exponent, add(exponent, csel(is_not_zero, exponent_bias,7037imm(0, vec_elem)))));70387039ir_variable *bits = body.make_temp(uvec, "bits");7040body.emit(assign(bits, bitcast_f2u(x)));7041body.emit(assign(bits, bit_and(bits, sign_mantissa_mask)));7042body.emit(assign(bits, bit_or(bits, csel(is_not_zero, exponent_value,7043imm(0u, vec_elem)))));7044body.emit(ret(bitcast_u2f(bits)));70457046return sig;7047}70487049ir_function_signature *7050builtin_builder::_uaddCarry(const glsl_type *type)7051{7052ir_variable *x = in_var(type, "x");7053ir_variable *y = in_var(type, "y");7054ir_variable *carry = out_var(type, "carry");7055MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 3, x, y, carry);70567057body.emit(assign(carry, ir_builder::carry(x, y)));7058body.emit(ret(add(x, y)));70597060return sig;7061}70627063ir_function_signature *7064builtin_builder::_addSaturate(builtin_available_predicate avail,7065const glsl_type *type)7066{7067return binop(avail, ir_binop_add_sat, type, type, type);7068}70697070ir_function_signature *7071builtin_builder::_usubBorrow(const glsl_type *type)7072{7073ir_variable *x = in_var(type, "x");7074ir_variable *y = in_var(type, "y");7075ir_variable *borrow = out_var(type, "borrow");7076MAKE_SIG(type, gpu_shader5_or_es31_or_integer_functions, 3, x, y, borrow);70777078body.emit(assign(borrow, ir_builder::borrow(x, y)));7079body.emit(ret(sub(x, y)));70807081return sig;7082}70837084ir_function_signature *7085builtin_builder::_subtractSaturate(builtin_available_predicate avail,7086const glsl_type *type)7087{7088return binop(avail, ir_binop_sub_sat, type, type, type);7089}70907091ir_function_signature *7092builtin_builder::_absoluteDifference(builtin_available_predicate avail,7093const glsl_type *type)7094{7095/* absoluteDifference returns an unsigned type that has the same number of7096* bits and number of vector elements as the type of the operands.7097*/7098return binop(avail, ir_binop_abs_sub,7099glsl_type::get_instance(glsl_unsigned_base_type_of(type->base_type),7100type->vector_elements, 1),7101type, type);7102}71037104ir_function_signature *7105builtin_builder::_average(builtin_available_predicate avail,7106const glsl_type *type)7107{7108return binop(avail, ir_binop_avg, type, type, type);7109}71107111ir_function_signature *7112builtin_builder::_averageRounded(builtin_available_predicate avail,7113const glsl_type *type)7114{7115return binop(avail, ir_binop_avg_round, type, type, type);7116}71177118/**7119* For both imulExtended() and umulExtended() built-ins.7120*/7121ir_function_signature *7122builtin_builder::_mulExtended(const glsl_type *type)7123{7124const glsl_type *mul_type, *unpack_type;7125ir_expression_operation unpack_op;71267127if (type->base_type == GLSL_TYPE_INT) {7128unpack_op = ir_unop_unpack_int_2x32;7129mul_type = glsl_type::get_instance(GLSL_TYPE_INT64, type->vector_elements, 1);7130unpack_type = glsl_type::ivec2_type;7131} else {7132unpack_op = ir_unop_unpack_uint_2x32;7133mul_type = glsl_type::get_instance(GLSL_TYPE_UINT64, type->vector_elements, 1);7134unpack_type = glsl_type::uvec2_type;7135}71367137ir_variable *x = in_var(type, "x");7138ir_variable *y = in_var(type, "y");7139ir_variable *msb = out_var(type, "msb");7140ir_variable *lsb = out_var(type, "lsb");7141MAKE_SIG(glsl_type::void_type, gpu_shader5_or_es31_or_integer_functions, 4, x, y, msb, lsb);71427143ir_variable *unpack_val = body.make_temp(unpack_type, "_unpack_val");71447145ir_expression *mul_res = new(mem_ctx) ir_expression(ir_binop_mul, mul_type,7146new(mem_ctx)ir_dereference_variable(x),7147new(mem_ctx)ir_dereference_variable(y));71487149if (type->vector_elements == 1) {7150body.emit(assign(unpack_val, expr(unpack_op, mul_res)));7151body.emit(assign(msb, swizzle_y(unpack_val)));7152body.emit(assign(lsb, swizzle_x(unpack_val)));7153} else {7154for (int i = 0; i < type->vector_elements; i++) {7155body.emit(assign(unpack_val, expr(unpack_op, swizzle(mul_res, i, 1))));7156body.emit(assign(array_ref(msb, i), swizzle_y(unpack_val)));7157body.emit(assign(array_ref(lsb, i), swizzle_x(unpack_val)));7158}7159}71607161return sig;7162}71637164ir_function_signature *7165builtin_builder::_multiply32x16(builtin_available_predicate avail,7166const glsl_type *type)7167{7168return binop(avail, ir_binop_mul_32x16, type, type, type);7169}71707171ir_function_signature *7172builtin_builder::_interpolateAtCentroid(const glsl_type *type)7173{7174ir_variable *interpolant = in_var(type, "interpolant");7175interpolant->data.must_be_shader_input = 1;7176MAKE_SIG(type, fs_interpolate_at, 1, interpolant);71777178body.emit(ret(interpolate_at_centroid(interpolant)));71797180return sig;7181}71827183ir_function_signature *7184builtin_builder::_interpolateAtOffset(const glsl_type *type)7185{7186ir_variable *interpolant = in_var(type, "interpolant");7187interpolant->data.must_be_shader_input = 1;7188ir_variable *offset = in_var(glsl_type::vec2_type, "offset");7189MAKE_SIG(type, fs_interpolate_at, 2, interpolant, offset);71907191body.emit(ret(interpolate_at_offset(interpolant, offset)));71927193return sig;7194}71957196ir_function_signature *7197builtin_builder::_interpolateAtSample(const glsl_type *type)7198{7199ir_variable *interpolant = in_var(type, "interpolant");7200interpolant->data.must_be_shader_input = 1;7201ir_variable *sample_num = in_var(glsl_type::int_type, "sample_num");7202MAKE_SIG(type, fs_interpolate_at, 2, interpolant, sample_num);72037204body.emit(ret(interpolate_at_sample(interpolant, sample_num)));72057206return sig;7207}72087209ir_function_signature *7210builtin_builder::_atomic_counter_intrinsic(builtin_available_predicate avail,7211enum ir_intrinsic_id id)7212{7213ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");7214MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 1, counter);7215return sig;7216}72177218ir_function_signature *7219builtin_builder::_atomic_counter_intrinsic1(builtin_available_predicate avail,7220enum ir_intrinsic_id id)7221{7222ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");7223ir_variable *data = in_var(glsl_type::uint_type, "data");7224MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 2, counter, data);7225return sig;7226}72277228ir_function_signature *7229builtin_builder::_atomic_counter_intrinsic2(builtin_available_predicate avail,7230enum ir_intrinsic_id id)7231{7232ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");7233ir_variable *compare = in_var(glsl_type::uint_type, "compare");7234ir_variable *data = in_var(glsl_type::uint_type, "data");7235MAKE_INTRINSIC(glsl_type::uint_type, id, avail, 3, counter, compare, data);7236return sig;7237}72387239ir_function_signature *7240builtin_builder::_atomic_intrinsic2(builtin_available_predicate avail,7241const glsl_type *type,7242enum ir_intrinsic_id id)7243{7244ir_variable *atomic = in_var(type, "atomic");7245ir_variable *data = in_var(type, "data");7246MAKE_INTRINSIC(type, id, avail, 2, atomic, data);7247return sig;7248}72497250ir_function_signature *7251builtin_builder::_atomic_intrinsic3(builtin_available_predicate avail,7252const glsl_type *type,7253enum ir_intrinsic_id id)7254{7255ir_variable *atomic = in_var(type, "atomic");7256ir_variable *data1 = in_var(type, "data1");7257ir_variable *data2 = in_var(type, "data2");7258MAKE_INTRINSIC(type, id, avail, 3, atomic, data1, data2);7259return sig;7260}72617262ir_function_signature *7263builtin_builder::_atomic_counter_op(const char *intrinsic,7264builtin_available_predicate avail)7265{7266ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");7267MAKE_SIG(glsl_type::uint_type, avail, 1, counter);72687269ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");7270body.emit(call(shader->symbols->get_function(intrinsic), retval,7271sig->parameters));7272body.emit(ret(retval));7273return sig;7274}72757276ir_function_signature *7277builtin_builder::_atomic_counter_op1(const char *intrinsic,7278builtin_available_predicate avail)7279{7280ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");7281ir_variable *data = in_var(glsl_type::uint_type, "data");7282MAKE_SIG(glsl_type::uint_type, avail, 2, counter, data);72837284ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");72857286/* Instead of generating an __intrinsic_atomic_sub, generate an7287* __intrinsic_atomic_add with the data parameter negated.7288*/7289if (strcmp("__intrinsic_atomic_sub", intrinsic) == 0) {7290ir_variable *const neg_data =7291body.make_temp(glsl_type::uint_type, "neg_data");72927293body.emit(assign(neg_data, neg(data)));72947295exec_list parameters;72967297parameters.push_tail(new(mem_ctx) ir_dereference_variable(counter));7298parameters.push_tail(new(mem_ctx) ir_dereference_variable(neg_data));72997300ir_function *const func =7301shader->symbols->get_function("__intrinsic_atomic_add");7302ir_instruction *const c = call(func, retval, parameters);73037304assert(c != NULL);7305assert(parameters.is_empty());73067307body.emit(c);7308} else {7309body.emit(call(shader->symbols->get_function(intrinsic), retval,7310sig->parameters));7311}73127313body.emit(ret(retval));7314return sig;7315}73167317ir_function_signature *7318builtin_builder::_atomic_counter_op2(const char *intrinsic,7319builtin_available_predicate avail)7320{7321ir_variable *counter = in_var(glsl_type::atomic_uint_type, "atomic_counter");7322ir_variable *compare = in_var(glsl_type::uint_type, "compare");7323ir_variable *data = in_var(glsl_type::uint_type, "data");7324MAKE_SIG(glsl_type::uint_type, avail, 3, counter, compare, data);73257326ir_variable *retval = body.make_temp(glsl_type::uint_type, "atomic_retval");7327body.emit(call(shader->symbols->get_function(intrinsic), retval,7328sig->parameters));7329body.emit(ret(retval));7330return sig;7331}73327333ir_function_signature *7334builtin_builder::_atomic_op2(const char *intrinsic,7335builtin_available_predicate avail,7336const glsl_type *type)7337{7338ir_variable *atomic = in_var(type, "atomic_var");7339ir_variable *data = in_var(type, "atomic_data");7340MAKE_SIG(type, avail, 2, atomic, data);73417342atomic->data.implicit_conversion_prohibited = true;73437344ir_variable *retval = body.make_temp(type, "atomic_retval");7345body.emit(call(shader->symbols->get_function(intrinsic), retval,7346sig->parameters));7347body.emit(ret(retval));7348return sig;7349}73507351ir_function_signature *7352builtin_builder::_atomic_op3(const char *intrinsic,7353builtin_available_predicate avail,7354const glsl_type *type)7355{7356ir_variable *atomic = in_var(type, "atomic_var");7357ir_variable *data1 = in_var(type, "atomic_data1");7358ir_variable *data2 = in_var(type, "atomic_data2");7359MAKE_SIG(type, avail, 3, atomic, data1, data2);73607361atomic->data.implicit_conversion_prohibited = true;73627363ir_variable *retval = body.make_temp(type, "atomic_retval");7364body.emit(call(shader->symbols->get_function(intrinsic), retval,7365sig->parameters));7366body.emit(ret(retval));7367return sig;7368}73697370ir_function_signature *7371builtin_builder::_min3(const glsl_type *type)7372{7373ir_variable *x = in_var(type, "x");7374ir_variable *y = in_var(type, "y");7375ir_variable *z = in_var(type, "z");7376MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);73777378ir_expression *min3 = min2(x, min2(y,z));7379body.emit(ret(min3));73807381return sig;7382}73837384ir_function_signature *7385builtin_builder::_max3(const glsl_type *type)7386{7387ir_variable *x = in_var(type, "x");7388ir_variable *y = in_var(type, "y");7389ir_variable *z = in_var(type, "z");7390MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);73917392ir_expression *max3 = max2(x, max2(y,z));7393body.emit(ret(max3));73947395return sig;7396}73977398ir_function_signature *7399builtin_builder::_mid3(const glsl_type *type)7400{7401ir_variable *x = in_var(type, "x");7402ir_variable *y = in_var(type, "y");7403ir_variable *z = in_var(type, "z");7404MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);74057406ir_expression *mid3 = max2(min2(x, y), max2(min2(x, z), min2(y, z)));7407body.emit(ret(mid3));74087409return sig;7410}74117412static builtin_available_predicate7413get_image_available_predicate(const glsl_type *type, unsigned flags)7414{7415if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE) &&7416type->sampled_type == GLSL_TYPE_FLOAT)7417return shader_image_atomic_exchange_float;74187419if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_ADD) &&7420type->sampled_type == GLSL_TYPE_FLOAT)7421return shader_image_atomic_add_float;74227423else if (flags & (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE |7424IMAGE_FUNCTION_AVAIL_ATOMIC_ADD |7425IMAGE_FUNCTION_AVAIL_ATOMIC))7426return shader_image_atomic;74277428else if (flags & IMAGE_FUNCTION_EXT_ONLY)7429return shader_image_load_store_ext;74307431else7432return shader_image_load_store;7433}74347435ir_function_signature *7436builtin_builder::_image_prototype(const glsl_type *image_type,7437unsigned num_arguments,7438unsigned flags)7439{7440const glsl_type *data_type = glsl_type::get_instance(7441image_type->sampled_type,7442(flags & IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE ? 4 : 1),74431);7444const glsl_type *ret_type = (flags & IMAGE_FUNCTION_RETURNS_VOID ?7445glsl_type::void_type : data_type);74467447/* Addressing arguments that are always present. */7448ir_variable *image = in_var(image_type, "image");7449ir_variable *coord = in_var(7450glsl_type::ivec(image_type->coordinate_components()), "coord");74517452ir_function_signature *sig = new_sig(7453ret_type, get_image_available_predicate(image_type, flags),74542, image, coord);74557456/* Sample index for multisample images. */7457if (image_type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS)7458sig->parameters.push_tail(in_var(glsl_type::int_type, "sample"));74597460/* Data arguments. */7461for (unsigned i = 0; i < num_arguments; ++i) {7462char *arg_name = ralloc_asprintf(NULL, "arg%d", i);7463sig->parameters.push_tail(in_var(data_type, arg_name));7464ralloc_free(arg_name);7465}74667467/* Set the maximal set of qualifiers allowed for this image7468* built-in. Function calls with arguments having fewer7469* qualifiers than present in the prototype are allowed by the7470* spec, but not with more, i.e. this will make the compiler7471* accept everything that needs to be accepted, and reject cases7472* like loads from write-only or stores to read-only images.7473*/7474image->data.memory_read_only = (flags & IMAGE_FUNCTION_READ_ONLY) != 0;7475image->data.memory_write_only = (flags & IMAGE_FUNCTION_WRITE_ONLY) != 0;7476image->data.memory_coherent = true;7477image->data.memory_volatile = true;7478image->data.memory_restrict = true;74797480return sig;7481}74827483ir_function_signature *7484builtin_builder::_image_size_prototype(const glsl_type *image_type,7485unsigned /* num_arguments */,7486unsigned /* flags */)7487{7488const glsl_type *ret_type;7489unsigned num_components = image_type->coordinate_components();74907491/* From the ARB_shader_image_size extension:7492* "Cube images return the dimensions of one face."7493*/7494if (image_type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE &&7495!image_type->sampler_array) {7496num_components = 2;7497}74987499/* FIXME: Add the highp precision qualifier for GLES 3.10 when it is7500* supported by mesa.7501*/7502ret_type = glsl_type::get_instance(GLSL_TYPE_INT, num_components, 1);75037504ir_variable *image = in_var(image_type, "image");7505ir_function_signature *sig = new_sig(ret_type, shader_image_size, 1, image);75067507/* Set the maximal set of qualifiers allowed for this image7508* built-in. Function calls with arguments having fewer7509* qualifiers than present in the prototype are allowed by the7510* spec, but not with more, i.e. this will make the compiler7511* accept everything that needs to be accepted, and reject cases7512* like loads from write-only or stores to read-only images.7513*/7514image->data.memory_read_only = true;7515image->data.memory_write_only = true;7516image->data.memory_coherent = true;7517image->data.memory_volatile = true;7518image->data.memory_restrict = true;75197520return sig;7521}75227523ir_function_signature *7524builtin_builder::_image_samples_prototype(const glsl_type *image_type,7525unsigned /* num_arguments */,7526unsigned /* flags */)7527{7528ir_variable *image = in_var(image_type, "image");7529ir_function_signature *sig =7530new_sig(glsl_type::int_type, shader_samples, 1, image);75317532/* Set the maximal set of qualifiers allowed for this image7533* built-in. Function calls with arguments having fewer7534* qualifiers than present in the prototype are allowed by the7535* spec, but not with more, i.e. this will make the compiler7536* accept everything that needs to be accepted, and reject cases7537* like loads from write-only or stores to read-only images.7538*/7539image->data.memory_read_only = true;7540image->data.memory_write_only = true;7541image->data.memory_coherent = true;7542image->data.memory_volatile = true;7543image->data.memory_restrict = true;75447545return sig;7546}75477548ir_function_signature *7549builtin_builder::_image(image_prototype_ctr prototype,7550const glsl_type *image_type,7551const char *intrinsic_name,7552unsigned num_arguments,7553unsigned flags,7554enum ir_intrinsic_id id)7555{7556ir_function_signature *sig = (this->*prototype)(image_type,7557num_arguments, flags);75587559if (flags & IMAGE_FUNCTION_EMIT_STUB) {7560ir_factory body(&sig->body, mem_ctx);7561ir_function *f = shader->symbols->get_function(intrinsic_name);75627563if (flags & IMAGE_FUNCTION_RETURNS_VOID) {7564body.emit(call(f, NULL, sig->parameters));7565} else {7566ir_variable *ret_val =7567body.make_temp(sig->return_type, "_ret_val");7568body.emit(call(f, ret_val, sig->parameters));7569body.emit(ret(ret_val));7570}75717572sig->is_defined = true;75737574} else {7575sig->intrinsic_id = id;7576}75777578return sig;7579}75807581ir_function_signature *7582builtin_builder::_memory_barrier_intrinsic(builtin_available_predicate avail,7583enum ir_intrinsic_id id)7584{7585MAKE_INTRINSIC(glsl_type::void_type, id, avail, 0);7586return sig;7587}75887589ir_function_signature *7590builtin_builder::_memory_barrier(const char *intrinsic_name,7591builtin_available_predicate avail)7592{7593MAKE_SIG(glsl_type::void_type, avail, 0);7594body.emit(call(shader->symbols->get_function(intrinsic_name),7595NULL, sig->parameters));7596return sig;7597}75987599ir_function_signature *7600builtin_builder::_ballot_intrinsic()7601{7602ir_variable *value = in_var(glsl_type::bool_type, "value");7603MAKE_INTRINSIC(glsl_type::uint64_t_type, ir_intrinsic_ballot, shader_ballot,76041, value);7605return sig;7606}76077608ir_function_signature *7609builtin_builder::_ballot()7610{7611ir_variable *value = in_var(glsl_type::bool_type, "value");76127613MAKE_SIG(glsl_type::uint64_t_type, shader_ballot, 1, value);7614ir_variable *retval = body.make_temp(glsl_type::uint64_t_type, "retval");76157616body.emit(call(shader->symbols->get_function("__intrinsic_ballot"),7617retval, sig->parameters));7618body.emit(ret(retval));7619return sig;7620}76217622ir_function_signature *7623builtin_builder::_read_first_invocation_intrinsic(const glsl_type *type)7624{7625ir_variable *value = in_var(type, "value");7626MAKE_INTRINSIC(type, ir_intrinsic_read_first_invocation, shader_ballot,76271, value);7628return sig;7629}76307631ir_function_signature *7632builtin_builder::_read_first_invocation(const glsl_type *type)7633{7634ir_variable *value = in_var(type, "value");76357636MAKE_SIG(type, shader_ballot, 1, value);7637ir_variable *retval = body.make_temp(type, "retval");76387639body.emit(call(shader->symbols->get_function("__intrinsic_read_first_invocation"),7640retval, sig->parameters));7641body.emit(ret(retval));7642return sig;7643}76447645ir_function_signature *7646builtin_builder::_read_invocation_intrinsic(const glsl_type *type)7647{7648ir_variable *value = in_var(type, "value");7649ir_variable *invocation = in_var(glsl_type::uint_type, "invocation");7650MAKE_INTRINSIC(type, ir_intrinsic_read_invocation, shader_ballot,76512, value, invocation);7652return sig;7653}76547655ir_function_signature *7656builtin_builder::_read_invocation(const glsl_type *type)7657{7658ir_variable *value = in_var(type, "value");7659ir_variable *invocation = in_var(glsl_type::uint_type, "invocation");76607661MAKE_SIG(type, shader_ballot, 2, value, invocation);7662ir_variable *retval = body.make_temp(type, "retval");76637664body.emit(call(shader->symbols->get_function("__intrinsic_read_invocation"),7665retval, sig->parameters));7666body.emit(ret(retval));7667return sig;7668}76697670ir_function_signature *7671builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail,7672enum ir_intrinsic_id id)7673{7674MAKE_INTRINSIC(glsl_type::void_type, id, avail, 0);7675return sig;7676}76777678ir_function_signature *7679builtin_builder::_invocation_interlock(const char *intrinsic_name,7680builtin_available_predicate avail)7681{7682MAKE_SIG(glsl_type::void_type, avail, 0);7683body.emit(call(shader->symbols->get_function(intrinsic_name),7684NULL, sig->parameters));7685return sig;7686}76877688ir_function_signature *7689builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail,7690const glsl_type *type)7691{7692MAKE_INTRINSIC(type, ir_intrinsic_shader_clock, avail, 0);7693return sig;7694}76957696ir_function_signature *7697builtin_builder::_shader_clock(builtin_available_predicate avail,7698const glsl_type *type)7699{7700MAKE_SIG(type, avail, 0);77017702ir_variable *retval = body.make_temp(glsl_type::uvec2_type, "clock_retval");77037704body.emit(call(shader->symbols->get_function("__intrinsic_shader_clock"),7705retval, sig->parameters));77067707if (type == glsl_type::uint64_t_type) {7708body.emit(ret(expr(ir_unop_pack_uint_2x32, retval)));7709} else {7710body.emit(ret(retval));7711}77127713return sig;7714}77157716ir_function_signature *7717builtin_builder::_vote_intrinsic(builtin_available_predicate avail,7718enum ir_intrinsic_id id)7719{7720ir_variable *value = in_var(glsl_type::bool_type, "value");7721MAKE_INTRINSIC(glsl_type::bool_type, id, avail, 1, value);7722return sig;7723}77247725ir_function_signature *7726builtin_builder::_vote(const char *intrinsic_name,7727builtin_available_predicate avail)7728{7729ir_variable *value = in_var(glsl_type::bool_type, "value");77307731MAKE_SIG(glsl_type::bool_type, avail, 1, value);77327733ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval");77347735body.emit(call(shader->symbols->get_function(intrinsic_name),7736retval, sig->parameters));7737body.emit(ret(retval));7738return sig;7739}77407741ir_function_signature *7742builtin_builder::_helper_invocation_intrinsic()7743{7744MAKE_INTRINSIC(glsl_type::bool_type, ir_intrinsic_helper_invocation,7745demote_to_helper_invocation, 0);7746return sig;7747}77487749ir_function_signature *7750builtin_builder::_helper_invocation()7751{7752MAKE_SIG(glsl_type::bool_type, demote_to_helper_invocation, 0);77537754ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval");77557756body.emit(call(shader->symbols->get_function("__intrinsic_helper_invocation"),7757retval, sig->parameters));7758body.emit(ret(retval));77597760return sig;7761}77627763/** @} */77647765/******************************************************************************/77667767/* The singleton instance of builtin_builder. */7768static builtin_builder builtins;7769static uint32_t builtin_users = 0;77707771/**7772* External API (exposing the built-in module to the rest of the compiler):7773* @{7774*/7775extern "C" void7776_mesa_glsl_builtin_functions_init_or_ref()7777{7778mtx_lock(&builtins_lock);7779if (builtin_users++ == 0)7780builtins.initialize();7781mtx_unlock(&builtins_lock);7782}77837784extern "C" void7785_mesa_glsl_builtin_functions_decref()7786{7787mtx_lock(&builtins_lock);7788assert(builtin_users != 0);7789if (--builtin_users == 0)7790builtins.release();7791mtx_unlock(&builtins_lock);7792}77937794ir_function_signature *7795_mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,7796const char *name, exec_list *actual_parameters)7797{7798ir_function_signature *s;7799mtx_lock(&builtins_lock);7800s = builtins.find(state, name, actual_parameters);7801mtx_unlock(&builtins_lock);78027803return s;7804}78057806bool7807_mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name)7808{7809ir_function *f;7810bool ret = false;7811mtx_lock(&builtins_lock);7812f = builtins.shader->symbols->get_function(name);7813if (f != NULL) {7814foreach_in_list(ir_function_signature, sig, &f->signatures) {7815if (sig->is_builtin_available(state)) {7816ret = true;7817break;7818}7819}7820}7821mtx_unlock(&builtins_lock);78227823return ret;7824}78257826gl_shader *7827_mesa_glsl_get_builtin_function_shader()7828{7829return builtins.shader;7830}783178327833/**7834* Get the function signature for main from a shader7835*/7836ir_function_signature *7837_mesa_get_main_function_signature(glsl_symbol_table *symbols)7838{7839ir_function *const f = symbols->get_function("main");7840if (f != NULL) {7841exec_list void_parameters;78427843/* Look for the 'void main()' signature and ensure that it's defined.7844* This keeps the linker from accidentally pick a shader that just7845* contains a prototype for main.7846*7847* We don't have to check for multiple definitions of main (in multiple7848* shaders) because that would have already been caught above.7849*/7850ir_function_signature *sig =7851f->matching_signature(NULL, &void_parameters, false);7852if ((sig != NULL) && sig->is_defined) {7853return sig;7854}7855}78567857return NULL;7858}78597860/** @} */786178627863