Drop macro wrappers for the aligned memory functions

This commit is contained in:
Kristian Høgsberg 2010-02-19 13:16:57 -05:00
parent 3ef51b4bd9
commit 99ae9e8d7d
18 changed files with 37 additions and 48 deletions

View File

@ -185,7 +185,7 @@ void ffbInitVB( GLcontext *ctx )
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
fmesa->verts = (ffb_vertex *)ALIGN_MALLOC(size * sizeof(ffb_vertex), 32);
fmesa->verts = (ffb_vertex *)_mesa_align_malloc(size * sizeof(ffb_vertex), 32);
{
static int firsttime = 1;
@ -201,7 +201,7 @@ void ffbFreeVB( GLcontext *ctx )
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
if (fmesa->verts) {
ALIGN_FREE(fmesa->verts);
_mesa_align_free(fmesa->verts);
fmesa->verts = 0;
}
}

View File

@ -338,7 +338,7 @@ void gammaInitVB( GLcontext *ctx )
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
gmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
gmesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32);
{
static int firsttime = 1;
@ -355,7 +355,7 @@ void gammaFreeVB( GLcontext *ctx )
{
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
if (gmesa->verts) {
ALIGN_FREE(gmesa->verts);
_mesa_align_free(gmesa->verts);
gmesa->verts = 0;
}
}

View File

@ -131,12 +131,12 @@ static drmBufMapPtr i810_create_empty_buffers(void)
{
drmBufMapPtr retval;
retval = (drmBufMapPtr)ALIGN_MALLOC(sizeof(drmBufMap), 32);
retval = (drmBufMapPtr)_mesa_align_malloc(sizeof(drmBufMap), 32);
if(retval == NULL) return NULL;
memset(retval, 0, sizeof(drmBufMap));
retval->list = (drmBufPtr)ALIGN_MALLOC(sizeof(drmBuf) * I810_DMA_BUF_NR, 32);
retval->list = (drmBufPtr)_mesa_align_malloc(sizeof(drmBuf) * I810_DMA_BUF_NR, 32);
if(retval->list == NULL) {
ALIGN_FREE(retval);
_mesa_align_free(retval);
return NULL;
}
memset(retval->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR);

View File

@ -464,7 +464,7 @@ void i810InitVB( GLcontext *ctx )
i810ContextPtr imesa = I810_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
imesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
imesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32);
{
static int firsttime = 1;
@ -480,7 +480,7 @@ void i810FreeVB( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
if (imesa->verts) {
ALIGN_FREE(imesa->verts);
_mesa_align_free(imesa->verts);
imesa->verts = 0;
}
}

View File

@ -211,7 +211,7 @@ GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
/* Allocate the vertex buffer
*/
mmesa->vert_buf = ALIGN_MALLOC(MACH64_BUFFER_SIZE, 32);
mmesa->vert_buf = _mesa_align_malloc(MACH64_BUFFER_SIZE, 32);
if ( !mmesa->vert_buf )
return GL_FALSE;
mmesa->vert_used = 0;
@ -291,7 +291,7 @@ void mach64DestroyContext( __DRIcontext *driContextPriv )
/* Free the vertex buffer */
if ( mmesa->vert_buf )
ALIGN_FREE( mmesa->vert_buf );
_mesa_align_free( mmesa->vert_buf );
/* free the Mesa context */
mmesa->glCtx->DriverCtx = NULL;

View File

@ -619,7 +619,7 @@ void mach64InitVB( GLcontext *ctx )
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
mmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
mmesa->verts = (GLubyte *)_mesa_align_malloc(size * 4 * 16, 32);
{
static int firsttime = 1;
@ -635,7 +635,7 @@ void mach64FreeVB( GLcontext *ctx )
{
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
if (mmesa->verts) {
ALIGN_FREE(mmesa->verts);
_mesa_align_free(mmesa->verts);
mmesa->verts = 0;
}
}

View File

@ -451,7 +451,7 @@ void mgaInitVB( GLcontext *ctx )
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
mmesa->verts = (GLubyte *)ALIGN_MALLOC(size * sizeof(mgaVertex), 32);
mmesa->verts = (GLubyte *)_mesa_align_malloc(size * sizeof(mgaVertex), 32);
{
static int firsttime = 1;
@ -471,7 +471,7 @@ void mgaFreeVB( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
if (mmesa->verts) {
ALIGN_FREE(mmesa->verts);
_mesa_align_free(mmesa->verts);
mmesa->verts = 0;
}
}

View File

@ -331,7 +331,7 @@ void tdfxInitVB( GLcontext *ctx )
firsttime = 0;
}
fxMesa->verts = ALIGN_MALLOC(size * sizeof(tdfxVertex), 32);
fxMesa->verts = _mesa_align_malloc(size * sizeof(tdfxVertex), 32);
fxMesa->vertexFormat = TDFX_LAYOUT_TINY;
fxMesa->SetupIndex = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
}
@ -341,7 +341,7 @@ void tdfxFreeVB( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
if (fxMesa->verts) {
ALIGN_FREE(fxMesa->verts);
_mesa_align_free(fxMesa->verts);
fxMesa->verts = 0;
}
}

View File

@ -808,7 +808,7 @@ void fxAllocVB( GLcontext *ctx )
firsttime = 0;
}
fxMesa->verts = (GrVertex *)ALIGN_MALLOC(size * sizeof(GrVertex), 32);
fxMesa->verts = (GrVertex *)_mesa_align_malloc(size * sizeof(GrVertex), 32);
fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA;
}
@ -817,7 +817,7 @@ void fxFreeVB( GLcontext *ctx )
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
if (fxMesa->verts) {
ALIGN_FREE(fxMesa->verts);
_mesa_align_free(fxMesa->verts);
fxMesa->verts = 0;
}
}

View File

@ -60,17 +60,6 @@ extern "C" {
/** Free memory */
#define FREE(PTR) free(PTR)
/** Allocate \p BYTES aligned at \p N bytes */
#define ALIGN_MALLOC(BYTES, N) _mesa_align_malloc(BYTES, N)
/** Allocate and zero \p BYTES bytes aligned at \p N bytes */
#define ALIGN_CALLOC(BYTES, N) _mesa_align_calloc(BYTES, N)
/** Allocate a structure of type \p T aligned at \p N bytes */
#define ALIGN_MALLOC_STRUCT(T, N) (struct T *) _mesa_align_malloc(sizeof(struct T), N)
/** Allocate and zero a structure of type \p T aligned at \p N bytes */
#define ALIGN_CALLOC_STRUCT(T, N) (struct T *) _mesa_align_calloc(sizeof(struct T), N)
/** Free aligned memory */
#define ALIGN_FREE(PTR) _mesa_align_free(PTR)
/*@}*/

View File

@ -208,7 +208,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
(void) cycles;
mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
mat->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
mat->inv = m = mat->m;
init_matrix( m );
@ -327,7 +327,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
}
}
ALIGN_FREE( mat->m );
_mesa_align_free( mat->m );
return 1;
}

View File

@ -183,7 +183,7 @@ static int test_transform_function( transform_func func, int psize,
return 0;
}
mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
mat->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
mat->type = mtypes[mtype];
m = mat->m;
@ -273,7 +273,7 @@ static int test_transform_function( transform_func func, int psize,
}
}
ALIGN_FREE( mat->m );
_mesa_align_free( mat->m );
return 1;
}

View File

@ -1484,7 +1484,7 @@ _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
void
_math_matrix_ctr( GLmatrix *m )
{
m->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
m->m = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->m)
memcpy( m->m, Identity, sizeof(Identity) );
m->inv = NULL;
@ -1503,11 +1503,11 @@ void
_math_matrix_dtr( GLmatrix *m )
{
if (m->m) {
ALIGN_FREE( m->m );
_mesa_align_free( m->m );
m->m = NULL;
}
if (m->inv) {
ALIGN_FREE( m->inv );
_mesa_align_free( m->inv );
m->inv = NULL;
}
}
@ -1523,7 +1523,7 @@ void
_math_matrix_alloc_inv( GLmatrix *m )
{
if (!m->inv) {
m->inv = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
m->inv = (GLfloat *) _mesa_align_malloc( 16 * sizeof(GLfloat), 16 );
if (m->inv)
memcpy( m->inv, Identity, 16 * sizeof(GLfloat) );
}

View File

@ -101,7 +101,7 @@ _mesa_vector4f_alloc( GLvector4f *v, GLbitfield flags, GLuint count,
{
v->stride = 4 * sizeof(GLfloat);
v->size = 2;
v->storage = ALIGN_MALLOC( count * 4 * sizeof(GLfloat), alignment );
v->storage = _mesa_align_malloc( count * 4 * sizeof(GLfloat), alignment );
v->storage_count = count;
v->start = (GLfloat *) v->storage;
v->data = (GLfloat (*)[4]) v->storage;
@ -119,7 +119,7 @@ void
_mesa_vector4f_free( GLvector4f *v )
{
if (v->flags & VEC_MALLOC) {
ALIGN_FREE( v->storage );
_mesa_align_free( v->storage );
v->data = NULL;
v->start = NULL;
v->storage = NULL;

View File

@ -514,7 +514,7 @@ init_vp(GLcontext *ctx, struct tnl_pipeline_stage *stage)
/* a few other misc allocations */
_mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
store->clipmask = (GLubyte *) _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
return GL_TRUE;
}
@ -537,7 +537,7 @@ dtr(struct tnl_pipeline_stage *stage)
/* free misc arrays */
_mesa_vector4f_free( &store->ndcCoords );
ALIGN_FREE( store->clipmask );
_mesa_align_free( store->clipmask );
FREE( store );
stage->privatePtr = NULL;

View File

@ -246,7 +246,7 @@ static GLboolean init_vertex_stage( GLcontext *ctx,
_mesa_vector4f_alloc( &store->clip, 0, size, 32 );
_mesa_vector4f_alloc( &store->proj, 0, size, 32 );
store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
store->clipmask = (GLubyte *) _mesa_align_malloc(sizeof(GLubyte)*size, 32 );
if (!store->clipmask ||
!store->eye.data ||
@ -265,7 +265,7 @@ static void dtr( struct tnl_pipeline_stage *stage )
_mesa_vector4f_free( &store->eye );
_mesa_vector4f_free( &store->clip );
_mesa_vector4f_free( &store->proj );
ALIGN_FREE( store->clipmask );
_mesa_align_free( store->clipmask );
FREE(store);
stage->privatePtr = NULL;
stage->run = init_vertex_stage;

View File

@ -494,7 +494,7 @@ void _tnl_init_vertices( GLcontext *ctx,
if (max_vertex_size > vtx->max_vertex_size) {
_tnl_free_vertices( ctx );
vtx->max_vertex_size = max_vertex_size;
vtx->vertex_buf = (GLubyte *)ALIGN_CALLOC(vb_size * max_vertex_size, 32 );
vtx->vertex_buf = (GLubyte *)_mesa_align_calloc(vb_size * max_vertex_size, 32 );
invalidate_funcs(vtx);
}
@ -541,7 +541,7 @@ void _tnl_free_vertices( GLcontext *ctx )
struct tnl_clipspace_fastpath *fp, *tmp;
if (vtx->vertex_buf) {
ALIGN_FREE(vtx->vertex_buf);
_mesa_align_free(vtx->vertex_buf);
vtx->vertex_buf = NULL;
}

View File

@ -781,7 +781,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
ctx->Shared->NullBufferObj);
ASSERT(!exec->vtx.buffer_map);
exec->vtx.buffer_map = (GLfloat *)ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE, 64);
exec->vtx.buffer_map = (GLfloat *)_mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
vbo_exec_vtxfmt_init( exec );
@ -835,7 +835,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec )
ASSERT(exec->vtx.bufferobj->Name == 0 ||
exec->vtx.bufferobj->Name == IMM_BUFFER_NAME);
if (exec->vtx.bufferobj->Name == 0) {
ALIGN_FREE(exec->vtx.buffer_map);
_mesa_align_free(exec->vtx.buffer_map);
exec->vtx.buffer_map = NULL;
exec->vtx.buffer_ptr = NULL;
}