gallium: add draw_stage::destroy().
authorMichal <michal@tungstengraphics.com>
Fri, 23 Nov 2007 11:30:51 +0000 (11:30 +0000)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Sun, 9 Dec 2007 14:03:34 +0000 (14:03 +0000)
17 files changed:
src/mesa/pipe/draw/draw_clip.c
src/mesa/pipe/draw/draw_context.c
src/mesa/pipe/draw/draw_cull.c
src/mesa/pipe/draw/draw_feedback.c
src/mesa/pipe/draw/draw_flatshade.c
src/mesa/pipe/draw/draw_linestipple.c
src/mesa/pipe/draw/draw_offset.c
src/mesa/pipe/draw/draw_private.h
src/mesa/pipe/draw/draw_twoside.c
src/mesa/pipe/draw/draw_unfilled.c
src/mesa/pipe/draw/draw_validate.c
src/mesa/pipe/draw/draw_vbuf.c
src/mesa/pipe/draw/draw_wide_prims.c
src/mesa/pipe/i915simple/i915_prim_emit.c
src/mesa/pipe/softpipe/sp_prim_setup.c
src/mesa/pipe/softpipe/sp_prim_vbuf.c
src/mesa/pipe/tgsi/exec/tgsi_exec.c

index e4c257a0ee26048c9b2ff2eaf0958ef3f6fb0609..c50376f11fe37642dd9005a232ce8fd9abefac89 100644 (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;
 
index e7997180b5bcd9fc74482a8927756460d8aa1a55..c7ad4c3d68ca1e8ca045d5aa9df271aec7c74d37 100644 (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 );
 }
index f898834ba5d265c619789015788fbceba07455cc..9bd53f45f26ff5c92ab1b6d81ef80e08a443f0f1 100644 (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;
 }
index b9906e5b4b0348fed983490ac6e76c2d93c99d29..aea6a8184c0bfa20a7241b204d78597f598b2c4c 100644 (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;
 }
index d46e53f2be2e7bd7ef27d3cda7d627572abc9c74..d7551e794812ad65beef4fa604e3d90cf452d34b 100644 (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;
 }
index 1fac1ebe66eb5428932f088583b6be888dd3ecee..5f0db99b23fc1ee32ce82562d12bba6d2c135665 100644 (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;
 }
index 6acc7cbcd29ed579cb13fb221884b64aa0ab51a8..f8a01db3dd87c6c4ced761a61864ceacc91127fb 100644 (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;
 }
index 53d7451113111421f41f4a9554c7b044af16f2a8..ca5ca7b3c90c0871cdfdb244c49db00c8029e90b 100644 (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 * );
 };
 
 
index d987b0059865fdafb5baceca994b2e05149b7c8e..00b4ee45cdc18b7bfbd8e06ba54b8f5255db6e7c 100644 (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;
 }
index 6cab086a45216047b415cbb65753410993d915a6..786826b33c1af7ffadb5430bd56affc20e72fad4 100644 (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;
 }
index 4e8f986b272a62cb28a170a12905ac0aecc0214b..8ce4a926e2225373d6ef23cbe700989cb9b923ad 100644 (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;
 }
index d00cdec56c62b1de958b0fc7f8a646dac5310795..d010aaba07609b72bba62e0c90fb2b5acff67627 100644 (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;
index 494a2bc619985552f26a8efaad66e8a10625664f..a56c9b88939f1ece7b31e66ee5975d02b097dcda 100644 (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;
 }
index 0a8be79ae47503ef498b38127e9c0dbe21cd7e65..c50a59158993a953e4037d3e4843030b972ff869 100644 (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;
 }
index 9f5a43a8278e245e17ebff14e478987ae72d4413..6980564bdc83dd9f4940fa9526de99f8adaf6fb0 100644 (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;
 
index 59cf1c4eb7544fe0bdce5289c9a3cfcfdc7c8ca4..2cfdeb5809033146ad9a686744dea171bc736ea7 100644 (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;
index dd11dd58b78b8cc24d572ddfc1777a4b5487f819..d036e9d38369be359c9ec7eb0240215072888e8f 100644 (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;