[Mesa-dev] [PATCH] mesa: pack int from uint with clamping.
Dave Airlie
airlied at gmail.com
Sun Jan 29 09:15:14 PST 2012
From: Dave Airlie <airlied at redhat.com>
if the test I wrote in piglit for sint-uint is correct, this fixes
things in one direction, reading a UINT32 buffer into a INT32 output.
The other case will need a bit more work.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/main/pack.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index d07e2aa..18848cf 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -461,6 +461,14 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef SRC_CONVERT
#undef FN_NAME
+#define DST_TYPE GLint
+#define SRC_CONVERT(x) MIN2(x, 0x7fffffff)
+#define FN_NAME pack_int_from_uint_rgba
+#include "pack_tmp.h"
+#undef DST_TYPE
+#undef SRC_CONVERT
+#undef FN_NAME
+
#define DST_TYPE GLushort
#define SRC_CONVERT(x) MIN2(x, 0xffff)
#define FN_NAME pack_ushort_from_uint_rgba
@@ -503,8 +511,7 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4],
pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n);
break;
case GL_INT:
- /* No conversion necessary. */
- pack_uint_from_uint_rgba(dstAddr, dstFormat, rgba, n);
+ pack_int_from_uint_rgba(dstAddr, dstFormat, rgba, n);
break;
case GL_UNSIGNED_SHORT:
pack_ushort_from_uint_rgba(dstAddr, dstFormat, rgba, n);
--
1.7.7.4
More information about the mesa-dev
mailing list