main: Added entry points for glTextureSubImage*D.
[mesa.git] / src / mesa / main / glformats.c
index 7969f77a4e31730a470f53457513cbffcb3b00f0..00478f989a68c6e9c451cfbc3b3e60e644c78f29 100644 (file)
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 
@@ -188,8 +189,6 @@ _mesa_components_in_format(GLenum format)
    case GL_RG:
    case GL_YCBCR_MESA:
    case GL_DEPTH_STENCIL_EXT:
-   case GL_DUDV_ATI:
-   case GL_DU8DV8_ATI:
    case GL_RG_INTEGER:
       return 2;
 
@@ -344,11 +343,180 @@ _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type)
          return sizeof(GLuint);
       else
          return -1;
+   case GL_UNSIGNED_INT_10F_11F_11F_REV:
+      if (comps == 3)
+         return sizeof(GLuint);
+      else
+         return -1;
    default:
       return -1;
    }
 }
 
+/**
+ * Test if the given format is unsized.
+ */
+GLboolean
+_mesa_is_enum_format_unsized(GLenum format)
+{
+   switch (format) {
+   case GL_RGBA:
+   case GL_BGRA:
+   case GL_ABGR_EXT:
+   case GL_RGB:
+   case GL_BGR:
+   case GL_RG:
+   case GL_RED:
+   case GL_GREEN:
+   case GL_BLUE:
+   case GL_ALPHA:
+   case GL_INTENSITY:
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_ALPHA:
+
+   case GL_SRGB:
+   case GL_SRGB_ALPHA:
+   case GL_SLUMINANCE:
+   case GL_SLUMINANCE_ALPHA:
+
+   case GL_RGBA_SNORM:
+   case GL_RGB_SNORM:
+   case GL_RG_SNORM:
+   case GL_RED_SNORM:
+   case GL_ALPHA_SNORM:
+   case GL_INTENSITY_SNORM:
+   case GL_LUMINANCE_SNORM:
+   case GL_LUMINANCE_ALPHA_SNORM:
+
+   case GL_RED_INTEGER:
+   case GL_GREEN_INTEGER:
+   case GL_BLUE_INTEGER:
+   case GL_ALPHA_INTEGER:
+   case GL_RGB_INTEGER:
+   case GL_RGBA_INTEGER:
+   case GL_BGR_INTEGER:
+   case GL_BGRA_INTEGER:
+   case GL_RG_INTEGER:
+   case GL_LUMINANCE_INTEGER_EXT:
+   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+
+   case GL_DEPTH_COMPONENT:
+   case GL_DEPTH_STENCIL:
+   case GL_STENCIL_INDEX:
+      return GL_TRUE;
+   default:
+      return GL_FALSE;
+   }
+}
+
+/**
+ * Test if the given format is a UNORM (unsigned-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_unorm(GLenum format)
+{
+      switch(format) {
+      case GL_RED:
+      case GL_GREEN:
+      case GL_BLUE:
+      case GL_ALPHA:
+      case GL_ALPHA4:
+      case GL_ALPHA8:
+      case GL_ALPHA12:
+      case GL_ALPHA16:
+      case 1:
+      case GL_LUMINANCE:
+      case GL_SLUMINANCE:
+      case GL_LUMINANCE4:
+      case GL_LUMINANCE8:
+      case GL_LUMINANCE12:
+      case GL_LUMINANCE16:
+      case 2:
+      case GL_LUMINANCE_ALPHA:
+      case GL_SLUMINANCE_ALPHA:
+      case GL_LUMINANCE4_ALPHA4:
+      case GL_LUMINANCE6_ALPHA2:
+      case GL_LUMINANCE8_ALPHA8:
+      case GL_LUMINANCE12_ALPHA4:
+      case GL_LUMINANCE12_ALPHA12:
+      case GL_LUMINANCE16_ALPHA16:
+      case GL_INTENSITY:
+      case GL_INTENSITY4:
+      case GL_INTENSITY8:
+      case GL_INTENSITY12:
+      case GL_INTENSITY16:
+      case GL_R8:
+      case GL_R16:
+      case GL_RG:
+      case GL_RG8:
+      case GL_RG16:
+      case 3:
+      case GL_RGB:
+      case GL_BGR:
+      case GL_SRGB:
+      case GL_R3_G3_B2:
+      case GL_RGB4:
+      case GL_RGB5:
+      case GL_RGB565:
+      case GL_RGB8:
+      case GL_RGB10:
+      case GL_RGB12:
+      case GL_RGB16:
+      case 4:
+      case GL_ABGR_EXT:
+      case GL_RGBA:
+      case GL_BGRA:
+      case GL_SRGB_ALPHA:
+      case GL_RGBA2:
+      case GL_RGBA4:
+      case GL_RGB5_A1:
+      case GL_RGBA8:
+      case GL_RGB10_A2:
+      case GL_RGBA12:
+      case GL_RGBA16:
+         return GL_TRUE;
+      default:
+         return GL_FALSE;
+   }
+}
+
+/**
+ * Test if the given format is a SNORM (signed-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_snorm(GLenum format)
+{
+   switch (format) {
+   /* signed, normalized texture formats */
+   case GL_RED_SNORM:
+   case GL_R8_SNORM:
+   case GL_R16_SNORM:
+   case GL_RG_SNORM:
+   case GL_RG8_SNORM:
+   case GL_RG16_SNORM:
+   case GL_RGB_SNORM:
+   case GL_RGB8_SNORM:
+   case GL_RGB16_SNORM:
+   case GL_RGBA_SNORM:
+   case GL_RGBA8_SNORM:
+   case GL_RGBA16_SNORM:
+   case GL_ALPHA_SNORM:
+   case GL_ALPHA8_SNORM:
+   case GL_ALPHA16_SNORM:
+   case GL_LUMINANCE_SNORM:
+   case GL_LUMINANCE8_SNORM:
+   case GL_LUMINANCE16_SNORM:
+   case GL_LUMINANCE_ALPHA_SNORM:
+   case GL_LUMINANCE8_ALPHA8_SNORM:
+   case GL_LUMINANCE16_ALPHA16_SNORM:
+   case GL_INTENSITY_SNORM:
+   case GL_INTENSITY8_SNORM:
+   case GL_INTENSITY16_SNORM:
+      return GL_TRUE;
+   default:
+      return GL_FALSE;
+   }
+}
 
 /**
  * Test if the given format is an integer (non-normalized) format.
@@ -452,36 +620,6 @@ _mesa_is_enum_format_integer(GLenum format)
 }
 
 
-/**
- * Test if the given type is an integer (non-normalized) format.
- */
-GLboolean
-_mesa_is_type_integer(GLenum type)
-{
-   switch (type) {
-   case GL_INT:
-   case GL_UNSIGNED_INT:
-   case GL_SHORT:
-   case GL_UNSIGNED_SHORT:
-   case GL_BYTE:
-   case GL_UNSIGNED_BYTE:
-      return GL_TRUE;
-   default:
-      return GL_FALSE;
-   }
-}
-
-
-/**
- * Test if the given format or type is an integer (non-normalized) format.
- */
-extern GLboolean
-_mesa_is_enum_format_or_type_integer(GLenum format, GLenum type)
-{
-   return _mesa_is_enum_format_integer(format) || _mesa_is_type_integer(type);
-}
-
-
 GLboolean
 _mesa_is_type_unsigned(GLenum type)
 {
@@ -649,6 +787,10 @@ _mesa_is_color_format(GLenum format)
       case GL_COMPRESSED_SIGNED_RG11_EAC:
       case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
       case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+      case GL_COMPRESSED_RGBA_BPTC_UNORM:
+      case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
+      case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
+      case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
       /* generic integer formats */
       case GL_RED_INTEGER_EXT:
       case GL_GREEN_INTEGER_EXT:
@@ -840,22 +982,6 @@ _mesa_is_depth_or_stencil_format(GLenum format)
 }
 
 
-/**
- * Test if the given image format is a dudv format.
- */
-GLboolean
-_mesa_is_dudv_format(GLenum format)
-{
-   switch (format) {
-      case GL_DUDV_ATI:
-      case GL_DU8DV8_ATI:
-         return GL_TRUE;
-      default:
-         return GL_FALSE;
-   }
-}
-
-
 /**
  * Test if an image format is a supported compressed format.
  * \param format the internal format token provided by the user.
@@ -867,18 +993,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
    switch (format) {
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return ctx->Extensions.EXT_texture_compression_s3tc;
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return (_mesa_is_desktop_gl(ctx) &&
-             ctx->Extensions.EXT_texture_compression_s3tc) ||
-            (ctx->API == API_OPENGLES2 &&
-             ctx->Extensions.ANGLE_texture_compression_dxt);
+      /* Assume that the ANGLE flag will always be set if the EXT flag is set.
+       */
+      return ctx->Extensions.ANGLE_texture_compression_dxt;
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
-      return _mesa_is_desktop_gl(ctx) && ctx->Extensions.S3_s3tc;
+      return _mesa_is_desktop_gl(ctx) &&
+         ctx->Extensions.ANGLE_texture_compression_dxt;
    case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
@@ -918,7 +1043,13 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
    case GL_COMPRESSED_SIGNED_RG11_EAC:
    case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
    case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
-      return _mesa_is_gles3(ctx);
+      return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility;
+   case GL_COMPRESSED_RGBA_BPTC_UNORM:
+   case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
+   case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
+   case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
+      return _mesa_is_desktop_gl(ctx) &&
+         ctx->Extensions.ARB_texture_compression_bptc;
    case GL_PALETTE4_RGB8_OES:
    case GL_PALETTE4_RGBA8_OES:
    case GL_PALETTE4_R5_G6_B5_OES:
@@ -1131,76 +1262,60 @@ GLenum
 _mesa_get_nongeneric_internalformat(GLenum format)
 {
    switch (format) {
-      /* GL 1.1 formats. */
-      case 4:
-      case GL_RGBA:
-         return GL_RGBA8;
-
-      case 3:
-      case GL_RGB:
-         return GL_RGB8;
-
-      case 2:
-      case GL_LUMINANCE_ALPHA:
-         return GL_LUMINANCE8_ALPHA8;
-
-      case 1:
-      case GL_LUMINANCE:
-         return GL_LUMINANCE8;
-
-      case GL_ALPHA:
-         return GL_ALPHA8;
-
-      case GL_INTENSITY:
-         return GL_INTENSITY8;
-
-      /* GL_ARB_texture_rg */
-      case GL_RED:
-         return GL_R8;
-
-      case GL_RG:
-         return GL_RG8;
-
-      /* GL_EXT_texture_sRGB */
-      case GL_SRGB:
-         return GL_SRGB8;
-
-      case GL_SRGB_ALPHA:
-         return GL_SRGB8_ALPHA8;
-
-      case GL_SLUMINANCE:
-         return GL_SLUMINANCE8;
-
-      case GL_SLUMINANCE_ALPHA:
-         return GL_SLUMINANCE8_ALPHA8;
-
-      /* GL_EXT_texture_snorm */
-      case GL_RGBA_SNORM:
-         return GL_RGBA8_SNORM;
-
-      case GL_RGB_SNORM:
-         return GL_RGB8_SNORM;
-
-      case GL_RG_SNORM:
-         return GL_RG8_SNORM;
-
-      case GL_RED_SNORM:
-         return GL_R8_SNORM;
-
-      case GL_LUMINANCE_ALPHA_SNORM:
-         return GL_LUMINANCE8_ALPHA8_SNORM;
-
-      case GL_LUMINANCE_SNORM:
-         return GL_LUMINANCE8_SNORM;
+   /* GL 1.1 formats. */
+   case 4:
+   case GL_RGBA:
+      return GL_RGBA8;
+   case 3:
+   case GL_RGB:
+      return GL_RGB8;
+   case 2:
+   case GL_LUMINANCE_ALPHA:
+      return GL_LUMINANCE8_ALPHA8;
+   case 1:
+   case GL_LUMINANCE:
+      return GL_LUMINANCE8;
+   case GL_ALPHA:
+      return GL_ALPHA8;
+   case GL_INTENSITY:
+      return GL_INTENSITY8;
 
-      case GL_ALPHA_SNORM:
-         return GL_ALPHA8_SNORM;
+   /* GL_ARB_texture_rg */
+   case GL_RED:
+      return GL_R8;
+   case GL_RG:
+      return GL_RG8;
 
-      case GL_INTENSITY_SNORM:
-         return GL_INTENSITY8_SNORM;
+   /* GL_EXT_texture_sRGB */
+   case GL_SRGB:
+      return GL_SRGB8;
+   case GL_SRGB_ALPHA:
+      return GL_SRGB8_ALPHA8;
+   case GL_SLUMINANCE:
+      return GL_SLUMINANCE8;
+   case GL_SLUMINANCE_ALPHA:
+      return GL_SLUMINANCE8_ALPHA8;
+
+   /* GL_EXT_texture_snorm */
+   case GL_RGBA_SNORM:
+      return GL_RGBA8_SNORM;
+   case GL_RGB_SNORM:
+      return GL_RGB8_SNORM;
+   case GL_RG_SNORM:
+      return GL_RG8_SNORM;
+   case GL_RED_SNORM:
+      return GL_R8_SNORM;
+   case GL_LUMINANCE_ALPHA_SNORM:
+      return GL_LUMINANCE8_ALPHA8_SNORM;
+   case GL_LUMINANCE_SNORM:
+      return GL_LUMINANCE8_SNORM;
+   case GL_ALPHA_SNORM:
+      return GL_ALPHA8_SNORM;
+   case GL_INTENSITY_SNORM:
+      return GL_INTENSITY8_SNORM;
 
-      default:
-         return format;
+   default:
+      return format;
    }
 }
 
@@ -1214,22 +1329,20 @@ _mesa_get_linear_internalformat(GLenum format)
    switch (format) {
    case GL_SRGB:
       return GL_RGB;
-
    case GL_SRGB_ALPHA:
       return GL_RGBA;
-
    case GL_SRGB8:
       return GL_RGB8;
-
    case GL_SRGB8_ALPHA8:
       return GL_RGBA8;
-
-   case GL_SLUMINANCE:
+   case GL_SLUMINANCE8:
       return GL_LUMINANCE8;
-
+   case GL_SLUMINANCE:
+      return GL_LUMINANCE;
    case GL_SLUMINANCE_ALPHA:
+      return GL_LUMINANCE_ALPHA;
+   case GL_SLUMINANCE8_ALPHA8:
       return GL_LUMINANCE8_ALPHA8;
-
    default:
       return format;
    }
@@ -1251,6 +1364,22 @@ GLenum
 _mesa_error_check_format_and_type(const struct gl_context *ctx,
                                   GLenum format, GLenum type)
 {
+   /* From OpenGL 3.3 spec, page 220:
+    *    "If the format is DEPTH_STENCIL, then values are taken from
+    *    both the depth buffer and the stencil buffer. If there is no
+    *    depth buffer or if there is no stencil buffer, then the error
+    *    INVALID_OPERATION occurs. If the type parameter is not
+    *    UNSIGNED_INT_24_8 or FLOAT_32_UNSIGNED_INT_24_8_REV, then the
+    *    error INVALID_ENUM occurs."
+    *
+    * OpenGL ES still generates GL_INVALID_OPERATION because glReadPixels
+    * cannot be used to read depth or stencil in that API.
+    */
+   if (_mesa_is_desktop_gl(ctx) && format == GL_DEPTH_STENCIL
+       && type != GL_UNSIGNED_INT_24_8
+       && type != GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
+      return GL_INVALID_ENUM;
+
    /* special type-based checks (see glReadPixels, glDrawPixels error lists) */
    switch (type) {
    case GL_BITMAP:
@@ -1296,9 +1425,6 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
       return GL_INVALID_OPERATION;
 
    case GL_UNSIGNED_INT_24_8:
-      if (!ctx->Extensions.EXT_packed_depth_stencil) {
-         return GL_INVALID_ENUM;
-      }
       if (format != GL_DEPTH_STENCIL) {
          return GL_INVALID_OPERATION;
       }
@@ -1339,10 +1465,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_INT:
             case GL_UNSIGNED_INT:
             case GL_FLOAT:
-               return GL_NO_ERROR;
             case GL_HALF_FLOAT:
-               return ctx->Extensions.ARB_half_float_pixel
-                  ? GL_NO_ERROR : GL_INVALID_ENUM;
+               return GL_NO_ERROR;
             default:
                return GL_INVALID_ENUM;
          }
@@ -1365,10 +1489,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_INT:
             case GL_UNSIGNED_INT:
             case GL_FLOAT:
-               return GL_NO_ERROR;
             case GL_HALF_FLOAT:
-               return ctx->Extensions.ARB_half_float_pixel
-                  ? GL_NO_ERROR : GL_INVALID_ENUM;
+               return GL_NO_ERROR;
             default:
                return GL_INVALID_ENUM;
          }
@@ -1384,10 +1506,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_INT:
             case GL_UNSIGNED_INT:
             case GL_FLOAT:
-               return GL_NO_ERROR;
             case GL_HALF_FLOAT:
-               return ctx->Extensions.ARB_half_float_pixel
-                  ? GL_NO_ERROR : GL_INVALID_ENUM;
+               return GL_NO_ERROR;
             default:
                return GL_INVALID_ENUM;
          }
@@ -1405,14 +1525,12 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_UNSIGNED_BYTE_2_3_3_REV:
             case GL_UNSIGNED_SHORT_5_6_5:
             case GL_UNSIGNED_SHORT_5_6_5_REV:
+            case GL_HALF_FLOAT:
                return GL_NO_ERROR;
             case GL_UNSIGNED_INT_2_10_10_10_REV:
                /* OK by GL_EXT_texture_type_2_10_10_10_REV */
                return (ctx->API == API_OPENGLES2)
                   ? GL_NO_ERROR : GL_INVALID_ENUM;
-            case GL_HALF_FLOAT:
-               return ctx->Extensions.ARB_half_float_pixel
-                  ? GL_NO_ERROR : GL_INVALID_ENUM;
             case GL_UNSIGNED_INT_5_9_9_9_REV:
                return ctx->Extensions.EXT_texture_shared_exponent
                   ? GL_NO_ERROR : GL_INVALID_ENUM;
@@ -1435,10 +1553,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_INT:
             case GL_UNSIGNED_INT:
             case GL_FLOAT:
-               return GL_NO_ERROR;
             case GL_HALF_FLOAT:
-               return ctx->Extensions.ARB_half_float_pixel
-                  ? GL_NO_ERROR : GL_INVALID_ENUM;
+               return GL_NO_ERROR;
             default:
                return GL_INVALID_ENUM;
          }
@@ -1462,10 +1578,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
             case GL_UNSIGNED_INT_8_8_8_8_REV:
             case GL_UNSIGNED_INT_10_10_10_2:
             case GL_UNSIGNED_INT_2_10_10_10_REV:
-               return GL_NO_ERROR;
             case GL_HALF_FLOAT:
-               return ctx->Extensions.ARB_half_float_pixel
-                  ? GL_NO_ERROR : GL_INVALID_ENUM;
+               return GL_NO_ERROR;
             default:
                return GL_INVALID_ENUM;
          }
@@ -1479,42 +1593,14 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
          else
             return GL_INVALID_OPERATION;
 
-      case GL_DEPTH_STENCIL_EXT:
-         if (ctx->Extensions.EXT_packed_depth_stencil &&
-             type == GL_UNSIGNED_INT_24_8)
+      case GL_DEPTH_STENCIL:
+         if (type == GL_UNSIGNED_INT_24_8)
             return GL_NO_ERROR;
          else if (ctx->Extensions.ARB_depth_buffer_float &&
              type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
             return GL_NO_ERROR;
-         switch (type) {
-         case GL_BYTE:
-         case GL_UNSIGNED_BYTE:
-         case GL_SHORT:
-         case GL_UNSIGNED_SHORT:
-         case GL_INT:
-         case GL_UNSIGNED_INT:
-         case GL_FLOAT:
-            return GL_INVALID_OPERATION;
-         default:
-            return GL_INVALID_ENUM;
-         }
-
-      case GL_DUDV_ATI:
-      case GL_DU8DV8_ATI:
-         if (!ctx->Extensions.ATI_envmap_bumpmap)
+         else
             return GL_INVALID_ENUM;
-         switch (type) {
-            case GL_BYTE:
-            case GL_UNSIGNED_BYTE:
-            case GL_SHORT:
-            case GL_UNSIGNED_SHORT:
-            case GL_INT:
-            case GL_UNSIGNED_INT:
-            case GL_FLOAT:
-               return GL_NO_ERROR;
-            default:
-               return GL_INVALID_ENUM;
-         }
 
       /* integer-valued formats */
       case GL_RED_INTEGER_EXT:
@@ -1697,11 +1783,8 @@ _mesa_es_error_check_format_and_type(GLenum format, GLenum type,
  */
 GLenum
 _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
-                                      GLenum internalFormat,
-                                      unsigned dimensions)
+                                      GLenum internalFormat)
 {
-   GLboolean type_valid = GL_TRUE;
-
    switch (format) {
    case GL_RGBA:
       switch (type) {
@@ -2068,17 +2151,16 @@ _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
       break;
 
    case GL_DEPTH_COMPONENT:
-      if (dimensions != 2) {
-         return GL_INVALID_OPERATION;
-      }
       switch (type) {
       case GL_UNSIGNED_SHORT:
-         if (internalFormat != GL_DEPTH_COMPONENT16)
+         if (internalFormat != GL_DEPTH_COMPONENT
+             && internalFormat != GL_DEPTH_COMPONENT16)
             return GL_INVALID_OPERATION;
          break;
 
       case GL_UNSIGNED_INT:
          switch (internalFormat) {
+         case GL_DEPTH_COMPONENT:
          case GL_DEPTH_COMPONENT16:
          case GL_DEPTH_COMPONENT24:
             break;
@@ -2098,12 +2180,10 @@ _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
       break;
 
    case GL_DEPTH_STENCIL:
-      if (dimensions != 2) {
-         return GL_INVALID_OPERATION;
-      }
       switch (type) {
       case GL_UNSIGNED_INT_24_8:
-         if (internalFormat != GL_DEPTH24_STENCIL8)
+         if (internalFormat != GL_DEPTH_STENCIL
+             && internalFormat != GL_DEPTH24_STENCIL8)
             return GL_INVALID_OPERATION;
          break;
 
@@ -2125,5 +2205,5 @@ _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
       break;
    }
 
-   return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
+   return GL_NO_ERROR;
 }