[Mesa-dev] [PATCH 5/5] mesa: Expose GL_OES_required_internalformat on GLES contexts.
Eric Anholt
eric at anholt.net
Tue May 2 19:33:07 UTC 2017
This extension is effectively a backport of GLES3's internalformat
handling to GLES 1/2. It guarantees that sized internalformats specified
for textures and renderbuffers have at least the specified size stored.
That's a pretty minimal requirement, so I think it can be dummy_true and
exposed as a standard in Mesa.
As a side effect, it also allows GL_RGB565 to be specified as a texture
format, not just as a renderbuffer. Mesa had previously been allowing 565
textures, which angered DEQP in the absence of this extension being
exposed.
---
docs/features.txt | 2 +-
src/mesa/main/extensions_table.h | 1 +
src/mesa/main/glformats.c | 78 ++++++++++++++++++++++++++++++++++------
src/mesa/main/teximage.c | 31 +++++-----------
4 files changed, 79 insertions(+), 33 deletions(-)
diff --git a/docs/features.txt b/docs/features.txt
index e18bf54a4870..e8358a6885e7 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -311,7 +311,7 @@ Khronos, ARB, and OES extensions that are not part of any OpenGL or OpenGL ES ve
GL_OES_depth_texture_cube_map DONE (all drivers that support GLSL 1.30+)
GL_OES_EGL_image DONE (all drivers)
GL_OES_EGL_image_external_essl3 not started
- GL_OES_required_internalformat not started - GLES2 extension based on OpenGL ES 3.0 feature
+ GL_OES_required_internalformat DONE (all drivers)
GL_OES_surfaceless_context DONE (all drivers)
GL_OES_texture_compression_astc DONE (core only)
GL_OES_texture_float DONE (i965, r300, r600, radeonsi, nv30, nv50, nvc0, softpipe, llvmpipe)
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index fdc163aadb3a..65048d53f52a 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -371,6 +371,7 @@ EXT(OES_point_sprite , ARB_point_sprite
EXT(OES_primitive_bounding_box , OES_primitive_bounding_box , x , x , x , 31, 2014)
EXT(OES_query_matrix , dummy_true , x , x , ES1, x , 2003)
EXT(OES_read_format , dummy_true , GLL, x , ES1, x , 2003)
+EXT(OES_required_internalformat , dummy_true , x , x , ES1, ES2, 2012)
EXT(OES_rgb8_rgba8 , dummy_true , x , x , ES1, ES2, 2005)
EXT(OES_sample_shading , OES_sample_variables , x , x , x , 30, 2014)
EXT(OES_sample_variables , OES_sample_variables , x , x , x , 30, 2014)
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 4f240206ff45..e4a981aee233 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2778,7 +2778,7 @@ _mesa_es3_effective_internal_format_for_format_and_type(GLenum format,
/**
* Do error checking of format/type combinations for OpenGL ES 3
- * glTex[Sub]Image.
+ * glTex[Sub]Image, or ES1/ES2 with GL_OES_required_internalformat.
* \return error code, or GL_NO_ERROR.
*/
GLenum
@@ -2841,7 +2841,10 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
case GL_RGBA8:
case GL_RGB5_A1:
case GL_RGBA4:
+ break;
case GL_SRGB8_ALPHA8_EXT:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
break;
default:
return GL_INVALID_OPERATION;
@@ -2849,7 +2852,7 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_BYTE:
- if (internalFormat != GL_RGBA8_SNORM)
+ if (ctx->Version <= 20 || internalFormat != GL_RGBA8_SNORM)
return GL_INVALID_OPERATION;
break;
@@ -2885,11 +2888,13 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_HALF_FLOAT:
- if (internalFormat != GL_RGBA16F)
+ if (ctx->Version <= 20 || internalFormat != GL_RGBA16F)
return GL_INVALID_OPERATION;
break;
case GL_FLOAT:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (internalFormat) {
case GL_RGBA16F:
case GL_RGBA32F:
@@ -2903,6 +2908,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_HALF_FLOAT_OES:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
if (ctx->Extensions.OES_texture_half_float && internalFormat == format)
break;
default:
@@ -2911,6 +2918,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RGBA_INTEGER:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
if (internalFormat != GL_RGBA8UI)
@@ -2959,7 +2968,10 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
case GL_RGB:
case GL_RGB8:
case GL_RGB565:
+ break;
case GL_SRGB8:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
break;
default:
return GL_INVALID_OPERATION;
@@ -2967,7 +2979,7 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_BYTE:
- if (internalFormat != GL_RGB8_SNORM)
+ if (ctx->Version <= 20 || internalFormat != GL_RGB8_SNORM)
return GL_INVALID_OPERATION;
break;
@@ -2982,16 +2994,18 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
- if (internalFormat != GL_R11F_G11F_B10F)
+ if (ctx->Version <= 20 || internalFormat != GL_R11F_G11F_B10F)
return GL_INVALID_OPERATION;
break;
case GL_UNSIGNED_INT_5_9_9_9_REV:
- if (internalFormat != GL_RGB9_E5)
+ if (ctx->Version <= 20 || internalFormat != GL_RGB9_E5)
return GL_INVALID_OPERATION;
break;
case GL_HALF_FLOAT:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (internalFormat) {
case GL_RGB16F:
case GL_R11F_G11F_B10F:
@@ -3003,6 +3017,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_FLOAT:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (internalFormat) {
case GL_RGB16F:
case GL_RGB32F:
@@ -3018,6 +3034,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_HALF_FLOAT_OES:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
if (!ctx->Extensions.OES_texture_half_float || internalFormat != format)
return GL_INVALID_OPERATION;
break;
@@ -3026,6 +3044,16 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
switch (internalFormat) {
case GL_RGB: /* GL_EXT_texture_type_2_10_10_10_REV */
break;
+ case GL_RGB10_EXT:
+ case GL_RGB8:
+ case GL_RGB565:
+ /* These seem like an odd combination to allow, but it's line 3 of
+ * Table 3.4 in the GL_OES_required_internalformat spec. GLES3
+ * doesn't do this.
+ */
+ if (ctx->Version > 20)
+ return GL_INVALID_OPERATION;
+ break;
default:
return GL_INVALID_OPERATION;
}
@@ -3037,6 +3065,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RGB_INTEGER:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
if (internalFormat != GL_RGB8UI)
@@ -3074,6 +3104,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RG:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
if (internalFormat != GL_RG8)
@@ -3121,6 +3153,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RG_INTEGER:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
if (internalFormat != GL_RG8UI)
@@ -3158,6 +3192,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RED:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
if (internalFormat != GL_R8)
@@ -3206,6 +3242,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_RED_INTEGER:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
switch (type) {
case GL_UNSIGNED_BYTE:
if (internalFormat != GL_R8UI)
@@ -3262,7 +3300,7 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_FLOAT:
- if (internalFormat != GL_DEPTH_COMPONENT32F)
+ if (ctx->Version <= 20 || internalFormat != GL_DEPTH_COMPONENT32F)
return GL_INVALID_OPERATION;
break;
@@ -3280,7 +3318,7 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
break;
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
- if (internalFormat != GL_DEPTH32F_STENCIL8)
+ if (ctx->Version <= 20 || internalFormat != GL_DEPTH32F_STENCIL8)
return GL_INVALID_OPERATION;
break;
@@ -3302,14 +3340,34 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
case GL_LUMINANCE_ALPHA:
switch (type) {
case GL_FLOAT:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
if (ctx->Extensions.OES_texture_float && internalFormat == format)
break;
case GL_HALF_FLOAT_OES:
+ if (ctx->Version <= 20)
+ return GL_INVALID_OPERATION;
if (ctx->Extensions.OES_texture_half_float && internalFormat == format)
break;
- default:
- if (type != GL_UNSIGNED_BYTE || format != internalFormat)
+ case GL_LUMINANCE_ALPHA:
+ if (type != GL_UNSIGNED_BYTE ||
+ !(internalFormat == GL_LUMINANCE_ALPHA ||
+ (ctx->Version <= 20 &&
+ internalFormat == GL_LUMINANCE8_ALPHA8)))
return GL_INVALID_OPERATION;
+ break;
+ case GL_LUMINANCE:
+ if (type != GL_UNSIGNED_BYTE || !(internalFormat == GL_LUMINANCE ||
+ (ctx->Version <= 20 &&
+ internalFormat == GL_LUMINANCE8)))
+ return GL_INVALID_OPERATION;
+ break;
+ case GL_ALPHA:
+ if (type != GL_UNSIGNED_BYTE || !(internalFormat == GL_ALPHA ||
+ (ctx->Version <= 20 &&
+ internalFormat == GL_ALPHA8)))
+ return GL_INVALID_OPERATION;
+ break;
}
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 1a00d251324f..bb395185ccd7 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1720,28 +1720,15 @@ texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
GLenum type, GLenum internalFormat,
GLuint dimensions, const char *callerName)
{
- GLenum err;
-
- if (_mesa_is_gles3(ctx)) {
- err = _mesa_es3_error_check_format_and_type(ctx, format, type,
- internalFormat);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err,
- "%s(format = %s, type = %s, internalformat = %s)",
- callerName, _mesa_enum_to_string(format),
- _mesa_enum_to_string(type),
- _mesa_enum_to_string(internalFormat));
- return true;
- }
- }
- else {
- err = _mesa_es_error_check_format_and_type(ctx, format, type, dimensions);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err, "%s(format = %s, type = %s)",
- callerName, _mesa_enum_to_string(format),
- _mesa_enum_to_string(type));
- return true;
- }
+ GLenum err = _mesa_es3_error_check_format_and_type(ctx, format, type,
+ internalFormat);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err,
+ "%s(format = %s, type = %s, internalformat = %s)",
+ callerName, _mesa_enum_to_string(format),
+ _mesa_enum_to_string(type),
+ _mesa_enum_to_string(internalFormat));
+ return true;
}
return false;
--
2.11.0
More information about the mesa-dev
mailing list