Re: [Mesa-dev] [PATCH V3 02/11] glsl: add texture gather changes
On 09/15/2013 02:58 AM, Chris Forbes wrote: > From: Maxence Le Dore > > V2 [Chris Forbes]: >- Add new pattern, fixup parameter reading. > > V3: Rebase onto new builtins machinery > > Reviewed-by: Kenneth Graunke > --- > src/glsl/builtin_functions.cpp | 35 +++ > src/glsl/glcpp/glcpp-parse.y| 3 +++ > src/glsl/glsl_parser_extras.cpp | 1 + > src/glsl/glsl_parser_extras.h | 2 ++ > src/glsl/ir.cpp | 2 +- > src/glsl/ir.h | 4 +++- > src/glsl/ir_clone.cpp | 1 + > src/glsl/ir_hv_accept.cpp | 1 + > src/glsl/ir_print_visitor.cpp | 3 ++- > src/glsl/ir_reader.cpp | 6 +- > src/glsl/ir_rvalue_visitor.cpp | 1 + > src/glsl/opt_tree_grafting.cpp | 1 + > src/glsl/standalone_scaffolding.cpp | 1 + > src/mesa/program/ir_to_mesa.cpp | 5 + > 14 files changed, 62 insertions(+), 4 deletions(-) > > diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp > index 528af0d..a7d454c 100644 > --- a/src/glsl/builtin_functions.cpp > +++ b/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) > @@ -1807,6 +1814,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/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y > index 6eaa5f9..c7ad3e9 100644 > --- a/src/glsl/glcpp/glcpp-parse.y > +++ b/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) > +
[Mesa-dev] [PATCH V3 02/11] glsl: add texture gather changes
From: Maxence Le Dore V2 [Chris Forbes]: - Add new pattern, fixup parameter reading. V3: Rebase onto new builtins machinery Reviewed-by: Kenneth Graunke --- src/glsl/builtin_functions.cpp | 35 +++ src/glsl/glcpp/glcpp-parse.y| 3 +++ src/glsl/glsl_parser_extras.cpp | 1 + src/glsl/glsl_parser_extras.h | 2 ++ src/glsl/ir.cpp | 2 +- src/glsl/ir.h | 4 +++- src/glsl/ir_clone.cpp | 1 + src/glsl/ir_hv_accept.cpp | 1 + src/glsl/ir_print_visitor.cpp | 3 ++- src/glsl/ir_reader.cpp | 6 +- src/glsl/ir_rvalue_visitor.cpp | 1 + src/glsl/opt_tree_grafting.cpp | 1 + src/glsl/standalone_scaffolding.cpp | 1 + src/mesa/program/ir_to_mesa.cpp | 5 + 14 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 528af0d..a7d454c 100644 --- a/src/glsl/builtin_functions.cpp +++ b/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) @@ -1807,6 +1814,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/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 6eaa5f9..c7ad3e9 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/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/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index cac5a18..aca0f5c 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parse