glsl: handle interactions between EXT_gpu_shader4 and texture extensions

also, EXT_texture_buffer_object has to be enabled separately.

Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Marek Olšák 2019-04-24 13:02:43 -04:00
parent e71936a731
commit 45ca7798dc
6 changed files with 415 additions and 324 deletions

File diff suppressed because it is too large Load diff

View file

@ -37,6 +37,7 @@
#include "compiler/glsl_types.h"
#include "glsl_parser_extras.h"
#include "util/macros.h"
#include "main/mtypes.h"
/**
* Declarations of type flyweights (glsl_type::_foo_type) and
@ -330,30 +331,44 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
add_type(symbols, glsl_type::uvec3_type);
add_type(symbols, glsl_type::uvec4_type);
add_type(symbols, glsl_type::sampler1DArray_type);
add_type(symbols, glsl_type::sampler2DArray_type);
add_type(symbols, glsl_type::sampler1DArrayShadow_type);
add_type(symbols, glsl_type::sampler2DArrayShadow_type);
add_type(symbols, glsl_type::samplerCubeShadow_type);
add_type(symbols, glsl_type::samplerBuffer_type);
add_type(symbols, glsl_type::isampler1D_type);
add_type(symbols, glsl_type::isampler2D_type);
add_type(symbols, glsl_type::isampler3D_type);
add_type(symbols, glsl_type::isamplerCube_type);
add_type(symbols, glsl_type::isampler2DRect_type);
add_type(symbols, glsl_type::isampler1DArray_type);
add_type(symbols, glsl_type::isampler2DArray_type);
add_type(symbols, glsl_type::isamplerBuffer_type);
if (state->ctx->Extensions.EXT_texture_array) {
add_type(symbols, glsl_type::sampler1DArray_type);
add_type(symbols, glsl_type::sampler2DArray_type);
add_type(symbols, glsl_type::sampler1DArrayShadow_type);
add_type(symbols, glsl_type::sampler2DArrayShadow_type);
}
if (state->ctx->Extensions.EXT_texture_buffer_object) {
add_type(symbols, glsl_type::samplerBuffer_type);
}
add_type(symbols, glsl_type::usampler1D_type);
add_type(symbols, glsl_type::usampler2D_type);
add_type(symbols, glsl_type::usampler3D_type);
add_type(symbols, glsl_type::usamplerCube_type);
add_type(symbols, glsl_type::usampler2DRect_type);
add_type(symbols, glsl_type::usampler1DArray_type);
add_type(symbols, glsl_type::usampler2DArray_type);
add_type(symbols, glsl_type::usamplerBuffer_type);
if (state->ctx->Extensions.EXT_texture_integer) {
add_type(symbols, glsl_type::isampler1D_type);
add_type(symbols, glsl_type::isampler2D_type);
add_type(symbols, glsl_type::isampler3D_type);
add_type(symbols, glsl_type::isamplerCube_type);
add_type(symbols, glsl_type::usampler1D_type);
add_type(symbols, glsl_type::usampler2D_type);
add_type(symbols, glsl_type::usampler3D_type);
add_type(symbols, glsl_type::usamplerCube_type);
if (state->ctx->Extensions.NV_texture_rectangle) {
add_type(symbols, glsl_type::isampler2DRect_type);
add_type(symbols, glsl_type::usampler2DRect_type);
}
if (state->ctx->Extensions.EXT_texture_array) {
add_type(symbols, glsl_type::isampler1DArray_type);
add_type(symbols, glsl_type::isampler2DArray_type);
add_type(symbols, glsl_type::usampler1DArray_type);
add_type(symbols, glsl_type::usampler2DArray_type);
}
if (state->ctx->Extensions.EXT_texture_buffer_object) {
add_type(symbols, glsl_type::isamplerBuffer_type);
add_type(symbols, glsl_type::usamplerBuffer_type);
}
}
}
if (state->EXT_texture_array_enable) {

View file

@ -27,6 +27,7 @@
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
#include "main/mtypes.h"
static int classify_identifier(struct _mesa_glsl_parse_state *, const char *,
unsigned name_len, YYSTYPE *output);
@ -398,25 +399,25 @@ sampler1D DEPRECATED_ES_TYPE(glsl_type::sampler1D_type);
sampler2D { yylval->type = glsl_type::sampler2D_type; return BASIC_TYPE_TOK; }
sampler3D { yylval->type = glsl_type::sampler3D_type; return BASIC_TYPE_TOK; }
samplerCube { yylval->type = glsl_type::samplerCube_type; return BASIC_TYPE_TOK; }
sampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::sampler1DArray_type);
sampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::sampler2DArray_type);
sampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArray_type);
sampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArray_type);
sampler1DShadow DEPRECATED_ES_TYPE(glsl_type::sampler1DShadow_type);
sampler2DShadow { yylval->type = glsl_type::sampler2DShadow_type; return BASIC_TYPE_TOK; }
samplerCubeShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::samplerCubeShadow_type);
sampler1DArrayShadow TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::sampler1DArrayShadow_type);
sampler2DArrayShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::sampler2DArrayShadow_type);
isampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::isampler1D_type);
isampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::isampler2D_type);
isampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::isampler3D_type);
isamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::isamplerCube_type);
isampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::isampler1DArray_type);
isampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::isampler2DArray_type);
usampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::usampler1D_type);
usampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::usampler2D_type);
usampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::usampler3D_type);
usamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::usamplerCube_type);
usampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::usampler1DArray_type);
usampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable, glsl_type::usampler2DArray_type);
sampler1DArrayShadow TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler1DArrayShadow_type);
sampler2DArrayShadow TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::sampler2DArrayShadow_type);
isampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler1D_type);
isampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler2D_type);
isampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler3D_type);
isamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isamplerCube_type);
isampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::isampler1DArray_type);
isampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::isampler2DArray_type);
usampler1D TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler1D_type);
usampler2D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler2D_type);
usampler3D TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler3D_type);
usamplerCube TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usamplerCube_type);
usampler1DArray TYPE_WITH_ALT(130, 300, 130, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::usampler1DArray_type);
usampler2DArray TYPE_WITH_ALT(130, 300, 130, 300, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_integer && yyextra->ctx->Extensions.EXT_texture_array, glsl_type::usampler2DArray_type);
/* additional keywords in ARB_texture_multisample, included in GLSL 1.50 */
/* these are reserved but not defined in GLSL 3.00 */
@ -656,15 +657,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 TYPE_WITH_ALT(130, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || yyextra->EXT_gpu_shader4_enable, glsl_type::samplerBuffer_type);
samplerBuffer TYPE_WITH_ALT(130, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || (yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_buffer_object), glsl_type::samplerBuffer_type);
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 TYPE_WITH_ALT(140, 300, 140, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::isampler2DRect_type);
usampler2DRect TYPE_WITH_ALT(140, 300, 140, 0, yyextra->EXT_gpu_shader4_enable, glsl_type::usampler2DRect_type);
isamplerBuffer TYPE_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || yyextra->EXT_gpu_shader4_enable, glsl_type::isamplerBuffer_type);
usamplerBuffer TYPE_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || yyextra->EXT_gpu_shader4_enable, glsl_type::usamplerBuffer_type);
isampler2DRect TYPE_WITH_ALT(140, 300, 140, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.NV_texture_rectangle && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::isampler2DRect_type);
usampler2DRect TYPE_WITH_ALT(140, 300, 140, 0, yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.NV_texture_rectangle && yyextra->ctx->Extensions.EXT_texture_integer, glsl_type::usampler2DRect_type);
isamplerBuffer TYPE_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || (yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_buffer_object && yyextra->ctx->Extensions.EXT_texture_integer), glsl_type::isamplerBuffer_type);
usamplerBuffer TYPE_WITH_ALT(140, 300, 140, 320, yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable || (yyextra->EXT_gpu_shader4_enable && yyextra->ctx->Extensions.EXT_texture_buffer_object && yyextra->ctx->Extensions.EXT_texture_integer), glsl_type::usamplerBuffer_type);
/* Additional reserved words in GLSL ES 3.00 */
resource KEYWORD(420, 300, 0, 0, RESOURCE);

View file

@ -287,7 +287,7 @@ EXT(EXT_texture3D , dummy_true
EXT(EXT_texture_array , EXT_texture_array , GLL, GLC, x , x , 2006)
EXT(EXT_texture_border_clamp , ARB_texture_border_clamp , x , x , x , ES2, 2014)
EXT(EXT_texture_buffer , OES_texture_buffer , x , x , x , 31, 2014)
EXT(EXT_texture_buffer_object , EXT_gpu_shader4 , GLL, x , x , x , 2007)
EXT(EXT_texture_buffer_object , EXT_texture_buffer_object , GLL, x , x , x , 2007)
EXT(EXT_texture_compression_bptc , ARB_texture_compression_bptc , x , x , x , 30, 2017)
EXT(EXT_texture_compression_dxt1 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2004)
EXT(EXT_texture_compression_latc , EXT_texture_compression_latc , GLL, x , x , x , 2006)

View file

@ -4281,6 +4281,7 @@ struct gl_extensions
GLboolean EXT_sRGB;
GLboolean EXT_stencil_two_side;
GLboolean EXT_texture_array;
GLboolean EXT_texture_buffer_object;
GLboolean EXT_texture_compression_latc;
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_compression_s3tc_srgb;

View file

@ -1113,6 +1113,7 @@ void st_init_extensions(struct pipe_screen *screen,
* pipe cap.
*/
extensions->EXT_gpu_shader4 = GL_TRUE;
extensions->EXT_texture_buffer_object = GL_TRUE;
if (screen->get_param(screen, PIPE_CAP_TGSI_ARRAY_COMPONENTS))
extensions->ARB_enhanced_layouts = GL_TRUE;