[Mesa-dev] [PATCH v3] mesa: enable EXT_render_snorm extension
Tapani Pälli
tapani.palli at intel.com
Thu Aug 2 11:14:31 UTC 2018
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 <tapani.palli at intel.com>
---
src/mesa/main/extensions_table.h | 1 +
src/mesa/main/fbobject.c | 31 +++++++++++++++++++++++--------
src/mesa/main/glformats.c | 9 +++++++++
src/mesa/main/mtypes.h | 1 +
src/mesa/main/readpix.c | 19 +++++++++++++++++++
src/mesa/main/teximage.c | 3 ++-
6 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 3f01896cae..c3a69b8987 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -246,6 +246,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 cfe2174ef1..2534b1df29 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -728,7 +728,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:
@@ -741,8 +749,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;
@@ -1997,25 +2003,34 @@ _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)
? 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)
? 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)
? 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 667020c193..bbeb6034dd 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 d71872835d..5ff23a57b1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4204,6 +4204,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 e8c28d8616..2cbb578a37 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 948c7df051..50cc4652ce 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));
--
2.14.4
More information about the mesa-dev
mailing list