diff options
author | Eric Anholt <[email protected]> | 2017-05-01 09:28:33 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2017-10-10 09:31:29 -0700 |
commit | c16a7443e9999a80bc1e87134297f96f1216d702 (patch) | |
tree | 6608a2a5e3341e15367572dcab721e4d52baee9c /src/mesa/main/glformats.c | |
parent | cee5585da7e8a164952347c8dbf72844cad85d9d (diff) |
mesa: Expose GL_OES_required_internalformat on GLES contexts.
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.
v2: Allow 2101010rev with sized internalformats even on GLES3, citing the
extension spec. Extend extension checks for GLES2 contexts exposing
with texture_float, texture_half_float, and texture_rg.
v3: Fix ALPHA/LUMINANCE/LUMINANCE_ALPHA error checking (GLES3 CTS
failures)
v4: Mark GL_RGB10 non-color-renderable on ES, fix A/L/LA errors on GLES2
with float formats.
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/main/glformats.c')
-rw-r--r-- | src/mesa/main/glformats.c | 79 |
1 files changed, 63 insertions, 16 deletions
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index aec41f07993..7b4b405a814 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -2779,7 +2779,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 @@ -2842,7 +2842,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; @@ -2850,7 +2853,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; @@ -2876,9 +2879,11 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, case GL_UNSIGNED_INT_2_10_10_10_REV: switch (internalFormat) { - case GL_RGBA: /* GL_EXT_texture_type_2_10_10_10_REV */ + case GL_RGBA: case GL_RGB10_A2: case GL_RGB5_A1: + if (!ctx->Extensions.EXT_texture_type_2_10_10_10_REV) + return GL_INVALID_OPERATION; break; default: return GL_INVALID_OPERATION; @@ -2886,7 +2891,7 @@ _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; @@ -2894,6 +2899,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, switch (internalFormat) { case GL_RGBA16F: case GL_RGBA32F: + if (ctx->Version <= 20) + return GL_INVALID_OPERATION; break; case GL_RGBA: if (ctx->Extensions.OES_texture_float && internalFormat == format) @@ -2912,6 +2919,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) @@ -2960,7 +2969,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; @@ -2968,7 +2980,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; @@ -2983,16 +2995,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: @@ -3009,6 +3023,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, case GL_RGB32F: case GL_R11F_G11F_B10F: case GL_RGB9_E5: + if (ctx->Version <= 20) + return GL_INVALID_OPERATION; break; case GL_RGB: if (ctx->Extensions.OES_texture_float && internalFormat == format) @@ -3025,7 +3041,16 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, case GL_UNSIGNED_INT_2_10_10_10_REV: switch (internalFormat) { - case GL_RGB: /* GL_EXT_texture_type_2_10_10_10_REV */ + case GL_RGB: + case GL_RGB10: + case GL_RGB8: + case GL_RGB565: + /* GL_EXT_texture_type_2_10_10_10_REV allows GL_RGB even though + * GLES3 doesn't, and GL_OES_required_internalformat extends that + * to allow the sized RGB internalformats as well. + */ + if (!ctx->Extensions.EXT_texture_type_2_10_10_10_REV) + return GL_INVALID_OPERATION; break; default: return GL_INVALID_OPERATION; @@ -3038,6 +3063,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) @@ -3075,6 +3102,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, break; case GL_RG: + if (!ctx->Extensions.ARB_texture_rg) + return GL_INVALID_OPERATION; switch (type) { case GL_UNSIGNED_BYTE: if (internalFormat != GL_RG8) @@ -3122,6 +3151,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) @@ -3159,6 +3190,8 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, break; case GL_RED: + if (!ctx->Extensions.ARB_texture_rg) + return GL_INVALID_OPERATION; switch (type) { case GL_UNSIGNED_BYTE: if (internalFormat != GL_R8) @@ -3207,6 +3240,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) @@ -3263,7 +3298,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; @@ -3281,7 +3316,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; @@ -3303,15 +3338,27 @@ _mesa_es3_error_check_format_and_type(const struct gl_context *ctx, case GL_LUMINANCE_ALPHA: switch (type) { case GL_FLOAT: - if (ctx->Extensions.OES_texture_float && internalFormat == format) - break; + if (!ctx->Extensions.OES_texture_float || internalFormat != format) + return GL_INVALID_OPERATION; + break; case GL_HALF_FLOAT_OES: - if (ctx->Extensions.OES_texture_half_float && internalFormat == format) - break; - default: - if (type != GL_UNSIGNED_BYTE || format != internalFormat) + if (!ctx->Extensions.OES_texture_half_float || internalFormat != format) return GL_INVALID_OPERATION; + break; + case GL_UNSIGNED_BYTE: + if (!(format == internalFormat || + (format == GL_ALPHA && internalFormat == GL_ALPHA8) || + (format == GL_LUMINANCE && internalFormat == GL_LUMINANCE8) || + (format == GL_LUMINANCE_ALPHA && + ((internalFormat == GL_LUMINANCE8_ALPHA8) || + (internalFormat == GL_LUMINANCE4_ALPHA4))))) { + return GL_INVALID_OPERATION; + } + break; + default: + return GL_INVALID_OPERATION; } + break; } return GL_NO_ERROR; |