gallium/noop: don't leak resources due to take_ownership
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27492>
diff --git a/src/gallium/auxiliary/driver_noop/noop_state.c b/src/gallium/auxiliary/driver_noop/noop_state.c
index 2b40d34..dcd7dc9 100644
--- a/src/gallium/auxiliary/driver_noop/noop_state.c
+++ b/src/gallium/auxiliary/driver_noop/noop_state.c
@@ -128,6 +128,12 @@
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 @@
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 @@
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,