From 0496cd5e5aa8b86c0bd3d1a6cac3a170b6df3d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 5 Feb 2024 19:33:25 -0500 Subject: [PATCH] gallium/noop: don't leak resources due to take_ownership Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/auxiliary/driver_noop/noop_state.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gallium/auxiliary/driver_noop/noop_state.c b/src/gallium/auxiliary/driver_noop/noop_state.c index 2b40d34a1fb..dcd7dc960b4 100644 --- a/src/gallium/auxiliary/driver_noop/noop_state.c +++ b/src/gallium/auxiliary/driver_noop/noop_state.c @@ -128,6 +128,12 @@ static void noop_set_sampler_views(struct pipe_context *ctx, bool take_ownership, struct pipe_sampler_view **views) { + if (take_ownership && views) { + for (unsigned i = 0; i < count; i++) { + struct pipe_sampler_view *view = views[i]; + pipe_sampler_view_reference(&view, NULL); + } + } } static void noop_bind_sampler_states(struct pipe_context *ctx, @@ -180,6 +186,10 @@ static void noop_set_constant_buffer(struct pipe_context *ctx, bool take_ownership, const struct pipe_constant_buffer *cb) { + if (take_ownership && cb) { + struct pipe_resource *buf = cb->buffer; + pipe_resource_reference(&buf, NULL); + } } static void noop_set_inlinable_constants(struct pipe_context *ctx, @@ -217,6 +227,12 @@ static void noop_set_vertex_buffers(struct pipe_context *ctx, unsigned count, const struct pipe_vertex_buffer *buffers) { + for (unsigned i = 0; i < count; i++) { + if (!buffers[i].is_user_buffer) { + struct pipe_resource *buf = buffers[i].buffer.resource; + pipe_resource_reference(&buf, NULL); + } + } } static void *noop_create_vertex_elements(struct pipe_context *ctx,