X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fglsl%2Fbuiltin_functions.cpp;h=f6c208e60c1f14995443cde0d42965c4871efac8;hb=39006590517de05709d32378d6024de8041035d0;hp=4a6c5afd65c9e6ed7499168066b563b2f3aa6dc1;hpb=695b04f7eb24bff108e8d85c476adb5cf9de6f2d;p=mesa.git diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 4a6c5afd65c..f6c208e60c1 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -53,15 +53,36 @@ * name and parameters. */ + +/** + * Unfortunately, some versions of MinGW produce bad code if this file + * is compiled with -O2 or -O3. The resulting driver will crash in random + * places if the app uses GLSL. + * The work-around is to disable optimizations for just this file. Luckily, + * this code is basically just executed once. + * + * MinGW 4.6.3 (in Ubuntu 13.10) does not have this bug. + * MinGW 5.3.1 (in Ubuntu 16.04) definitely has this bug. + * MinGW 6.2.0 (in Ubuntu 16.10) definitely has this bug. + * MinGW x.y.z - don't know. Assume versions after 4.6.x are buggy + */ + +#if defined(__MINGW32__) && ((__GNUC__ * 100) + __GNUC_MINOR >= 407) +#warning "disabling optimizations for this file to work around compiler bug" +#pragma GCC optimize("O1") +#endif + + #include #include -#include "main/core.h" /* for struct gl_shader */ +#include "main/mtypes.h" #include "main/shaderobj.h" #include "ir_builder.h" #include "glsl_parser_extras.h" #include "program/prog_instruction.h" #include #include "builtin_functions.h" +#include "util/hash_table.h" #define M_PIf ((float) M_PI) #define M_PI_2f ((float) M_PI_2) @@ -83,14 +104,16 @@ static bool compatibility_vs_only(const _mesa_glsl_parse_state *state) { return state->stage == MESA_SHADER_VERTEX && - state->language_version <= 130 && + (state->compat_shader || state->ARB_compatibility_enable) && !state->es_shader; } static bool -fs_only(const _mesa_glsl_parse_state *state) +derivatives_only(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT; + return state->stage == MESA_SHADER_FRAGMENT || + (state->stage == MESA_SHADER_COMPUTE && + state->NV_compute_shader_derivatives_enable); } static bool @@ -106,9 +129,10 @@ v110(const _mesa_glsl_parse_state *state) } static bool -v110_fs_only(const _mesa_glsl_parse_state *state) +v110_derivatives_only(const _mesa_glsl_parse_state *state) { - return !state->es_shader && state->stage == MESA_SHADER_FRAGMENT; + return !state->es_shader && + derivatives_only(state); } static bool @@ -130,10 +154,16 @@ v130_desktop(const _mesa_glsl_parse_state *state) } static bool -v130_fs_only(const _mesa_glsl_parse_state *state) +v460_desktop(const _mesa_glsl_parse_state *state) +{ + return state->is_version(460, 0); +} + +static bool +v130_derivatives_only(const _mesa_glsl_parse_state *state) { return state->is_version(130, 300) && - state->stage == MESA_SHADER_FRAGMENT; + derivatives_only(state); } static bool @@ -143,10 +173,10 @@ v140_or_es3(const _mesa_glsl_parse_state *state) } static bool -v400_fs_only(const _mesa_glsl_parse_state *state) +v400_derivatives_only(const _mesa_glsl_parse_state *state) { return state->is_version(400, 0) && - state->stage == MESA_SHADER_FRAGMENT; + derivatives_only(state); } static bool @@ -161,6 +191,14 @@ texture_external(const _mesa_glsl_parse_state *state) return state->OES_EGL_image_external_enable; } +static bool +texture_external_es3(const _mesa_glsl_parse_state *state) +{ + return state->OES_EGL_image_external_essl3_enable && + state->es_shader && + state->is_version(0, 300); +} + /** True if texturing functions with explicit LOD are allowed. */ static bool lod_exists_in_stage(const _mesa_glsl_parse_state *state) @@ -175,7 +213,8 @@ lod_exists_in_stage(const _mesa_glsl_parse_state *state) */ return state->stage == MESA_SHADER_VERTEX || state->is_version(130, 300) || - state->ARB_shader_texture_lod_enable; + state->ARB_shader_texture_lod_enable || + state->EXT_gpu_shader4_enable; } static bool @@ -236,6 +275,102 @@ shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state) state->is_version(400, 300); } +static bool +gpu_shader4(const _mesa_glsl_parse_state *state) +{ + return state->EXT_gpu_shader4_enable; +} + +static bool +gpu_shader4_integer(const _mesa_glsl_parse_state *state) +{ + return state->EXT_gpu_shader4_enable && + state->ctx->Extensions.EXT_texture_integer; +} + +static bool +gpu_shader4_array(const _mesa_glsl_parse_state *state) +{ + return state->EXT_gpu_shader4_enable && + state->ctx->Extensions.EXT_texture_array; +} + +static bool +gpu_shader4_array_integer(const _mesa_glsl_parse_state *state) +{ + return gpu_shader4_array(state) && + state->ctx->Extensions.EXT_texture_integer; +} + +static bool +gpu_shader4_rect(const _mesa_glsl_parse_state *state) +{ + return state->EXT_gpu_shader4_enable && + state->ctx->Extensions.NV_texture_rectangle; +} + +static bool +gpu_shader4_rect_integer(const _mesa_glsl_parse_state *state) +{ + return gpu_shader4_rect(state) && + state->ctx->Extensions.EXT_texture_integer; +} + +static bool +gpu_shader4_tbo(const _mesa_glsl_parse_state *state) +{ + return state->EXT_gpu_shader4_enable && + state->ctx->Extensions.EXT_texture_buffer_object; +} + +static bool +gpu_shader4_tbo_integer(const _mesa_glsl_parse_state *state) +{ + return gpu_shader4_tbo(state) && + state->ctx->Extensions.EXT_texture_integer; +} + +static bool +gpu_shader4_derivs_only(const _mesa_glsl_parse_state *state) +{ + return state->EXT_gpu_shader4_enable && + derivatives_only(state); +} + +static bool +gpu_shader4_integer_derivs_only(const _mesa_glsl_parse_state *state) +{ + return gpu_shader4_derivs_only(state) && + state->ctx->Extensions.EXT_texture_integer; +} + +static bool +gpu_shader4_array_derivs_only(const _mesa_glsl_parse_state *state) +{ + return gpu_shader4_derivs_only(state) && + state->ctx->Extensions.EXT_texture_array; +} + +static bool +gpu_shader4_array_integer_derivs_only(const _mesa_glsl_parse_state *state) +{ + return gpu_shader4_array_derivs_only(state) && + state->ctx->Extensions.EXT_texture_integer; +} + +static bool +v130_or_gpu_shader4(const _mesa_glsl_parse_state *state) +{ + return state->is_version(130, 300) || state->EXT_gpu_shader4_enable; +} + +static bool +v130_or_gpu_shader4_and_tex_shadow_lod(const _mesa_glsl_parse_state *state) +{ + return v130_or_gpu_shader4(state) && + state->EXT_texture_shadow_lod_enable; +} + static bool gpu_shader5(const _mesa_glsl_parse_state *state) { @@ -301,20 +436,24 @@ static bool texture_array_lod(const _mesa_glsl_parse_state *state) { return lod_exists_in_stage(state) && - state->EXT_texture_array_enable; + (state->EXT_texture_array_enable || + (state->EXT_gpu_shader4_enable && + state->ctx->Extensions.EXT_texture_array)); } static bool -fs_texture_array(const _mesa_glsl_parse_state *state) +texture_array(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT && - state->EXT_texture_array_enable; + return state->EXT_texture_array_enable || + (state->EXT_gpu_shader4_enable && + state->ctx->Extensions.EXT_texture_array); } static bool -texture_array(const _mesa_glsl_parse_state *state) +texture_array_derivs_only(const _mesa_glsl_parse_state *state) { - return state->EXT_texture_array_enable; + return derivatives_only(state) && + texture_array(state); } static bool @@ -347,10 +486,10 @@ texture_samples_identical_array(const _mesa_glsl_parse_state *state) } static bool -fs_texture_cube_map_array(const _mesa_glsl_parse_state *state) +derivatives_texture_cube_map_array(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT && - state->has_texture_cube_map_array(); + return state->has_texture_cube_map_array() && + derivatives_only(state); } static bool @@ -359,6 +498,14 @@ texture_cube_map_array(const _mesa_glsl_parse_state *state) return state->has_texture_cube_map_array(); } +static bool +v130_or_gpu_shader4_and_tex_cube_map_array(const _mesa_glsl_parse_state *state) +{ + return texture_cube_map_array(state) && + v130_or_gpu_shader4(state) && + state->EXT_texture_shadow_lod_enable; +} + static bool texture_query_levels(const _mesa_glsl_parse_state *state) { @@ -369,8 +516,9 @@ texture_query_levels(const _mesa_glsl_parse_state *state) static bool texture_query_lod(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT && - state->ARB_texture_query_lod_enable; + return derivatives_only(state) && + (state->ARB_texture_query_lod_enable || + state->EXT_texture_query_lod_enable); } static bool @@ -383,6 +531,12 @@ texture_gather_cube_map_array(const _mesa_glsl_parse_state *state) state->OES_texture_cube_map_array_enable; } +static bool +texture_texture4(const _mesa_glsl_parse_state *state) +{ + return state->AMD_texture_texture4_enable; +} + static bool texture_gather_or_es31(const _mesa_glsl_parse_state *state) { @@ -405,19 +559,20 @@ texture_gather_only_or_es31(const _mesa_glsl_parse_state *state) state->is_version(0, 310)); } -/* Desktop GL or OES_standard_derivatives + fragment shader only */ +/* Desktop GL or OES_standard_derivatives */ static bool -fs_oes_derivatives(const _mesa_glsl_parse_state *state) +derivatives(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT && + return derivatives_only(state) && (state->is_version(110, 300) || - state->OES_standard_derivatives_enable); + state->OES_standard_derivatives_enable || + state->ctx->Const.AllowGLSLRelaxedES); } static bool -fs_derivative_control(const _mesa_glsl_parse_state *state) +derivative_control(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT && + return derivatives_only(state) && (state->is_version(450, 0) || state->ARB_derivative_control_enable); } @@ -441,10 +596,10 @@ tex3d(const _mesa_glsl_parse_state *state) } static bool -fs_tex3d(const _mesa_glsl_parse_state *state) +derivatives_tex3d(const _mesa_glsl_parse_state *state) { - return state->stage == MESA_SHADER_FRAGMENT && - (!state->es_shader || state->OES_texture_3D_enable); + return (!state->es_shader || state->OES_texture_3D_enable) && + derivatives_only(state); } static bool @@ -465,6 +620,30 @@ shader_atomic_counter_ops(const _mesa_glsl_parse_state *state) return state->ARB_shader_atomic_counter_ops_enable; } +static bool +shader_atomic_counter_ops_or_v460_desktop(const _mesa_glsl_parse_state *state) +{ + return state->ARB_shader_atomic_counter_ops_enable || v460_desktop(state); +} + +static bool +shader_ballot(const _mesa_glsl_parse_state *state) +{ + return state->ARB_shader_ballot_enable; +} + +static bool +supports_arb_fragment_shader_interlock(const _mesa_glsl_parse_state *state) +{ + return state->ARB_fragment_shader_interlock_enable; +} + +static bool +supports_nv_fragment_shader_interlock(const _mesa_glsl_parse_state *state) +{ + return state->NV_fragment_shader_interlock_enable; +} + static bool shader_clock(const _mesa_glsl_parse_state *state) { @@ -475,7 +654,8 @@ static bool shader_clock_int64(const _mesa_glsl_parse_state *state) { return state->ARB_shader_clock_enable && - state->ARB_gpu_shader_int64_enable; + (state->ARB_gpu_shader_int64_enable || + state->AMD_gpu_shader_int64_enable); } static bool @@ -494,7 +674,14 @@ static bool shader_image_load_store(const _mesa_glsl_parse_state *state) { return (state->is_version(420, 310) || - state->ARB_shader_image_load_store_enable); + state->ARB_shader_image_load_store_enable || + state->EXT_shader_image_load_store_enable); +} + +static bool +shader_image_load_store_ext(const _mesa_glsl_parse_state *state) +{ + return state->EXT_shader_image_load_store_enable; } static bool @@ -502,6 +689,7 @@ shader_image_atomic(const _mesa_glsl_parse_state *state) { return (state->is_version(420, 320) || state->ARB_shader_image_load_store_enable || + state->EXT_shader_image_load_store_enable || state->OES_shader_image_atomic_enable); } @@ -510,7 +698,14 @@ shader_image_atomic_exchange_float(const _mesa_glsl_parse_state *state) { return (state->is_version(450, 320) || state->ARB_ES3_1_compatibility_enable || - state->OES_shader_image_atomic_enable); + state->OES_shader_image_atomic_enable || + state->NV_shader_atomic_float_enable); +} + +static bool +shader_image_atomic_add_float(const _mesa_glsl_parse_state *state) +{ + return state->NV_shader_atomic_float_enable; } static bool @@ -557,6 +752,12 @@ compute_shader(const _mesa_glsl_parse_state *state) return state->stage == MESA_SHADER_COMPUTE; } +static bool +compute_shader_supported(const _mesa_glsl_parse_state *state) +{ + return state->has_compute_shader(); +} + static bool buffer_atomics_supported(const _mesa_glsl_parse_state *state) { @@ -576,11 +777,85 @@ vote(const _mesa_glsl_parse_state *state) return state->ARB_shader_group_vote_enable; } +static bool +vote_ext(const _mesa_glsl_parse_state *state) +{ + return state->EXT_shader_group_vote_enable; +} + +static bool +vote_or_v460_desktop(const _mesa_glsl_parse_state *state) +{ + return state->EXT_shader_group_vote_enable || state->ARB_shader_group_vote_enable || v460_desktop(state); +} + static bool integer_functions_supported(const _mesa_glsl_parse_state *state) { return state->extensions->MESA_shader_integer_functions; } + +static bool +NV_shader_atomic_float_supported(const _mesa_glsl_parse_state *state) +{ + return state->extensions->NV_shader_atomic_float; +} + +static bool +shader_atomic_float_add(const _mesa_glsl_parse_state *state) +{ + return state->NV_shader_atomic_float_enable; +} + +static bool +shader_atomic_float_exchange(const _mesa_glsl_parse_state *state) +{ + return state->NV_shader_atomic_float_enable || + state->INTEL_shader_atomic_float_minmax_enable; +} + +static bool +INTEL_shader_atomic_float_minmax_supported(const _mesa_glsl_parse_state *state) +{ + return state->extensions->INTEL_shader_atomic_float_minmax; +} + +static bool +shader_atomic_float_minmax(const _mesa_glsl_parse_state *state) +{ + return state->INTEL_shader_atomic_float_minmax_enable; +} + +static bool +demote_to_helper_invocation(const _mesa_glsl_parse_state *state) +{ + return state->EXT_demote_to_helper_invocation_enable; +} + +static bool +shader_integer_functions2(const _mesa_glsl_parse_state *state) +{ + return state->INTEL_shader_integer_functions2_enable; +} + +static bool +shader_integer_functions2_int64(const _mesa_glsl_parse_state *state) +{ + return state->INTEL_shader_integer_functions2_enable && state->has_int64(); +} + +static bool +is_nir(const _mesa_glsl_parse_state *state) +{ + return state->ctx->Const.ShaderCompilerOptions[state->stage].NirOptions; +} + +static bool +is_not_nir(const _mesa_glsl_parse_state *state) +{ + return !is_nir(state); +} + /** @} */ /******************************************************************************/ @@ -693,7 +968,8 @@ private: ir_expression_operation opcode, const glsl_type *return_type, const glsl_type *param0_type, - const glsl_type *param1_type); + const glsl_type *param1_type, + bool swap_operands = false); #define B0(X) ir_function_signature *_##X(); #define B1(X) ir_function_signature *_##X(const glsl_type *); @@ -710,6 +986,8 @@ private: B1(acos) B1(atan2) B1(atan) + B1(atan2_op) + B1(atan_op) B1(sinh) B1(cosh) B1(tanh) @@ -726,6 +1004,7 @@ private: BA1(abs) BA1(sign) BA1(floor) + BA1(truncate) BA1(trunc) BA1(round) BA1(roundEven) @@ -799,7 +1078,7 @@ private: B1(all); B1(not); BA2(textureSize); - B1(textureSamples); + BA1(textureSamples); /** Flags to _texture() */ #define TEX_PROJECT 1 @@ -814,7 +1093,9 @@ private: const glsl_type *sampler_type, const glsl_type *coord_type, int flags = 0); - B0(textureCubeArrayShadow); + ir_function_signature *_textureCubeArrayShadow(ir_texture_opcode opcode, + builtin_available_predicate avail, + const glsl_type *x); ir_function_signature *_texelFetch(builtin_available_predicate avail, const glsl_type *return_type, const glsl_type *sampler_type, @@ -830,7 +1111,7 @@ private: B0(barrier) BA2(textureQueryLod); - B1(textureQueryLevels); + BA1(textureQueryLevels); BA2(textureSamplesIdentical); B1(dFdx); B1(dFdy); @@ -852,13 +1133,21 @@ private: B1(bitCount) B1(findLSB) B1(findMSB) + BA1(countLeadingZeros) + BA1(countTrailingZeros) BA1(fma) B2(ldexp) B2(frexp) B2(dfrexp) B1(uaddCarry) B1(usubBorrow) + BA1(addSaturate) + BA1(subtractSaturate) + BA1(absoluteDifference) + BA1(average) + BA1(averageRounded) B1(mulExtended) + BA1(multiply32x16) B1(interpolateAtCentroid) B1(interpolateAtOffset) B1(interpolateAtSample) @@ -915,12 +1204,33 @@ private: ir_function_signature *_memory_barrier(const char *intrinsic_name, builtin_available_predicate avail); + ir_function_signature *_ballot_intrinsic(); + ir_function_signature *_ballot(); + ir_function_signature *_read_first_invocation_intrinsic(const glsl_type *type); + ir_function_signature *_read_first_invocation(const glsl_type *type); + ir_function_signature *_read_invocation_intrinsic(const glsl_type *type); + ir_function_signature *_read_invocation(const glsl_type *type); + + + ir_function_signature *_invocation_interlock_intrinsic( + builtin_available_predicate avail, + enum ir_intrinsic_id id); + ir_function_signature *_invocation_interlock( + const char *intrinsic_name, + builtin_available_predicate avail); + ir_function_signature *_shader_clock_intrinsic(builtin_available_predicate avail, const glsl_type *type); ir_function_signature *_shader_clock(builtin_available_predicate avail, const glsl_type *type); - ir_function_signature *_vote(enum ir_expression_operation opcode); + ir_function_signature *_vote_intrinsic(builtin_available_predicate avail, + enum ir_intrinsic_id id); + ir_function_signature *_vote(const char *intrinsic_name, + builtin_available_predicate avail); + + ir_function_signature *_helper_invocation_intrinsic(); + ir_function_signature *_helper_invocation(); #undef B0 #undef B1 @@ -940,7 +1250,10 @@ enum image_function_flags { IMAGE_FUNCTION_WRITE_ONLY = (1 << 5), IMAGE_FUNCTION_AVAIL_ATOMIC = (1 << 6), IMAGE_FUNCTION_MS_ONLY = (1 << 7), - IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8) + IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE = (1 << 8), + IMAGE_FUNCTION_AVAIL_ATOMIC_ADD = (1 << 9), + IMAGE_FUNCTION_EXT_ONLY = (1 << 10), + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE = (1 << 11), }; } /* anonymous namespace */ @@ -992,6 +1305,8 @@ builtin_builder::initialize() if (mem_ctx != NULL) return; + glsl_type_singleton_init_or_ref(); + mem_ctx = ralloc_context(NULL); create_shader(); create_intrinsics(); @@ -1006,6 +1321,8 @@ builtin_builder::release() ralloc_free(shader); shader = NULL; + + glsl_type_singleton_decref(); } void @@ -1048,7 +1365,10 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_add), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_intrinsic2(NV_shader_atomic_float_supported, + glsl_type::float_type, + ir_intrinsic_generic_atomic_add), + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_add), NULL); add_function("__intrinsic_atomic_min", @@ -1058,7 +1378,10 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_min), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported, + glsl_type::float_type, + ir_intrinsic_generic_atomic_min), + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_min), NULL); add_function("__intrinsic_atomic_max", @@ -1068,7 +1391,10 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_max), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_intrinsic2(INTEL_shader_atomic_float_minmax_supported, + glsl_type::float_type, + ir_intrinsic_generic_atomic_max), + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_max), NULL); add_function("__intrinsic_atomic_and", @@ -1078,7 +1404,7 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_and), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_and), NULL); add_function("__intrinsic_atomic_or", @@ -1088,7 +1414,7 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_or), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_or), NULL); add_function("__intrinsic_atomic_xor", @@ -1098,7 +1424,7 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_xor), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_xor), NULL); add_function("__intrinsic_atomic_exchange", @@ -1108,7 +1434,10 @@ builtin_builder::create_intrinsics() _atomic_intrinsic2(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_exchange), - _atomic_counter_intrinsic1(shader_atomic_counter_ops, + _atomic_intrinsic2(NV_shader_atomic_float_supported, + glsl_type::float_type, + ir_intrinsic_generic_atomic_exchange), + _atomic_counter_intrinsic1(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_exchange), NULL); add_function("__intrinsic_atomic_comp_swap", @@ -1118,7 +1447,10 @@ builtin_builder::create_intrinsics() _atomic_intrinsic3(buffer_atomics_supported, glsl_type::int_type, ir_intrinsic_generic_atomic_comp_swap), - _atomic_counter_intrinsic2(shader_atomic_counter_ops, + _atomic_intrinsic3(INTEL_shader_atomic_float_minmax_supported, + glsl_type::float_type, + ir_intrinsic_generic_atomic_comp_swap), + _atomic_counter_intrinsic2(shader_atomic_counter_ops_or_v460_desktop, ir_intrinsic_atomic_counter_comp_swap), NULL); @@ -1133,15 +1465,15 @@ builtin_builder::create_intrinsics() ir_intrinsic_group_memory_barrier), NULL); add_function("__intrinsic_memory_barrier_atomic_counter", - _memory_barrier_intrinsic(compute_shader, + _memory_barrier_intrinsic(compute_shader_supported, ir_intrinsic_memory_barrier_atomic_counter), NULL); add_function("__intrinsic_memory_barrier_buffer", - _memory_barrier_intrinsic(compute_shader, + _memory_barrier_intrinsic(compute_shader_supported, ir_intrinsic_memory_barrier_buffer), NULL); add_function("__intrinsic_memory_barrier_image", - _memory_barrier_intrinsic(compute_shader, + _memory_barrier_intrinsic(compute_shader_supported, ir_intrinsic_memory_barrier_image), NULL); add_function("__intrinsic_memory_barrier_shared", @@ -1149,10 +1481,69 @@ builtin_builder::create_intrinsics() ir_intrinsic_memory_barrier_shared), NULL); + add_function("__intrinsic_begin_invocation_interlock", + _invocation_interlock_intrinsic( + supports_arb_fragment_shader_interlock, + ir_intrinsic_begin_invocation_interlock), NULL); + + add_function("__intrinsic_end_invocation_interlock", + _invocation_interlock_intrinsic( + supports_arb_fragment_shader_interlock, + ir_intrinsic_end_invocation_interlock), NULL); + add_function("__intrinsic_shader_clock", _shader_clock_intrinsic(shader_clock, glsl_type::uvec2_type), NULL); + + add_function("__intrinsic_vote_all", + _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_all), + NULL); + add_function("__intrinsic_vote_any", + _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_any), + NULL); + add_function("__intrinsic_vote_eq", + _vote_intrinsic(vote_or_v460_desktop, ir_intrinsic_vote_eq), + NULL); + + add_function("__intrinsic_ballot", _ballot_intrinsic(), NULL); + + add_function("__intrinsic_read_invocation", + _read_invocation_intrinsic(glsl_type::float_type), + _read_invocation_intrinsic(glsl_type::vec2_type), + _read_invocation_intrinsic(glsl_type::vec3_type), + _read_invocation_intrinsic(glsl_type::vec4_type), + + _read_invocation_intrinsic(glsl_type::int_type), + _read_invocation_intrinsic(glsl_type::ivec2_type), + _read_invocation_intrinsic(glsl_type::ivec3_type), + _read_invocation_intrinsic(glsl_type::ivec4_type), + + _read_invocation_intrinsic(glsl_type::uint_type), + _read_invocation_intrinsic(glsl_type::uvec2_type), + _read_invocation_intrinsic(glsl_type::uvec3_type), + _read_invocation_intrinsic(glsl_type::uvec4_type), + NULL); + + add_function("__intrinsic_read_first_invocation", + _read_first_invocation_intrinsic(glsl_type::float_type), + _read_first_invocation_intrinsic(glsl_type::vec2_type), + _read_first_invocation_intrinsic(glsl_type::vec3_type), + _read_first_invocation_intrinsic(glsl_type::vec4_type), + + _read_first_invocation_intrinsic(glsl_type::int_type), + _read_first_invocation_intrinsic(glsl_type::ivec2_type), + _read_first_invocation_intrinsic(glsl_type::ivec3_type), + _read_first_invocation_intrinsic(glsl_type::ivec4_type), + + _read_first_invocation_intrinsic(glsl_type::uint_type), + _read_first_invocation_intrinsic(glsl_type::uvec2_type), + _read_first_invocation_intrinsic(glsl_type::uvec3_type), + _read_first_invocation_intrinsic(glsl_type::uvec4_type), + NULL); + + add_function("__intrinsic_helper_invocation", + _helper_invocation_intrinsic(), NULL); } /** @@ -1249,9 +1640,9 @@ builtin_builder::create_builtins() _##NAME(always_available, glsl_type::ivec3_type), \ _##NAME(always_available, glsl_type::ivec4_type), \ \ - _##NAME(v130, glsl_type::uvec2_type), \ - _##NAME(v130, glsl_type::uvec3_type), \ - _##NAME(v130, glsl_type::uvec4_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \ _##NAME(fp64, glsl_type::dvec2_type), \ _##NAME(fp64, glsl_type::dvec3_type), \ _##NAME(fp64, glsl_type::dvec4_type), \ @@ -1288,9 +1679,9 @@ builtin_builder::create_builtins() _##NAME(always_available, glsl_type::ivec3_type), \ _##NAME(always_available, glsl_type::ivec4_type), \ \ - _##NAME(v130, glsl_type::uvec2_type), \ - _##NAME(v130, glsl_type::uvec3_type), \ - _##NAME(v130, glsl_type::uvec4_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type), \ \ _##NAME(always_available, glsl_type::bvec2_type), \ _##NAME(always_available, glsl_type::bvec3_type), \ @@ -1329,14 +1720,14 @@ builtin_builder::create_builtins() _##NAME(always_available, glsl_type::ivec3_type, glsl_type::ivec3_type), \ _##NAME(always_available, glsl_type::ivec4_type, glsl_type::ivec4_type), \ \ - _##NAME(v130, glsl_type::uint_type, glsl_type::uint_type), \ - _##NAME(v130, glsl_type::uvec2_type, glsl_type::uint_type), \ - _##NAME(v130, glsl_type::uvec3_type, glsl_type::uint_type), \ - _##NAME(v130, glsl_type::uvec4_type, glsl_type::uint_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uint_type, glsl_type::uint_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uint_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uint_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uint_type), \ \ - _##NAME(v130, glsl_type::uvec2_type, glsl_type::uvec2_type), \ - _##NAME(v130, glsl_type::uvec3_type, glsl_type::uvec3_type), \ - _##NAME(v130, glsl_type::uvec4_type, glsl_type::uvec4_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec2_type, glsl_type::uvec2_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec3_type, glsl_type::uvec3_type), \ + _##NAME(v130_or_gpu_shader4, glsl_type::uvec4_type, glsl_type::uvec4_type), \ \ _##NAME(fp64, glsl_type::double_type, glsl_type::double_type), \ _##NAME(fp64, glsl_type::dvec2_type, glsl_type::double_type), \ @@ -1379,6 +1770,14 @@ builtin_builder::create_builtins() _atan2(glsl_type::vec2_type), _atan2(glsl_type::vec3_type), _atan2(glsl_type::vec4_type), + _atan_op(glsl_type::float_type), + _atan_op(glsl_type::vec2_type), + _atan_op(glsl_type::vec3_type), + _atan_op(glsl_type::vec4_type), + _atan2_op(glsl_type::float_type), + _atan2_op(glsl_type::vec2_type), + _atan2_op(glsl_type::vec3_type), + _atan2_op(glsl_type::vec4_type), NULL); F(sinh) @@ -1403,6 +1802,14 @@ builtin_builder::create_builtins() FD(ceil) FD(fract) + add_function("truncate", + _truncate(gpu_shader4, glsl_type::float_type), + _truncate(gpu_shader4, glsl_type::vec2_type), + _truncate(gpu_shader4, glsl_type::vec3_type), + _truncate(gpu_shader4, glsl_type::vec4_type), + NULL); + + add_function("mod", _mod(always_available, glsl_type::float_type, glsl_type::float_type), _mod(always_available, glsl_type::vec2_type, glsl_type::float_type), @@ -1752,16 +2159,66 @@ builtin_builder::create_builtins() _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::sampler2DMSArray_type), _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::isampler2DMSArray_type), _textureSize(texture_multisample_array, glsl_type::ivec3_type, glsl_type::usampler2DMSArray_type), + + _textureSize(texture_external_es3, glsl_type::ivec2_type, glsl_type::samplerExternalOES_type), + NULL); + + add_function("textureSize1D", + _textureSize(gpu_shader4, glsl_type::int_type, glsl_type::sampler1D_type), + _textureSize(gpu_shader4_integer, glsl_type::int_type, glsl_type::isampler1D_type), + _textureSize(gpu_shader4_integer, glsl_type::int_type, glsl_type::usampler1D_type), + NULL); + + add_function("textureSize2D", + _textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::sampler2D_type), + _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isampler2D_type), + _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usampler2D_type), + NULL); + + add_function("textureSize3D", + _textureSize(gpu_shader4, glsl_type::ivec3_type, glsl_type::sampler3D_type), + _textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::isampler3D_type), + _textureSize(gpu_shader4_integer, glsl_type::ivec3_type, glsl_type::usampler3D_type), + NULL); + + add_function("textureSizeCube", + _textureSize(gpu_shader4, glsl_type::ivec2_type, glsl_type::samplerCube_type), + _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::isamplerCube_type), + _textureSize(gpu_shader4_integer, glsl_type::ivec2_type, glsl_type::usamplerCube_type), + NULL); + + add_function("textureSize1DArray", + _textureSize(gpu_shader4_array, glsl_type::ivec2_type, glsl_type::sampler1DArray_type), + _textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::isampler1DArray_type), + _textureSize(gpu_shader4_array_integer, glsl_type::ivec2_type, glsl_type::usampler1DArray_type), + NULL); + + add_function("textureSize2DArray", + _textureSize(gpu_shader4_array, glsl_type::ivec3_type, glsl_type::sampler2DArray_type), + _textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::isampler2DArray_type), + _textureSize(gpu_shader4_array_integer, glsl_type::ivec3_type, glsl_type::usampler2DArray_type), + NULL); + + add_function("textureSize2DRect", + _textureSize(gpu_shader4_rect, glsl_type::ivec2_type, glsl_type::sampler2DRect_type), + _textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::isampler2DRect_type), + _textureSize(gpu_shader4_rect_integer, glsl_type::ivec2_type, glsl_type::usampler2DRect_type), + NULL); + + add_function("textureSizeBuffer", + _textureSize(gpu_shader4_tbo, glsl_type::int_type, glsl_type::samplerBuffer_type), + _textureSize(gpu_shader4_tbo_integer, glsl_type::int_type, glsl_type::isamplerBuffer_type), + _textureSize(gpu_shader4_tbo_integer, glsl_type::int_type, glsl_type::usamplerBuffer_type), NULL); add_function("textureSamples", - _textureSamples(glsl_type::sampler2DMS_type), - _textureSamples(glsl_type::isampler2DMS_type), - _textureSamples(glsl_type::usampler2DMS_type), + _textureSamples(shader_samples, glsl_type::sampler2DMS_type), + _textureSamples(shader_samples, glsl_type::isampler2DMS_type), + _textureSamples(shader_samples, glsl_type::usampler2DMS_type), - _textureSamples(glsl_type::sampler2DMSArray_type), - _textureSamples(glsl_type::isampler2DMSArray_type), - _textureSamples(glsl_type::usampler2DMSArray_type), + _textureSamples(shader_samples, glsl_type::sampler2DMSArray_type), + _textureSamples(shader_samples, glsl_type::isampler2DMSArray_type), + _textureSamples(shader_samples, glsl_type::usampler2DMSArray_type), NULL); add_function("texture", @@ -1802,7 +2259,7 @@ builtin_builder::create_builtins() /* samplerCubeArrayShadow is special; it has an extra parameter * for the shadow comparator since there is no vec5 type. */ - _textureCubeArrayShadow(), + _textureCubeArrayShadow(ir_tex, texture_cube_map_array, glsl_type::samplerCubeArrayShadow_type), _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type), _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type), @@ -1810,39 +2267,46 @@ builtin_builder::create_builtins() _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type), + _texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type), - _texture(ir_txb, fs_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type), - _texture(ir_txb, fs_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type), - _texture(ir_txb, fs_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), + _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type), + _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type), + _texture(ir_txb, derivatives_texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type), + + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), + _texture(ir_tex, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + _texture(ir_txb, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + + _textureCubeArrayShadow(ir_tex, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type), + _textureCubeArrayShadow(ir_txb, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type), NULL); add_function("textureLod", @@ -1878,6 +2342,9 @@ builtin_builder::create_builtins() _texture(ir_txl, texture_cube_map_array, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type), _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), + _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + _texture(ir_txl, v130_or_gpu_shader4_and_tex_shadow_lod, glsl_type::float_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type), + _textureCubeArrayShadow(ir_txl, v130_or_gpu_shader4_and_tex_cube_map_array, glsl_type::samplerCubeArrayShadow_type), NULL); add_function("textureOffset", @@ -1919,30 +2386,106 @@ builtin_builder::create_builtins() */ _texture(ir_tex, v130_desktop, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), + _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), + _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), + NULL); + + add_function("texture1DOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET), + NULL); + + add_function("texture2DOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + add_function("texture3DOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + add_function("texture2DRectOffset", + _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + add_function("shadow2DRectOffset", + _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + add_function("shadow1DOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + add_function("shadow2DOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), + add_function("texture1DArrayOffset", + _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); + + add_function("texture2DArrayOffset", + _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow1DArrayOffset", + _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txb, gpu_shader4_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow2DArrayOffset", + _texture(ir_tex, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET), NULL); add_function("textureProj", @@ -1969,6 +2512,9 @@ builtin_builder::create_builtins() _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, v130, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), @@ -1976,26 +2522,26 @@ builtin_builder::create_builtins() _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("texelFetch", @@ -2034,6 +2580,51 @@ builtin_builder::create_builtins() _texelFetch(texture_multisample_array, glsl_type::vec4_type, glsl_type::sampler2DMSArray_type, glsl_type::ivec3_type), _texelFetch(texture_multisample_array, glsl_type::ivec4_type, glsl_type::isampler2DMSArray_type, glsl_type::ivec3_type), _texelFetch(texture_multisample_array, glsl_type::uvec4_type, glsl_type::usampler2DMSArray_type, glsl_type::ivec3_type), + + _texelFetch(texture_external_es3, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::ivec2_type), + + NULL); + + add_function("texelFetch1D", + _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type), + _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type), + _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type), + NULL); + + add_function("texelFetch2D", + _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type), + NULL); + + add_function("texelFetch3D", + _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type), + _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type), + _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type), + NULL); + + add_function("texelFetch2DRect", + _texelFetch(gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type), + NULL); + + add_function("texelFetch1DArray", + _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type), + NULL); + + add_function("texelFetch2DArray", + _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type), + NULL); + + add_function("texelFetchBuffer", + _texelFetch(gpu_shader4_tbo, glsl_type::vec4_type, glsl_type::samplerBuffer_type, glsl_type::int_type), + _texelFetch(gpu_shader4_tbo_integer, glsl_type::ivec4_type, glsl_type::isamplerBuffer_type, glsl_type::int_type), + _texelFetch(gpu_shader4_tbo_integer, glsl_type::uvec4_type, glsl_type::usamplerBuffer_type, glsl_type::int_type), NULL); add_function("texelFetchOffset", @@ -2063,6 +2654,42 @@ builtin_builder::create_builtins() NULL); + add_function("texelFetch1DOffset", + _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::int_type, glsl_type::int_type), + _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::int_type, glsl_type::int_type), + _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::int_type, glsl_type::int_type), + NULL); + + add_function("texelFetch2DOffset", + _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + NULL); + + add_function("texelFetch3DOffset", + _texelFetch(gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type), + _texelFetch(gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type), + _texelFetch(gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::ivec3_type, glsl_type::ivec3_type), + NULL); + + add_function("texelFetch2DRectOffset", + _texelFetch(gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + NULL); + + add_function("texelFetch1DArrayOffset", + _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::ivec2_type, glsl_type::int_type), + NULL); + + add_function("texelFetch2DArrayOffset", + _texelFetch(gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type), + _texelFetch(gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::ivec3_type, glsl_type::ivec2_type), + NULL); + add_function("textureProjOffset", _texture(ir_tex, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), _texture(ir_tex, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), @@ -2094,26 +2721,88 @@ builtin_builder::create_builtins() _texture(ir_tex, v130, glsl_type::float_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - - _texture(ir_txb, v130_fs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), - _texture(ir_txb, v130_fs_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, v130_derivatives_only, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture1DProjOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture2DProjOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture3DProjOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow1DProjOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow2DProjOffset", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture2DRectProjOffset", + _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow2DRectProjOffset", + _texture(ir_tex, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), NULL); add_function("textureLodOffset", @@ -2141,6 +2830,49 @@ builtin_builder::create_builtins() _texture(ir_txl, v130, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), + _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), + NULL); + + add_function("texture1DLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET), + NULL); + + add_function("texture2DLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); + + add_function("texture3DLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow1DLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow2DLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("texture1DArrayLodOffset", + _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); + + add_function("texture2DArrayLodOffset", + _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow1DArrayLodOffset", + _texture(ir_txl, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), NULL); add_function("textureProjLod", @@ -2189,6 +2921,38 @@ builtin_builder::create_builtins() _texture(ir_txl, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), NULL); + add_function("texture1DProjLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture2DProjLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture3DProjLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow1DProjLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow2DProjLodOffset", + _texture(ir_txl, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + add_function("textureGrad", _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), @@ -2266,6 +3030,62 @@ builtin_builder::create_builtins() _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET), NULL); + add_function("texture1DGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type, TEX_OFFSET), + NULL); + + add_function("texture2DGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); + + add_function("texture3DGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("texture2DRectGradOffset", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); + + add_function("shadow2DRectGradOffset", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow1DGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow2DGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("texture1DArrayGradOffset", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type, TEX_OFFSET), + NULL); + + add_function("texture2DArrayGradOffset", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow1DArrayGradOffset", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + + add_function("shadow2DArrayGradOffset", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type, TEX_OFFSET), + NULL); + add_function("textureProjGrad", _texture(ir_txd, v130, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), _texture(ir_txd, v130, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), @@ -2330,6 +3150,51 @@ builtin_builder::create_builtins() _texture(ir_txd, v130, glsl_type::float_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), NULL); + add_function("texture1DProjGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture2DProjGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture3DProjGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("texture2DRectProjGradOffset", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow2DRectProjGradOffset", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow1DProjGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + + add_function("shadow2DProjGradOffset", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT | TEX_OFFSET), + NULL); + add_function("EmitVertex", _EmitVertex(), NULL); add_function("EndPrimitive", _EndPrimitive(), NULL); add_function("EmitStreamVertex", @@ -2380,72 +3245,72 @@ builtin_builder::create_builtins() NULL); add_function("textureQueryLod", - _textureQueryLod(v400_fs_only, glsl_type::sampler1D_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::isampler1D_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::usampler1D_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler1D_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isampler1D_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usampler1D_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler2D_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::isampler2D_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::usampler2D_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler2D_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isampler2D_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usampler2D_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler3D_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::isampler3D_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::usampler3D_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler3D_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isampler3D_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usampler3D_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::samplerCube_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::isamplerCube_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::usamplerCube_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::samplerCube_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usamplerCube_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler1DArray_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::isampler1DArray_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::usampler1DArray_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArray_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isampler1DArray_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usampler1DArray_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler2DArray_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::isampler2DArray_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::usampler2DArray_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArray_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isampler2DArray_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usampler2DArray_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::samplerCubeArray_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArray_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::isamplerCubeArray_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::usamplerCubeArray_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler1DShadow_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler2DShadow_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type), - _textureQueryLod(v400_fs_only, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type), - _textureQueryLod(v400_fs_only, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DShadow_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DShadow_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler1DArrayShadow_type, glsl_type::float_type), + _textureQueryLod(v400_derivatives_only, glsl_type::sampler2DArrayShadow_type, glsl_type::vec2_type), + _textureQueryLod(v400_derivatives_only, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec3_type), NULL); add_function("textureQueryLevels", - _textureQueryLevels(glsl_type::sampler1D_type), - _textureQueryLevels(glsl_type::sampler2D_type), - _textureQueryLevels(glsl_type::sampler3D_type), - _textureQueryLevels(glsl_type::samplerCube_type), - _textureQueryLevels(glsl_type::sampler1DArray_type), - _textureQueryLevels(glsl_type::sampler2DArray_type), - _textureQueryLevels(glsl_type::samplerCubeArray_type), - _textureQueryLevels(glsl_type::sampler1DShadow_type), - _textureQueryLevels(glsl_type::sampler2DShadow_type), - _textureQueryLevels(glsl_type::samplerCubeShadow_type), - _textureQueryLevels(glsl_type::sampler1DArrayShadow_type), - _textureQueryLevels(glsl_type::sampler2DArrayShadow_type), - _textureQueryLevels(glsl_type::samplerCubeArrayShadow_type), - - _textureQueryLevels(glsl_type::isampler1D_type), - _textureQueryLevels(glsl_type::isampler2D_type), - _textureQueryLevels(glsl_type::isampler3D_type), - _textureQueryLevels(glsl_type::isamplerCube_type), - _textureQueryLevels(glsl_type::isampler1DArray_type), - _textureQueryLevels(glsl_type::isampler2DArray_type), - _textureQueryLevels(glsl_type::isamplerCubeArray_type), - - _textureQueryLevels(glsl_type::usampler1D_type), - _textureQueryLevels(glsl_type::usampler2D_type), - _textureQueryLevels(glsl_type::usampler3D_type), - _textureQueryLevels(glsl_type::usamplerCube_type), - _textureQueryLevels(glsl_type::usampler1DArray_type), - _textureQueryLevels(glsl_type::usampler2DArray_type), - _textureQueryLevels(glsl_type::usamplerCubeArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler1D_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler2D_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler3D_type), + _textureQueryLevels(texture_query_levels, glsl_type::samplerCube_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler1DArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler2DArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler1DShadow_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler2DShadow_type), + _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeShadow_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler1DArrayShadow_type), + _textureQueryLevels(texture_query_levels, glsl_type::sampler2DArrayShadow_type), + _textureQueryLevels(texture_query_levels, glsl_type::samplerCubeArrayShadow_type), + + _textureQueryLevels(texture_query_levels, glsl_type::isampler1D_type), + _textureQueryLevels(texture_query_levels, glsl_type::isampler2D_type), + _textureQueryLevels(texture_query_levels, glsl_type::isampler3D_type), + _textureQueryLevels(texture_query_levels, glsl_type::isamplerCube_type), + _textureQueryLevels(texture_query_levels, glsl_type::isampler1DArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::isampler2DArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::isamplerCubeArray_type), + + _textureQueryLevels(texture_query_levels, glsl_type::usampler1D_type), + _textureQueryLevels(texture_query_levels, glsl_type::usampler2D_type), + _textureQueryLevels(texture_query_levels, glsl_type::usampler3D_type), + _textureQueryLevels(texture_query_levels, glsl_type::usamplerCube_type), + _textureQueryLevels(texture_query_levels, glsl_type::usampler1DArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::usampler2DArray_type), + _textureQueryLevels(texture_query_levels, glsl_type::usamplerCubeArray_type), NULL); @@ -2460,132 +3325,214 @@ builtin_builder::create_builtins() NULL); add_function("texture1D", - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type), NULL); add_function("texture1DArray", - _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), - _texture(ir_txb, fs_texture_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), + _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txb, texture_array_derivs_only,glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type), NULL); add_function("texture1DProj", - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("texture1DLod", _texture(ir_txl, tex1d_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type), NULL); add_function("texture1DArrayLod", _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type), NULL); add_function("texture1DProjLod", _texture(ir_txl, tex1d_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), _texture(ir_txl, tex1d_lod, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("texture2D", - _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), - _texture(ir_txb, fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), - _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type), + _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), + _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec2_type), NULL); add_function("texture2DArray", - _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), - _texture(ir_txb, fs_texture_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), + _texture(ir_tex, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txb, gpu_shader4_array_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), NULL); add_function("texture2DProj", - _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), - _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), - _texture(ir_txb, fs_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT), - _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, texture_external, glsl_type::vec4_type, glsl_type::samplerExternalOES_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("texture2DLod", _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), NULL); add_function("texture2DArrayLod", _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txl, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), NULL); add_function("texture2DProjLod", _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("texture3D", - _texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), - _texture(ir_txb, fs_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), + _texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), + _texture(ir_txb, derivatives_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type), NULL); add_function("texture3DProj", - _texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, fs_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, derivatives_tex3d, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("texture3DLod", _texture(ir_txl, tex3d_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type), NULL); add_function("texture3DProjLod", _texture(ir_txl, tex3d_lod, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("textureCube", - _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), - _texture(ir_txb, fs_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_tex, always_available, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_txb, derivatives_only, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _texture(ir_tex, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), + _texture(ir_txb, gpu_shader4_integer_derivs_only, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), NULL); add_function("textureCubeLod", _texture(ir_txl, lod_exists_in_stage, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _texture(ir_txl, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), NULL); add_function("texture2DRect", _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type), NULL); add_function("texture2DRectProj", _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), _texture(ir_tex, texture_rectangle, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_tex, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("shadow1D", - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), NULL); add_function("shadow1DArray", _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), - _texture(ir_txb, fs_texture_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), + _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), NULL); add_function("shadow2D", - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), NULL); add_function("shadow2DArray", _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), - _texture(ir_txb, fs_texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), NULL); add_function("shadow1DProj", - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("shadow2DArray", + _texture(ir_tex, texture_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + _texture(ir_txb, texture_array_derivs_only, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + NULL); + + add_function("shadowCube", + _texture(ir_tex, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type), + _texture(ir_txb, gpu_shader4_derivs_only, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type), NULL); add_function("shadow2DProj", - _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), - _texture(ir_txb, v110_fs_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_tex, v110, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txb, v110_derivatives_only, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), NULL); add_function("shadow1DLod", @@ -2679,6 +3626,121 @@ builtin_builder::create_builtins() _texture(ir_txd, shader_texture_lod_and_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT), NULL); + add_function("texture4", + _texture(ir_tg4, texture_texture4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + NULL); + + add_function("texture1DGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::float_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::float_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::float_type), + NULL); + + add_function("texture1DProjGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec2_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler1D_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("texture1DArrayGrad", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler1DArray_type, glsl_type::vec2_type), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler1DArray_type, glsl_type::vec2_type), + NULL); + + add_function("texture2DGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), + NULL); + + add_function("texture2DProjGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("texture2DArrayGrad", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), + _texture(ir_txd, gpu_shader4_array_integer, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), + NULL); + + add_function("texture3DGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec3_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec3_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec3_type), + NULL); + + add_function("texture3DProjGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usampler3D_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("textureCubeGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _texture(ir_txd, gpu_shader4_integer, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), + NULL); + + add_function("shadow1DGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec3_type), + NULL); + + add_function("shadow1DProjGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler1DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("shadow1DArrayGrad", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type), + NULL); + + add_function("shadow2DGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec3_type), + NULL); + + add_function("shadow2DProjGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("shadow2DArrayGrad", + _texture(ir_txd, gpu_shader4_array, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec4_type), + NULL); + + add_function("texture2DRectGrad", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type), + NULL); + + add_function("texture2DRectProjGrad", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec3_type, TEX_PROJECT), + _texture(ir_txd, gpu_shader4_rect_integer, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("shadow2DRectGrad", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec3_type), + NULL); + + add_function("shadow2DRectProjGrad", + _texture(ir_txd, gpu_shader4_rect, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec4_type, TEX_PROJECT), + NULL); + + add_function("shadowCubeGrad", + _texture(ir_txd, gpu_shader4, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec4_type), + NULL); + add_function("textureGather", _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), @@ -2942,6 +4004,43 @@ builtin_builder::create_builtins() shader_atomic_counter_ops), NULL); + add_function("atomicCounterAdd", + _atomic_counter_op1("__intrinsic_atomic_add", + v460_desktop), + NULL); + add_function("atomicCounterSubtract", + _atomic_counter_op1("__intrinsic_atomic_sub", + v460_desktop), + NULL); + add_function("atomicCounterMin", + _atomic_counter_op1("__intrinsic_atomic_min", + v460_desktop), + NULL); + add_function("atomicCounterMax", + _atomic_counter_op1("__intrinsic_atomic_max", + v460_desktop), + NULL); + add_function("atomicCounterAnd", + _atomic_counter_op1("__intrinsic_atomic_and", + v460_desktop), + NULL); + add_function("atomicCounterOr", + _atomic_counter_op1("__intrinsic_atomic_or", + v460_desktop), + NULL); + add_function("atomicCounterXor", + _atomic_counter_op1("__intrinsic_atomic_xor", + v460_desktop), + NULL); + add_function("atomicCounterExchange", + _atomic_counter_op1("__intrinsic_atomic_exchange", + v460_desktop), + NULL); + add_function("atomicCounterCompSwap", + _atomic_counter_op2("__intrinsic_atomic_comp_swap", + v460_desktop), + NULL); + add_function("atomicAdd", _atomic_op2("__intrinsic_atomic_add", buffer_atomics_supported, @@ -2949,6 +4048,9 @@ builtin_builder::create_builtins() _atomic_op2("__intrinsic_atomic_add", buffer_atomics_supported, glsl_type::int_type), + _atomic_op2("__intrinsic_atomic_add", + shader_atomic_float_add, + glsl_type::float_type), NULL); add_function("atomicMin", _atomic_op2("__intrinsic_atomic_min", @@ -2957,6 +4059,9 @@ builtin_builder::create_builtins() _atomic_op2("__intrinsic_atomic_min", buffer_atomics_supported, glsl_type::int_type), + _atomic_op2("__intrinsic_atomic_min", + shader_atomic_float_minmax, + glsl_type::float_type), NULL); add_function("atomicMax", _atomic_op2("__intrinsic_atomic_max", @@ -2965,6 +4070,9 @@ builtin_builder::create_builtins() _atomic_op2("__intrinsic_atomic_max", buffer_atomics_supported, glsl_type::int_type), + _atomic_op2("__intrinsic_atomic_max", + shader_atomic_float_minmax, + glsl_type::float_type), NULL); add_function("atomicAnd", _atomic_op2("__intrinsic_atomic_and", @@ -2997,6 +4105,9 @@ builtin_builder::create_builtins() _atomic_op2("__intrinsic_atomic_exchange", buffer_atomics_supported, glsl_type::int_type), + _atomic_op2("__intrinsic_atomic_exchange", + shader_atomic_float_exchange, + glsl_type::float_type), NULL); add_function("atomicCompSwap", _atomic_op3("__intrinsic_atomic_comp_swap", @@ -3005,6 +4116,9 @@ builtin_builder::create_builtins() _atomic_op3("__intrinsic_atomic_comp_swap", buffer_atomics_supported, glsl_type::int_type), + _atomic_op3("__intrinsic_atomic_comp_swap", + shader_atomic_float_minmax, + glsl_type::float_type), NULL); add_function("min3", @@ -3058,46 +4172,140 @@ builtin_builder::create_builtins() _mid3(glsl_type::uvec4_type), NULL); - add_image_functions(true); + add_image_functions(true); + + add_function("memoryBarrier", + _memory_barrier("__intrinsic_memory_barrier", + shader_image_load_store), + NULL); + add_function("groupMemoryBarrier", + _memory_barrier("__intrinsic_group_memory_barrier", + compute_shader), + NULL); + add_function("memoryBarrierAtomicCounter", + _memory_barrier("__intrinsic_memory_barrier_atomic_counter", + compute_shader_supported), + NULL); + add_function("memoryBarrierBuffer", + _memory_barrier("__intrinsic_memory_barrier_buffer", + compute_shader_supported), + NULL); + add_function("memoryBarrierImage", + _memory_barrier("__intrinsic_memory_barrier_image", + compute_shader_supported), + NULL); + add_function("memoryBarrierShared", + _memory_barrier("__intrinsic_memory_barrier_shared", + compute_shader), + NULL); + + add_function("ballotARB", _ballot(), NULL); + + add_function("readInvocationARB", + _read_invocation(glsl_type::float_type), + _read_invocation(glsl_type::vec2_type), + _read_invocation(glsl_type::vec3_type), + _read_invocation(glsl_type::vec4_type), + + _read_invocation(glsl_type::int_type), + _read_invocation(glsl_type::ivec2_type), + _read_invocation(glsl_type::ivec3_type), + _read_invocation(glsl_type::ivec4_type), + + _read_invocation(glsl_type::uint_type), + _read_invocation(glsl_type::uvec2_type), + _read_invocation(glsl_type::uvec3_type), + _read_invocation(glsl_type::uvec4_type), + NULL); + + add_function("readFirstInvocationARB", + _read_first_invocation(glsl_type::float_type), + _read_first_invocation(glsl_type::vec2_type), + _read_first_invocation(glsl_type::vec3_type), + _read_first_invocation(glsl_type::vec4_type), + + _read_first_invocation(glsl_type::int_type), + _read_first_invocation(glsl_type::ivec2_type), + _read_first_invocation(glsl_type::ivec3_type), + _read_first_invocation(glsl_type::ivec4_type), + + _read_first_invocation(glsl_type::uint_type), + _read_first_invocation(glsl_type::uvec2_type), + _read_first_invocation(glsl_type::uvec3_type), + _read_first_invocation(glsl_type::uvec4_type), + NULL); + + add_function("clock2x32ARB", + _shader_clock(shader_clock, + glsl_type::uvec2_type), + NULL); + + add_function("clockARB", + _shader_clock(shader_clock_int64, + glsl_type::uint64_t_type), + NULL); + + add_function("beginInvocationInterlockARB", + _invocation_interlock( + "__intrinsic_begin_invocation_interlock", + supports_arb_fragment_shader_interlock), + NULL); + + add_function("endInvocationInterlockARB", + _invocation_interlock( + "__intrinsic_end_invocation_interlock", + supports_arb_fragment_shader_interlock), + NULL); + + add_function("beginInvocationInterlockNV", + _invocation_interlock( + "__intrinsic_begin_invocation_interlock", + supports_nv_fragment_shader_interlock), + NULL); + + add_function("endInvocationInterlockNV", + _invocation_interlock( + "__intrinsic_end_invocation_interlock", + supports_nv_fragment_shader_interlock), + NULL); - add_function("memoryBarrier", - _memory_barrier("__intrinsic_memory_barrier", - shader_image_load_store), + add_function("anyInvocationARB", + _vote("__intrinsic_vote_any", vote), NULL); - add_function("groupMemoryBarrier", - _memory_barrier("__intrinsic_group_memory_barrier", - compute_shader), + + add_function("allInvocationsARB", + _vote("__intrinsic_vote_all", vote), NULL); - add_function("memoryBarrierAtomicCounter", - _memory_barrier("__intrinsic_memory_barrier_atomic_counter", - compute_shader), + + add_function("allInvocationsEqualARB", + _vote("__intrinsic_vote_eq", vote), NULL); - add_function("memoryBarrierBuffer", - _memory_barrier("__intrinsic_memory_barrier_buffer", - compute_shader), + + add_function("anyInvocationEXT", + _vote("__intrinsic_vote_any", vote_ext), NULL); - add_function("memoryBarrierImage", - _memory_barrier("__intrinsic_memory_barrier_image", - compute_shader), + + add_function("allInvocationsEXT", + _vote("__intrinsic_vote_all", vote_ext), NULL); - add_function("memoryBarrierShared", - _memory_barrier("__intrinsic_memory_barrier_shared", - compute_shader), + + add_function("allInvocationsEqualEXT", + _vote("__intrinsic_vote_eq", vote_ext), NULL); - add_function("clock2x32ARB", - _shader_clock(shader_clock, - glsl_type::uvec2_type), + add_function("anyInvocation", + _vote("__intrinsic_vote_any", v460_desktop), NULL); - add_function("clockARB", - _shader_clock(shader_clock_int64, - glsl_type::uint64_t_type), + add_function("allInvocations", + _vote("__intrinsic_vote_all", v460_desktop), NULL); - add_function("anyInvocationARB", _vote(ir_unop_vote_any), NULL); - add_function("allInvocationsARB", _vote(ir_unop_vote_all), NULL); - add_function("allInvocationsEqualARB", _vote(ir_unop_vote_eq), NULL); + add_function("allInvocationsEqual", + _vote("__intrinsic_vote_eq", v460_desktop), + NULL); + + add_function("helperInvocationEXT", _helper_invocation(), NULL); add_function("__builtin_idiv64", generate_ir::idiv64(mem_ctx, integer_functions_supported), @@ -3123,6 +4331,227 @@ builtin_builder::create_builtins() generate_ir::umul64(mem_ctx, integer_functions_supported), NULL); + add_function("countLeadingZeros", + _countLeadingZeros(shader_integer_functions2, + glsl_type::uint_type), + _countLeadingZeros(shader_integer_functions2, + glsl_type::uvec2_type), + _countLeadingZeros(shader_integer_functions2, + glsl_type::uvec3_type), + _countLeadingZeros(shader_integer_functions2, + glsl_type::uvec4_type), + NULL); + + add_function("countTrailingZeros", + _countTrailingZeros(shader_integer_functions2, + glsl_type::uint_type), + _countTrailingZeros(shader_integer_functions2, + glsl_type::uvec2_type), + _countTrailingZeros(shader_integer_functions2, + glsl_type::uvec3_type), + _countTrailingZeros(shader_integer_functions2, + glsl_type::uvec4_type), + NULL); + + add_function("absoluteDifference", + _absoluteDifference(shader_integer_functions2, + glsl_type::int_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::ivec2_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::ivec3_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::ivec4_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::uint_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::uvec2_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::uvec3_type), + _absoluteDifference(shader_integer_functions2, + glsl_type::uvec4_type), + + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::int64_t_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::i64vec2_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::i64vec3_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::i64vec4_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::uint64_t_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::u64vec2_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::u64vec3_type), + _absoluteDifference(shader_integer_functions2_int64, + glsl_type::u64vec4_type), + NULL); + + add_function("addSaturate", + _addSaturate(shader_integer_functions2, + glsl_type::int_type), + _addSaturate(shader_integer_functions2, + glsl_type::ivec2_type), + _addSaturate(shader_integer_functions2, + glsl_type::ivec3_type), + _addSaturate(shader_integer_functions2, + glsl_type::ivec4_type), + _addSaturate(shader_integer_functions2, + glsl_type::uint_type), + _addSaturate(shader_integer_functions2, + glsl_type::uvec2_type), + _addSaturate(shader_integer_functions2, + glsl_type::uvec3_type), + _addSaturate(shader_integer_functions2, + glsl_type::uvec4_type), + + _addSaturate(shader_integer_functions2_int64, + glsl_type::int64_t_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::i64vec2_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::i64vec3_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::i64vec4_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::uint64_t_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::u64vec2_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::u64vec3_type), + _addSaturate(shader_integer_functions2_int64, + glsl_type::u64vec4_type), + NULL); + + add_function("average", + _average(shader_integer_functions2, + glsl_type::int_type), + _average(shader_integer_functions2, + glsl_type::ivec2_type), + _average(shader_integer_functions2, + glsl_type::ivec3_type), + _average(shader_integer_functions2, + glsl_type::ivec4_type), + _average(shader_integer_functions2, + glsl_type::uint_type), + _average(shader_integer_functions2, + glsl_type::uvec2_type), + _average(shader_integer_functions2, + glsl_type::uvec3_type), + _average(shader_integer_functions2, + glsl_type::uvec4_type), + + _average(shader_integer_functions2_int64, + glsl_type::int64_t_type), + _average(shader_integer_functions2_int64, + glsl_type::i64vec2_type), + _average(shader_integer_functions2_int64, + glsl_type::i64vec3_type), + _average(shader_integer_functions2_int64, + glsl_type::i64vec4_type), + _average(shader_integer_functions2_int64, + glsl_type::uint64_t_type), + _average(shader_integer_functions2_int64, + glsl_type::u64vec2_type), + _average(shader_integer_functions2_int64, + glsl_type::u64vec3_type), + _average(shader_integer_functions2_int64, + glsl_type::u64vec4_type), + NULL); + + add_function("averageRounded", + _averageRounded(shader_integer_functions2, + glsl_type::int_type), + _averageRounded(shader_integer_functions2, + glsl_type::ivec2_type), + _averageRounded(shader_integer_functions2, + glsl_type::ivec3_type), + _averageRounded(shader_integer_functions2, + glsl_type::ivec4_type), + _averageRounded(shader_integer_functions2, + glsl_type::uint_type), + _averageRounded(shader_integer_functions2, + glsl_type::uvec2_type), + _averageRounded(shader_integer_functions2, + glsl_type::uvec3_type), + _averageRounded(shader_integer_functions2, + glsl_type::uvec4_type), + + _averageRounded(shader_integer_functions2_int64, + glsl_type::int64_t_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::i64vec2_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::i64vec3_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::i64vec4_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::uint64_t_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::u64vec2_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::u64vec3_type), + _averageRounded(shader_integer_functions2_int64, + glsl_type::u64vec4_type), + NULL); + + add_function("subtractSaturate", + _subtractSaturate(shader_integer_functions2, + glsl_type::int_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::ivec2_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::ivec3_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::ivec4_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::uint_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::uvec2_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::uvec3_type), + _subtractSaturate(shader_integer_functions2, + glsl_type::uvec4_type), + + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::int64_t_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::i64vec2_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::i64vec3_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::i64vec4_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::uint64_t_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::u64vec2_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::u64vec3_type), + _subtractSaturate(shader_integer_functions2_int64, + glsl_type::u64vec4_type), + NULL); + + add_function("multiply32x16", + _multiply32x16(shader_integer_functions2, + glsl_type::int_type), + _multiply32x16(shader_integer_functions2, + glsl_type::ivec2_type), + _multiply32x16(shader_integer_functions2, + glsl_type::ivec3_type), + _multiply32x16(shader_integer_functions2, + glsl_type::ivec4_type), + _multiply32x16(shader_integer_functions2, + glsl_type::uint_type), + _multiply32x16(shader_integer_functions2, + glsl_type::uvec2_type), + _multiply32x16(shader_integer_functions2, + glsl_type::uvec3_type), + _multiply32x16(shader_integer_functions2, + glsl_type::uvec4_type), + NULL); + #undef F #undef FI #undef FIUD_VEC @@ -3203,14 +4632,15 @@ builtin_builder::add_image_function(const char *name, ir_function *f = new(mem_ctx) ir_function(name); for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) { - if ((types[i]->sampled_type != GLSL_TYPE_FLOAT || - (flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) && - (types[i]->sampler_dimensionality == GLSL_SAMPLER_DIM_MS || - !(flags & IMAGE_FUNCTION_MS_ONLY))) - f->add_signature(_image(prototype, types[i], intrinsic_name, - num_arguments, flags, intrinsic_id)); + if (types[i]->sampled_type == GLSL_TYPE_FLOAT && !(flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) + continue; + if (types[i]->sampled_type == GLSL_TYPE_INT && !(flags & IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE)) + continue; + if ((types[i]->sampler_dimensionality != GLSL_SAMPLER_DIM_MS) && (flags & IMAGE_FUNCTION_MS_ONLY)) + continue; + f->add_signature(_image(prototype, types[i], intrinsic_name, + num_arguments, flags, intrinsic_id)); } - shader->symbols->add_function(f); } @@ -3224,6 +4654,7 @@ builtin_builder::add_image_functions(bool glsl) &builtin_builder::_image_prototype, 0, (flags | IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE | + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE | IMAGE_FUNCTION_READ_ONLY), ir_intrinsic_image_load); @@ -3233,6 +4664,7 @@ builtin_builder::add_image_functions(bool glsl) (flags | IMAGE_FUNCTION_RETURNS_VOID | IMAGE_FUNCTION_HAS_VECTOR_DATA_TYPE | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE | + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE | IMAGE_FUNCTION_WRITE_ONLY), ir_intrinsic_image_store); @@ -3240,32 +4672,40 @@ builtin_builder::add_image_functions(bool glsl) add_image_function(glsl ? "imageAtomicAdd" : "__intrinsic_image_atomic_add", "__intrinsic_image_atomic_add", - &builtin_builder::_image_prototype, 1, atom_flags, + &builtin_builder::_image_prototype, 1, + (flags | IMAGE_FUNCTION_AVAIL_ATOMIC_ADD | + IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE | + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE), ir_intrinsic_image_atomic_add); add_image_function(glsl ? "imageAtomicMin" : "__intrinsic_image_atomic_min", "__intrinsic_image_atomic_min", - &builtin_builder::_image_prototype, 1, atom_flags, + &builtin_builder::_image_prototype, 1, + atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_atomic_min); add_image_function(glsl ? "imageAtomicMax" : "__intrinsic_image_atomic_max", "__intrinsic_image_atomic_max", - &builtin_builder::_image_prototype, 1, atom_flags, + &builtin_builder::_image_prototype, 1, + atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_atomic_max); add_image_function(glsl ? "imageAtomicAnd" : "__intrinsic_image_atomic_and", "__intrinsic_image_atomic_and", - &builtin_builder::_image_prototype, 1, atom_flags, + &builtin_builder::_image_prototype, 1, + atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_atomic_and); add_image_function(glsl ? "imageAtomicOr" : "__intrinsic_image_atomic_or", "__intrinsic_image_atomic_or", - &builtin_builder::_image_prototype, 1, atom_flags, + &builtin_builder::_image_prototype, 1, + atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_atomic_or); add_image_function(glsl ? "imageAtomicXor" : "__intrinsic_image_atomic_xor", "__intrinsic_image_atomic_xor", - &builtin_builder::_image_prototype, 1, atom_flags, + &builtin_builder::_image_prototype, 1, + atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_atomic_xor); add_image_function((glsl ? "imageAtomicExchange" : @@ -3273,27 +4713,43 @@ builtin_builder::add_image_functions(bool glsl) "__intrinsic_image_atomic_exchange", &builtin_builder::_image_prototype, 1, (flags | IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE | + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE), ir_intrinsic_image_atomic_exchange); add_image_function((glsl ? "imageAtomicCompSwap" : "__intrinsic_image_atomic_comp_swap"), "__intrinsic_image_atomic_comp_swap", - &builtin_builder::_image_prototype, 2, atom_flags, + &builtin_builder::_image_prototype, 2, + atom_flags | IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_atomic_comp_swap); add_image_function(glsl ? "imageSize" : "__intrinsic_image_size", "__intrinsic_image_size", &builtin_builder::_image_size_prototype, 1, - flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE, + flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE | + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE, ir_intrinsic_image_size); add_image_function(glsl ? "imageSamples" : "__intrinsic_image_samples", "__intrinsic_image_samples", &builtin_builder::_image_samples_prototype, 1, flags | IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE | + IMAGE_FUNCTION_SUPPORTS_SIGNED_DATA_TYPE | IMAGE_FUNCTION_MS_ONLY, ir_intrinsic_image_samples); + + /* EXT_shader_image_load_store */ + add_image_function(glsl ? "imageAtomicIncWrap" : "__intrinsic_image_atomic_inc_wrap", + "__intrinsic_image_atomic_inc_wrap", + &builtin_builder::_image_prototype, 1, + (atom_flags | IMAGE_FUNCTION_EXT_ONLY), + ir_intrinsic_image_atomic_inc_wrap); + add_image_function(glsl ? "imageAtomicDecWrap" : "__intrinsic_image_atomic_dec_wrap", + "__intrinsic_image_atomic_dec_wrap", + &builtin_builder::_image_prototype, 1, + (atom_flags | IMAGE_FUNCTION_EXT_ONLY), + ir_intrinsic_image_atomic_dec_wrap); } ir_variable * @@ -3344,7 +4800,7 @@ builtin_builder::imm(const glsl_type *type, const ir_constant_data &data) return new(mem_ctx) ir_constant(type, &data); } -#define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val) +#define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val) ir_dereference_variable * builtin_builder::var_ref(ir_variable *var) @@ -3433,12 +4889,18 @@ builtin_builder::binop(builtin_available_predicate avail, ir_expression_operation opcode, const glsl_type *return_type, const glsl_type *param0_type, - const glsl_type *param1_type) + const glsl_type *param1_type, + bool swap_operands) { ir_variable *x = in_var(param0_type, "x"); ir_variable *y = in_var(param1_type, "y"); MAKE_SIG(return_type, avail, 2, x, y); - body.emit(ret(expr(opcode, x, y))); + + if (swap_operands) + body.emit(ret(expr(opcode, y, x))); + else + body.emit(ret(expr(opcode, x, y))); + return sig; } @@ -3560,44 +5022,88 @@ builtin_builder::_acos(const glsl_type *type) ir_function_signature * builtin_builder::_atan2(const glsl_type *type) { - ir_variable *vec_y = in_var(type, "vec_y"); - ir_variable *vec_x = in_var(type, "vec_x"); - MAKE_SIG(type, always_available, 2, vec_y, vec_x); - - ir_variable *vec_result = body.make_temp(type, "vec_result"); - ir_variable *r = body.make_temp(glsl_type::float_type, "r"); - for (int i = 0; i < type->vector_elements; i++) { - ir_variable *y = body.make_temp(glsl_type::float_type, "y"); - ir_variable *x = body.make_temp(glsl_type::float_type, "x"); - body.emit(assign(y, swizzle(vec_y, i, 1))); - body.emit(assign(x, swizzle(vec_x, i, 1))); - - /* If |x| >= 1.0e-8 * |y|: */ - ir_if *outer_if = - new(mem_ctx) ir_if(greater(abs(x), mul(imm(1.0e-8f), abs(y)))); - - ir_factory outer_then(&outer_if->then_instructions, mem_ctx); - - /* Then...call atan(y/x) */ - do_atan(outer_then, glsl_type::float_type, r, div(y, x)); - - /* ...and fix it up: */ - ir_if *inner_if = new(mem_ctx) ir_if(less(x, imm(0.0f))); - inner_if->then_instructions.push_tail( - if_tree(gequal(y, imm(0.0f)), - assign(r, add(r, imm(M_PIf))), - assign(r, sub(r, imm(M_PIf))))); - outer_then.emit(inner_if); + const unsigned n = type->vector_elements; + ir_variable *y = in_var(type, "y"); + ir_variable *x = in_var(type, "x"); + MAKE_SIG(type, is_not_nir, 2, y, x); - /* Else... */ - outer_if->else_instructions.push_tail( - assign(r, mul(sign(y), imm(M_PI_2f)))); + /* If we're on the left half-plane rotate the coordinates π/2 clock-wise + * for the y=0 discontinuity to end up aligned with the vertical + * discontinuity of atan(s/t) along t=0. This also makes sure that we + * don't attempt to divide by zero along the vertical line, which may give + * unspecified results on non-GLSL 4.1-capable hardware. + */ + ir_variable *flip = body.make_temp(glsl_type::bvec(n), "flip"); + body.emit(assign(flip, gequal(imm(0.0f, n), x))); + ir_variable *s = body.make_temp(type, "s"); + body.emit(assign(s, csel(flip, abs(x), y))); + ir_variable *t = body.make_temp(type, "t"); + body.emit(assign(t, csel(flip, y, abs(x)))); - body.emit(outer_if); + /* If the magnitude of the denominator exceeds some huge value, scale down + * the arguments in order to prevent the reciprocal operation from flushing + * its result to zero, which would cause precision problems, and for s + * infinite would cause us to return a NaN instead of the correct finite + * value. + * + * If fmin and fmax are respectively the smallest and largest positive + * normalized floating point values representable by the implementation, + * the constants below should be in agreement with: + * + * huge <= 1 / fmin + * scale <= 1 / fmin / fmax (for |t| >= huge) + * + * In addition scale should be a negative power of two in order to avoid + * loss of precision. The values chosen below should work for most usual + * floating point representations with at least the dynamic range of ATI's + * 24-bit representation. + */ + ir_constant *huge = imm(1e18f, n); + ir_variable *scale = body.make_temp(type, "scale"); + body.emit(assign(scale, csel(gequal(abs(t), huge), + imm(0.25f, n), imm(1.0f, n)))); + ir_variable *rcp_scaled_t = body.make_temp(type, "rcp_scaled_t"); + body.emit(assign(rcp_scaled_t, rcp(mul(t, scale)))); + ir_expression *s_over_t = mul(mul(s, scale), rcp_scaled_t); + + /* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily + * that ∞/∞ = 1) in order to comply with the rather artificial rules + * inherited from IEEE 754-2008, namely: + * + * "atan2(±∞, −∞) is ±3π/4 + * atan2(±∞, +∞) is ±π/4" + * + * Note that this is inconsistent with the rules for the neighborhood of + * zero that are based on iterated limits: + * + * "atan2(±0, −0) is ±π + * atan2(±0, +0) is ±0" + * + * but GLSL specifically allows implementations to deviate from IEEE rules + * at (0,0), so we take that license (i.e. pretend that 0/0 = 1 here as + * well). + */ + ir_expression *tan = csel(equal(abs(x), abs(y)), + imm(1.0f, n), abs(s_over_t)); - body.emit(assign(vec_result, r, 1 << i)); - } - body.emit(ret(vec_result)); + /* Calculate the arctangent and fix up the result if we had flipped the + * coordinate system. + */ + ir_variable *arc = body.make_temp(type, "arc"); + do_atan(body, type, arc, tan); + body.emit(assign(arc, add(arc, mul(b2f(flip), imm(M_PI_2f))))); + + /* Rather convoluted calculation of the sign of the result. When x < 0 we + * cannot use fsign because we need to be able to distinguish between + * negative and positive zero. Unfortunately we cannot use bitwise + * arithmetic tricks either because of back-ends without integer support. + * When x >= 0 rcp_scaled_t will always be non-negative so this won't be + * able to distinguish between negative and positive zero, but we don't + * care because atan2 is continuous along the whole positive y = 0 + * half-line, so it won't affect the result significantly. + */ + body.emit(ret(csel(less(min2(y, rcp_scaled_t), imm(0.0f, n)), + neg(arc), arc))); return sig; } @@ -3656,7 +5162,7 @@ ir_function_signature * builtin_builder::_atan(const glsl_type *type) { ir_variable *y_over_x = in_var(type, "y_over_x"); - MAKE_SIG(type, always_available, 1, y_over_x); + MAKE_SIG(type, is_not_nir, 1, y_over_x); ir_variable *tmp = body.make_temp(type, "tmp"); do_atan(body, type, tmp, y_over_x); @@ -3695,19 +5201,17 @@ builtin_builder::_tanh(const glsl_type *type) ir_variable *x = in_var(type, "x"); MAKE_SIG(type, v130, 1, x); - /* tanh(x) := (0.5 * (e^x - e^(-x))) / (0.5 * (e^x + e^(-x))) - * - * With a little algebra this reduces to (e^2x - 1) / (e^2x + 1) - * - * Clamp x to (-inf, +10] to avoid precision problems. When x > 10, e^2x - * is so much larger than 1.0 that 1.0 gets flushed to zero in the - * computation e^2x +/- 1 so it can be ignored. + /* Clamp x to [-10, +10] to avoid precision problems. + * When x > 10, e^(-x) is so small relative to e^x that it gets flushed to + * zero in the computation e^x + e^(-x). The same happens in the other + * direction when x < -10. */ ir_variable *t = body.make_temp(type, "tmp"); - body.emit(assign(t, min2(x, imm(10.0f)))); + body.emit(assign(t, min2(max2(x, imm(-10.0f)), imm(10.0f)))); - body.emit(ret(div(sub(exp(mul(t, imm(2.0f))), imm(1.0f)), - add(exp(mul(t, imm(2.0f))), imm(1.0f))))); + /* (e^x - e^(-x)) / (e^x + e^(-x)) */ + body.emit(ret(div(sub(exp(t), exp(neg(t))), + add(exp(t), exp(neg(t)))))); return sig; } @@ -3759,6 +5263,7 @@ UNOP(exp, ir_unop_exp, always_available) UNOP(log, ir_unop_log, always_available) UNOP(exp2, ir_unop_exp2, always_available) UNOP(log2, ir_unop_log2, always_available) +UNOP(atan_op, ir_unop_atan, is_nir) UNOPA(sqrt, ir_unop_sqrt) UNOPA(inversesqrt, ir_unop_rsq) @@ -3767,6 +5272,7 @@ UNOPA(inversesqrt, ir_unop_rsq) UNOPA(abs, ir_unop_abs) UNOPA(sign, ir_unop_sign) UNOPA(floor, ir_unop_floor) +UNOPA(truncate, ir_unop_trunc) UNOPA(trunc, ir_unop_trunc) UNOPA(round, ir_unop_round_even) UNOPA(roundEven, ir_unop_round_even) @@ -3868,14 +5374,14 @@ builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_ ir_variable *t = body.make_temp(x_type, "t"); if (x_type->vector_elements == 1) { /* Both are floats */ - if (edge_type->base_type == GLSL_TYPE_DOUBLE) + if (edge_type->is_double()) body.emit(assign(t, f2d(b2f(gequal(x, edge))))); else body.emit(assign(t, b2f(gequal(x, edge)))); } else if (edge_type->vector_elements == 1) { /* x is a vector but edge is a float */ for (int i = 0; i < x_type->vector_elements; i++) { - if (edge_type->base_type == GLSL_TYPE_DOUBLE) + if (edge_type->is_double()) body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), edge))), 1 << i)); else body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), edge)), 1 << i)); @@ -3883,7 +5389,7 @@ builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_ } else { /* Both are vectors */ for (int i = 0; i < x_type->vector_elements; i++) { - if (edge_type->base_type == GLSL_TYPE_DOUBLE) + if (edge_type->is_double()) body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1)))), 1 << i)); else @@ -3957,6 +5463,12 @@ builtin_builder::_isinf(builtin_available_predicate avail, const glsl_type *type return sig; } +ir_function_signature * +builtin_builder::_atan2_op(const glsl_type *x_type) +{ + return binop(is_nir, ir_binop_atan2, x_type, x_type, x_type); +} + ir_function_signature * builtin_builder::_floatBitsToInt(const glsl_type *type) { @@ -4335,7 +5847,7 @@ builtin_builder::_outerProduct(builtin_available_predicate avail, const glsl_typ ir_variable *c; ir_variable *r; - if (type->base_type == GLSL_TYPE_DOUBLE) { + if (type->is_double()) { r = in_var(glsl_type::dvec(type->matrix_columns), "r"); c = in_var(glsl_type::dvec(type->vector_elements), "c"); } else { @@ -4727,16 +6239,18 @@ ir_function_signature * builtin_builder::_lessThanEqual(builtin_available_predicate avail, const glsl_type *type) { - return binop(avail, ir_binop_lequal, - glsl_type::bvec(type->vector_elements), type, type); + return binop(avail, ir_binop_gequal, + glsl_type::bvec(type->vector_elements), type, type, + true); } ir_function_signature * builtin_builder::_greaterThan(builtin_available_predicate avail, const glsl_type *type) { - return binop(avail, ir_binop_greater, - glsl_type::bvec(type->vector_elements), type, type); + return binop(avail, ir_binop_less, + glsl_type::bvec(type->vector_elements), type, type, + true); } ir_function_signature * @@ -4830,10 +6344,11 @@ builtin_builder::_textureSize(builtin_available_predicate avail, } ir_function_signature * -builtin_builder::_textureSamples(const glsl_type *sampler_type) +builtin_builder::_textureSamples(builtin_available_predicate avail, + const glsl_type *sampler_type) { ir_variable *s = in_var(sampler_type, "sampler"); - MAKE_SIG(glsl_type::int_type, shader_samples, 1, s); + MAKE_SIG(glsl_type::int_type, avail, 1, s); ir_texture *tex = new(mem_ctx) ir_texture(ir_texture_samples); tex->set_sampler(new(mem_ctx) ir_dereference_variable(s), glsl_type::int_type); @@ -4947,19 +6462,33 @@ builtin_builder::_texture(ir_texture_opcode opcode, } ir_function_signature * -builtin_builder::_textureCubeArrayShadow() +builtin_builder::_textureCubeArrayShadow(ir_texture_opcode opcode, + builtin_available_predicate avail, + const glsl_type *sampler_type) { - ir_variable *s = in_var(glsl_type::samplerCubeArrayShadow_type, "sampler"); + ir_variable *s = in_var(sampler_type, "sampler"); ir_variable *P = in_var(glsl_type::vec4_type, "P"); ir_variable *compare = in_var(glsl_type::float_type, "compare"); - MAKE_SIG(glsl_type::float_type, texture_cube_map_array, 3, s, P, compare); + MAKE_SIG(glsl_type::float_type, avail, 3, s, P, compare); - ir_texture *tex = new(mem_ctx) ir_texture(ir_tex); + ir_texture *tex = new(mem_ctx) ir_texture(opcode); tex->set_sampler(var_ref(s), glsl_type::float_type); tex->coordinate = var_ref(P); tex->shadow_comparator = var_ref(compare); + if (opcode == ir_txb) { + ir_variable *bias = in_var(glsl_type::float_type, "bias"); + sig->parameters.push_tail(bias); + tex->lod_info.bias = var_ref(bias); + } + + if (opcode == ir_txl) { + ir_variable *lod = in_var(glsl_type::float_type, "lod"); + sig->parameters.push_tail(lod); + tex->lod_info.lod = var_ref(lod); + } + body.emit(ret(tex)); return sig; @@ -5097,11 +6626,12 @@ builtin_builder::_textureQueryLod(builtin_available_predicate avail, } ir_function_signature * -builtin_builder::_textureQueryLevels(const glsl_type *sampler_type) +builtin_builder::_textureQueryLevels(builtin_available_predicate avail, + const glsl_type *sampler_type) { ir_variable *s = in_var(sampler_type, "sampler"); const glsl_type *return_type = glsl_type::int_type; - MAKE_SIG(return_type, texture_query_levels, 1, s); + MAKE_SIG(return_type, avail, 1, s); ir_texture *tex = new(mem_ctx) ir_texture(ir_query_levels); tex->set_sampler(var_ref(s), return_type); @@ -5130,18 +6660,18 @@ builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail, return sig; } -UNOP(dFdx, ir_unop_dFdx, fs_oes_derivatives) -UNOP(dFdxCoarse, ir_unop_dFdx_coarse, fs_derivative_control) -UNOP(dFdxFine, ir_unop_dFdx_fine, fs_derivative_control) -UNOP(dFdy, ir_unop_dFdy, fs_oes_derivatives) -UNOP(dFdyCoarse, ir_unop_dFdy_coarse, fs_derivative_control) -UNOP(dFdyFine, ir_unop_dFdy_fine, fs_derivative_control) +UNOP(dFdx, ir_unop_dFdx, derivatives) +UNOP(dFdxCoarse, ir_unop_dFdx_coarse, derivative_control) +UNOP(dFdxFine, ir_unop_dFdx_fine, derivative_control) +UNOP(dFdy, ir_unop_dFdy, derivatives) +UNOP(dFdyCoarse, ir_unop_dFdy_coarse, derivative_control) +UNOP(dFdyFine, ir_unop_dFdy_fine, derivative_control) ir_function_signature * builtin_builder::_fwidth(const glsl_type *type) { ir_variable *p = in_var(type, "p"); - MAKE_SIG(type, fs_oes_derivatives, 1, p); + MAKE_SIG(type, derivatives, 1, p); body.emit(ret(add(abs(expr(ir_unop_dFdx, p)), abs(expr(ir_unop_dFdy, p))))); @@ -5152,7 +6682,7 @@ ir_function_signature * builtin_builder::_fwidthCoarse(const glsl_type *type) { ir_variable *p = in_var(type, "p"); - MAKE_SIG(type, fs_derivative_control, 1, p); + MAKE_SIG(type, derivative_control, 1, p); body.emit(ret(add(abs(expr(ir_unop_dFdx_coarse, p)), abs(expr(ir_unop_dFdy_coarse, p))))); @@ -5164,7 +6694,7 @@ ir_function_signature * builtin_builder::_fwidthFine(const glsl_type *type) { ir_variable *p = in_var(type, "p"); - MAKE_SIG(type, fs_derivative_control, 1, p); + MAKE_SIG(type, derivative_control, 1, p); body.emit(ret(add(abs(expr(ir_unop_dFdx_fine, p)), abs(expr(ir_unop_dFdy_fine, p))))); @@ -5175,103 +6705,52 @@ builtin_builder::_fwidthFine(const glsl_type *type) ir_function_signature * builtin_builder::_noise1(const glsl_type *type) { - return unop(v110, ir_unop_noise, glsl_type::float_type, type); + /* From the GLSL 4.60 specification: + * + * "The noise functions noise1, noise2, noise3, and noise4 have been + * deprecated starting with version 4.4 of GLSL. When not generating + * SPIR-V they are defined to return the value 0.0 or a vector whose + * components are all 0.0. When generating SPIR-V the noise functions + * are not declared and may not be used." + * + * In earlier versions of the GLSL specification attempt to define some + * sort of statistical noise function. However, the function's + * characteristics have always been such that always returning 0 is + * valid and Mesa has always returned 0 for noise on most drivers. + */ + ir_variable *p = in_var(type, "p"); + MAKE_SIG(glsl_type::float_type, v110, 1, p); + body.emit(ret(imm(glsl_type::float_type, ir_constant_data()))); + return sig; } ir_function_signature * builtin_builder::_noise2(const glsl_type *type) { + /* See builtin_builder::_noise1 */ ir_variable *p = in_var(type, "p"); MAKE_SIG(glsl_type::vec2_type, v110, 1, p); - - ir_constant_data b_offset; - b_offset.f[0] = 601.0f; - b_offset.f[1] = 313.0f; - b_offset.f[2] = 29.0f; - b_offset.f[3] = 277.0f; - - ir_variable *a = body.make_temp(glsl_type::float_type, "a"); - ir_variable *b = body.make_temp(glsl_type::float_type, "b"); - ir_variable *t = body.make_temp(glsl_type::vec2_type, "t"); - body.emit(assign(a, expr(ir_unop_noise, p))); - body.emit(assign(b, expr(ir_unop_noise, add(p, imm(type, b_offset))))); - body.emit(assign(t, a, WRITEMASK_X)); - body.emit(assign(t, b, WRITEMASK_Y)); - body.emit(ret(t)); - + body.emit(ret(imm(glsl_type::vec2_type, ir_constant_data()))); return sig; } ir_function_signature * builtin_builder::_noise3(const glsl_type *type) { + /* See builtin_builder::_noise1 */ ir_variable *p = in_var(type, "p"); MAKE_SIG(glsl_type::vec3_type, v110, 1, p); - - ir_constant_data b_offset; - b_offset.f[0] = 601.0f; - b_offset.f[1] = 313.0f; - b_offset.f[2] = 29.0f; - b_offset.f[3] = 277.0f; - - ir_constant_data c_offset; - c_offset.f[0] = 1559.0f; - c_offset.f[1] = 113.0f; - c_offset.f[2] = 1861.0f; - c_offset.f[3] = 797.0f; - - ir_variable *a = body.make_temp(glsl_type::float_type, "a"); - ir_variable *b = body.make_temp(glsl_type::float_type, "b"); - ir_variable *c = body.make_temp(glsl_type::float_type, "c"); - ir_variable *t = body.make_temp(glsl_type::vec3_type, "t"); - body.emit(assign(a, expr(ir_unop_noise, p))); - body.emit(assign(b, expr(ir_unop_noise, add(p, imm(type, b_offset))))); - body.emit(assign(c, expr(ir_unop_noise, add(p, imm(type, c_offset))))); - body.emit(assign(t, a, WRITEMASK_X)); - body.emit(assign(t, b, WRITEMASK_Y)); - body.emit(assign(t, c, WRITEMASK_Z)); - body.emit(ret(t)); - + body.emit(ret(imm(glsl_type::vec3_type, ir_constant_data()))); return sig; } ir_function_signature * builtin_builder::_noise4(const glsl_type *type) { + /* See builtin_builder::_noise1 */ ir_variable *p = in_var(type, "p"); MAKE_SIG(glsl_type::vec4_type, v110, 1, p); - - ir_variable *_p = body.make_temp(type, "_p"); - - ir_constant_data p_offset; - p_offset.f[0] = 1559.0f; - p_offset.f[1] = 113.0f; - p_offset.f[2] = 1861.0f; - p_offset.f[3] = 797.0f; - - body.emit(assign(_p, add(p, imm(type, p_offset)))); - - ir_constant_data offset; - offset.f[0] = 601.0f; - offset.f[1] = 313.0f; - offset.f[2] = 29.0f; - offset.f[3] = 277.0f; - - ir_variable *a = body.make_temp(glsl_type::float_type, "a"); - ir_variable *b = body.make_temp(glsl_type::float_type, "b"); - ir_variable *c = body.make_temp(glsl_type::float_type, "c"); - ir_variable *d = body.make_temp(glsl_type::float_type, "d"); - ir_variable *t = body.make_temp(glsl_type::vec4_type, "t"); - body.emit(assign(a, expr(ir_unop_noise, p))); - body.emit(assign(b, expr(ir_unop_noise, add(p, imm(type, offset))))); - body.emit(assign(c, expr(ir_unop_noise, _p))); - body.emit(assign(d, expr(ir_unop_noise, add(_p, imm(type, offset))))); - body.emit(assign(t, a, WRITEMASK_X)); - body.emit(assign(t, b, WRITEMASK_Y)); - body.emit(assign(t, c, WRITEMASK_Z)); - body.emit(assign(t, d, WRITEMASK_W)); - body.emit(ret(t)); - + body.emit(ret(imm(glsl_type::vec4_type, ir_constant_data()))); return sig; } @@ -5339,6 +6818,28 @@ builtin_builder::_findMSB(const glsl_type *type) glsl_type::ivec(type->vector_elements), type); } +ir_function_signature * +builtin_builder::_countLeadingZeros(builtin_available_predicate avail, + const glsl_type *type) +{ + return unop(avail, ir_unop_clz, + glsl_type::uvec(type->vector_elements), type); +} + +ir_function_signature * +builtin_builder::_countTrailingZeros(builtin_available_predicate avail, + const glsl_type *type) +{ + ir_variable *a = in_var(type, "a"); + MAKE_SIG(glsl_type::uvec(type->vector_elements), avail, 1, a); + + body.emit(ret(ir_builder::min2( + ir_builder::i2u(ir_builder::expr(ir_unop_find_lsb, a)), + imm(32u)))); + + return sig; +} + ir_function_signature * builtin_builder::_fma(builtin_available_predicate avail, const glsl_type *type) { @@ -5355,7 +6856,7 @@ builtin_builder::_fma(builtin_available_predicate avail, const glsl_type *type) ir_function_signature * builtin_builder::_ldexp(const glsl_type *x_type, const glsl_type *exp_type) { - return binop(x_type->base_type == GLSL_TYPE_DOUBLE ? fp64 : gpu_shader5_or_es31_or_integer_functions, + return binop(x_type->is_double() ? fp64 : gpu_shader5_or_es31_or_integer_functions, ir_binop_ldexp, x_type, x_type, exp_type); } @@ -5434,6 +6935,13 @@ builtin_builder::_uaddCarry(const glsl_type *type) return sig; } +ir_function_signature * +builtin_builder::_addSaturate(builtin_available_predicate avail, + const glsl_type *type) +{ + return binop(avail, ir_binop_add_sat, type, type, type); +} + ir_function_signature * builtin_builder::_usubBorrow(const glsl_type *type) { @@ -5448,24 +6956,93 @@ builtin_builder::_usubBorrow(const glsl_type *type) return sig; } +ir_function_signature * +builtin_builder::_subtractSaturate(builtin_available_predicate avail, + const glsl_type *type) +{ + return binop(avail, ir_binop_sub_sat, type, type, type); +} + +ir_function_signature * +builtin_builder::_absoluteDifference(builtin_available_predicate avail, + const glsl_type *type) +{ + /* absoluteDifference returns an unsigned type that has the same number of + * bits and number of vector elements as the type of the operands. + */ + return binop(avail, ir_binop_abs_sub, + glsl_type::get_instance(glsl_unsigned_base_type_of(type->base_type), + type->vector_elements, 1), + type, type); +} + +ir_function_signature * +builtin_builder::_average(builtin_available_predicate avail, + const glsl_type *type) +{ + return binop(avail, ir_binop_avg, type, type, type); +} + +ir_function_signature * +builtin_builder::_averageRounded(builtin_available_predicate avail, + const glsl_type *type) +{ + return binop(avail, ir_binop_avg_round, type, type, type); +} + /** * For both imulExtended() and umulExtended() built-ins. */ ir_function_signature * builtin_builder::_mulExtended(const glsl_type *type) { + const glsl_type *mul_type, *unpack_type; + ir_expression_operation unpack_op; + + if (type->base_type == GLSL_TYPE_INT) { + unpack_op = ir_unop_unpack_int_2x32; + mul_type = glsl_type::get_instance(GLSL_TYPE_INT64, type->vector_elements, 1); + unpack_type = glsl_type::ivec2_type; + } else { + unpack_op = ir_unop_unpack_uint_2x32; + mul_type = glsl_type::get_instance(GLSL_TYPE_UINT64, type->vector_elements, 1); + unpack_type = glsl_type::uvec2_type; + } + ir_variable *x = in_var(type, "x"); ir_variable *y = in_var(type, "y"); ir_variable *msb = out_var(type, "msb"); ir_variable *lsb = out_var(type, "lsb"); MAKE_SIG(glsl_type::void_type, gpu_shader5_or_es31_or_integer_functions, 4, x, y, msb, lsb); - body.emit(assign(msb, imul_high(x, y))); - body.emit(assign(lsb, mul(x, y))); + ir_variable *unpack_val = body.make_temp(unpack_type, "_unpack_val"); + + ir_expression *mul_res = new(mem_ctx) ir_expression(ir_binop_mul, mul_type, + new(mem_ctx)ir_dereference_variable(x), + new(mem_ctx)ir_dereference_variable(y)); + + if (type->vector_elements == 1) { + body.emit(assign(unpack_val, expr(unpack_op, mul_res))); + body.emit(assign(msb, swizzle_y(unpack_val))); + body.emit(assign(lsb, swizzle_x(unpack_val))); + } else { + for (int i = 0; i < type->vector_elements; i++) { + body.emit(assign(unpack_val, expr(unpack_op, swizzle(mul_res, i, 1)))); + body.emit(assign(array_ref(msb, i), swizzle_y(unpack_val))); + body.emit(assign(array_ref(lsb, i), swizzle_x(unpack_val))); + } + } return sig; } +ir_function_signature * +builtin_builder::_multiply32x16(builtin_available_predicate avail, + const glsl_type *type) +{ + return binop(avail, ir_binop_mul_32x16, type, type, type); +} + ir_function_signature * builtin_builder::_interpolateAtCentroid(const glsl_type *type) { @@ -5710,10 +7287,18 @@ get_image_available_predicate(const glsl_type *type, unsigned flags) type->sampled_type == GLSL_TYPE_FLOAT) return shader_image_atomic_exchange_float; + if ((flags & IMAGE_FUNCTION_AVAIL_ATOMIC_ADD) && + type->sampled_type == GLSL_TYPE_FLOAT) + return shader_image_atomic_add_float; + else if (flags & (IMAGE_FUNCTION_AVAIL_ATOMIC_EXCHANGE | + IMAGE_FUNCTION_AVAIL_ATOMIC_ADD | IMAGE_FUNCTION_AVAIL_ATOMIC)) return shader_image_atomic; + else if (flags & IMAGE_FUNCTION_EXT_ONLY) + return shader_image_load_store_ext; + else return shader_image_load_store; } @@ -5757,11 +7342,11 @@ builtin_builder::_image_prototype(const glsl_type *image_type, * accept everything that needs to be accepted, and reject cases * like loads from write-only or stores to read-only images. */ - image->data.image_read_only = (flags & IMAGE_FUNCTION_READ_ONLY) != 0; - image->data.image_write_only = (flags & IMAGE_FUNCTION_WRITE_ONLY) != 0; - image->data.image_coherent = true; - image->data.image_volatile = true; - image->data.image_restrict = true; + image->data.memory_read_only = (flags & IMAGE_FUNCTION_READ_ONLY) != 0; + image->data.memory_write_only = (flags & IMAGE_FUNCTION_WRITE_ONLY) != 0; + image->data.memory_coherent = true; + image->data.memory_volatile = true; + image->data.memory_restrict = true; return sig; } @@ -5797,11 +7382,11 @@ builtin_builder::_image_size_prototype(const glsl_type *image_type, * accept everything that needs to be accepted, and reject cases * like loads from write-only or stores to read-only images. */ - image->data.image_read_only = true; - image->data.image_write_only = true; - image->data.image_coherent = true; - image->data.image_volatile = true; - image->data.image_restrict = true; + image->data.memory_read_only = true; + image->data.memory_write_only = true; + image->data.memory_coherent = true; + image->data.memory_volatile = true; + image->data.memory_restrict = true; return sig; } @@ -5822,11 +7407,11 @@ builtin_builder::_image_samples_prototype(const glsl_type *image_type, * accept everything that needs to be accepted, and reject cases * like loads from write-only or stores to read-only images. */ - image->data.image_read_only = true; - image->data.image_write_only = true; - image->data.image_coherent = true; - image->data.image_volatile = true; - image->data.image_restrict = true; + image->data.memory_read_only = true; + image->data.memory_write_only = true; + image->data.memory_coherent = true; + image->data.memory_volatile = true; + image->data.memory_restrict = true; return sig; } @@ -5882,6 +7467,95 @@ builtin_builder::_memory_barrier(const char *intrinsic_name, return sig; } +ir_function_signature * +builtin_builder::_ballot_intrinsic() +{ + ir_variable *value = in_var(glsl_type::bool_type, "value"); + MAKE_INTRINSIC(glsl_type::uint64_t_type, ir_intrinsic_ballot, shader_ballot, + 1, value); + return sig; +} + +ir_function_signature * +builtin_builder::_ballot() +{ + ir_variable *value = in_var(glsl_type::bool_type, "value"); + + MAKE_SIG(glsl_type::uint64_t_type, shader_ballot, 1, value); + ir_variable *retval = body.make_temp(glsl_type::uint64_t_type, "retval"); + + body.emit(call(shader->symbols->get_function("__intrinsic_ballot"), + retval, sig->parameters)); + body.emit(ret(retval)); + return sig; +} + +ir_function_signature * +builtin_builder::_read_first_invocation_intrinsic(const glsl_type *type) +{ + ir_variable *value = in_var(type, "value"); + MAKE_INTRINSIC(type, ir_intrinsic_read_first_invocation, shader_ballot, + 1, value); + return sig; +} + +ir_function_signature * +builtin_builder::_read_first_invocation(const glsl_type *type) +{ + ir_variable *value = in_var(type, "value"); + + MAKE_SIG(type, shader_ballot, 1, value); + ir_variable *retval = body.make_temp(type, "retval"); + + body.emit(call(shader->symbols->get_function("__intrinsic_read_first_invocation"), + retval, sig->parameters)); + body.emit(ret(retval)); + return sig; +} + +ir_function_signature * +builtin_builder::_read_invocation_intrinsic(const glsl_type *type) +{ + ir_variable *value = in_var(type, "value"); + ir_variable *invocation = in_var(glsl_type::uint_type, "invocation"); + MAKE_INTRINSIC(type, ir_intrinsic_read_invocation, shader_ballot, + 2, value, invocation); + return sig; +} + +ir_function_signature * +builtin_builder::_read_invocation(const glsl_type *type) +{ + ir_variable *value = in_var(type, "value"); + ir_variable *invocation = in_var(glsl_type::uint_type, "invocation"); + + MAKE_SIG(type, shader_ballot, 2, value, invocation); + ir_variable *retval = body.make_temp(type, "retval"); + + body.emit(call(shader->symbols->get_function("__intrinsic_read_invocation"), + retval, sig->parameters)); + body.emit(ret(retval)); + return sig; +} + +ir_function_signature * +builtin_builder::_invocation_interlock_intrinsic(builtin_available_predicate avail, + enum ir_intrinsic_id id) +{ + MAKE_INTRINSIC(glsl_type::void_type, id, avail, 0); + return sig; +} + +ir_function_signature * +builtin_builder::_invocation_interlock(const char *intrinsic_name, + builtin_available_predicate avail) +{ + MAKE_SIG(glsl_type::void_type, avail, 0); + body.emit(call(shader->symbols->get_function(intrinsic_name), + NULL, sig->parameters)); + return sig; +} + ir_function_signature * builtin_builder::_shader_clock_intrinsic(builtin_available_predicate avail, const glsl_type *type) @@ -5896,7 +7570,7 @@ builtin_builder::_shader_clock(builtin_available_predicate avail, { MAKE_SIG(type, avail, 0); - ir_variable *retval = body.make_temp(type, "clock_retval"); + ir_variable *retval = body.make_temp(glsl_type::uvec2_type, "clock_retval"); body.emit(call(shader->symbols->get_function("__intrinsic_shader_clock"), retval, sig->parameters)); @@ -5911,12 +7585,49 @@ builtin_builder::_shader_clock(builtin_available_predicate avail, } ir_function_signature * -builtin_builder::_vote(enum ir_expression_operation opcode) +builtin_builder::_vote_intrinsic(builtin_available_predicate avail, + enum ir_intrinsic_id id) +{ + ir_variable *value = in_var(glsl_type::bool_type, "value"); + MAKE_INTRINSIC(glsl_type::bool_type, id, avail, 1, value); + return sig; +} + +ir_function_signature * +builtin_builder::_vote(const char *intrinsic_name, + builtin_available_predicate avail) { ir_variable *value = in_var(glsl_type::bool_type, "value"); - MAKE_SIG(glsl_type::bool_type, vote, 1, value); - body.emit(ret(expr(opcode, value))); + MAKE_SIG(glsl_type::bool_type, avail, 1, value); + + ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval"); + + body.emit(call(shader->symbols->get_function(intrinsic_name), + retval, sig->parameters)); + body.emit(ret(retval)); + return sig; +} + +ir_function_signature * +builtin_builder::_helper_invocation_intrinsic() +{ + MAKE_INTRINSIC(glsl_type::bool_type, ir_intrinsic_helper_invocation, + demote_to_helper_invocation, 0); + return sig; +} + +ir_function_signature * +builtin_builder::_helper_invocation() +{ + MAKE_SIG(glsl_type::bool_type, demote_to_helper_invocation, 0); + + ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval"); + + body.emit(call(shader->symbols->get_function("__intrinsic_helper_invocation"), + retval, sig->parameters)); + body.emit(ret(retval)); + return sig; } @@ -5927,24 +7638,28 @@ builtin_builder::_vote(enum ir_expression_operation opcode) /* The singleton instance of builtin_builder. */ static builtin_builder builtins; static mtx_t builtins_lock = _MTX_INITIALIZER_NP; +static uint32_t builtin_users = 0; /** * External API (exposing the built-in module to the rest of the compiler): * @{ */ -void -_mesa_glsl_initialize_builtin_functions() +extern "C" void +_mesa_glsl_builtin_functions_init_or_ref() { mtx_lock(&builtins_lock); - builtins.initialize(); + if (builtin_users++ == 0) + builtins.initialize(); mtx_unlock(&builtins_lock); } -void -_mesa_glsl_release_builtin_functions() +extern "C" void +_mesa_glsl_builtin_functions_decref() { mtx_lock(&builtins_lock); - builtins.release(); + assert(builtin_users != 0); + if (--builtin_users == 0) + builtins.release(); mtx_unlock(&builtins_lock); } @@ -5952,21 +7667,32 @@ ir_function_signature * _mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state, const char *name, exec_list *actual_parameters) { - ir_function_signature * s; + ir_function_signature *s; mtx_lock(&builtins_lock); s = builtins.find(state, name, actual_parameters); mtx_unlock(&builtins_lock); + return s; } -ir_function * -_mesa_glsl_find_builtin_function_by_name(const char *name) +bool +_mesa_glsl_has_builtin_function(_mesa_glsl_parse_state *state, const char *name) { ir_function *f; + bool ret = false; mtx_lock(&builtins_lock); f = builtins.shader->symbols->get_function(name); + if (f != NULL) { + foreach_in_list(ir_function_signature, sig, &f->signatures) { + if (sig->is_builtin_available(state)) { + ret = true; + break; + } + } + } mtx_unlock(&builtins_lock); - return f; + + return ret; } gl_shader *