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

Author: Eric Anholt <[email protected]>
Date:   Wed Nov 18 11:23:30 2020 -0800

gallium: Fix leak of bound SSBOs at CSO context destruction.

Cc: mesa-stable
Reviewed-by: Rob Clark <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7695>

---

 src/gallium/auxiliary/cso_cache/cso_context.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 1f8e9c36924..1b8ca6bd1fd 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -371,6 +371,7 @@ void cso_destroy_context( struct cso_context *ctx )
 
       {
          static struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS] 
= { NULL };
+         static struct pipe_shader_buffer ssbos[PIPE_MAX_SHADER_BUFFERS] = { 0 
};
          static void *zeros[PIPE_MAX_SAMPLERS] = { NULL };
          struct pipe_screen *scr = ctx->pipe->screen;
          enum pipe_shader_type sh;
@@ -379,14 +380,20 @@ void cso_destroy_context( struct cso_context *ctx )
                                                
PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
             int maxview = scr->get_shader_param(scr, sh,
                                                 
PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS);
+            int maxssbo = scr->get_shader_param(scr, sh,
+                                                
PIPE_SHADER_CAP_MAX_SHADER_BUFFERS);
             assert(maxsam <= PIPE_MAX_SAMPLERS);
             assert(maxview <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
+            assert(maxssbo <= PIPE_MAX_SHADER_BUFFERS);
             if (maxsam > 0) {
                ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam, zeros);
             }
             if (maxview > 0) {
                ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview, views);
             }
+            if (maxssbo > 0) {
+               ctx->pipe->set_shader_buffers(ctx->pipe, sh, 0, maxssbo, ssbos, 
0);
+            }
          }
       }
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to