diff options
Diffstat (limited to 'mesalib')
24 files changed, 108 insertions, 6 deletions
diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt index 9b056d016..b16ec6fdb 100644 --- a/mesalib/docs/GL3.txt +++ b/mesalib/docs/GL3.txt @@ -105,7 +105,7 @@ GL_ARB_shader_subroutine not started GL_ARB_tessellation_shader not started GL_ARB_texture_buffer_object_rgb32 DONE (i965, softpipe) GL_ARB_texture_cube_map_array DONE (i965, softpipe) -GL_ARB_texture_gather started (Maxence, Chris) +GL_ARB_texture_gather DONE (i965) GL_ARB_transform_feedback2 DONE GL_ARB_transform_feedback3 DONE diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp index 72054e0fe..df735ef31 100644 --- a/mesalib/src/glsl/builtin_functions.cpp +++ b/mesalib/src/glsl/builtin_functions.cpp @@ -262,6 +262,13 @@ texture_query_lod(const _mesa_glsl_parse_state *state) state->ARB_texture_query_lod_enable; } +static bool +texture_gather(const _mesa_glsl_parse_state *state) +{ + return state->is_version(400, 0) || + state->ARB_texture_gather_enable; +} + /* Desktop GL or OES_standard_derivatives + fragment shader only */ static bool fs_oes_derivatives(const _mesa_glsl_parse_state *state) @@ -1816,6 +1823,34 @@ 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("textureGather", + _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type), + _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type), + _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type), + + _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type), + _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type), + _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type), + + _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type), + _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type), + _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type), + + _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type), + _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type), + _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type), + NULL); + + add_function("textureGatherOffset", + _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET), + + _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET), + NULL); + F(dFdx) F(dFdy) F(fwidth) diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y index 6eaa5f95e..c7ad3e958 100644 --- a/mesalib/src/glsl/glcpp/glcpp-parse.y +++ b/mesalib/src/glsl/glcpp/glcpp-parse.y @@ -1248,6 +1248,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) if (extensions->EXT_shader_integer_mix) add_builtin_define(parser, "GL_EXT_shader_integer_mix", 1); + + if (extensions->ARB_texture_gather) + add_builtin_define(parser, "GL_ARB_texture_gather", 1); } } diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp index 4f2f2893a..7368a7156 100644 --- a/mesalib/src/glsl/glsl_parser_extras.cpp +++ b/mesalib/src/glsl/glsl_parser_extras.cpp @@ -522,6 +522,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(ARB_gpu_shader5, true, false, ARB_gpu_shader5), EXT(AMD_vertex_shader_layer, true, false, AMD_vertex_shader_layer), EXT(EXT_shader_integer_mix, true, true, EXT_shader_integer_mix), + EXT(ARB_texture_gather, true, false, ARB_texture_gather), }; #undef EXT diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h index 4833436a3..5c3733d6e 100755 --- a/mesalib/src/glsl/glsl_parser_extras.h +++ b/mesalib/src/glsl/glsl_parser_extras.h @@ -278,6 +278,8 @@ struct _mesa_glsl_parse_state { bool ARB_fragment_coord_conventions_warn; bool ARB_texture_rectangle_enable; bool ARB_texture_rectangle_warn; + bool ARB_texture_gather_enable; + bool ARB_texture_gather_warn; bool EXT_texture_array_enable; bool EXT_texture_array_warn; bool ARB_shader_texture_lod_enable; diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp index b0f92cb3f..81c6380ca 100644 --- a/mesalib/src/glsl/ir.cpp +++ b/mesalib/src/glsl/ir.cpp @@ -1374,7 +1374,7 @@ ir_dereference::is_lvalue() const } -static const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf", "txf_ms", "txs", "lod" }; +static const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf", "txf_ms", "txs", "lod", "tg4" }; const char *ir_texture::opcode_string() { diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h index 6c5630b09..885837a7a 100644 --- a/mesalib/src/glsl/ir.h +++ b/mesalib/src/glsl/ir.h @@ -1559,7 +1559,8 @@ enum ir_texture_opcode { ir_txf, /**< Texel fetch with explicit LOD */ ir_txf_ms, /**< Multisample texture fetch */ ir_txs, /**< Texture size */ - ir_lod /**< Texture lod query */ + ir_lod, /**< Texture lod query */ + ir_tg4 /**< Texture gather */ }; @@ -1584,6 +1585,7 @@ enum ir_texture_opcode { * <type> <sampler> <coordinate> <sample_index>) * (txs <type> <sampler> <lod>) * (lod <type> <sampler> <coordinate>) + * (tg4 <type> <sampler> <coordinate> 0) */ class ir_texture : public ir_rvalue { public: diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp index fb303b0b7..fe531a8e3 100644 --- a/mesalib/src/glsl/ir_clone.cpp +++ b/mesalib/src/glsl/ir_clone.cpp @@ -248,6 +248,7 @@ ir_texture::clone(void *mem_ctx, struct hash_table *ht) const switch (this->op) { case ir_tex: case ir_lod: + case ir_tg4: break; case ir_txb: new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht); diff --git a/mesalib/src/glsl/ir_hv_accept.cpp b/mesalib/src/glsl/ir_hv_accept.cpp index 76a607d17..3877e721c 100644 --- a/mesalib/src/glsl/ir_hv_accept.cpp +++ b/mesalib/src/glsl/ir_hv_accept.cpp @@ -214,6 +214,7 @@ ir_texture::accept(ir_hierarchical_visitor *v) switch (this->op) { case ir_tex: case ir_lod: + case ir_tg4: break; case ir_txb: s = this->lod_info.bias->accept(v); diff --git a/mesalib/src/glsl/ir_print_visitor.cpp b/mesalib/src/glsl/ir_print_visitor.cpp index b5183108d..2c06b95f6 100644 --- a/mesalib/src/glsl/ir_print_visitor.cpp +++ b/mesalib/src/glsl/ir_print_visitor.cpp @@ -266,7 +266,7 @@ void ir_print_visitor::visit(ir_texture *ir) printf(" "); } - if (ir->op != ir_txf && ir->op != ir_txf_ms && ir->op != ir_txs) { + if (ir->op != ir_txf && ir->op != ir_txf_ms && ir->op != ir_txs && ir->op != ir_tg4) { if (ir->projector) ir->projector->accept(this); else @@ -285,6 +285,7 @@ void ir_print_visitor::visit(ir_texture *ir) { case ir_tex: case ir_lod: + case ir_tg4: break; case ir_txb: ir->lod_info.bias->accept(this); diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp index f0318ea21..8038b8f5d 100644 --- a/mesalib/src/glsl/ir_reader.cpp +++ b/mesalib/src/glsl/ir_reader.cpp @@ -947,6 +947,8 @@ ir_reader::read_texture(s_expression *expr) { "txf_ms", s_type, s_sampler, s_coord, s_sample_index }; s_pattern txs_pattern[] = { "txs", s_type, s_sampler, s_lod }; + s_pattern tg4_pattern[] = + { "tg4", s_type, s_sampler, s_coord, s_offset }; s_pattern other_pattern[] = { tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod }; @@ -960,6 +962,8 @@ ir_reader::read_texture(s_expression *expr) op = ir_txf_ms; } else if (MATCH(expr, txs_pattern)) { op = ir_txs; + } else if (MATCH(expr, tg4_pattern)) { + op = ir_tg4; } else if (MATCH(expr, other_pattern)) { op = ir_texture::get_opcode(tag->value()); if (op == -1) @@ -1010,7 +1014,7 @@ ir_reader::read_texture(s_expression *expr) } } - if (op != ir_txf && op != ir_txf_ms && op != ir_txs && op != ir_lod) { + if (op != ir_txf && op != ir_txf_ms && op != ir_txs && op != ir_lod && op != ir_tg4) { s_int *proj_as_int = SX_AS_INT(s_proj); if (proj_as_int && proj_as_int->value() == 1) { tex->projector = NULL; diff --git a/mesalib/src/glsl/ir_rvalue_visitor.cpp b/mesalib/src/glsl/ir_rvalue_visitor.cpp index 8eb1c62c3..4c3d81320 100644 --- a/mesalib/src/glsl/ir_rvalue_visitor.cpp +++ b/mesalib/src/glsl/ir_rvalue_visitor.cpp @@ -57,6 +57,7 @@ ir_rvalue_base_visitor::rvalue_visit(ir_texture *ir) switch (ir->op) { case ir_tex: case ir_lod: + case ir_tg4: break; case ir_txb: handle_rvalue(&ir->lod_info.bias); diff --git a/mesalib/src/glsl/ir_set_program_inouts.cpp b/mesalib/src/glsl/ir_set_program_inouts.cpp index 1267d6d71..ab23538c3 100644 --- a/mesalib/src/glsl/ir_set_program_inouts.cpp +++ b/mesalib/src/glsl/ir_set_program_inouts.cpp @@ -59,6 +59,7 @@ public: virtual ir_visitor_status visit_enter(ir_function_signature *); virtual ir_visitor_status visit_enter(ir_expression *); virtual ir_visitor_status visit_enter(ir_discard *); + virtual ir_visitor_status visit_enter(ir_texture *); virtual ir_visitor_status visit(ir_dereference_variable *); private: @@ -319,6 +320,14 @@ ir_set_program_inouts_visitor::visit_enter(ir_discard *) return visit_continue; } +ir_visitor_status +ir_set_program_inouts_visitor::visit_enter(ir_texture *ir) +{ + if (ir->op == ir_tg4) + prog->UsesGather = true; + return visit_continue; +} + void do_set_program_inouts(exec_list *instructions, struct gl_program *prog, GLenum shader_type) diff --git a/mesalib/src/glsl/opt_tree_grafting.cpp b/mesalib/src/glsl/opt_tree_grafting.cpp index 9aceb134d..03b920d8a 100644 --- a/mesalib/src/glsl/opt_tree_grafting.cpp +++ b/mesalib/src/glsl/opt_tree_grafting.cpp @@ -275,6 +275,7 @@ ir_tree_grafting_visitor::visit_enter(ir_texture *ir) switch (ir->op) { case ir_tex: case ir_lod: + case ir_tg4: break; case ir_txb: if (do_graft(&ir->lod_info.bias)) diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp index 6dec205f7..b03734c06 100644 --- a/mesalib/src/glsl/standalone_scaffolding.cpp +++ b/mesalib/src/glsl/standalone_scaffolding.cpp @@ -105,6 +105,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.ARB_texture_multisample = true; ctx->Extensions.ARB_texture_query_lod = true; ctx->Extensions.ARB_gpu_shader5 = true; + ctx->Extensions.ARB_texture_gather = true; ctx->Const.GLSLVersion = 120; diff --git a/mesalib/src/mapi/glapi/gen/ARB_texture_gather.xml b/mesalib/src/mapi/glapi/gen/ARB_texture_gather.xml new file mode 100644 index 000000000..41714aced --- /dev/null +++ b/mesalib/src/mapi/glapi/gen/ARB_texture_gather.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd"> + +<OpenGLAPI> + +<category name="GL_ARB_texture_gather" number="72"> + + <enum name="MIN_PROGRAM_TEXTURE_GATHER_OFFSET" value="0x8E5E"/> + <enum name="MAX_PROGRAM_TEXTURE_GATHER_OFFSET" value="0x8E5F"/> + + <!-- This exists only in the ARB extension; not in GL4 --> + <enum name="MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB" value="0x8F9F"/> + +</category> + +</OpenGLAPI> diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am index 9b9b99505..6bb2f1ec7 100644 --- a/mesalib/src/mapi/glapi/gen/Makefile.am +++ b/mesalib/src/mapi/glapi/gen/Makefile.am @@ -111,6 +111,7 @@ API_XML = \ ARB_texture_buffer_range.xml \ ARB_texture_compression_rgtc.xml \ ARB_texture_float.xml \ + ARB_texture_gather.xml \ ARB_texture_rg.xml \ ARB_texture_storage.xml \ ARB_vertex_array_object.xml \ diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml index c65dd3cef..c78d7b9bb 100755 --- a/mesalib/src/mapi/glapi/gen/gl_API.xml +++ b/mesalib/src/mapi/glapi/gen/gl_API.xml @@ -8189,7 +8189,7 @@ <!-- 70. GL_ARB_sample_shading --> <xi:include href="ARB_texture_cube_map_array.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> -<!-- 72. GL_ARB_texture_gather --> +<xi:include href="ARB_texture_gather.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <!-- 73. GL_ARB_texture_query_lod --> <!-- ARB extension number 74 is a WGL extension. --> diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 310518c92..0d1f71c71 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -652,6 +652,10 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.MinProgramTexelOffset = -8; ctx->Const.MaxProgramTexelOffset = 7; + /* GL_ARB_texture_gather */ + ctx->Const.MinProgramTextureGatherOffset = -8; + ctx->Const.MaxProgramTextureGatherOffset = 7; + /* GL_ARB_robustness */ ctx->Const.ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB; diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 51a8051e2..c0f17c5fd 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -142,6 +142,7 @@ static const struct extension extension_table[] = { { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GLL, 2001 }, { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GLL, 2001 }, { "GL_ARB_texture_float", o(ARB_texture_float), GL, 2004 }, + { "GL_ARB_texture_gather", o(ARB_texture_gather), GL, 2009 }, { "GL_ARB_texture_mirrored_repeat", o(dummy_true), GLL, 2001 }, { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL, 2009 }, { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL, 2003 }, diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 7af5f5591..89b3bf09d 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -366,6 +366,7 @@ EXTRA_EXT(ARB_map_buffer_alignment); EXTRA_EXT(ARB_texture_cube_map_array); EXTRA_EXT(ARB_texture_buffer_range); EXTRA_EXT(ARB_texture_multisample); +EXTRA_EXT(ARB_texture_gather); static const int extra_ARB_color_buffer_float_or_glcore[] = { diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py index 8147dd0b8..e80a23c11 100644 --- a/mesalib/src/mesa/main/get_hash_params.py +++ b/mesalib/src/mesa/main/get_hash_params.py @@ -716,6 +716,12 @@ descriptor=[ # GL_ARB_texture_cube_map_array [ "TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB", "LOC_CUSTOM, TYPE_INT, TEXTURE_CUBE_ARRAY_INDEX, extra_ARB_texture_cube_map_array" ], + +# GL_ARB_texture_gather + [ "MIN_PROGRAM_TEXTURE_GATHER_OFFSET", "CONTEXT_INT(Const.MinProgramTextureGatherOffset), extra_ARB_texture_gather"], + [ "MAX_PROGRAM_TEXTURE_GATHER_OFFSET", "CONTEXT_INT(Const.MaxProgramTextureGatherOffset), extra_ARB_texture_gather"], + [ "MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB", "CONTEXT_INT(Const.MaxProgramTextureGatherComponents), extra_ARB_texture_gather"], + ]}, # Enums restricted to OpenGL Core profile diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index d82672dc9..514f81048 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1963,6 +1963,8 @@ struct gl_program GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ + GLboolean UsesGather; /**< Does this program use gather4 at all? */ + /** Named parameters, constants, etc. from program text */ struct gl_program_parameter_list *Parameters; @@ -3081,6 +3083,11 @@ struct gl_constants /** GL_EXT_gpu_shader4 */ GLint MinProgramTexelOffset, MaxProgramTexelOffset; + /** GL_ARB_texture_gather */ + GLuint MinProgramTextureGatherOffset; + GLuint MaxProgramTextureGatherOffset; + GLuint MaxProgramTextureGatherComponents; + /* GL_ARB_robustness */ GLenum ResetStrategy; @@ -3210,6 +3217,7 @@ struct gl_extensions GLboolean ARB_texture_env_crossbar; GLboolean ARB_texture_env_dot3; GLboolean ARB_texture_float; + GLboolean ARB_texture_gather; GLboolean ARB_texture_multisample; GLboolean ARB_texture_non_power_of_two; GLboolean ARB_texture_query_lod; diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index b08107b1c..f180a7f64 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -2066,6 +2066,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir) case ir_lod: assert(!"Unexpected ir_lod opcode"); break; + case ir_tg4: + assert(!"Unexpected ir_tg4 opcode"); + break; } const glsl_type *sampler_type = ir->sampler->type; |