Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

mesa: new _mesa_error_check_format_and_type() function

This replaces the _mesa_is_legal_format_and_type() function.

According to the spec, some invalid format/type combinations to
glDrawPixels, ReadPixels and glTexImage should generate
GL_INVALID_ENUM but others should generate GL_INVALID_OPERATION.

With the old function we didn't make that distinction and generated
GL_INVALID_ENUM errors instead of GL_INVALID_OPERATION.  The new
function returns one of those errors or GL_NO_ERROR.

This will also let us remove some redundant format/type checks in
follow-on commit.

v2: add more checks for ARB_texture_rgb10_a2ui at the top of
_mesa_error_check_format_and_type() per Ian.

Signed-off-by: Brian Paul <brianp@vmware.com>
  • Loading branch information...
commit 627b435dfe17698a1c69e9a259838fc6f2e6bd4e 1 parent 699e3b9
authored February 07, 2012
216  src/mesa/main/image.c
@@ -356,18 +356,83 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type )
356 356
 
357 357
 
358 358
 /**
359  
- * Test for a legal pixel format and type.
  359
+ * Do error checking of format/type combinations for glReadPixels,
  360
+ * glDrawPixels and glTex[Sub]Image.  Note that depending on the format
  361
+ * and type values, we may either generate GL_INVALID_OPERATION or
  362
+ * GL_INVALID_ENUM.
360 363
  *
361 364
  * \param format pixel format.
362 365
  * \param type pixel type.
363 366
  *
364  
- * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE
365  
- * otherwise.
  367
+ * \return GL_INVALID_ENUM, GL_INVALID_OPERATION or GL_NO_ERROR
366 368
  */
367  
-GLboolean
368  
-_mesa_is_legal_format_and_type(const struct gl_context *ctx,
369  
-                               GLenum format, GLenum type)
  369
+GLenum
  370
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
  371
+                                  GLenum format, GLenum type)
370 372
 {
  373
+   /* special type-based checks (see glReadPixels, glDrawPixels error lists) */
  374
+   switch (type) {
  375
+   case GL_BITMAP:
  376
+      if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) {
  377
+         return GL_INVALID_ENUM;
  378
+      }
  379
+      break;
  380
+
  381
+   case GL_UNSIGNED_BYTE_3_3_2:
  382
+   case GL_UNSIGNED_BYTE_2_3_3_REV:
  383
+   case GL_UNSIGNED_SHORT_5_6_5:
  384
+   case GL_UNSIGNED_SHORT_5_6_5_REV:
  385
+      if (format == GL_RGB) {
  386
+         break; /* OK */
  387
+      }
  388
+      if (format == GL_RGB_INTEGER_EXT &&
  389
+          ctx->Extensions.ARB_texture_rgb10_a2ui) {
  390
+         break; /* OK */
  391
+      }
  392
+      return GL_INVALID_OPERATION;
  393
+
  394
+   case GL_UNSIGNED_SHORT_4_4_4_4:
  395
+   case GL_UNSIGNED_SHORT_4_4_4_4_REV:
  396
+   case GL_UNSIGNED_SHORT_5_5_5_1:
  397
+   case GL_UNSIGNED_SHORT_1_5_5_5_REV:
  398
+   case GL_UNSIGNED_INT_8_8_8_8:
  399
+   case GL_UNSIGNED_INT_8_8_8_8_REV:
  400
+   case GL_UNSIGNED_INT_10_10_10_2:
  401
+   case GL_UNSIGNED_INT_2_10_10_10_REV:
  402
+      if (format == GL_RGBA ||
  403
+          format == GL_BGRA ||
  404
+          format == GL_ABGR_EXT) {
  405
+         break; /* OK */
  406
+      }
  407
+      if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
  408
+          ctx->Extensions.ARB_texture_rgb10_a2ui) {
  409
+         break; /* OK */
  410
+      }
  411
+      return GL_INVALID_OPERATION;
  412
+
  413
+   case GL_UNSIGNED_INT_24_8:
  414
+      if (!ctx->Extensions.EXT_packed_depth_stencil) {
  415
+         return GL_INVALID_ENUM;
  416
+      }
  417
+      if (format != GL_DEPTH_STENCIL) {
  418
+         return GL_INVALID_OPERATION;
  419
+      }
  420
+      return GL_NO_ERROR;
  421
+
  422
+   case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
  423
+      if (!ctx->Extensions.ARB_depth_buffer_float) {
  424
+         return GL_INVALID_ENUM;
  425
+      }
  426
+      if (format != GL_DEPTH_STENCIL) {
  427
+         return GL_INVALID_OPERATION;
  428
+      }
  429
+      return GL_NO_ERROR;
  430
+
  431
+   default:
  432
+      ; /* fall-through */
  433
+   }
  434
+
  435
+   /* now, for each format, check the type for compatibility */
371 436
    switch (format) {
372 437
       case GL_COLOR_INDEX:
373 438
       case GL_STENCIL_INDEX:
@@ -380,12 +445,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
380 445
             case GL_INT:
381 446
             case GL_UNSIGNED_INT:
382 447
             case GL_FLOAT:
383  
-               return GL_TRUE;
384  
-            case GL_HALF_FLOAT_ARB:
385  
-               return ctx->Extensions.ARB_half_float_pixel;
  448
+               return GL_NO_ERROR;
  449
+            case GL_HALF_FLOAT:
  450
+               return ctx->Extensions.ARB_half_float_pixel
  451
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
386 452
             default:
387  
-               return GL_FALSE;
  453
+               return GL_INVALID_ENUM;
388 454
          }
  455
+
389 456
       case GL_RED:
390 457
       case GL_GREEN:
391 458
       case GL_BLUE:
@@ -404,16 +471,17 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
404 471
             case GL_INT:
405 472
             case GL_UNSIGNED_INT:
406 473
             case GL_FLOAT:
407  
-               return GL_TRUE;
408  
-            case GL_HALF_FLOAT_ARB:
409  
-               return ctx->Extensions.ARB_half_float_pixel;
  474
+               return GL_NO_ERROR;
  475
+            case GL_HALF_FLOAT:
  476
+               return ctx->Extensions.ARB_half_float_pixel
  477
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
410 478
             default:
411  
-               return GL_FALSE;
  479
+               return GL_INVALID_ENUM;
412 480
          }
  481
+
413 482
       case GL_RG:
414 483
 	 if (!ctx->Extensions.ARB_texture_rg)
415  
-	    return GL_FALSE;
416  
-
  484
+	    return GL_INVALID_ENUM;
417 485
          switch (type) {
418 486
             case GL_BYTE:
419 487
             case GL_UNSIGNED_BYTE:
@@ -422,12 +490,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
422 490
             case GL_INT:
423 491
             case GL_UNSIGNED_INT:
424 492
             case GL_FLOAT:
425  
-               return GL_TRUE;
426  
-            case GL_HALF_FLOAT_ARB:
427  
-               return ctx->Extensions.ARB_half_float_pixel;
  493
+               return GL_NO_ERROR;
  494
+            case GL_HALF_FLOAT:
  495
+               return ctx->Extensions.ARB_half_float_pixel
  496
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
428 497
             default:
429  
-               return GL_FALSE;
  498
+               return GL_INVALID_ENUM;
430 499
          }
  500
+
431 501
       case GL_RGB:
432 502
          switch (type) {
433 503
             case GL_BYTE:
@@ -441,16 +511,20 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
441 511
             case GL_UNSIGNED_BYTE_2_3_3_REV:
442 512
             case GL_UNSIGNED_SHORT_5_6_5:
443 513
             case GL_UNSIGNED_SHORT_5_6_5_REV:
444  
-               return GL_TRUE;
445  
-            case GL_HALF_FLOAT_ARB:
446  
-               return ctx->Extensions.ARB_half_float_pixel;
  514
+               return GL_NO_ERROR;
  515
+            case GL_HALF_FLOAT:
  516
+               return ctx->Extensions.ARB_half_float_pixel
  517
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
447 518
             case GL_UNSIGNED_INT_5_9_9_9_REV:
448  
-               return ctx->Extensions.EXT_texture_shared_exponent;
  519
+               return ctx->Extensions.EXT_texture_shared_exponent
  520
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
449 521
             case GL_UNSIGNED_INT_10F_11F_11F_REV:
450  
-               return ctx->Extensions.EXT_packed_float;
  522
+               return ctx->Extensions.EXT_packed_float
  523
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
451 524
             default:
452  
-               return GL_FALSE;
  525
+               return GL_INVALID_ENUM;
453 526
          }
  527
+
454 528
       case GL_BGR:
455 529
          switch (type) {
456 530
             /* NOTE: no packed types are supported with BGR.  That's
@@ -463,12 +537,14 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
463 537
             case GL_INT:
464 538
             case GL_UNSIGNED_INT:
465 539
             case GL_FLOAT:
466  
-               return GL_TRUE;
467  
-            case GL_HALF_FLOAT_ARB:
468  
-               return ctx->Extensions.ARB_half_float_pixel;
  540
+               return GL_NO_ERROR;
  541
+            case GL_HALF_FLOAT:
  542
+               return ctx->Extensions.ARB_half_float_pixel
  543
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
469 544
             default:
470  
-               return GL_FALSE;
  545
+               return GL_INVALID_ENUM;
471 546
          }
  547
+
472 548
       case GL_RGBA:
473 549
       case GL_BGRA:
474 550
       case GL_ABGR_EXT:
@@ -488,28 +564,37 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
488 564
             case GL_UNSIGNED_INT_8_8_8_8_REV:
489 565
             case GL_UNSIGNED_INT_10_10_10_2:
490 566
             case GL_UNSIGNED_INT_2_10_10_10_REV:
491  
-               return GL_TRUE;
492  
-            case GL_HALF_FLOAT_ARB:
493  
-               return ctx->Extensions.ARB_half_float_pixel;
  567
+               return GL_NO_ERROR;
  568
+            case GL_HALF_FLOAT:
  569
+               return ctx->Extensions.ARB_half_float_pixel
  570
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
494 571
             default:
495  
-               return GL_FALSE;
  572
+               return GL_INVALID_ENUM;
496 573
          }
  574
+
497 575
       case GL_YCBCR_MESA:
  576
+         if (!ctx->Extensions.MESA_ycbcr_texture)
  577
+            return GL_INVALID_ENUM;
498 578
          if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
499 579
              type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
500  
-            return GL_TRUE;
  580
+            return GL_NO_ERROR;
501 581
          else
502  
-            return GL_FALSE;
  582
+            return GL_INVALID_OPERATION;
  583
+
503 584
       case GL_DEPTH_STENCIL_EXT:
504  
-         if ((ctx->Extensions.EXT_packed_depth_stencil &&
505  
-              type == GL_UNSIGNED_INT_24_8_EXT) ||
506  
-             (ctx->Extensions.ARB_depth_buffer_float &&
507  
-              type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV))
508  
-            return GL_TRUE;
  585
+         if (ctx->Extensions.EXT_packed_depth_stencil &&
  586
+             type == GL_UNSIGNED_INT_24_8)
  587
+            return GL_NO_ERROR;
  588
+         else if (ctx->Extensions.ARB_depth_buffer_float &&
  589
+             type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
  590
+            return GL_NO_ERROR;
509 591
          else
510  
-            return GL_FALSE;
  592
+            return GL_INVALID_ENUM;
  593
+
511 594
       case GL_DUDV_ATI:
512 595
       case GL_DU8DV8_ATI:
  596
+         if (!ctx->Extensions.ATI_envmap_bumpmap)
  597
+            return GL_INVALID_ENUM;
513 598
          switch (type) {
514 599
             case GL_BYTE:
515 600
             case GL_UNSIGNED_BYTE:
@@ -518,9 +603,9 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
518 603
             case GL_INT:
519 604
             case GL_UNSIGNED_INT:
520 605
             case GL_FLOAT:
521  
-               return GL_TRUE;
  606
+               return GL_NO_ERROR;
522 607
             default:
523  
-               return GL_FALSE;
  608
+               return GL_INVALID_ENUM;
524 609
          }
525 610
 
526 611
       /* integer-valued formats */
@@ -536,10 +621,11 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
536 621
             case GL_UNSIGNED_SHORT:
537 622
             case GL_INT:
538 623
             case GL_UNSIGNED_INT:
539  
-               return ctx->VersionMajor >= 3 ||
540  
-                      ctx->Extensions.EXT_texture_integer;
  624
+               return (ctx->VersionMajor >= 3 ||
  625
+                       ctx->Extensions.EXT_texture_integer)
  626
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
541 627
             default:
542  
-               return GL_FALSE;
  628
+               return GL_INVALID_ENUM;
543 629
          }
544 630
 
545 631
       case GL_RGB_INTEGER_EXT:
@@ -550,15 +636,17 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
550 636
             case GL_UNSIGNED_SHORT:
551 637
             case GL_INT:
552 638
             case GL_UNSIGNED_INT:
553  
-               return ctx->VersionMajor >= 3 ||
554  
-                      ctx->Extensions.EXT_texture_integer;
  639
+               return (ctx->VersionMajor >= 3 ||
  640
+                       ctx->Extensions.EXT_texture_integer)
  641
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
555 642
             case GL_UNSIGNED_BYTE_3_3_2:
556 643
             case GL_UNSIGNED_BYTE_2_3_3_REV:
557 644
             case GL_UNSIGNED_SHORT_5_6_5:
558 645
             case GL_UNSIGNED_SHORT_5_6_5_REV:
559  
-               return ctx->Extensions.ARB_texture_rgb10_a2ui;
  646
+               return ctx->Extensions.ARB_texture_rgb10_a2ui
  647
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
560 648
             default:
561  
-               return GL_FALSE;
  649
+               return GL_INVALID_ENUM;
562 650
          }
563 651
 
564 652
       case GL_BGR_INTEGER_EXT:
@@ -570,10 +658,11 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
570 658
             case GL_INT:
571 659
             case GL_UNSIGNED_INT:
572 660
             /* NOTE: no packed formats w/ BGR format */
573  
-               return ctx->VersionMajor >= 3 ||
574  
-                      ctx->Extensions.EXT_texture_integer;
  661
+               return (ctx->VersionMajor >= 3 ||
  662
+                       ctx->Extensions.EXT_texture_integer)
  663
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
575 664
             default:
576  
-               return GL_FALSE;
  665
+               return GL_INVALID_ENUM;
577 666
          }
578 667
 
579 668
       case GL_RGBA_INTEGER_EXT:
@@ -585,8 +674,9 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
585 674
             case GL_UNSIGNED_SHORT:
586 675
             case GL_INT:
587 676
             case GL_UNSIGNED_INT:
588  
-               return ctx->VersionMajor >= 3 ||
589  
-                      ctx->Extensions.EXT_texture_integer;
  677
+               return (ctx->VersionMajor >= 3 ||
  678
+                       ctx->Extensions.EXT_texture_integer)
  679
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
590 680
             case GL_UNSIGNED_SHORT_4_4_4_4:
591 681
             case GL_UNSIGNED_SHORT_4_4_4_4_REV:
592 682
             case GL_UNSIGNED_SHORT_5_5_5_1:
@@ -595,9 +685,10 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
595 685
             case GL_UNSIGNED_INT_8_8_8_8_REV:
596 686
             case GL_UNSIGNED_INT_10_10_10_2:
597 687
             case GL_UNSIGNED_INT_2_10_10_10_REV:
598  
-               return ctx->Extensions.ARB_texture_rgb10_a2ui;
  688
+               return ctx->Extensions.ARB_texture_rgb10_a2ui
  689
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
599 690
             default:
600  
-               return GL_FALSE;
  691
+               return GL_INVALID_ENUM;
601 692
          }
602 693
 
603 694
       case GL_LUMINANCE_INTEGER_EXT:
@@ -609,15 +700,16 @@ _mesa_is_legal_format_and_type(const struct gl_context *ctx,
609 700
             case GL_UNSIGNED_SHORT:
610 701
             case GL_INT:
611 702
             case GL_UNSIGNED_INT:
612  
-               return ctx->Extensions.EXT_texture_integer;
  703
+               return ctx->Extensions.EXT_texture_integer
  704
+                  ? GL_NO_ERROR : GL_INVALID_ENUM;
613 705
             default:
614  
-               return GL_FALSE;
  706
+               return GL_INVALID_ENUM;
615 707
          }
616 708
 
617 709
       default:
618  
-         ; /* fall-through */
  710
+         return GL_INVALID_ENUM;
619 711
    }
620  
-   return GL_FALSE;
  712
+   return GL_NO_ERROR;
621 713
 }
622 714
 
623 715
 
6  src/mesa/main/image.h
@@ -53,9 +53,9 @@ _mesa_components_in_format( GLenum format );
53 53
 extern GLint
54 54
 _mesa_bytes_per_pixel( GLenum format, GLenum type );
55 55
 
56  
-extern GLboolean
57  
-_mesa_is_legal_format_and_type(const struct gl_context *ctx,
58  
-                               GLenum format, GLenum type);
  56
+extern GLenum
  57
+_mesa_error_check_format_and_type(const struct gl_context *ctx,
  58
+                                  GLenum format, GLenum type);
59 59
 
60 60
 extern GLboolean
61 61
 _mesa_is_color_format(GLenum format);
9  src/mesa/main/readpix.c
@@ -588,6 +588,7 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
588 588
 {
589 589
    const char *readDraw = drawing ? "Draw" : "Read";
590 590
    const GLboolean reading = !drawing;
  591
+   GLenum err;
591 592
 
592 593
    /* state validation should have already been done */
593 594
    ASSERT(ctx->NewState == 0x0);
@@ -609,9 +610,9 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
609 610
    }
610 611
 
611 612
    /* basic combinations test */
612  
-   if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
613  
-      _mesa_error(ctx, GL_INVALID_ENUM,
614  
-                  "gl%sPixels(format or type)", readDraw);
  613
+   err = _mesa_error_check_format_and_type(ctx, format, type);
  614
+   if (err != GL_NO_ERROR) {
  615
+      _mesa_error(ctx, err, "gl%sPixels(format or type)", readDraw);
615 616
       return GL_TRUE;
616 617
    }
617 618
 
@@ -715,7 +716,7 @@ _mesa_error_check_format_type(struct gl_context *ctx, GLenum format,
715 716
       }
716 717
       break;
717 718
    default:
718  
-      /* this should have been caught in _mesa_is_legal_format_type() */
  719
+      /* this should have been caught in _mesa_error_check_format_type() */
719 720
       _mesa_problem(ctx, "unexpected format in _mesa_%sPixels", readDraw);
720 721
       return GL_TRUE;
721 722
    }
16  src/mesa/main/texgetimage.c
@@ -734,7 +734,7 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
734 734
    struct gl_texture_image *texImage;
735 735
    const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
736 736
    const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
737  
-   GLenum baseFormat;
  737
+   GLenum baseFormat, err;
738 738
 
739 739
    if (maxLevels == 0) {
740 740
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)", target);
@@ -777,6 +777,12 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
777 777
    if (!ctx->Extensions.ATI_envmap_bumpmap
778 778
        && _mesa_is_dudv_format(format)) {
779 779
       _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
  780
+      return;
  781
+   }
  782
+
  783
+   err = _mesa_error_check_format_and_type(ctx, format, type);
  784
+   if (err != GL_NO_ERROR) {
  785
+      _mesa_error(ctx, err, "glGetTexImage(format/type)");
780 786
       return GL_TRUE;
781 787
    }
782 788
 
@@ -787,14 +793,6 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level,
787 793
       return GL_TRUE;
788 794
    }
789 795
 
790  
-   if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
791  
-      /* GL_INVALID_OPERATION is generated by a format/type
792  
-       * mismatch (see the 1.2 spec page 94, sec 3.6.4.)
793  
-       */
794  
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(target)");
795  
-      return GL_TRUE;
796  
-   }
797  
-
798 796
    texImage = _mesa_select_tex_image(ctx, texObj, target, level);
799 797
    if (!texImage) {
800 798
       /* non-existant texture image */
25  src/mesa/main/teximage.c
@@ -1511,6 +1511,7 @@ texture_error_check( struct gl_context *ctx,
1511 1511
    const GLboolean isProxy = target == proxyTarget;
1512 1512
    GLboolean sizeOK = GL_TRUE;
1513 1513
    GLboolean colorFormat;
  1514
+   GLenum err;
1514 1515
 
1515 1516
    /* Even though there are no color-index textures, we still have to support
1516 1517
     * uploading color-index data and remapping it to RGB via the
@@ -1579,16 +1580,10 @@ texture_error_check( struct gl_context *ctx,
1579 1580
    }
1580 1581
 
1581 1582
    /* Check incoming image format and type */
1582  
-   if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
1583  
-      /* Normally, GL_INVALID_OPERATION is generated by a format/type
1584  
-       * mismatch (see the 1.2 spec page 94, sec 3.6.4.).  But with the
1585  
-       * GL_EXT_texture_integer extension, some combinations should generate
1586  
-       * GL_INVALID_ENUM instead (grr!).
1587  
-       */
  1583
+   err = _mesa_error_check_format_and_type(ctx, format, type);
  1584
+   if (err != GL_NO_ERROR) {
1588 1585
       if (!isProxy) {
1589  
-         GLenum error = _mesa_is_integer_format(format)
1590  
-            ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
1591  
-         _mesa_error(ctx, error,
  1586
+         _mesa_error(ctx, err,
1592 1587
                      "glTexImage%dD(incompatible format 0x%x, type 0x%x)",
1593 1588
                      dimensions, format, type);
1594 1589
       }
@@ -1737,6 +1732,8 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions,
1737 1732
                         GLint width, GLint height, GLint depth,
1738 1733
                         GLenum format, GLenum type )
1739 1734
 {
  1735
+   GLenum err;
  1736
+
1740 1737
    /* Basic level check */
1741 1738
    if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
1742 1739
       _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level);
@@ -1760,13 +1757,9 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions,
1760 1757
       return GL_TRUE;
1761 1758
    }
1762 1759
 
1763  
-   if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
1764  
-      /* As with the glTexImage2D check above, the error code here
1765  
-       * depends on texture integer.
1766  
-       */
1767  
-      GLenum error = _mesa_is_integer_format(format)
1768  
-         ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
1769  
-      _mesa_error(ctx, error,
  1760
+   err = _mesa_error_check_format_and_type(ctx, format, type);
  1761
+   if (err != GL_NO_ERROR) {
  1762
+      _mesa_error(ctx, err,
1770 1763
                   "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)",
1771 1764
                   dimensions, format, type);
1772 1765
       return GL_TRUE;

0 notes on commit 627b435

Please sign in to comment.
Something went wrong with that request. Please try again.