summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-10-22 17:38:33 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-11-03 19:38:55 +0100
commitb6c2ed26fba7d030cd96d73e9c5be8af601e8b84 (patch)
tree983b711ed5db0db38b29d54e94e6d8fc6ef42f58
parent2a6e09a16289747982c035bbf058183d78467916 (diff)
gallium: clarify the constraints on sampler_view_destroy
r600 expects the context that created the sampler view to still be alive (there is a per-context list of sampler views). svga currently bails when the context of destruction is not the same as creation. The GL state tracker, which is the only one that runs into the multi-context subtleties (due to share groups), already guarantees that sampler views are destroyed before their context of creation is destroyed. Most drivers are context-agnostic, so the warning message in pipe_sampler_view_release doesn't really make sense. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h16
-rw-r--r--src/gallium/include/pipe/p_context.h10
-rw-r--r--src/mesa/state_tracker/st_sampler_view.c1
3 files changed, 20 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 79f62c3226..790352d780 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -149,6 +149,12 @@ pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
*ptr = tex;
}
+/**
+ * Set *ptr to \p view with proper reference counting.
+ *
+ * The caller must guarantee that \p view and *ptr must have been created in
+ * the same context (if they exist), and that this must be the current context.
+ */
static inline void
pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view)
{
@@ -162,18 +168,16 @@ pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_
/**
* Similar to pipe_sampler_view_reference() but always set the pointer to
- * NULL and pass in an explicit context. Passing an explicit context is a
- * work-around for fixing a dangling context pointer problem when textures
- * are shared by multiple contexts. XXX fix this someday.
+ * NULL and pass in the current context explicitly.
+ *
+ * If *ptr is non-NULL, it may refer to a view that was created in a different
+ * context (however, that context must still be alive).
*/
static inline void
pipe_sampler_view_release(struct pipe_context *ctx,
struct pipe_sampler_view **ptr)
{
struct pipe_sampler_view *old_view = *ptr;
- if (*ptr && (*ptr)->context != ctx) {
- debug_printf_once(("context mis-match in pipe_sampler_view_release()\n"));
- }
if (pipe_reference_described(&(*ptr)->reference, NULL,
(debug_reference_descriptor)debug_describe_sampler_view)) {
ctx->sampler_view_destroy(ctx, old_view);
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 4609d4dbf2..087836d1c0 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -508,6 +508,16 @@ struct pipe_context {
struct pipe_resource *texture,
const struct pipe_sampler_view *templat);
+ /**
+ * Destroy a view on a texture.
+ *
+ * \param ctx the current context
+ * \param view the view to be destroyed
+ *
+ * \note The current context may not be the context in which the view was
+ * created (view->context). However, the caller must guarantee that
+ * the context which created the view is still alive.
+ */
void (*sampler_view_destroy)(struct pipe_context *ctx,
struct pipe_sampler_view *view);
diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c
index 0d7b63af75..892725671d 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -116,7 +116,6 @@ st_texture_release_all_sampler_views(struct st_context *st,
{
GLuint i;
- /* XXX This should use sampler_views[i]->pipe, not st->pipe */
for (i = 0; i < stObj->num_sampler_views; ++i)
pipe_sampler_view_release(st->pipe, &stObj->sampler_views[i].view);
}