summaryrefslogtreecommitdiff
path: root/src/mesa/array_cache
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-04-21 19:39:48 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-04-21 19:39:48 +0000
commitf3781eaafa54d1e4fef0de427b294c02257a3c4d (patch)
tree7883dbaecec1000dc1e9935794d7ec3e5a82334d /src/mesa/array_cache
parentb7752724d930aa8b93617829d814b20509f85069 (diff)
added support for vertex program attribute arrays
Diffstat (limited to 'src/mesa/array_cache')
-rw-r--r--src/mesa/array_cache/ac_context.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/mesa/array_cache/ac_context.c b/src/mesa/array_cache/ac_context.c
index f5a9b4623d..4ecd643b4c 100644
--- a/src/mesa/array_cache/ac_context.c
+++ b/src/mesa/array_cache/ac_context.c
@@ -1,10 +1,10 @@
-/* $Id: ac_context.c,v 1.6 2001/12/14 02:50:57 brianp Exp $ */
+/* $Id: ac_context.c,v 1.7 2002/04/21 19:39:48 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -35,6 +35,11 @@
#include "array_cache/ac_context.h"
+
+/*
+ * Initialize the array fallbacks. That is, by default the fallback arrays
+ * point into the current vertex attribute values in ctx->Current.Attrib[]
+ */
static void _ac_fallbacks_init( GLcontext *ctx )
{
ACcontext *ac = AC_CONTEXT(ctx);
@@ -105,9 +110,23 @@ static void _ac_fallbacks_init( GLcontext *ctx )
cl->Ptr = (void *) &ctx->Current.EdgeFlag;
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ cl = &ac->Fallback.Attrib[i];
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (void *) ctx->Current.Attrib[i];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+ }
}
+/*
+ * Initialize the array cache pointers, types, strides, etc.
+ */
static void _ac_cache_init( GLcontext *ctx )
{
ACcontext *ac = AC_CONTEXT(ctx);
@@ -169,7 +188,7 @@ static void _ac_cache_init( GLcontext *ctx )
cl->Enabled = 1;
cl->Flags = 0;
- for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) {
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
cl = &ac->Cache.TexCoord[i];
cl->Size = 4;
cl->Type = GL_FLOAT;
@@ -188,6 +207,17 @@ static void _ac_cache_init( GLcontext *ctx )
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+
+ for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
+ cl = &ac->Cache.Attrib[i];
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 4 * sizeof(GLfloat);
+ cl->Ptr = MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+ }
}
@@ -229,6 +259,10 @@ static void _ac_raw_init( GLcontext *ctx )
ac->IsCached.TexCoord[i] = GL_FALSE;
}
+ for (i = 0 ; i < VERT_ATTRIB_MAX ; i++) {
+ ac->Raw.Attrib[i] = ac->Fallback.Attrib[i];
+ ac->IsCached.Attrib[i] = GL_FALSE;
+ }
}
GLboolean _ac_CreateContext( GLcontext *ctx )
@@ -262,6 +296,11 @@ void _ac_DestroyContext( GLcontext *ctx )
FREE( ac->Cache.TexCoord[i].Ptr );
}
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ if (ac->Cache.Attrib[i].Ptr)
+ FREE( ac->Cache.Attrib[i].Ptr );
+ }
+
if (ac->Elts) FREE( ac->Elts );
/* Free the context structure itself */