From f7333b6345deb1c0322079039544bc322ca1dad9 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Tue, 10 Jul 2012 10:41:46 -0700 Subject: [PATCH] mesa pack: handle packed integer formats with clamping Signed-off-by: Jordan Justen Reviewed-by: Brian Paul --- src/mesa/main/pack.c | 629 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 619 insertions(+), 10 deletions(-) diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c index 8ea5853897f..7aebd45ea2b 100644 --- a/src/mesa/main/pack.c +++ b/src/mesa/main/pack.c @@ -516,11 +516,24 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef SRC_TYPE +static void +_pack_rgba_span_from_uints_problem(struct gl_context *ctx, + GLenum dstFormat, GLenum dstType) +{ + _mesa_problem(ctx, + "Unsupported type (%s) / format (%s) " + "in _mesa_pack_rgba_span_from_uints", + _mesa_lookup_enum_by_nr(dstType), + _mesa_lookup_enum_by_nr(dstFormat)); +} + void _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][4], GLenum dstFormat, GLenum dstType, GLvoid *dstAddr) { + GLuint i; + switch(dstType) { case GL_UNSIGNED_INT: pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); @@ -540,12 +553,304 @@ _mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][ case GL_BYTE: pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); break; - + case GL_UNSIGNED_BYTE_3_3_2: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLubyte *dst = (GLubyte *) dstAddr; + for (i=0;i