From 5313b294e68f6b03e6b26930c68fbb30ae16e7c4 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Wed, 17 Aug 2016 14:53:38 -0700 Subject: [PATCH] svga: add a cleanup function to clean up sampler state This patch adds a cleanup function to clean up sampler state at context destruction time. Reviewed-by: Brian Paul --- src/gallium/drivers/svga/svga_context.c | 12 +----------- src/gallium/drivers/svga/svga_context.h | 1 + src/gallium/drivers/svga/svga_pipe_sampler.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index 7ac90f71755..475b2b53f5e 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -66,16 +66,6 @@ static void svga_destroy( struct pipe_context *pipe ) } } - /* free polygon stipple state */ - if (svga->polygon_stipple.sampler) { - pipe->delete_sampler_state(pipe, svga->polygon_stipple.sampler); - } - if (svga->polygon_stipple.sampler_view) { - pipe->sampler_view_destroy(pipe, - &svga->polygon_stipple.sampler_view->base); - } - pipe_resource_reference(&svga->polygon_stipple.texture, NULL); - /* free HW constant buffers */ for (shader = 0; shader < ARRAY_SIZE(svga->state.hw_draw.constbuf); shader++) { pipe_resource_reference(&svga->state.hw_draw.constbuf[shader], NULL); @@ -91,9 +81,9 @@ static void svga_destroy( struct pipe_context *pipe ) util_blitter_destroy(svga->blitter); + svga_cleanup_sampler_state(svga); svga_cleanup_framebuffer( svga ); svga_cleanup_tss_binding( svga ); - svga_cleanup_vertex_state(svga); svga_destroy_swtnl( svga ); diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 8ed612d1190..a5ec78c9093 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -639,6 +639,7 @@ void svga_init_stream_output_functions( struct svga_context *svga ); void svga_init_clear_functions( struct svga_context *svga ); void svga_cleanup_vertex_state( struct svga_context *svga ); +void svga_cleanup_sampler_state( struct svga_context *svga ); void svga_cleanup_tss_binding( struct svga_context *svga ); void svga_cleanup_framebuffer( struct svga_context *svga ); diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index 326519caeff..ae19b7ee0a6 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -538,6 +538,26 @@ done: SVGA_STATS_TIME_POP(svga_sws(svga)); } +/** + * Clean up sampler, sampler view state at context destruction time + */ +void +svga_cleanup_sampler_state(struct svga_context *svga) +{ + if (!svga_have_vgpu10(svga)) + return; + + /* free polygon stipple state */ + if (svga->polygon_stipple.sampler) { + svga->pipe.delete_sampler_state(&svga->pipe, svga->polygon_stipple.sampler); + } + + if (svga->polygon_stipple.sampler_view) { + svga->pipe.sampler_view_destroy(&svga->pipe, + &svga->polygon_stipple.sampler_view->base); + } + pipe_resource_reference(&svga->polygon_stipple.texture, NULL); +} void svga_init_sampler_functions( struct svga_context *svga ) -- 2.30.2