hardware/intel/intel-driver
Revisión | 321523682b52e1479db258a9e5cd207ee0a28521 (tree) |
---|---|
Tiempo | 2015-05-25 09:25:42 |
Autor | Gwenole Beauchesne <gb.devel@gmai...> |
Commiter | Xiang, Haihao |
vpp: fix memory leak in DNDI code path.
The original current_out_surface was never released on exit. Main
reason for that is the legacy VPP framework that did not allow the
VADriverContextP handle to be passed down to the desired .finalize()
hook. Improved that to bring it on par with the VEBOX code path.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
@@ -1386,7 +1386,8 @@ gen8_post_processing( | ||
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | static void |
1389 | -gen8_post_processing_context_finalize(struct i965_post_processing_context *pp_context) | |
1389 | +gen8_post_processing_context_finalize(VADriverContextP ctx, | |
1390 | + struct i965_post_processing_context *pp_context) | |
1390 | 1391 | { |
1391 | 1392 | dri_bo_unreference(pp_context->surface_state_binding_table.bo); |
1392 | 1393 | pp_context->surface_state_binding_table.bo = NULL; |
@@ -5272,7 +5272,8 @@ i965_image_processing(VADriverContextP ctx, | ||
5272 | 5272 | } |
5273 | 5273 | |
5274 | 5274 | static void |
5275 | -i965_post_processing_context_finalize(struct i965_post_processing_context *pp_context) | |
5275 | +i965_post_processing_context_finalize(VADriverContextP ctx, | |
5276 | + struct i965_post_processing_context *pp_context) | |
5276 | 5277 | { |
5277 | 5278 | int i; |
5278 | 5279 |
@@ -5301,6 +5302,13 @@ i965_post_processing_context_finalize(struct i965_post_processing_context *pp_co | ||
5301 | 5302 | dri_bo_unreference(pp_context->pp_dndi_context.stmm_bo); |
5302 | 5303 | pp_context->pp_dndi_context.stmm_bo = NULL; |
5303 | 5304 | |
5305 | + if (pp_context->pp_dndi_context.current_out_surface != VA_INVALID_ID) { | |
5306 | + i965_DestroySurfaces(ctx, | |
5307 | + &pp_context->pp_dndi_context.current_out_surface, 1); | |
5308 | + pp_context->pp_dndi_context.current_out_surface = VA_INVALID_ID; | |
5309 | + pp_context->pp_dndi_context.current_out_obj_surface = NULL; | |
5310 | + } | |
5311 | + | |
5304 | 5312 | dri_bo_unreference(pp_context->pp_dn_context.stmm_bo); |
5305 | 5313 | pp_context->pp_dn_context.stmm_bo = NULL; |
5306 | 5314 |
@@ -5324,7 +5332,7 @@ i965_post_processing_terminate(VADriverContextP ctx) | ||
5324 | 5332 | struct i965_post_processing_context *pp_context = i965->pp_context; |
5325 | 5333 | |
5326 | 5334 | if (pp_context) { |
5327 | - pp_context->finalize(pp_context); | |
5335 | + pp_context->finalize(ctx, pp_context); | |
5328 | 5336 | free(pp_context); |
5329 | 5337 | } |
5330 | 5338 |
@@ -5938,9 +5946,10 @@ error: | ||
5938 | 5946 | static void |
5939 | 5947 | i965_proc_context_destroy(void *hw_context) |
5940 | 5948 | { |
5941 | - struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context; | |
5949 | + struct i965_proc_context * const proc_context = hw_context; | |
5950 | + VADriverContextP const ctx = proc_context->driver_context; | |
5942 | 5951 | |
5943 | - i965_post_processing_context_finalize(&proc_context->pp_context); | |
5952 | + i965_post_processing_context_finalize(ctx, &proc_context->pp_context); | |
5944 | 5953 | intel_batchbuffer_free(proc_context->base.batch); |
5945 | 5954 | free(proc_context); |
5946 | 5955 | } |
@@ -5955,6 +5964,7 @@ i965_proc_context_init(VADriverContextP ctx, struct object_config *obj_config) | ||
5955 | 5964 | proc_context->base.destroy = i965_proc_context_destroy; |
5956 | 5965 | proc_context->base.run = i965_proc_picture; |
5957 | 5966 | proc_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); |
5967 | + proc_context->driver_context = ctx; | |
5958 | 5968 | i965->codec_info->post_processing_context_init(ctx, &proc_context->pp_context, proc_context->base.batch); |
5959 | 5969 | |
5960 | 5970 | return (struct hw_context *)proc_context; |
@@ -542,12 +542,14 @@ struct i965_post_processing_context | ||
542 | 542 | const VARectangle *dst_rect, |
543 | 543 | int pp_index, |
544 | 544 | void * filter_param); |
545 | - void (*finalize)(struct i965_post_processing_context *pp_context); | |
545 | + void (*finalize)(VADriverContextP ctx, | |
546 | + struct i965_post_processing_context *pp_context); | |
546 | 547 | }; |
547 | 548 | |
548 | 549 | struct i965_proc_context |
549 | 550 | { |
550 | 551 | struct hw_context base; |
552 | + void *driver_context; | |
551 | 553 | struct i965_post_processing_context pp_context; |
552 | 554 | }; |
553 | 555 |