mesa/glformats: make _mesa_gles_error_check_format_and_type() more consistent
[mesa.git] / 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;
          }