From 51c0c71811508b6658e0d5dcff8426b618322a73 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 28 Apr 2001 08:39:17 +0000 Subject: Support for floating point color representation in tnl module. --- src/mesa/array_cache/ac_context.c | 29 ++++++++--- src/mesa/array_cache/ac_import.c | 101 +++++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 40 deletions(-) (limited to 'src/mesa/array_cache') diff --git a/src/mesa/array_cache/ac_context.c b/src/mesa/array_cache/ac_context.c index 2e11414079..e9c4fe869a 100644 --- a/src/mesa/array_cache/ac_context.c +++ b/src/mesa/array_cache/ac_context.c @@ -1,4 +1,4 @@ -/* $Id: ac_context.c,v 1.3 2001/03/12 00:48:41 gareth Exp $ */ +/* $Id: ac_context.c,v 1.4 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -48,22 +48,25 @@ static void _ac_fallbacks_init( GLcontext *ctx ) cl->StrideB = 0; cl->Ptr = (void *) ctx->Current.Normal; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ cl = &ac->Fallback.Color; cl->Size = 4; - cl->Type = GL_UNSIGNED_BYTE; + cl->Type = GL_FLOAT; cl->Stride = 0; cl->StrideB = 0; cl->Ptr = (void *) ctx->Current.Color; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ cl = &ac->Fallback.SecondaryColor; cl->Size = 3; - cl->Type = GL_UNSIGNED_BYTE; + cl->Type = GL_FLOAT; cl->Stride = 0; cl->StrideB = 0; cl->Ptr = (void *) ctx->Current.SecondaryColor; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ cl = &ac->Fallback.FogCoord; cl->Size = 1; @@ -72,6 +75,7 @@ static void _ac_fallbacks_init( GLcontext *ctx ) cl->StrideB = 0; cl->Ptr = (void *) &ctx->Current.FogCoord; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ cl = &ac->Fallback.Index; cl->Size = 1; @@ -80,6 +84,7 @@ static void _ac_fallbacks_init( GLcontext *ctx ) cl->StrideB = 0; cl->Ptr = (void *) &ctx->Current.Index; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) { cl = &ac->Fallback.TexCoord[i]; @@ -89,6 +94,7 @@ static void _ac_fallbacks_init( GLcontext *ctx ) cl->StrideB = 0; cl->Ptr = (void *) ctx->Current.Texcoord[i]; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ } cl = &ac->Fallback.EdgeFlag; @@ -98,6 +104,7 @@ static void _ac_fallbacks_init( GLcontext *ctx ) cl->StrideB = 0; cl->Ptr = (void *) &ctx->Current.EdgeFlag; cl->Enabled = 1; + cl->Flags = CA_CLIENT_DATA; /* hack */ } @@ -115,6 +122,7 @@ static void _ac_cache_init( GLcontext *ctx ) cl->StrideB = 4 * sizeof(GLfloat); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; cl = &ac->Cache.Normal; cl->Size = 3; @@ -123,22 +131,25 @@ static void _ac_cache_init( GLcontext *ctx ) cl->StrideB = 3 * sizeof(GLfloat); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; cl = &ac->Cache.Color; cl->Size = 4; - cl->Type = GL_UNSIGNED_BYTE; + cl->Type = GL_FLOAT; cl->Stride = 0; - cl->StrideB = 4 * sizeof(GLubyte); + cl->StrideB = 4 * sizeof(GLfloat); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; cl = &ac->Cache.SecondaryColor; cl->Size = 3; - cl->Type = GL_UNSIGNED_BYTE; + cl->Type = GL_FLOAT; cl->Stride = 0; - cl->StrideB = 4 * sizeof(GLubyte); + cl->StrideB = 4 * sizeof(GLfloat); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; cl = &ac->Cache.FogCoord; cl->Size = 1; @@ -147,6 +158,7 @@ static void _ac_cache_init( GLcontext *ctx ) cl->StrideB = sizeof(GLfloat); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; cl = &ac->Cache.Index; cl->Size = 1; @@ -155,6 +167,7 @@ static void _ac_cache_init( GLcontext *ctx ) cl->StrideB = sizeof(GLuint); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) { cl = &ac->Cache.TexCoord[i]; @@ -164,6 +177,7 @@ static void _ac_cache_init( GLcontext *ctx ) cl->StrideB = 4 * sizeof(GLfloat); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; } cl = &ac->Cache.EdgeFlag; @@ -173,6 +187,7 @@ static void _ac_cache_init( GLcontext *ctx ) cl->StrideB = sizeof(GLubyte); cl->Ptr = MALLOC( cl->StrideB * size ); cl->Enabled = 1; + cl->Flags = 0; } diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index 334b3673f2..a2f3ceabad 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -1,4 +1,4 @@ -/* $Id: ac_import.c,v 1.13 2001/04/17 21:08:32 brianp Exp $ */ +/* $Id: ac_import.c,v 1.14 2001/04/28 08:39:18 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -178,6 +178,65 @@ static void reset_edgeflag( GLcontext *ctx ) } + +static void import( GLcontext *ctx, + GLenum type, + struct gl_client_array *to, + struct gl_client_array *from ) +{ + ACcontext *ac = AC_CONTEXT(ctx); + + if (type == 0) + type = from->Type; + + switch (type) { + case GL_FLOAT: + _math_trans_4f( (GLfloat (*)[4]) to->Ptr, + from->Ptr, + from->StrideB, + from->Type, + from->Size, + 0, + ac->count - ac->start); + + to->StrideB = 4 * sizeof(GLfloat); + to->Type = GL_FLOAT; + break; + + case GL_UNSIGNED_BYTE: + _math_trans_4ub( (GLubyte (*)[4]) to->Ptr, + from->Ptr, + from->StrideB, + from->Type, + from->Size, + 0, + ac->count - ac->start); + + to->StrideB = 4 * sizeof(GLubyte); + to->Type = GL_UNSIGNED_BYTE; + break; + + case GL_UNSIGNED_SHORT: + _math_trans_4us( (GLushort (*)[4]) to->Ptr, + from->Ptr, + from->StrideB, + from->Type, + from->Size, + 0, + ac->count - ac->start); + + to->StrideB = 4 * sizeof(GLushort); + to->Type = GL_UNSIGNED_SHORT; + break; + + default: + ASSERT(0); + break; + } +} + + + /* Functions to import array ranges with specified types and strides. */ static void import_texcoord( GLcontext *ctx, GLuint unit, @@ -257,6 +316,9 @@ static void import_normal( GLcontext *ctx, ac->IsCached.Normal = GL_TRUE; } + + + static void import_color( GLcontext *ctx, GLenum type, GLuint stride ) { @@ -264,22 +326,8 @@ static void import_color( GLcontext *ctx, struct gl_client_array *from = &ac->Raw.Color; struct gl_client_array *to = &ac->Cache.Color; - /* Limited choices at this stage: - */ - ASSERT(type == CHAN_TYPE); - ASSERT(stride == 4 * sizeof(GLchan) || stride == 0); - - _math_trans_4chan( (GLchan (*)[4]) to->Ptr, - from->Ptr, - from->StrideB, - from->Type, - from->Size, - 0, - ac->count - ac->start); - - to->Size = from->Size; - to->StrideB = 4 * sizeof(GLchan); - to->Type = CHAN_TYPE; + import( ctx, type, to, from ); + ac->IsCached.Color = GL_TRUE; } @@ -314,21 +362,8 @@ static void import_secondarycolor( GLcontext *ctx, struct gl_client_array *from = &ac->Raw.SecondaryColor; struct gl_client_array *to = &ac->Cache.SecondaryColor; - /* Limited choices at this stage: - */ - ASSERT(type == CHAN_TYPE); - ASSERT(stride == 4 * sizeof(GLchan) || stride == 0); - - _math_trans_4chan( (GLchan (*)[4]) to->Ptr, - from->Ptr, - from->StrideB, - from->Type, - from->Size, - 0, - ac->count - ac->start); + import( ctx, type, to, from ); - to->StrideB = 4 * sizeof(GLchan); - to->Type = CHAN_TYPE; ac->IsCached.SecondaryColor = GL_TRUE; } @@ -509,7 +544,7 @@ struct gl_client_array *_ac_import_color( GLcontext *ctx, /* Do we need to pull in a copy of the client data: */ - if (ac->Raw.Color.Type != type || + if ((type != 0 && ac->Raw.Color.Type != type) || (reqstride != 0 && ac->Raw.Color.StrideB != (GLint) reqstride) || reqwriteable) { @@ -576,7 +611,7 @@ struct gl_client_array *_ac_import_secondarycolor( GLcontext *ctx, /* Do we need to pull in a copy of the client data: */ - if (ac->Raw.SecondaryColor.Type != type || + if ((type != 0 && ac->Raw.SecondaryColor.Type != type) || (reqstride != 0 && ac->Raw.SecondaryColor.StrideB != (GLint)reqstride) || reqwriteable) { -- cgit v1.2.3