release all BOs when terminating
authorXiang, Haihao <haihao.xiang@intel.com>
Sat, 2 Apr 2011 04:38:36 +0000 (12:38 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 7 Apr 2011 06:44:58 +0000 (14:44 +0800)
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
i965_drv_video/gen6_mfc.c
i965_drv_video/i965_encoder.c

index 81520ed..602d0d2 100644 (file)
@@ -462,45 +462,37 @@ static void gen6_mfc_init(VADriverContextP ctx)
     bcs_state->mfc_indirect_pak_bse_object.bo = NULL;
 
     for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){
+        dri_bo_unreference(bcs_state->direct_mv_buffers[i].bo);
         bcs_state->direct_mv_buffers[i].bo = NULL;
-    }          
-    for (i = 0; i < MAX_MFC_REFERENCE_SURFACES; i++){
-        bcs_state->reference_surfaces[i].surface_id = VA_INVALID_SURFACE;  
     }
 
-    if ( bcs_state->intra_row_store_scratch_buffer.bo == 0) {
-        //bo = bcs_state->intra_row_store_scratch_buffer.bo;
-        //dri_bo_unreference(bo);
-        bo = dri_bo_alloc(i965->intel.bufmgr,
-                          "Buffer",
-                          128 * 64,
-                          64);
-        assert(bo);
-        bcs_state->intra_row_store_scratch_buffer.bo = bo;
+    for (i = 0; i < MAX_MFC_REFERENCE_SURFACES; i++){
+        bcs_state->reference_surfaces[i].surface_id = VA_INVALID_SURFACE;  
     }
 
-    if ( bcs_state->deblocking_filter_row_store_scratch_buffer.bo == 0) {              
-        //bo = bcs_state->deblocking_filter_row_store_scratch_buffer.bo;
-        //dri_bo_unreference(bo);
-        bo = dri_bo_alloc(i965->intel.bufmgr,
-                          "Buffer",
-                          49152,  /* 6 * 128 * 64 */
-                          64);
-        assert(bo);
-        bcs_state->deblocking_filter_row_store_scratch_buffer.bo = bo;
-    }
+    dri_bo_unreference(bcs_state->intra_row_store_scratch_buffer.bo);
+    bo = dri_bo_alloc(i965->intel.bufmgr,
+                      "Buffer",
+                      128 * 64,
+                      64);
+    assert(bo);
+    bcs_state->intra_row_store_scratch_buffer.bo = bo;
 
-    if ( bcs_state->bsd_mpc_row_store_scratch_buffer.bo == 0) {        
-        //bo = bcs_state->bsd_mpc_row_store_scratch_buffer.bo;
-        //dri_bo_unreference(bo);
-        bo = dri_bo_alloc(i965->intel.bufmgr,
-                          "Buffer",
-                          12288, /* 1.5 * 128 * 64 */
-                          0x1000);
-        assert(bo);
-        bcs_state->bsd_mpc_row_store_scratch_buffer.bo = bo;
-    }
+    dri_bo_unreference(bcs_state->deblocking_filter_row_store_scratch_buffer.bo);
+    bo = dri_bo_alloc(i965->intel.bufmgr,
+                      "Buffer",
+                      49152,  /* 6 * 128 * 64 */
+                      64);
+    assert(bo);
+    bcs_state->deblocking_filter_row_store_scratch_buffer.bo = bo;
 
+    dri_bo_unreference(bcs_state->bsd_mpc_row_store_scratch_buffer.bo);
+    bo = dri_bo_alloc(i965->intel.bufmgr,
+                      "Buffer",
+                      12288, /* 1.5 * 128 * 64 */
+                      0x1000);
+    assert(bo);
+    bcs_state->bsd_mpc_row_store_scratch_buffer.bo = bo;
 }
 
 void gen6_mfc_avc_pipeline_programing(VADriverContextP ctx, void *obj)
index f5b48d6..cb21344 100644 (file)
@@ -328,9 +328,12 @@ Bool i965_encoder_terminate(VADriverContextP ctx)
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct gen6_media_state *media_state = &i965->gen6_media_state;
+    struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state;
     int i;
 
-    gen6_vme_terminate(ctx);
+    if (IS_GEN6(i965->intel.device_id)) {
+        gen6_vme_terminate(ctx);
+    }
 
     for (i = 0; i < MAX_MEDIA_SURFACES_GEN6; i++) {
         dri_bo_unreference(media_state->surface_state[i].bo);
@@ -352,5 +355,31 @@ Bool i965_encoder_terminate(VADriverContextP ctx)
     dri_bo_unreference(media_state->vme_state.bo);
     media_state->vme_state.bo = NULL;
 
+    dri_bo_unreference(bcs_state->post_deblocking_output.bo);
+    bcs_state->post_deblocking_output.bo = NULL;
+
+    dri_bo_unreference(bcs_state->pre_deblocking_output.bo);
+    bcs_state->pre_deblocking_output.bo = NULL;
+
+    dri_bo_unreference(bcs_state->uncompressed_picture_source.bo);
+    bcs_state->uncompressed_picture_source.bo = NULL;
+
+    dri_bo_unreference(bcs_state->mfc_indirect_pak_bse_object.bo); 
+    bcs_state->mfc_indirect_pak_bse_object.bo = NULL;
+
+    for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){
+        dri_bo_unreference(bcs_state->direct_mv_buffers[i].bo);
+        bcs_state->direct_mv_buffers[i].bo = NULL;
+    }
+
+    dri_bo_unreference(bcs_state->intra_row_store_scratch_buffer.bo);
+    bcs_state->intra_row_store_scratch_buffer.bo = NULL;
+
+    dri_bo_unreference(bcs_state->deblocking_filter_row_store_scratch_buffer.bo);
+    bcs_state->deblocking_filter_row_store_scratch_buffer.bo = NULL;
+
+    dri_bo_unreference(bcs_state->bsd_mpc_row_store_scratch_buffer.bo);
+    bcs_state->bsd_mpc_row_store_scratch_buffer.bo = NULL;
+
     return True;
 }