mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-21 15:10:21 +01:00
remove this module
This commit is contained in:
parent
b1f176039a
commit
72b68455eb
6 changed files with 0 additions and 1568 deletions
|
|
@ -1,375 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "macros.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#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);
|
||||
struct gl_client_array *cl;
|
||||
GLuint i;
|
||||
|
||||
cl = &ac->Fallback.Normal;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.Color;
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.SecondaryColor;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.FogCoord;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) &ctx->Current.Attrib[VERT_ATTRIB_FOG];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Fallback.Index;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) &ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
|
||||
cl = &ac->Fallback.TexCoord[i];
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
|
||||
cl = &ac->Fallback.EdgeFlag;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_UNSIGNED_BYTE;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 0;
|
||||
cl->Ptr = (GLubyte *) &ctx->Current.EdgeFlag;
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
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 = (GLubyte *) ctx->Current.Attrib[i];
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = CA_CLIENT_DATA; /* hack */
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the array cache pointers, types, strides, etc.
|
||||
*/
|
||||
static void _ac_cache_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
struct gl_client_array *cl;
|
||||
GLuint size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
|
||||
GLuint i;
|
||||
|
||||
cl = &ac->Cache.Vertex;
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.Normal;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 3 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.Color;
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.SecondaryColor;
|
||||
cl->Size = 3;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.FogCoord;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
cl = &ac->Cache.Index;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
cl = &ac->Cache.TexCoord[i];
|
||||
cl->Size = 4;
|
||||
cl->Type = GL_FLOAT;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = 4 * sizeof(GLfloat);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
|
||||
cl = &ac->Cache.EdgeFlag;
|
||||
cl->Size = 1;
|
||||
cl->Type = GL_UNSIGNED_BYTE;
|
||||
cl->Stride = 0;
|
||||
cl->StrideB = sizeof(GLubyte);
|
||||
cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
|
||||
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 = (GLubyte *) MALLOC( cl->StrideB * size );
|
||||
cl->Enabled = 1;
|
||||
cl->Flags = 0;
|
||||
#if FEATURE_ARB_vertex_buffer_object
|
||||
cl->BufferObj = ctx->Array.NullBufferObj;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* This storage used to hold translated client data if type or stride
|
||||
* need to be fixed.
|
||||
*/
|
||||
static void _ac_elts_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
GLuint size = 1000;
|
||||
|
||||
ac->Elts = (GLuint *)MALLOC( sizeof(GLuint) * size );
|
||||
ac->elt_size = size;
|
||||
}
|
||||
|
||||
static void _ac_raw_init( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
GLuint i;
|
||||
|
||||
ac->Raw.Color = ac->Fallback.Color;
|
||||
ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
|
||||
ac->Raw.FogCoord = ac->Fallback.FogCoord;
|
||||
ac->Raw.Index = ac->Fallback.Index;
|
||||
ac->Raw.Normal = ac->Fallback.Normal;
|
||||
ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
|
||||
ac->Raw.Vertex = ctx->Array.ArrayObj->Vertex;
|
||||
|
||||
ac->IsCached.Color = GL_FALSE;
|
||||
ac->IsCached.EdgeFlag = GL_FALSE;
|
||||
ac->IsCached.FogCoord = GL_FALSE;
|
||||
ac->IsCached.Index = GL_FALSE;
|
||||
ac->IsCached.Normal = GL_FALSE;
|
||||
ac->IsCached.SecondaryColor = GL_FALSE;
|
||||
ac->IsCached.Vertex = GL_FALSE;
|
||||
|
||||
for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
|
||||
ac->Raw.TexCoord[i] = ac->Fallback.TexCoord[i];
|
||||
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 )
|
||||
{
|
||||
ctx->acache_context = CALLOC(sizeof(ACcontext));
|
||||
if (ctx->acache_context) {
|
||||
_ac_cache_init( ctx );
|
||||
_ac_fallbacks_init( ctx );
|
||||
_ac_raw_init( ctx );
|
||||
_ac_elts_init( ctx );
|
||||
return GL_TRUE;
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void _ac_DestroyContext( GLcontext *ctx )
|
||||
{
|
||||
struct gl_buffer_object *nullObj = ctx->Array.NullBufferObj;
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
GLint i;
|
||||
|
||||
/* only free vertex data if it's really a pointer to vertex data and
|
||||
* not an offset into a buffer object.
|
||||
*/
|
||||
if (ac->Cache.Vertex.Ptr && ac->Cache.Vertex.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Vertex.Ptr );
|
||||
if (ac->Cache.Normal.Ptr && ac->Cache.Normal.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Normal.Ptr );
|
||||
if (ac->Cache.Color.Ptr && ac->Cache.Color.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Color.Ptr );
|
||||
if (ac->Cache.SecondaryColor.Ptr && ac->Cache.SecondaryColor.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.SecondaryColor.Ptr );
|
||||
if (ac->Cache.EdgeFlag.Ptr && ac->Cache.EdgeFlag.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.EdgeFlag.Ptr );
|
||||
if (ac->Cache.Index.Ptr && ac->Cache.Index.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Index.Ptr );
|
||||
if (ac->Cache.FogCoord.Ptr && ac->Cache.FogCoord.BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.FogCoord.Ptr );
|
||||
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
if (ac->Cache.TexCoord[i].Ptr && ac->Cache.TexCoord[i].BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.TexCoord[i].Ptr );
|
||||
}
|
||||
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||
if (ac->Cache.Attrib[i].Ptr && ac->Cache.Attrib[i].BufferObj == nullObj)
|
||||
FREE( (void *) ac->Cache.Attrib[i].Ptr );
|
||||
}
|
||||
|
||||
if (ac->Elts)
|
||||
FREE( ac->Elts );
|
||||
|
||||
/* Free the context structure itself */
|
||||
FREE(ac);
|
||||
ctx->acache_context = NULL;
|
||||
}
|
||||
|
||||
void _ac_InvalidateState( GLcontext *ctx, GLuint new_state )
|
||||
{
|
||||
AC_CONTEXT(ctx)->NewState |= new_state;
|
||||
AC_CONTEXT(ctx)->NewArrayState |= ctx->Array.NewState;
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 5.1
|
||||
*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#ifndef _AC_CONTEXT_H
|
||||
#define _AC_CONTEXT_H
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "array_cache/acache.h"
|
||||
|
||||
/* These are used to make the ctx->Current values look like
|
||||
* arrays (with zero StrideB).
|
||||
*/
|
||||
struct ac_arrays {
|
||||
struct gl_client_array Vertex;
|
||||
struct gl_client_array Normal;
|
||||
struct gl_client_array Color;
|
||||
struct gl_client_array SecondaryColor;
|
||||
struct gl_client_array FogCoord;
|
||||
struct gl_client_array Index;
|
||||
struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
struct gl_client_array EdgeFlag;
|
||||
struct gl_client_array Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
|
||||
};
|
||||
|
||||
struct ac_array_pointers {
|
||||
struct gl_client_array *Vertex;
|
||||
struct gl_client_array *Normal;
|
||||
struct gl_client_array *Color;
|
||||
struct gl_client_array *SecondaryColor;
|
||||
struct gl_client_array *FogCoord;
|
||||
struct gl_client_array *Index;
|
||||
struct gl_client_array *TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
struct gl_client_array *EdgeFlag;
|
||||
struct gl_client_array *Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
|
||||
};
|
||||
|
||||
struct ac_array_flags {
|
||||
GLboolean Vertex;
|
||||
GLboolean Normal;
|
||||
GLboolean Color;
|
||||
GLboolean SecondaryColor;
|
||||
GLboolean FogCoord;
|
||||
GLboolean Index;
|
||||
GLboolean TexCoord[MAX_TEXTURE_COORD_UNITS];
|
||||
GLboolean EdgeFlag;
|
||||
GLboolean Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
GLuint NewState; /* not needed? */
|
||||
GLuint NewArrayState;
|
||||
|
||||
/* Facility for importing and caching array data:
|
||||
*/
|
||||
struct ac_arrays Fallback;
|
||||
struct ac_arrays Cache;
|
||||
struct ac_arrays Raw;
|
||||
struct ac_array_flags IsCached;
|
||||
GLuint start;
|
||||
GLuint count;
|
||||
|
||||
/* Facility for importing element lists:
|
||||
*/
|
||||
GLuint *Elts;
|
||||
GLuint elt_size;
|
||||
|
||||
} ACcontext;
|
||||
|
||||
#define AC_CONTEXT(ctx) ((ACcontext *)ctx->acache_context)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,922 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
*
|
||||
* Copyright (C) 1999-2006 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "macros.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "math/m_translate.h"
|
||||
#include "array_cache/ac_context.h"
|
||||
#include "math/m_translate.h"
|
||||
|
||||
#define STRIDE_ARRAY( array, offset ) \
|
||||
do { \
|
||||
GLubyte *tmp = ADD_POINTERS( (array).BufferObj->Data, (array).Ptr ) \
|
||||
+ (offset) * (array).StrideB; \
|
||||
(array).Ptr = tmp; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Set the array pointer back to its source when the cached data is
|
||||
* invalidated:
|
||||
*/
|
||||
static void
|
||||
reset_texcoord( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->TexCoord[unit].Enabled) {
|
||||
ac->Raw.TexCoord[unit] = ctx->Array.ArrayObj->TexCoord[unit];
|
||||
STRIDE_ARRAY(ac->Raw.TexCoord[unit], ac->start);
|
||||
}
|
||||
else {
|
||||
ac->Raw.TexCoord[unit] = ac->Fallback.TexCoord[unit];
|
||||
|
||||
if (ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3] != 1.0)
|
||||
ac->Raw.TexCoord[unit].Size = 4;
|
||||
else if (ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2] != 0.0)
|
||||
ac->Raw.TexCoord[unit].Size = 3;
|
||||
else
|
||||
ac->Raw.TexCoord[unit].Size = 2;
|
||||
}
|
||||
|
||||
ac->IsCached.TexCoord[unit] = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_TEXCOORD(unit);
|
||||
}
|
||||
|
||||
static void
|
||||
reset_vertex( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
ASSERT(ctx->Array.ArrayObj->Vertex.Enabled
|
||||
|| (ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled));
|
||||
ac->Raw.Vertex = ctx->Array.ArrayObj->Vertex;
|
||||
STRIDE_ARRAY(ac->Raw.Vertex, ac->start);
|
||||
ac->IsCached.Vertex = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_VERTEX;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_normal( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->Normal.Enabled) {
|
||||
ac->Raw.Normal = ctx->Array.ArrayObj->Normal;
|
||||
STRIDE_ARRAY(ac->Raw.Normal, ac->start);
|
||||
}
|
||||
else {
|
||||
ac->Raw.Normal = ac->Fallback.Normal;
|
||||
}
|
||||
|
||||
ac->IsCached.Normal = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_NORMAL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_color( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->Color.Enabled) {
|
||||
ac->Raw.Color = ctx->Array.ArrayObj->Color;
|
||||
STRIDE_ARRAY(ac->Raw.Color, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.Color = ac->Fallback.Color;
|
||||
|
||||
ac->IsCached.Color = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_COLOR0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_secondarycolor( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
|
||||
ac->Raw.SecondaryColor = ctx->Array.ArrayObj->SecondaryColor;
|
||||
STRIDE_ARRAY(ac->Raw.SecondaryColor, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
|
||||
|
||||
ac->IsCached.SecondaryColor = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_COLOR1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_index( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->Index.Enabled) {
|
||||
ac->Raw.Index = ctx->Array.ArrayObj->Index;
|
||||
STRIDE_ARRAY(ac->Raw.Index, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.Index = ac->Fallback.Index;
|
||||
|
||||
ac->IsCached.Index = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_INDEX;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_fogcoord( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->FogCoord.Enabled) {
|
||||
ac->Raw.FogCoord = ctx->Array.ArrayObj->FogCoord;
|
||||
STRIDE_ARRAY(ac->Raw.FogCoord, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.FogCoord = ac->Fallback.FogCoord;
|
||||
|
||||
ac->IsCached.FogCoord = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reset_edgeflag( GLcontext *ctx )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
|
||||
ac->Raw.EdgeFlag = ctx->Array.ArrayObj->EdgeFlag;
|
||||
STRIDE_ARRAY(ac->Raw.EdgeFlag, ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
|
||||
|
||||
ac->IsCached.EdgeFlag = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_EDGEFLAG;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \param index the generic vertex array number.
|
||||
*/
|
||||
static void
|
||||
reset_attrib( GLcontext *ctx, GLuint index )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (ctx->Array.ArrayObj->VertexAttrib[index].Enabled) {
|
||||
ac->Raw.Attrib[index] = ctx->Array.ArrayObj->VertexAttrib[index];
|
||||
STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
|
||||
}
|
||||
else
|
||||
ac->Raw.Attrib[index] = ac->Fallback.Attrib[index];
|
||||
|
||||
ac->IsCached.Attrib[index] = GL_FALSE;
|
||||
ac->NewArrayState &= ~_NEW_ARRAY_ATTRIB(index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generic import function for color data
|
||||
*/
|
||||
static void
|
||||
import( const GLcontext *ctx,
|
||||
GLenum destType,
|
||||
struct gl_client_array *to,
|
||||
const struct gl_client_array *from )
|
||||
{
|
||||
const ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (destType == 0)
|
||||
destType = from->Type;
|
||||
|
||||
switch (destType) {
|
||||
case GL_FLOAT:
|
||||
_math_trans_4fn( (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:
|
||||
_mesa_problem(ctx, "Unexpected dest format in import()");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Functions to import array ranges with specified types and strides.
|
||||
* For example, if the vertex data is GLshort[2] and we want GLfloat[3]
|
||||
* we'll use an import function to do the data conversion.
|
||||
*/
|
||||
|
||||
static void
|
||||
import_texcoord( GLcontext *ctx, GLuint unit, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.TexCoord[unit];
|
||||
struct gl_client_array *to = &ac->Cache.TexCoord[unit];
|
||||
(void) type; (void) stride;
|
||||
|
||||
ASSERT(unit < ctx->Const.MaxTextureCoordUnits);
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
|
||||
ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
|
||||
|
||||
_math_trans_4f( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->Size = from->Size;
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.TexCoord[unit] = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_vertex( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Vertex;
|
||||
struct gl_client_array *to = &ac->Cache.Vertex;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
|
||||
|
||||
_math_trans_4f( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->Size = from->Size;
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.Vertex = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_normal( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Normal;
|
||||
struct gl_client_array *to = &ac->Cache.Normal;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 3*sizeof(GLfloat) || stride == 0);
|
||||
|
||||
_math_trans_3fn((GLfloat (*)[3]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = 3 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.Normal = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_color( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Color;
|
||||
struct gl_client_array *to = &ac->Cache.Color;
|
||||
(void) stride;
|
||||
|
||||
import( ctx, type, to, from );
|
||||
|
||||
ac->IsCached.Color = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_index( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Index;
|
||||
struct gl_client_array *to = &ac->Cache.Index;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_UNSIGNED_INT);
|
||||
ASSERT(stride == sizeof(GLuint) || stride == 0);
|
||||
|
||||
_math_trans_1ui( (GLuint *) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = sizeof(GLuint);
|
||||
to->Type = GL_UNSIGNED_INT;
|
||||
ac->IsCached.Index = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_secondarycolor( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.SecondaryColor;
|
||||
struct gl_client_array *to = &ac->Cache.SecondaryColor;
|
||||
(void) stride;
|
||||
|
||||
import( ctx, type, to, from );
|
||||
|
||||
ac->IsCached.SecondaryColor = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_fogcoord( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.FogCoord;
|
||||
struct gl_client_array *to = &ac->Cache.FogCoord;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == sizeof(GLfloat) || stride == 0);
|
||||
|
||||
_math_trans_1f( (GLfloat *) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.FogCoord = GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
import_edgeflag( GLcontext *ctx, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.EdgeFlag;
|
||||
struct gl_client_array *to = &ac->Cache.EdgeFlag;
|
||||
(void) type; (void) stride;
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_UNSIGNED_BYTE);
|
||||
ASSERT(stride == sizeof(GLubyte) || stride == 0);
|
||||
|
||||
_math_trans_1ub( (GLubyte *) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
|
||||
to->StrideB = sizeof(GLubyte);
|
||||
to->Type = GL_UNSIGNED_BYTE;
|
||||
ac->IsCached.EdgeFlag = GL_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* \param index the generic vertex array number
|
||||
*/
|
||||
static void
|
||||
import_attrib( GLcontext *ctx, GLuint index, GLenum type, GLuint stride )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
const struct gl_client_array *from = &ac->Raw.Attrib[index];
|
||||
struct gl_client_array *to = &ac->Cache.Attrib[index];
|
||||
(void) type; (void) stride;
|
||||
|
||||
ASSERT(index < MAX_VERTEX_PROGRAM_ATTRIBS);
|
||||
|
||||
/* Limited choices at this stage:
|
||||
*/
|
||||
ASSERT(type == GL_FLOAT);
|
||||
ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
|
||||
ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
|
||||
|
||||
if (from->Normalized) {
|
||||
_math_trans_4fn( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
}
|
||||
else {
|
||||
_math_trans_4f( (GLfloat (*)[4]) to->Ptr,
|
||||
from->Ptr,
|
||||
from->StrideB,
|
||||
from->Type,
|
||||
from->Size,
|
||||
0,
|
||||
ac->count - ac->start);
|
||||
}
|
||||
|
||||
to->Size = from->Size;
|
||||
to->StrideB = 4 * sizeof(GLfloat);
|
||||
to->Type = GL_FLOAT;
|
||||
ac->IsCached.Attrib[index] = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Externals to request arrays with specific properties:
|
||||
*/
|
||||
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_texcoord( GLcontext *ctx,
|
||||
GLuint unit,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
ASSERT(unit < MAX_TEXTURE_COORD_UNITS);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_TEXCOORD(unit))
|
||||
reset_texcoord( ctx, unit );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.TexCoord[unit].Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.TexCoord[unit].Type != type ||
|
||||
(reqstride != 0 && ac->Raw.TexCoord[unit].StrideB != (GLint)reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.TexCoord[unit])
|
||||
import_texcoord(ctx, unit, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.TexCoord[unit];
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.TexCoord[unit];
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_vertex( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_VERTEX)
|
||||
reset_vertex( ctx );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.Vertex.Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Vertex.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Vertex.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Vertex)
|
||||
import_vertex(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Vertex;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Vertex;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_normal( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_NORMAL)
|
||||
reset_normal( ctx );
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Normal.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Normal.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Normal)
|
||||
import_normal(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Normal;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_color( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_COLOR0)
|
||||
reset_color( ctx );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.Color.Size > (GLint) reqsize) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if ((type != 0 && ac->Raw.Color.Type != type) ||
|
||||
(reqstride != 0 && ac->Raw.Color.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Color) {
|
||||
import_color(ctx, type, reqstride );
|
||||
}
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Color;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Color;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_index( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_INDEX)
|
||||
reset_index( ctx );
|
||||
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Index.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Index.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Index)
|
||||
import_index(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Index;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Index;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_secondarycolor( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_COLOR1)
|
||||
reset_secondarycolor( ctx );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.SecondaryColor.Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if ((type != 0 && ac->Raw.SecondaryColor.Type != type) ||
|
||||
(reqstride != 0 && ac->Raw.SecondaryColor.StrideB != (GLint)reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.SecondaryColor)
|
||||
import_secondarycolor(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.SecondaryColor;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.SecondaryColor;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_fogcoord( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_FOGCOORD)
|
||||
reset_fogcoord( ctx );
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.FogCoord.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.FogCoord.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.FogCoord)
|
||||
import_fogcoord(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.FogCoord;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.FogCoord;
|
||||
}
|
||||
}
|
||||
|
||||
struct gl_client_array *
|
||||
_ac_import_edgeflag( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_EDGEFLAG)
|
||||
reset_edgeflag( ctx );
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.EdgeFlag.Type != type ||
|
||||
(reqstride != 0 && ac->Raw.EdgeFlag.StrideB != (GLint) reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.EdgeFlag)
|
||||
import_edgeflag(ctx, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.EdgeFlag;
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.EdgeFlag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For GL_ARB/NV_vertex_program
|
||||
* \param index index of the vertex array, starting at zero.
|
||||
*/
|
||||
struct gl_client_array *
|
||||
_ac_import_attrib( GLcontext *ctx,
|
||||
GLuint index,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwriteable,
|
||||
GLboolean *writeable )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
ASSERT(index < VERT_ATTRIB_MAX);
|
||||
|
||||
/* Can we keep the existing version?
|
||||
*/
|
||||
if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index))
|
||||
reset_attrib( ctx, index );
|
||||
|
||||
/* Is the request impossible?
|
||||
*/
|
||||
if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize)
|
||||
return NULL;
|
||||
|
||||
/* Do we need to pull in a copy of the client data:
|
||||
*/
|
||||
if (ac->Raw.Attrib[index].Type != type ||
|
||||
(reqstride != 0 && ac->Raw.Attrib[index].StrideB != (GLint)reqstride) ||
|
||||
reqwriteable)
|
||||
{
|
||||
if (!ac->IsCached.Attrib[index])
|
||||
import_attrib(ctx, index, type, reqstride );
|
||||
*writeable = GL_TRUE;
|
||||
return &ac->Cache.Attrib[index];
|
||||
}
|
||||
else {
|
||||
*writeable = GL_FALSE;
|
||||
return &ac->Raw.Attrib[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Clients must call this function to validate state and set bounds
|
||||
* before importing any data:
|
||||
*/
|
||||
void
|
||||
_ac_import_range( GLcontext *ctx, GLuint start, GLuint count )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (!ctx->Array.LockCount) {
|
||||
/* Not locked, discard cached data. Changes to lock
|
||||
* status are caught via. _ac_invalidate_state().
|
||||
*/
|
||||
ac->NewArrayState = _NEW_ARRAY_ALL;
|
||||
ac->start = start;
|
||||
ac->count = count;
|
||||
}
|
||||
else {
|
||||
/* Locked, discard data for any disabled arrays. Require that
|
||||
* the whole locked range always be dealt with, otherwise hard to
|
||||
* maintain cached data in the face of clipping.
|
||||
*/
|
||||
ac->NewArrayState |= ~ctx->Array.ArrayObj->_Enabled;
|
||||
ac->start = ctx->Array.LockFirst;
|
||||
ac->count = ctx->Array.LockCount;
|
||||
ASSERT(ac->start == start); /* hmm? */
|
||||
ASSERT(ac->count == count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Additional convienence function for importing the element list
|
||||
* for glDrawElements() and glDrawRangeElements().
|
||||
*/
|
||||
CONST void *
|
||||
_ac_import_elements( GLcontext *ctx,
|
||||
GLenum new_type,
|
||||
GLuint count,
|
||||
GLenum old_type,
|
||||
CONST void *indices )
|
||||
{
|
||||
ACcontext *ac = AC_CONTEXT(ctx);
|
||||
|
||||
if (old_type == new_type)
|
||||
return indices;
|
||||
|
||||
if (ac->elt_size < count * sizeof(GLuint)) {
|
||||
if (ac->Elts) FREE(ac->Elts);
|
||||
while (ac->elt_size < count * sizeof(GLuint))
|
||||
ac->elt_size *= 2;
|
||||
ac->Elts = (GLuint *) MALLOC(ac->elt_size);
|
||||
}
|
||||
|
||||
switch (new_type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
case GL_UNSIGNED_INT: {
|
||||
GLuint *out = (GLuint *)ac->Elts;
|
||||
GLuint i;
|
||||
|
||||
switch (old_type) {
|
||||
case GL_UNSIGNED_BYTE: {
|
||||
CONST GLubyte *in = (CONST GLubyte *)indices;
|
||||
for (i = 0 ; i < count ; i++)
|
||||
out[i] = in[i];
|
||||
break;
|
||||
}
|
||||
case GL_UNSIGNED_SHORT: {
|
||||
CONST GLushort *in = (CONST GLushort *)indices;
|
||||
for (i = 0 ; i < count ; i++)
|
||||
out[i] = in[i];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return (CONST void *)out;
|
||||
}
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.1
|
||||
*
|
||||
* 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"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#ifndef _ARRAYCACHE_H
|
||||
#define _ARRAYCACHE_H
|
||||
|
||||
#include "mtypes.h"
|
||||
|
||||
|
||||
extern GLboolean
|
||||
_ac_CreateContext( GLcontext *ctx );
|
||||
|
||||
extern void
|
||||
_ac_DestroyContext( GLcontext *ctx );
|
||||
|
||||
extern void
|
||||
_ac_InvalidateState( GLcontext *ctx, GLuint new_state );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_vertex( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_normal( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_color( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_index( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_secondarycolor( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_fogcoord( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_edgeflag( GLcontext *ctx,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_texcoord( GLcontext *ctx,
|
||||
GLuint unit,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
extern struct gl_client_array *
|
||||
_ac_import_attrib( GLcontext *ctx,
|
||||
GLuint index,
|
||||
GLenum type,
|
||||
GLuint reqstride,
|
||||
GLuint reqsize,
|
||||
GLboolean reqwritable,
|
||||
GLboolean *writable );
|
||||
|
||||
|
||||
/* Clients must call this function to validate state and set bounds
|
||||
* before importing any data:
|
||||
*/
|
||||
extern void
|
||||
_ac_import_range( GLcontext *ctx, GLuint start, GLuint count );
|
||||
|
||||
|
||||
/* Additional convenience function:
|
||||
*/
|
||||
extern CONST void *
|
||||
_ac_import_elements( GLcontext *ctx,
|
||||
GLenum new_type,
|
||||
GLuint count,
|
||||
GLenum old_type,
|
||||
CONST void *indices );
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
# Makefile for core library for VMS
|
||||
# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
|
||||
# Last revision : 16 June 2003
|
||||
|
||||
.first
|
||||
define gl [---.include.gl]
|
||||
define math [-.math]
|
||||
define array_cache [-.array_cache]
|
||||
|
||||
.include [---]mms-config.
|
||||
|
||||
##### MACROS #####
|
||||
|
||||
VPATH = RCS
|
||||
|
||||
INCDIR = [---.include],[-.main],[-.glapi]
|
||||
LIBDIR = [---.lib]
|
||||
CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
|
||||
|
||||
SOURCES = ac_context.c ac_import.c
|
||||
|
||||
OBJECTS = ac_context.obj,ac_import.obj
|
||||
##### RULES #####
|
||||
|
||||
VERSION=Mesa V3.4
|
||||
|
||||
##### TARGETS #####
|
||||
# Make the library
|
||||
$(LIBDIR)$(GL_LIB) : $(OBJECTS)
|
||||
@ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
|
||||
|
||||
clean :
|
||||
purge
|
||||
delete *.obj;*
|
||||
|
||||
ac_context.obj : ac_context.c
|
||||
ac_import.obj : ac_import.c
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
MESA_ARRAY_CACHE_SOURCES = \
|
||||
ac_context.c \
|
||||
ac_import.c
|
||||
Loading…
Add table
Reference in a new issue