Module: Mesa
Branch: master
Commit: 5313b294e68f6b03e6b26930c68fbb30ae16e7c4
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5313b294e68f6b03e6b26930c68fbb30ae16e7c4

Author: Charmaine Lee <charmai...@vmware.com>
Date:   Wed Aug 17 14:53:38 2016 -0700

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 <bri...@vmware.com>

---

 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 7ac90f7..475b2b5 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 8ed612d..a5ec78c 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 326519c..ae19b7e 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 )

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to