This patch is Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>
On 02/27/2016 01:30 PM, Ilia Mirkin wrote: > Expose the samplerBuffer/imageBuffer types, and allow the various > functions to operate on them. > > Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu> > --- > src/compiler/glsl/builtin_functions.cpp | 20 ++++++++++++++------ > src/compiler/glsl/builtin_types.cpp | 22 ++++++++++++++++------ > src/compiler/glsl/glcpp/glcpp-parse.y | 4 ++++ > src/compiler/glsl/glsl_lexer.ll | 12 ++++++------ > src/compiler/glsl/glsl_parser_extras.cpp | 2 ++ > src/compiler/glsl/glsl_parser_extras.h | 4 ++++ > 6 files changed, 46 insertions(+), 18 deletions(-) > > diff --git a/src/compiler/glsl/builtin_functions.cpp > b/src/compiler/glsl/builtin_functions.cpp > index fb3a666..b4a3e32 100644 > --- a/src/compiler/glsl/builtin_functions.cpp > +++ b/src/compiler/glsl/builtin_functions.cpp > @@ -184,6 +184,14 @@ v110_lod(const _mesa_glsl_parse_state *state) > } > > static bool > +texture_buffer(const _mesa_glsl_parse_state *state) > +{ > + return state->is_version(140, 320) || > + state->EXT_texture_buffer_enable || > + state->OES_texture_buffer_enable; > +} > + > +static bool > shader_texture_lod(const _mesa_glsl_parse_state *state) > { > return state->ARB_shader_texture_lod_enable; > @@ -1585,9 +1593,9 @@ builtin_builder::create_builtins() > _textureSize(v130, glsl_type::ivec2_type, > glsl_type::usampler2DRect_type), > _textureSize(v130, glsl_type::ivec2_type, > glsl_type::sampler2DRectShadow_type), > > - _textureSize(v140, glsl_type::int_type, > glsl_type::samplerBuffer_type), > - _textureSize(v140, glsl_type::int_type, > glsl_type::isamplerBuffer_type), > - _textureSize(v140, glsl_type::int_type, > glsl_type::usamplerBuffer_type), > + _textureSize(texture_buffer, glsl_type::int_type, > glsl_type::samplerBuffer_type), > + _textureSize(texture_buffer, glsl_type::int_type, > glsl_type::isamplerBuffer_type), > + _textureSize(texture_buffer, glsl_type::int_type, > glsl_type::usamplerBuffer_type), > _textureSize(texture_multisample, glsl_type::ivec2_type, > glsl_type::sampler2DMS_type), > _textureSize(texture_multisample, glsl_type::ivec2_type, > glsl_type::isampler2DMS_type), > _textureSize(texture_multisample, glsl_type::ivec2_type, > glsl_type::usampler2DMS_type), > @@ -1859,9 +1867,9 @@ builtin_builder::create_builtins() > _texelFetch(v130, glsl_type::ivec4_type, > glsl_type::isampler2DArray_type, glsl_type::ivec3_type), > _texelFetch(v130, glsl_type::uvec4_type, > glsl_type::usampler2DArray_type, glsl_type::ivec3_type), > > - _texelFetch(v140, glsl_type::vec4_type, > glsl_type::samplerBuffer_type, glsl_type::int_type), > - _texelFetch(v140, glsl_type::ivec4_type, > glsl_type::isamplerBuffer_type, glsl_type::int_type), > - _texelFetch(v140, glsl_type::uvec4_type, > glsl_type::usamplerBuffer_type, glsl_type::int_type), > + _texelFetch(texture_buffer, glsl_type::vec4_type, > glsl_type::samplerBuffer_type, glsl_type::int_type), > + _texelFetch(texture_buffer, glsl_type::ivec4_type, > glsl_type::isamplerBuffer_type, glsl_type::int_type), > + _texelFetch(texture_buffer, glsl_type::uvec4_type, > glsl_type::usamplerBuffer_type, glsl_type::int_type), > > _texelFetch(texture_multisample, glsl_type::vec4_type, > glsl_type::sampler2DMS_type, glsl_type::ivec2_type), > _texelFetch(texture_multisample, glsl_type::ivec4_type, > glsl_type::isampler2DMS_type, glsl_type::ivec2_type), > diff --git a/src/compiler/glsl/builtin_types.cpp > b/src/compiler/glsl/builtin_types.cpp > index ee24bd5..d250234 100644 > --- a/src/compiler/glsl/builtin_types.cpp > +++ b/src/compiler/glsl/builtin_types.cpp > @@ -179,7 +179,7 @@ static const struct builtin_type_versions { > T(sampler2DArray, 130, 300) > T(samplerCubeArray, 400, 999) > T(sampler2DRect, 140, 999) > - T(samplerBuffer, 140, 999) > + T(samplerBuffer, 140, 320) > T(sampler2DMS, 150, 310) > T(sampler2DMSArray, 150, 999) > > @@ -191,7 +191,7 @@ static const struct builtin_type_versions { > T(isampler2DArray, 130, 300) > T(isamplerCubeArray, 400, 999) > T(isampler2DRect, 140, 999) > - T(isamplerBuffer, 140, 999) > + T(isamplerBuffer, 140, 320) > T(isampler2DMS, 150, 310) > T(isampler2DMSArray, 150, 999) > > @@ -203,7 +203,7 @@ static const struct builtin_type_versions { > T(usampler2DArray, 130, 300) > T(usamplerCubeArray, 400, 999) > T(usampler2DRect, 140, 999) > - T(usamplerBuffer, 140, 999) > + T(usamplerBuffer, 140, 320) > T(usampler2DMS, 150, 310) > T(usampler2DMSArray, 150, 999) > > @@ -222,7 +222,7 @@ static const struct builtin_type_versions { > T(image3D, 420, 310) > T(image2DRect, 420, 999) > T(imageCube, 420, 310) > - T(imageBuffer, 420, 999) > + T(imageBuffer, 420, 320) > T(image1DArray, 420, 999) > T(image2DArray, 420, 310) > T(imageCubeArray, 420, 999) > @@ -233,7 +233,7 @@ static const struct builtin_type_versions { > T(iimage3D, 420, 310) > T(iimage2DRect, 420, 999) > T(iimageCube, 420, 310) > - T(iimageBuffer, 420, 999) > + T(iimageBuffer, 420, 320) > T(iimage1DArray, 420, 999) > T(iimage2DArray, 420, 310) > T(iimageCubeArray, 420, 999) > @@ -244,7 +244,7 @@ static const struct builtin_type_versions { > T(uimage3D, 420, 310) > T(uimage2DRect, 420, 999) > T(uimageCube, 420, 310) > - T(uimageBuffer, 420, 999) > + T(uimageBuffer, 420, 320) > T(uimage1DArray, 420, 999) > T(uimage2DArray, 420, 310) > T(uimageCubeArray, 420, 999) > @@ -371,6 +371,16 @@ _mesa_glsl_initialize_types(struct > _mesa_glsl_parse_state *state) > add_type(symbols, glsl_type::uimage2DMSArray_type); > } > > + if (state->EXT_texture_buffer_enable || state->OES_texture_buffer_enable) > { > + add_type(symbols, glsl_type::samplerBuffer_type); > + add_type(symbols, glsl_type::isamplerBuffer_type); > + add_type(symbols, glsl_type::usamplerBuffer_type); > + > + add_type(symbols, glsl_type::imageBuffer_type); > + add_type(symbols, glsl_type::iimageBuffer_type); > + add_type(symbols, glsl_type::uimageBuffer_type); > + } > + > if (state->has_atomic_counters()) { > add_type(symbols, glsl_type::atomic_uint_type); > } > diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y > b/src/compiler/glsl/glcpp/glcpp-parse.y > index 84d430f..7aa2696 100644 > --- a/src/compiler/glsl/glcpp/glcpp-parse.y > +++ b/src/compiler/glsl/glcpp/glcpp-parse.y > @@ -2406,6 +2406,10 @@ > _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t > versio > add_builtin_define(parser, "GL_EXT_gpu_shader5", 1); > add_builtin_define(parser, "GL_OES_gpu_shader5", 1); > } > + if (extensions->OES_texture_buffer) { > + add_builtin_define(parser, "GL_EXT_texture_buffer", 1); > + add_builtin_define(parser, "GL_OES_texture_buffer", 1); > + } > } > } > } else { > diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll > index 2256dbe..409086a 100644 > --- a/src/compiler/glsl/glsl_lexer.ll > +++ b/src/compiler/glsl/glsl_lexer.ll > @@ -369,7 +369,7 @@ image2D KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_l > image3D KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, IMAGE3D); > image2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IMAGE2DRECT); > imageCube KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, IMAGECUBE); > -imageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IMAGEBUFFER); > +imageBuffer KEYWORD_WITH_ALT(130, 300, 420, 320, > yyextra->ARB_shader_image_load_store_enable || > yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, > IMAGEBUFFER); > image1DArray KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IMAGE1DARRAY); > image2DArray KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, IMAGE2DARRAY); > imageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IMAGECUBEARRAY); > @@ -380,7 +380,7 @@ iimage2D KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_l > iimage3D KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, IIMAGE3D); > iimage2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IIMAGE2DRECT); > iimageCube KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, IIMAGECUBE); > -iimageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IIMAGEBUFFER); > +iimageBuffer KEYWORD_WITH_ALT(130, 300, 420, 320, > yyextra->ARB_shader_image_load_store_enable || > yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, > IIMAGEBUFFER); > iimage1DArray KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IIMAGE1DARRAY); > iimage2DArray KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, IIMAGE2DARRAY); > iimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, IIMAGECUBEARRAY); > @@ -391,7 +391,7 @@ uimage2D KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_l > uimage3D KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, UIMAGE3D); > uimage2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, UIMAGE2DRECT); > uimageCube KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, UIMAGECUBE); > -uimageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, UIMAGEBUFFER); > +uimageBuffer KEYWORD_WITH_ALT(130, 300, 420, 320, > yyextra->ARB_shader_image_load_store_enable || > yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, > UIMAGEBUFFER); > uimage1DArray KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, UIMAGE1DARRAY); > uimage2DArray KEYWORD_WITH_ALT(130, 300, 420, 310, > yyextra->ARB_shader_image_load_store_enable, UIMAGE2DARRAY); > uimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, > yyextra->ARB_shader_image_load_store_enable, UIMAGECUBEARRAY); > @@ -565,15 +565,15 @@ common KEYWORD(130, 300, 0, 0, COMMON); > partition KEYWORD(130, 300, 0, 0, PARTITION); > active KEYWORD(130, 300, 0, 0, ACTIVE); > superp KEYWORD(130, 100, 0, 0, SUPERP); > -samplerBuffer KEYWORD(130, 300, 140, 0, SAMPLERBUFFER); > +samplerBuffer KEYWORD_WITH_ALT(130, 300, 140, 320, > yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, > SAMPLERBUFFER); > filter KEYWORD(130, 300, 0, 0, FILTER); > row_major KEYWORD_WITH_ALT(130, 0, 140, 0, > yyextra->ARB_uniform_buffer_object_enable && !yyextra->es_shader, ROW_MAJOR); > > /* Additional reserved words in GLSL 1.40 */ > isampler2DRect KEYWORD(140, 300, 140, 0, ISAMPLER2DRECT); > usampler2DRect KEYWORD(140, 300, 140, 0, USAMPLER2DRECT); > -isamplerBuffer KEYWORD(140, 300, 140, 0, ISAMPLERBUFFER); > -usamplerBuffer KEYWORD(140, 300, 140, 0, USAMPLERBUFFER); > +isamplerBuffer KEYWORD_WITH_ALT(140, 300, 140, 320, > yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, > ISAMPLERBUFFER); > +usamplerBuffer KEYWORD_WITH_ALT(140, 300, 140, 320, > yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, > USAMPLERBUFFER); > > /* Additional reserved words in GLSL ES 3.00 */ > resource KEYWORD(0, 300, 0, 0, RESOURCE); > diff --git a/src/compiler/glsl/glsl_parser_extras.cpp > b/src/compiler/glsl/glsl_parser_extras.cpp > index d15947a..247cfc6 100644 > --- a/src/compiler/glsl/glsl_parser_extras.cpp > +++ b/src/compiler/glsl/glsl_parser_extras.cpp > @@ -617,6 +617,7 @@ static const _mesa_glsl_extension > _mesa_glsl_supported_extensions[] = { > EXT(OES_shader_multisample_interpolation, false, true, > OES_sample_variables), > EXT(OES_standard_derivatives, false, true, > OES_standard_derivatives), > EXT(OES_texture_3D, false, true, dummy_true), > + EXT(OES_texture_buffer, false, true, OES_texture_buffer), > EXT(OES_texture_storage_multisample_2d_array, false, true, > ARB_texture_multisample), > > /* All other extensions go here, sorted alphabetically. > @@ -634,6 +635,7 @@ static const _mesa_glsl_extension > _mesa_glsl_supported_extensions[] = { > EXT(EXT_shader_io_blocks, false, true, dummy_true), > EXT(EXT_shader_samples_identical, true, true, > EXT_shader_samples_identical), > EXT(EXT_texture_array, true, false, EXT_texture_array), > + EXT(EXT_texture_buffer, false, true, OES_texture_buffer), > }; > > #undef EXT > diff --git a/src/compiler/glsl/glsl_parser_extras.h > b/src/compiler/glsl/glsl_parser_extras.h > index 1a602d2..45f3a9b 100644 > --- a/src/compiler/glsl/glsl_parser_extras.h > +++ b/src/compiler/glsl/glsl_parser_extras.h > @@ -612,6 +612,8 @@ struct _mesa_glsl_parse_state { > bool OES_standard_derivatives_warn; > bool OES_texture_3D_enable; > bool OES_texture_3D_warn; > + bool OES_texture_buffer_enable; > + bool OES_texture_buffer_warn; > bool OES_texture_storage_multisample_2d_array_enable; > bool OES_texture_storage_multisample_2d_array_warn; > > @@ -643,6 +645,8 @@ struct _mesa_glsl_parse_state { > bool EXT_shader_samples_identical_warn; > bool EXT_texture_array_enable; > bool EXT_texture_array_warn; > + bool EXT_texture_buffer_enable; > + bool EXT_texture_buffer_warn; > /*@}*/ > > /** Extensions supported by the OpenGL implementation. */ > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev