From 7f5a3530125629a3553427988d04e75c31312ade Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 25 Aug 2021 12:54:46 -0400 Subject: [PATCH] aux/trace: use private refcounts for samplerviews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this avoids having the driver bypass the samplerview wrapper and destroying the samplerview prematurely, e.g., spec@sgis_generate_mipmap@gen-texsubimage Acked-by: Marek Olšák Part-of: --- src/gallium/auxiliary/driver_trace/tr_context.c | 10 ++++++++++ src/gallium/auxiliary/driver_trace/tr_texture.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/gallium/auxiliary/driver_trace/tr_context.c b/src/gallium/auxiliary/driver_trace/tr_context.c index 0f3b6cd79d7..3f35852a75b 100644 --- a/src/gallium/auxiliary/driver_trace/tr_context.c +++ b/src/gallium/auxiliary/driver_trace/tr_context.c @@ -1022,6 +1022,8 @@ trace_context_create_sampler_view(struct pipe_context *_pipe, pipe_resource_reference(&tr_view->base.texture, resource); tr_view->base.context = _pipe; tr_view->sampler_view = result; + result->reference.count += 100000000; + tr_view->refcount = 100000000; result = &tr_view->base; return result; @@ -1042,6 +1044,7 @@ trace_context_sampler_view_destroy(struct pipe_context *_pipe, trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, view); + p_atomic_add(&tr_view->sampler_view->reference.count, -tr_view->refcount); pipe_sampler_view_reference(&tr_view->sampler_view, NULL); trace_dump_call_end(); @@ -1126,6 +1129,13 @@ trace_context_set_sampler_views(struct pipe_context *_pipe, for (i = 0; i < num; ++i) { tr_view = trace_sampler_view(views[i]); + if (tr_view) { + tr_view->refcount--; + if (!tr_view->refcount) { + tr_view->refcount = 100000000; + p_atomic_add(&tr_view->sampler_view->reference.count, tr_view->refcount); + } + } unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } views = unwrapped_views; diff --git a/src/gallium/auxiliary/driver_trace/tr_texture.h b/src/gallium/auxiliary/driver_trace/tr_texture.h index 567842a5b22..b9caf968d16 100644 --- a/src/gallium/auxiliary/driver_trace/tr_texture.h +++ b/src/gallium/auxiliary/driver_trace/tr_texture.h @@ -57,6 +57,7 @@ struct trace_surface struct trace_sampler_view { struct pipe_sampler_view base; + unsigned refcount; struct pipe_sampler_view *sampler_view; };