gallium: add draw_stage::destroy().

This commit is contained in:
Michal 2007-11-23 11:30:51 +00:00 committed by José Fonseca
parent 74fe189b2e
commit d754548406
17 changed files with 128 additions and 7 deletions

View file

@ -415,6 +415,13 @@ static void clip_reset_stipple_counter( struct draw_stage *stage )
}
static void clip_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
/**
* Allocate a new clipper stage.
* \return pointer to new stage object
@ -432,6 +439,7 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw )
clipper->stage.tri = clip_tri;
clipper->stage.end = clip_end;
clipper->stage.reset_stipple_counter = clip_reset_stipple_counter;
clipper->stage.destroy = clip_destroy;
clipper->plane = draw->plane;

View file

@ -92,6 +92,16 @@ struct draw_context *draw_create( void )
void draw_destroy( struct draw_context *draw )
{
draw->pipeline.wide->destroy( draw->pipeline.wide );
draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
draw->pipeline.twoside->destroy( draw->pipeline.twoside );
draw->pipeline.offset->destroy( draw->pipeline.offset );
draw->pipeline.clip->destroy( draw->pipeline.clip );
draw->pipeline.flatshade->destroy( draw->pipeline.flatshade );
draw->pipeline.cull->destroy( draw->pipeline.cull );
draw->pipeline.feedback->destroy( draw->pipeline.feedback );
draw->pipeline.validate->destroy( draw->pipeline.validate );
draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
FREE( draw->vcache.vertex[0] ); /* Frees all the vertices. */
FREE( draw );
}

View file

@ -116,6 +116,14 @@ static void cull_reset_stipple_counter( struct draw_stage *stage )
stage->next->reset_stipple_counter( stage->next );
}
static void cull_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
/**
* Create a new polygon culling stage.
*/
@ -133,6 +141,7 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw )
cull->stage.tri = cull_tri;
cull->stage.end = cull_end;
cull->stage.reset_stipple_counter = cull_reset_stipple_counter;
cull->stage.destroy = cull_destroy;
return &cull->stage;
}

View file

@ -224,6 +224,12 @@ static void feedback_reset_stipple_counter( struct draw_stage *stage )
}
static void feedback_destroy( struct draw_stage *stage )
{
FREE( stage );
}
/**
* Create feedback drawing stage.
*/
@ -239,6 +245,7 @@ struct draw_stage *draw_feedback_stage( struct draw_context *draw )
feedback->stage.tri = feedback_tri;
feedback->stage.end = feedback_end;
feedback->stage.reset_stipple_counter = feedback_reset_stipple_counter;
feedback->stage.destroy = feedback_destroy;
return &feedback->stage;
}

View file

@ -127,6 +127,13 @@ static void flatshade_reset_stipple_counter( struct draw_stage *stage )
}
static void flatshade_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
/**
* Create flatshading drawing stage.
*/
@ -144,6 +151,7 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
flatshade->tri = flatshade_tri;
flatshade->end = flatshade_end;
flatshade->reset_stipple_counter = flatshade_reset_stipple_counter;
flatshade->destroy = flatshade_destroy;
return flatshade;
}

View file

@ -241,12 +241,18 @@ static void stipple_begin( struct clip_pipe_stage *stage )
}
static void stipple_end( struct clip_pipe_stage *stage )
{
stage->next->end( stage->next );
}
static void stipple_destroy( struct clip_pipe_stage *stage )
{
FREE( stage );
}
struct clip_pipe_stage *clip_pipe_stipple( struct clip_pipeline *pipe )
{
struct stipple_stage *stipple = CALLOC_STRUCT(stipple_stage);
@ -261,6 +267,7 @@ struct clip_pipe_stage *clip_pipe_stipple( struct clip_pipeline *pipe )
stipple->stage.tri = clip_passthrough_tri;
stipple->stage.reset_tmps = clip_pipe_reset_tmps;
stipple->stage.end = stipple_end;
stipple->stage.destroy = stipple_destroy;
return &stipple->stage;
}

View file

@ -151,6 +151,13 @@ static void offset_reset_stipple_counter( struct draw_stage *stage )
}
static void offset_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
/**
* Create polygon offset drawing stage.
*/
@ -168,6 +175,7 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw )
offset->stage.tri = offset_tri;
offset->stage.end = offset_end;
offset->stage.reset_stipple_counter = offset_reset_stipple_counter;
offset->stage.destroy = offset_destroy;
return &offset->stage;
}

View file

@ -124,6 +124,8 @@ struct draw_stage
void (*reset_tmps)( struct draw_stage * );
void (*reset_stipple_counter)( struct draw_stage * );
void (*destroy)( struct draw_stage * );
};

View file

@ -146,6 +146,13 @@ static void twoside_reset_stipple_counter( struct draw_stage *stage )
}
static void twoside_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
/**
* Create twoside pipeline stage.
*/
@ -163,6 +170,7 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw )
twoside->stage.tri = twoside_tri;
twoside->stage.end = twoside_end;
twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter;
twoside->stage.destroy = twoside_destroy;
return &twoside->stage;
}

View file

@ -168,6 +168,13 @@ static void unfilled_reset_stipple_counter( struct draw_stage *stage )
}
static void unfilled_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
/**
* Create unfilled triangle stage.
*/
@ -186,6 +193,7 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
unfilled->stage.tri = unfilled_tri;
unfilled->stage.end = unfilled_end;
unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
unfilled->stage.destroy = unfilled_destroy;
return &unfilled->stage;
}

View file

@ -110,6 +110,10 @@ static void validate_begin( struct draw_stage *stage )
}
static void validate_destroy( struct draw_stage *stage )
{
FREE( stage );
}
/**
@ -127,6 +131,7 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw )
stage->tri = NULL;
stage->end = NULL;
stage->reset_stipple_counter = NULL;
stage->destroy = validate_destroy;
return stage;
}

View file

@ -369,6 +369,15 @@ vbuf_reset_stipple_counter( struct draw_stage *stage )
}
static void vbuf_destroy( struct draw_stage *stage )
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
FREE( vbuf->indices );
FREE( stage );
}
/**
* Create a new primitive vbuf/render stage.
*/
@ -384,12 +393,12 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
vbuf->stage.tri = vbuf_first_tri;
vbuf->stage.end = vbuf_end;
vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter;
vbuf->stage.destroy = vbuf_destroy;
vbuf->render = render;
assert(render->max_indices < UNDEFINED_VERTEX_ID);
vbuf->max_indices = render->max_indices;
/* FIXME: free this memory on takedown */
vbuf->indices = MALLOC( vbuf->max_indices );
vbuf->vertices = NULL;

View file

@ -315,7 +315,6 @@ static void wide_begin( struct draw_stage *stage )
}
static void wide_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
@ -327,6 +326,14 @@ static void draw_reset_stipple_counter( struct draw_stage *stage )
stage->next->reset_stipple_counter( stage->next );
}
static void wide_destroy( struct draw_stage *stage )
{
draw_free_tmps( stage );
FREE( stage );
}
struct draw_stage *draw_wide_stage( struct draw_context *draw )
{
struct wide_stage *wide = CALLOC_STRUCT(wide_stage);
@ -341,6 +348,7 @@ struct draw_stage *draw_wide_stage( struct draw_context *draw )
wide->stage.tri = passthrough_tri;
wide->stage.end = wide_end;
wide->stage.reset_stipple_counter = draw_reset_stipple_counter;
wide->stage.destroy = wide_destroy;
return &wide->stage;
}

View file

@ -194,6 +194,11 @@ static void reset_stipple_counter( struct draw_stage *stage )
{
}
static void render_destroy( struct draw_stage *stage )
{
FREE( stage );
}
/**
* Create a new primitive setup/render stage. This gets plugged into
@ -211,6 +216,7 @@ struct draw_stage *i915_draw_render_stage( struct i915_context *i915 )
setup->stage.tri = setup_tri;
setup->stage.end = setup_end;
setup->stage.reset_stipple_counter = reset_stipple_counter;
setup->stage.destroy = render_destroy;
return &setup->stage;
}

View file

@ -1124,6 +1124,12 @@ static void reset_stipple_counter( struct draw_stage *stage )
}
static void render_destroy( struct draw_stage *stage )
{
FREE( stage );
}
/**
* Create a new primitive setup/render stage.
*/
@ -1139,6 +1145,7 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe )
setup->stage.tri = setup_tri;
setup->stage.end = setup_end;
setup->stage.reset_stipple_counter = reset_stipple_counter;
setup->stage.destroy = render_destroy;
setup->quad.coef = setup->coef;

View file

@ -275,6 +275,16 @@ static void reset_stipple_counter( struct draw_stage *stage )
}
static void vbuf_destroy( struct draw_stage *stage )
{
struct vbuf_stage *vbuf = vbuf_stage( stage );
FREE( vbuf->element_map );
FREE( vbuf->vertex_map );
FREE( stage );
}
/**
* Create a new primitive vbuf/render stage.
*/
@ -290,6 +300,7 @@ struct draw_stage *sp_draw_vbuf_stage( struct draw_context *draw_context,
vbuf->stage.tri = vbuf_first_tri;
vbuf->stage.end = vbuf_end;
vbuf->stage.reset_stipple_counter = reset_stipple_counter;
vbuf->stage.destroy = vbuf_destroy;
vbuf->pipe = pipe;
vbuf->draw = draw;

View file

@ -1808,7 +1808,7 @@ exec_instruction(
micro_sub( &r[2], &r[2], &r[5] );
if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
STORE( &r[2], 0, CHAN_X );
STORE( &r[2], 0, CHAN_X );
}
FETCH(&r[2], 1, CHAN_X);
@ -1821,7 +1821,7 @@ exec_instruction(
micro_sub( &r[3], &r[3], &r[1] );
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
STORE( &r[3], 0, CHAN_Y );
STORE( &r[3], 0, CHAN_Y );
}
micro_mul( &r[5], &r[5], &r[4] );
@ -1829,11 +1829,11 @@ exec_instruction(
micro_sub( &r[5], &r[5], &r[0] );
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
STORE( &r[5], 0, CHAN_Z );
STORE( &r[5], 0, CHAN_Z );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
break;