From: Tapani Pälli Date: Thu, 24 May 2018 11:05:27 +0000 (+0300) Subject: mesa: enable EXT_render_snorm extension X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0d356cf4781bece0dc9a7b84b4b38c45cb2e4eaa;p=mesa.git mesa: enable EXT_render_snorm extension Patch sets additional formats renderable and enables the extension when OpenGL ES 3.1 is supported. v2: instead of dummy_true, have a separate toggle for extension (Eric Anholt) v3: add missing checks, simplify some existing checks and fix glCopyTexImage2D check (Nanley Chery) add SHORT and BYTE support in read_pixels_es3_error_check Signed-off-by: Tapani Pälli Reviewed-by: Nanley Chery --- diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index bdba49d5380..af5ce118da4 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -247,6 +247,7 @@ EXT(EXT_polygon_offset_clamp , ARB_polygon_offset_clamp EXT(EXT_primitive_bounding_box , OES_primitive_bounding_box , x , x , x , 31, 2014) EXT(EXT_provoking_vertex , EXT_provoking_vertex , GLL, GLC, x , x , 2009) EXT(EXT_read_format_bgra , dummy_true , x , x , ES1, ES2, 2009) +EXT(EXT_render_snorm , EXT_render_snorm , x , x , x, 31, 2014) EXT(EXT_rescale_normal , dummy_true , GLL, x , x , x , 1997) EXT(EXT_robustness , KHR_robustness , x, x, x , ES2, 2011) EXT(EXT_secondary_color , dummy_true , GLL, x , x , x , 1999) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index c14c9f4047b..284990d7d00 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -729,7 +729,15 @@ is_format_color_renderable(const struct gl_context *ctx, mesa_format format, /* Reject additional cases for GLES */ switch (internalFormat) { + case GL_R8_SNORM: + case GL_RG8_SNORM: case GL_RGBA8_SNORM: + return _mesa_has_EXT_render_snorm(ctx); + case GL_R16_SNORM: + case GL_RG16_SNORM: + case GL_RGBA16_SNORM: + return _mesa_has_EXT_texture_norm16(ctx) && + _mesa_has_EXT_render_snorm(ctx); case GL_RGB32F: case GL_RGB32I: case GL_RGB32UI: @@ -742,8 +750,6 @@ is_format_color_renderable(const struct gl_context *ctx, mesa_format format, case GL_SRGB8: case GL_RGB10: case GL_RGB9_E5: - case GL_RG8_SNORM: - case GL_R8_SNORM: return GL_FALSE; default: break; @@ -2060,25 +2066,40 @@ _mesa_base_fbo_format(const struct gl_context *ctx, GLenum internalFormat) return ctx->API != API_OPENGLES && ctx->Extensions.ARB_texture_rg ? GL_RG : 0; /* signed normalized texture formats */ - case GL_RED_SNORM: case GL_R8_SNORM: + return _mesa_has_EXT_texture_snorm(ctx) || _mesa_has_EXT_render_snorm(ctx) + ? GL_RED : 0; + case GL_RED_SNORM: + return _mesa_has_EXT_texture_snorm(ctx) ? GL_RED : 0; case GL_R16_SNORM: - return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm + return _mesa_has_EXT_texture_snorm(ctx) || + (_mesa_has_EXT_render_snorm(ctx) && + _mesa_has_EXT_texture_norm16(ctx)) ? GL_RED : 0; - case GL_RG_SNORM: case GL_RG8_SNORM: + return _mesa_has_EXT_texture_snorm(ctx) || _mesa_has_EXT_render_snorm(ctx) + ? GL_RG : 0; + case GL_RG_SNORM: + _mesa_has_EXT_texture_snorm(ctx) ? GL_RG : 0; case GL_RG16_SNORM: - return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm + return _mesa_has_EXT_texture_snorm(ctx) || + (_mesa_has_EXT_render_snorm(ctx) && + _mesa_has_EXT_texture_norm16(ctx)) ? GL_RG : 0; case GL_RGB_SNORM: case GL_RGB8_SNORM: case GL_RGB16_SNORM: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm ? GL_RGB : 0; - case GL_RGBA_SNORM: case GL_RGBA8_SNORM: + return _mesa_has_EXT_texture_snorm(ctx) || _mesa_has_EXT_render_snorm(ctx) + ? GL_RGBA : 0; + case GL_RGBA_SNORM: + return _mesa_has_EXT_texture_snorm(ctx) ? GL_RGBA : 0; case GL_RGBA16_SNORM: - return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm + return _mesa_has_EXT_texture_snorm(ctx) || + (_mesa_has_EXT_render_snorm(ctx) && + _mesa_has_EXT_texture_norm16(ctx)) ? GL_RGBA : 0; case GL_ALPHA_SNORM: case GL_ALPHA8_SNORM: diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 667020c193c..bbeb6034dd7 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -3794,6 +3794,15 @@ _mesa_is_es3_color_renderable(const struct gl_context *ctx, case GL_RG16: case GL_RGBA16: return _mesa_has_EXT_texture_norm16(ctx); + case GL_R8_SNORM: + case GL_RG8_SNORM: + case GL_RGBA8_SNORM: + return _mesa_has_EXT_render_snorm(ctx); + case GL_R16_SNORM: + case GL_RG16_SNORM: + case GL_RGBA16_SNORM: + return _mesa_has_EXT_texture_norm16(ctx) && + _mesa_has_EXT_render_snorm(ctx); default: return false; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6c8724dca5b..50ef898fc4c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4223,6 +4223,7 @@ struct gl_extensions GLboolean EXT_pixel_buffer_object; GLboolean EXT_point_parameters; GLboolean EXT_provoking_vertex; + GLboolean EXT_render_snorm; GLboolean EXT_semaphore; GLboolean EXT_semaphore_fd; GLboolean EXT_shader_integer_mix; diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index e8c28d86162..2cbb578a37f 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -939,6 +939,25 @@ read_pixels_es3_error_check(struct gl_context *ctx, GLenum format, GLenum type, return GL_NO_ERROR; } } + if (type == GL_SHORT) { + switch (internalFormat) { + case GL_R16_SNORM: + case GL_RG16_SNORM: + case GL_RGBA16_SNORM: + if (_mesa_has_EXT_texture_norm16(ctx) && + _mesa_has_EXT_render_snorm(ctx)) + return GL_NO_ERROR; + } + } + if (type == GL_BYTE) { + switch (internalFormat) { + case GL_R8_SNORM: + case GL_RG8_SNORM: + case GL_RGBA8_SNORM: + if (_mesa_has_EXT_render_snorm(ctx)) + return GL_NO_ERROR; + } + } break; case GL_BGRA: /* GL_EXT_read_format_bgra */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 730ec888431..d45854bd17f 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2468,7 +2468,8 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, * types for SNORM formats. Also, conversion to SNORM formats is not * allowed by Table 3.2 on Page 110. */ - if (_mesa_is_enum_format_snorm(internalFormat)) { + if (!_mesa_has_EXT_render_snorm(ctx) && + _mesa_is_enum_format_snorm(internalFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexImage%dD(internalFormat=%s)", dimensions, _mesa_enum_to_string(internalFormat));