From a47965588fdaa75166c48d50974b38fcbfd2a749 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 3 Feb 2009 20:07:42 +0000 Subject: mesa: fix offset problem with interleaved arrays --- src/mesa/state_tracker/st_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 630ad2bcdf9..942f913ea21 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -379,7 +379,7 @@ setup_interleaved_attribs(GLcontext *ctx, else { vbuffer->buffer = NULL; pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer); - vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr; + vbuffer->buffer_offset = (unsigned) low; } vbuffer->stride = stride; /* in bytes */ vbuffer->max_index = max_index; -- cgit v1.2.3 From dc6cc4f9da25725d0b8f6efe571a5430fb399de5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 10 Feb 2009 13:40:00 +0000 Subject: mesa: Compare formats using nominal bytes per pixel. This is a temporary fix which works for the formats we care so far. The real fix would be abandon the concept "nominal bytes per pixel" entirely in Mesa, and use macropixels instead, as done in gallium interfaces already. --- src/mesa/state_tracker/st_cb_texture.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index d08229b57a3..9279a768c82 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1417,9 +1417,7 @@ st_finalize_texture(GLcontext *ctx, stObj->pt->width[0] != firstImage->base.Width2 || stObj->pt->height[0] != firstImage->base.Height2 || stObj->pt->depth[0] != firstImage->base.Depth2 || - stObj->pt->block.size != cpp || - stObj->pt->block.width != 1 || - stObj->pt->block.height != 1 || + stObj->pt->block.size/stObj->pt->block.width != cpp || /* Nominal bytes per pixel */ stObj->pt->compressed != firstImage->base.IsCompressed) { pipe_texture_release(&stObj->pt); ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; -- cgit v1.2.3 From b20a1b28b7e581304701c5802e8627003e461e45 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Tue, 10 Feb 2009 18:31:41 +0100 Subject: Missing: tgsi: Fix build -- rename Size to NrTokens. --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 5b5707fa1c5..8b9b18f94df 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -188,7 +188,7 @@ make_immediate(const float *value, uint size) struct tgsi_full_immediate imm; imm = tgsi_default_full_immediate(); - imm.Immediate.Size += size; + imm.Immediate.NrTokens += size; imm.Immediate.DataType = TGSI_IMM_FLOAT32; imm.u.Pointer = value; return imm; -- cgit v1.2.3 From 1a2f4dd8768703fbc1b2a0d5be342345644805b4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Feb 2009 10:08:25 -0700 Subject: mesa: consistantly use mesa memory-functions in gallium state tracker Use _mesa_malloc(), _mesa_free(), etc everywhere, not malloc(), free(), etc. Still using CALLOC_STRUCT() at this point. --- src/mesa/state_tracker/st_atom.c | 4 ++-- src/mesa/state_tracker/st_atom_shader.c | 4 ++-- src/mesa/state_tracker/st_cb_accum.c | 20 ++++++++++---------- src/mesa/state_tracker/st_cb_bitmap.c | 2 +- src/mesa/state_tracker/st_cb_bufferobjects.c | 2 +- src/mesa/state_tracker/st_cb_clear.c | 4 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 12 ++++++------ src/mesa/state_tracker/st_cb_fbo.c | 2 +- src/mesa/state_tracker/st_cb_program.c | 8 ++++---- src/mesa/state_tracker/st_cb_queryobj.c | 2 +- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_context.c | 4 ++-- src/mesa/state_tracker/st_draw.c | 2 +- src/mesa/state_tracker/st_program.c | 6 +++--- 14 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index fc8587f4598..f79092291b0 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -69,7 +69,7 @@ void st_init_atoms( struct st_context *st ) { GLuint i; - st->atoms = malloc(sizeof(atoms)); + st->atoms = _mesa_malloc(sizeof(atoms)); st->nr_atoms = sizeof(atoms)/sizeof(*atoms); memcpy(st->atoms, atoms, sizeof(atoms)); @@ -92,7 +92,7 @@ void st_init_atoms( struct st_context *st ) void st_destroy_atoms( struct st_context *st ) { if (st->atoms) { - free(st->atoms); + _mesa_free(st->atoms); st->atoms = NULL; } } diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index cbd414e2d3b..5653933e123 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -298,7 +298,7 @@ st_free_translated_vertex_programs(struct st_context *st, while (xvp) { next = xvp->next; - free(xvp); + _mesa_free(xvp); xvp = next; } } @@ -313,7 +313,7 @@ get_passthrough_fs(struct st_context *st) st->passthrough_fs = util_make_fragment_passthrough_shader(st->pipe, &shader); #if 0 /* We actually need to keep the tokens around at this time */ - free((void *) shader.tokens); + _mesa_free((void *) shader.tokens); #endif } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index a4e72b48ed4..2fc37343bdf 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -206,8 +206,8 @@ accum_accum(struct pipe_context *pipe, GLfloat value, color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); - colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + colorBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + accBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, colorBuf); acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf); @@ -218,8 +218,8 @@ accum_accum(struct pipe_context *pipe, GLfloat value, acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf); - free(colorBuf); - free(accBuf); + _mesa_free(colorBuf); + _mesa_free(accBuf); pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&color_surf, NULL); } @@ -242,7 +242,7 @@ accum_load(struct pipe_context *pipe, GLfloat value, color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); - buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, buf); @@ -252,7 +252,7 @@ accum_load(struct pipe_context *pipe, GLfloat value, acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, buf); - free(buf); + _mesa_free(buf); pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&color_surf, NULL); } @@ -271,7 +271,7 @@ accum_return(GLcontext *ctx, GLfloat value, GLfloat *abuf, *cbuf = NULL; GLint i, ch; - abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + abuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); @@ -283,7 +283,7 @@ accum_return(GLcontext *ctx, GLfloat value, acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, abuf); if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { - cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + cbuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, cbuf); } @@ -301,9 +301,9 @@ accum_return(GLcontext *ctx, GLfloat value, pipe_put_tile_rgba(color_surf, xpos, ypos, width, height, abuf); - free(abuf); + _mesa_free(abuf); if (cbuf) - free(cbuf); + _mesa_free(cbuf); pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&color_surf, NULL); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index f14e562400b..fff348de59e 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -827,7 +827,7 @@ st_destroy_bitmap(struct st_context *st) if (st->bitmap.cache) { pipe_texture_release(&st->bitmap.cache->texture); - FREE(st->bitmap.cache); + _mesa_free(st->bitmap.cache); st->bitmap.cache = NULL; } } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 07fa2afce05..e601ec46f8f 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -80,7 +80,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) if (st_obj->buffer) pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL); - free(st_obj); + _mesa_free(st_obj); } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 668c3f9ebf4..0eddda23a7a 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -98,12 +98,12 @@ st_destroy_clear(struct st_context *st) struct pipe_context *pipe = st->pipe; if (st->clear.vert_shader.tokens) { - FREE((void *) st->clear.vert_shader.tokens); + _mesa_free((void *) st->clear.vert_shader.tokens); st->clear.vert_shader.tokens = NULL; } if (st->clear.frag_shader.tokens) { - FREE((void *) st->clear.frag_shader.tokens); + _mesa_free((void *) st->clear.frag_shader.tokens); st->clear.frag_shader.tokens = NULL; } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 32bf21411da..cb4a01c22b6 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -896,7 +896,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, ubyte *buffer; int i; - buffer = malloc(width * height * sizeof(ubyte)); + buffer = _mesa_malloc(width * height * sizeof(ubyte)); if (!buffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels(stencil)"); return; @@ -950,7 +950,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } - free(buffer); + _mesa_free(buffer); /* unmap the stencil buffer */ screen->surface_unmap(screen, psDraw); @@ -1056,19 +1056,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (type == GL_COLOR) { /* alternate path using get/put_tile() */ - GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + GLfloat *buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(psRead, srcx, srcy, width, height, buf); pipe_put_tile_rgba(psTex, 0, 0, width, height, buf); - free(buf); + _mesa_free(buf); } else { /* GL_DEPTH */ - GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); + GLuint *buf = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); pipe_get_tile_z(psRead, srcx, srcy, width, height, buf); pipe_put_tile_z(psTex, 0, 0, width, height, buf); - free(buf); + _mesa_free(buf); } pipe_surface_reference(&psRead, NULL); } diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 9af648b8d0f..fd85a7a3050 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -194,7 +194,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) ASSERT(strb); pipe_surface_reference(&strb->surface, NULL); pipe_texture_reference(&strb->texture, NULL); - free(strb); + _mesa_free(strb); } diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index ea0fa20012e..44f47865f80 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -152,7 +152,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog) } if (stvp->state.tokens) { - FREE((void *) stvp->state.tokens); + _mesa_free((void *) stvp->state.tokens); stvp->state.tokens = NULL; } } @@ -167,7 +167,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog) } if (stfp->state.tokens) { - FREE((void *) stfp->state.tokens); + _mesa_free((void *) stfp->state.tokens); stfp->state.tokens = NULL; } @@ -214,7 +214,7 @@ static void st_program_string_notify( GLcontext *ctx, } if (stfp->state.tokens) { - FREE((void *) stfp->state.tokens); + _mesa_free((void *) stfp->state.tokens); stfp->state.tokens = NULL; } @@ -242,7 +242,7 @@ static void st_program_string_notify( GLcontext *ctx, } if (stvp->state.tokens) { - FREE((void *) stvp->state.tokens); + _mesa_free((void *) stvp->state.tokens); stvp->state.tokens = NULL; } diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index 21c2c7dd9ff..bd2716a45f5 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -87,7 +87,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) stq->pq = NULL; } - FREE(stq); + _mesa_free(stq); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 8867ca5652e..f4057778bda 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -102,7 +102,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim ) static void rastpos_destroy(struct draw_stage *stage) { - free(stage); + _mesa_free(stage); } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index e584a6ceeac..34f76d44625 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -217,7 +217,7 @@ static void st_destroy_context_priv( struct st_context *st ) st->default_texture = NULL; } - free( st ); + _mesa_free( st ); } @@ -245,7 +245,7 @@ void st_destroy_context( struct st_context *st ) pipe->destroy( pipe ); - free(ctx); + _mesa_free(ctx); } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index ae71d586c2f..b52e4886128 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -223,7 +223,7 @@ setup_edgeflags(GLcontext *ctx, GLenum primMode, GLint start, GLint count, if (!stobj) return NULL; - vec = (unsigned *) calloc(sizeof(unsigned), (count + 31) / 32); + vec = (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count + 31) / 32)); if (!vec) return NULL; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 442eeed1470..d2535b6a2fa 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -61,9 +61,9 @@ static INLINE void * mem_dup(const void *src, uint size) { - void *dup = MALLOC(size); + void *dup = _mesa_malloc(size); if (dup) - memcpy(dup, src, size); + _mesa_memcpy(dup, src, size); return dup; } @@ -307,7 +307,7 @@ st_translate_vertex_program(struct st_context *st, /* free old shader state, if any */ if (stvp->state.tokens) { - FREE((void *) stvp->state.tokens); + _mesa_free((void *) stvp->state.tokens); stvp->state.tokens = NULL; } if (stvp->driver_shader) { -- cgit v1.2.3 From f1a59a6dd7b7b0523db191d82b3af1a841c6475d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 12 Feb 2009 10:14:36 -0700 Subject: mesa: use new ST_CALLOC_STRUCT() macro in gallium state tracker --- src/mesa/state_tracker/st_atom_shader.c | 2 +- src/mesa/state_tracker/st_cb_bitmap.c | 2 +- src/mesa/state_tracker/st_cb_bufferobjects.c | 2 +- src/mesa/state_tracker/st_cb_fbo.c | 4 ++-- src/mesa/state_tracker/st_cb_feedback.c | 4 ++-- src/mesa/state_tracker/st_cb_program.c | 4 ++-- src/mesa/state_tracker/st_cb_queryobj.c | 2 +- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_cb_texture.c | 4 ++-- src/mesa/state_tracker/st_context.c | 2 +- src/mesa/state_tracker/st_context.h | 4 ++++ src/mesa/state_tracker/st_framebuffer.c | 2 +- 12 files changed, 19 insertions(+), 15 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 5653933e123..bed3ff4ae5b 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -165,7 +165,7 @@ find_translated_vp(struct st_context *st, /* No? Allocate translated vp object now */ if (!xvp) { - xvp = CALLOC_STRUCT(translated_vertex_program); + xvp = ST_CALLOC_STRUCT(translated_vertex_program); xvp->frag_inputs = fragInputsRead; xvp->master = stvp; diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index fff348de59e..da0ea645580 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -798,7 +798,7 @@ st_init_bitmap(struct st_context *st) } /* alloc bitmap cache object */ - st->bitmap.cache = CALLOC_STRUCT(bitmap_cache); + st->bitmap.cache = ST_CALLOC_STRUCT(bitmap_cache); reset_cache(st); } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index e601ec46f8f..aba1cda9323 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -55,7 +55,7 @@ static struct gl_buffer_object * st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target) { - struct st_buffer_object *st_obj = CALLOC_STRUCT(st_buffer_object); + struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object); if (!st_obj) return NULL; diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index fd85a7a3050..611d78df0c4 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -232,7 +232,7 @@ st_new_framebuffer(GLcontext *ctx, GLuint name) static struct gl_renderbuffer * st_new_renderbuffer(GLcontext *ctx, GLuint name) { - struct st_renderbuffer *strb = CALLOC_STRUCT(st_renderbuffer); + struct st_renderbuffer *strb = ST_CALLOC_STRUCT(st_renderbuffer); if (strb) { _mesa_init_renderbuffer(&strb->Base, name); strb->Base.Delete = st_renderbuffer_delete; @@ -254,7 +254,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples) { struct st_renderbuffer *strb; - strb = CALLOC_STRUCT(st_renderbuffer); + strb = ST_CALLOC_STRUCT(st_renderbuffer); if (!strb) { _mesa_error(NULL, GL_OUT_OF_MEMORY, "creating renderbuffer"); return NULL; diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index c7e8aa7cc56..86d35422622 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -184,7 +184,7 @@ feedback_destroy( struct draw_stage *stage ) static struct draw_stage * draw_glfeedback_stage(GLcontext *ctx, struct draw_context *draw) { - struct feedback_stage *fs = CALLOC_STRUCT(feedback_stage); + struct feedback_stage *fs = ST_CALLOC_STRUCT(feedback_stage); fs->stage.draw = draw; fs->stage.next = NULL; @@ -257,7 +257,7 @@ select_destroy( struct draw_stage *stage ) static struct draw_stage * draw_glselect_stage(GLcontext *ctx, struct draw_context *draw) { - struct feedback_stage *fs = CALLOC_STRUCT(feedback_stage); + struct feedback_stage *fs = ST_CALLOC_STRUCT(feedback_stage); fs->stage.draw = draw; fs->stage.next = NULL; diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 44f47865f80..4398ab28392 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -99,7 +99,7 @@ static struct gl_program *st_new_program( GLcontext *ctx, { switch (target) { case GL_VERTEX_PROGRAM_ARB: { - struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program); + struct st_vertex_program *prog = ST_CALLOC_STRUCT(st_vertex_program); prog->serialNo = SerialNo++; @@ -111,7 +111,7 @@ static struct gl_program *st_new_program( GLcontext *ctx, case GL_FRAGMENT_PROGRAM_ARB: case GL_FRAGMENT_PROGRAM_NV: { - struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program); + struct st_fragment_program *prog = ST_CALLOC_STRUCT(st_fragment_program); prog->serialNo = SerialNo++; diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index bd2716a45f5..dcf4c38eb61 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -64,7 +64,7 @@ st_query_object(struct gl_query_object *q) static struct gl_query_object * st_NewQueryObject(GLcontext *ctx, GLuint id) { - struct st_query_object *stq = CALLOC_STRUCT(st_query_object); + struct st_query_object *stq = ST_CALLOC_STRUCT(st_query_object); if (stq) { stq->base.Id = id; stq->base.Ready = GL_TRUE; diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index f4057778bda..7dd23527399 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -180,7 +180,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim) static struct rastpos_stage * new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw) { - struct rastpos_stage *rs = CALLOC_STRUCT(rastpos_stage); + struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage); GLuint i; rs->stage.draw = draw; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 9279a768c82..3dd1f1d737d 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -114,7 +114,7 @@ st_NewTextureImage(GLcontext * ctx) { DBG("%s\n", __FUNCTION__); (void) ctx; - return (struct gl_texture_image *) CALLOC_STRUCT(st_texture_image); + return (struct gl_texture_image *) ST_CALLOC_STRUCT(st_texture_image); } @@ -122,7 +122,7 @@ st_NewTextureImage(GLcontext * ctx) static struct gl_texture_object * st_NewTextureObject(GLcontext * ctx, GLuint name, GLenum target) { - struct st_texture_object *obj = CALLOC_STRUCT(st_texture_object); + struct st_texture_object *obj = ST_CALLOC_STRUCT(st_texture_object); DBG("%s\n", __FUNCTION__); _mesa_initialize_texture_object(&obj->base, name, target); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 34f76d44625..6d6c9f43329 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -105,7 +105,7 @@ static struct st_context * st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) { uint i; - struct st_context *st = CALLOC_STRUCT( st_context ); + struct st_context *st = ST_CALLOC_STRUCT( st_context ); ctx->st = st; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 695ac4a96f4..3547925ad7f 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -242,6 +242,10 @@ st_fb_orientation(const struct gl_framebuffer *fb) } +/** clear-alloc a struct-sized object, with casting */ +#define ST_CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T)) + + extern int st_get_msaa(void); diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 0d9c7b97e3d..0d4474a8b3a 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -49,7 +49,7 @@ st_create_framebuffer( const __GLcontextModes *visual, uint width, uint height, void *private) { - struct st_framebuffer *stfb = CALLOC_STRUCT(st_framebuffer); + struct st_framebuffer *stfb = ST_CALLOC_STRUCT(st_framebuffer); if (stfb) { int samples = st_get_msaa(); -- cgit v1.2.3