mesa/main: clean up integer texture check
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 15 Nov 2018 15:46:36 +0000 (16:46 +0100)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 3 Dec 2018 17:16:44 +0000 (18:16 +0100)
This makes the logic a little bit easier to follow, and reduce a bit of
repetition.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/main/context.h
src/mesa/main/glformats.c

index d8a548f1b1b69c37d70a1f9da8cb591e9f6e0869..d4fe774577e60da7860933ccefa75f84aa68b3f4 100644 (file)
@@ -337,6 +337,12 @@ _mesa_is_no_error_enabled(const struct gl_context *ctx)
 }
 
 
+static inline bool
+_mesa_has_integer_textures(const struct gl_context *ctx)
+{
+   return _mesa_has_EXT_texture_integer(ctx) || _mesa_is_gles3(ctx);
+}
+
 /**
  * Checks if the context supports geometry shaders.
  */
index 4bd2f9d7e2300f51c7c3029cfdbf4c1dd471e1fb..41e7393a46df72b785b517e0a085cd649df8cbf7 100644 (file)
@@ -2076,8 +2076,7 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_UNSIGNED_SHORT:
             case GL_INT:
             case GL_UNSIGNED_INT:
-               return (ctx->Version >= 30 ||
-                       ctx->Extensions.EXT_texture_integer)
+               return _mesa_has_integer_textures(ctx)
                   ? GL_NO_ERROR : GL_INVALID_ENUM;
             default:
                return GL_INVALID_ENUM;
@@ -2091,8 +2090,7 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_UNSIGNED_SHORT:
             case GL_INT:
             case GL_UNSIGNED_INT:
-               return (ctx->Version >= 30 ||
-                       ctx->Extensions.EXT_texture_integer)
+               return _mesa_has_integer_textures(ctx)
                   ? GL_NO_ERROR : GL_INVALID_ENUM;
             case GL_UNSIGNED_BYTE_3_3_2:
             case GL_UNSIGNED_BYTE_2_3_3_REV:
@@ -2113,8 +2111,7 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_INT:
             case GL_UNSIGNED_INT:
             /* NOTE: no packed formats w/ BGR format */
-               return (ctx->Version >= 30 ||
-                       ctx->Extensions.EXT_texture_integer)
+               return _mesa_has_integer_textures(ctx)
                   ? GL_NO_ERROR : GL_INVALID_ENUM;
             default:
                return GL_INVALID_ENUM;
@@ -2129,8 +2126,7 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_UNSIGNED_SHORT:
             case GL_INT:
             case GL_UNSIGNED_INT:
-               return (ctx->Version >= 30 ||
-                       ctx->Extensions.EXT_texture_integer)
+               return _mesa_has_integer_textures(ctx)
                   ? GL_NO_ERROR : GL_INVALID_ENUM;
             case GL_UNSIGNED_SHORT_4_4_4_4:
             case GL_UNSIGNED_SHORT_4_4_4_4_REV:
@@ -2493,8 +2489,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat)
       }
    }
 
-   if (ctx->Version >= 30 ||
-       ctx->Extensions.EXT_texture_integer) {
+   if (_mesa_has_integer_textures(ctx)) {
       switch (internalFormat) {
       case GL_RGBA8UI_EXT:
       case GL_RGBA16UI_EXT:
@@ -2568,9 +2563,9 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat)
       case GL_R16UI:
       case GL_R32I:
       case GL_R32UI:
-        if (ctx->Version < 30 && !ctx->Extensions.EXT_texture_integer)
-           break;
-        /* FALLTHROUGH */
+         if (!_mesa_has_integer_textures(ctx))
+            break;
+         /* FALLTHROUGH */
       case GL_R8:
       case GL_R16:
       case GL_RED:
@@ -2588,9 +2583,9 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat)
       case GL_RG16UI:
       case GL_RG32I:
       case GL_RG32UI:
-        if (ctx->Version < 30 && !ctx->Extensions.EXT_texture_integer)
-           break;
-        /* FALLTHROUGH */
+         if (!_mesa_has_integer_textures(ctx))
+            break;
+         /* FALLTHROUGH */
       case GL_RG:
       case GL_RG8:
       case GL_RG16: