summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2009-08-18 20:25:37 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-08-29 09:21:34 +0100
commita22f87c99462fd83dc398f4c06fc6d9997e15dba (patch)
tree27cfb130bbbdd4a5dca7536b50b2f0de46c2802a /src
parent49d83fdc4599256da9a33ed943009038859c34c5 (diff)
llvmpipe: use align_malloc for all structs containing ALIGN16 members
Unless the struct is allocated aligned, aligning the members isn't very helpful.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.c10
-rw-r--r--src/gallium/drivers/llvmpipe/lp_quad_fs.c6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c9
-rw-r--r--src/gallium/drivers/llvmpipe/lp_tile_cache.c5
4 files changed, 22 insertions, 8 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c
index 66d0cf7759..7e7015defc 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -106,7 +106,7 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
}
}
- FREE( llvmpipe );
+ align_free( llvmpipe );
}
static unsigned int
@@ -143,11 +143,17 @@ llvmpipe_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_context *
llvmpipe_create( struct pipe_screen *screen )
{
- struct llvmpipe_context *llvmpipe = CALLOC_STRUCT(llvmpipe_context);
+ struct llvmpipe_context *llvmpipe;
uint i;
+ llvmpipe = align_malloc(sizeof(struct llvmpipe_context), 16);
+ if (!llvmpipe)
+ return NULL;
+
util_init_math();
+ memset(llvmpipe, 0, sizeof *llvmpipe);
+
llvmpipe->pipe.winsys = screen->winsys;
llvmpipe->pipe.screen = screen;
llvmpipe->pipe.destroy = llvmpipe_destroy;
diff --git a/src/gallium/drivers/llvmpipe/lp_quad_fs.c b/src/gallium/drivers/llvmpipe/lp_quad_fs.c
index 1c44031872..5a4cadcd6b 100644
--- a/src/gallium/drivers/llvmpipe/lp_quad_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_quad_fs.c
@@ -237,7 +237,7 @@ shade_begin(struct quad_stage *qs)
static void
shade_destroy(struct quad_stage *qs)
{
- FREE( qs );
+ align_free( qs );
}
@@ -246,10 +246,12 @@ lp_quad_shade_stage( struct llvmpipe_context *llvmpipe )
{
struct quad_shade_stage *qss;
- qss = CALLOC_STRUCT(quad_shade_stage);
+ qss = align_malloc(sizeof(struct quad_shade_stage), 16);
if (!qss)
return NULL;
+ memset(qss, 0, sizeof *qss);
+
qss->stage.llvmpipe = llvmpipe;
qss->stage.begin = shade_begin;
qss->stage.run = shade_quads;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 04ae644ff9..f06538c75f 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -1358,7 +1358,7 @@ void setup_prepare( struct setup_context *setup )
void setup_destroy_context( struct setup_context *setup )
{
- FREE( setup );
+ align_free( setup );
}
@@ -1367,9 +1367,14 @@ void setup_destroy_context( struct setup_context *setup )
*/
struct setup_context *setup_create_context( struct llvmpipe_context *llvmpipe )
{
- struct setup_context *setup = CALLOC_STRUCT(setup_context);
+ struct setup_context *setup;
unsigned i;
+ setup = align_malloc(sizeof(struct setup_context), 16);
+ if (!setup)
+ return NULL;
+
+ memset(setup, 0, sizeof *setup);
setup->llvmpipe = llvmpipe;
for (i = 0; i < MAX_QUADS; i++) {
diff --git a/src/gallium/drivers/llvmpipe/lp_tile_cache.c b/src/gallium/drivers/llvmpipe/lp_tile_cache.c
index 94908f601c..e2fb157c02 100644
--- a/src/gallium/drivers/llvmpipe/lp_tile_cache.c
+++ b/src/gallium/drivers/llvmpipe/lp_tile_cache.c
@@ -88,8 +88,9 @@ lp_create_tile_cache( struct pipe_screen *screen )
struct llvmpipe_tile_cache *tc;
uint pos;
- tc = CALLOC_STRUCT( llvmpipe_tile_cache );
+ tc = align_malloc( sizeof(struct llvmpipe_tile_cache), 16 );
if (tc) {
+ memset(tc, 0, sizeof *tc);
tc->screen = screen;
for (pos = 0; pos < NUM_ENTRIES; pos++) {
tc->entries[pos].addr.bits.invalid = 1;
@@ -118,7 +119,7 @@ lp_destroy_tile_cache(struct llvmpipe_tile_cache *tc)
screen->tex_transfer_destroy(tc->tex_trans);
}
- FREE( tc );
+ align_free( tc );
}