[Mesa-dev] [PATCH 03/13] mesa: use _mesa_problem instead of assert for unsupported format/types

Jordan Justen jordan.l.justen at intel.com
Mon Jun 25 17:34:34 PDT 2012


For unsupported formats & types, use _mesa_problem, rather than
assert.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/main/pack.c     |   17 ++++++++++-------
 src/mesa/main/pack_tmp.h |    9 ++++++++-
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 388d635..a0c4fb3 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -500,26 +500,29 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
 {
    switch(dstType) {
    case GL_UNSIGNED_INT:
-      pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+      pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
       break;
    case GL_INT:
       /* No conversion necessary. */
-      pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+      pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
       break;
    case GL_UNSIGNED_SHORT:
-      pack_ushort_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+      pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
       break;
    case GL_SHORT:
-      pack_short_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+      pack_short_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
       break;
    case GL_UNSIGNED_BYTE:
-      pack_ubyte_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+      pack_ubyte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
       break;
    case GL_BYTE:
-      pack_byte_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+      pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n);
       break;
    default:
-      assert(0);
+      _mesa_problem(ctx,
+         "Unsupported type (%s) for format (%s)",
+         _mesa_lookup_enum_by_nr(dstType),
+         _mesa_lookup_enum_by_nr(dstFormat));
       return;
    }
 }
diff --git a/src/mesa/main/pack_tmp.h b/src/mesa/main/pack_tmp.h
index 83b6557..0d4eb38 100644
--- a/src/mesa/main/pack_tmp.h
+++ b/src/mesa/main/pack_tmp.h
@@ -22,7 +22,8 @@
  */
 
 static void
-FN_NAME(DST_TYPE *dst,
+FN_NAME(struct gl_context *ctx,
+	DST_TYPE *dst,
 	GLenum dstFormat,
 	SRC_TYPE rgba[][4],
 	int n)
@@ -111,5 +112,11 @@ FN_NAME(DST_TYPE *dst,
 	 dst[i*2+1] = SRC_CONVERT(rgba[i][ACOMP]);
       }
       break;
+
+   default:
+      _mesa_problem(ctx,
+         "Unsupported format (%s)",
+         _mesa_lookup_enum_by_nr(dstFormat));
+      break;
    }
 }
-- 
1.7.9.5



More information about the mesa-dev mailing list