mesa/glformats: make _mesa_gles_error_check_format_and_type() more consistent
authorEric Engestrom <eric@engestrom.ch>
Fri, 3 Jul 2020 00:40:26 +0000 (02:40 +0200)
committerMarge Bot <eric+marge@anholt.net>
Sat, 4 Jul 2020 09:14:42 +0000 (09:14 +0000)
Let's consistently use the following code format instead of relying on
falling through to `default`:

    if (!req)
       return GL_INVALID_OPERATION;
    break;

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5729>

src/mesa/main/glformats.c

index 252599340aa05f70072f1de109888c356464fa10..1d528f4bff54b609a78600190c6980e4e687fccd 100644 (file)
@@ -2926,18 +2926,18 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
                return GL_INVALID_OPERATION;
             break;
          case GL_RGBA:
-            if (_mesa_has_OES_texture_float(ctx) && internalFormat == format)
-               break;
-         /* fallthrough */
+            if (!_mesa_has_OES_texture_float(ctx) || internalFormat != format)
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }
          break;
 
       case GL_HALF_FLOAT_OES:
-         if (_mesa_has_OES_texture_half_float(ctx) && internalFormat == format)
-            break;
-         /* fallthrough */
+         if (!_mesa_has_OES_texture_half_float(ctx) || internalFormat != format)
+            return GL_INVALID_OPERATION;
+         break;
       default:
          return GL_INVALID_OPERATION;
       }
@@ -3068,9 +3068,9 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
                return GL_INVALID_OPERATION;
             break;
          case GL_RGB:
-            if (_mesa_has_OES_texture_float(ctx) && internalFormat == format)
-               break;
-            /* fallthrough */
+            if (!_mesa_has_OES_texture_float(ctx) || internalFormat != format)
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }
@@ -3180,10 +3180,10 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
                   return GL_INVALID_OPERATION;
                break;
             case GL_RG:
-               if (_mesa_has_rg_textures(ctx) &&
-                   _mesa_has_OES_texture_half_float(ctx))
-                  break;
-            /* fallthrough */
+               if (!_mesa_has_rg_textures(ctx) ||
+                   !_mesa_has_OES_texture_half_float(ctx))
+                  return GL_INVALID_OPERATION;
+               break;
             default:
                return GL_INVALID_OPERATION;
          }
@@ -3195,10 +3195,10 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
          case GL_RG32F:
             break;
          case GL_RG:
-            if (_mesa_has_rg_textures(ctx) &&
-                _mesa_has_OES_texture_float(ctx))
-               break;
-            /* fallthrough */
+            if (!_mesa_has_rg_textures(ctx) ||
+                !_mesa_has_OES_texture_float(ctx))
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }
@@ -3288,10 +3288,10 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
             break;
          case GL_RG:
          case GL_RED:
-            if (_mesa_has_rg_textures(ctx) &&
-                _mesa_has_OES_texture_half_float(ctx))
-               break;
-            /* fallthrough */
+            if (!_mesa_has_rg_textures(ctx) ||
+                !_mesa_has_OES_texture_half_float(ctx))
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }
@@ -3303,10 +3303,10 @@ _mesa_gles_error_check_format_and_type(const struct gl_context *ctx,
          case GL_R32F:
             break;
          case GL_RED:
-            if (_mesa_has_rg_textures(ctx) &&
-                _mesa_has_OES_texture_float(ctx))
-               break;
-            /* fallthrough */
+            if (!_mesa_has_rg_textures(ctx) ||
+                !_mesa_has_OES_texture_float(ctx))
+               return GL_INVALID_OPERATION;
+            break;
          default:
             return GL_INVALID_OPERATION;
          }