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

Cc: mesa-stable
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7695>
(cherry picked from commit 634384e4a0)
This commit is contained in:
Eric Anholt 2020-11-18 11:23:30 -08:00 committed by Dylan Baker
parent bcc8db867e
commit d6fd7acf9b
2 changed files with 8 additions and 1 deletions

View file

@ -256,7 +256,7 @@
"description": "gallium: Fix leak of bound SSBOs at CSO context destruction.",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},

View file

@ -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);
}
}
}