blob: c88ebc9fe0a3b1f719fd983516c7360376b58b58 [file] [log] [blame]
From 4f684afcab21b4d2f04c3c2414fde5d1183a2e98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Marchesin?= <marcheu@chromium.org>
Date: Tue, 6 Sep 2011 15:46:53 -0700
Subject: [PATCH] state_tracker/gallium: fix crash with st_renderbuffers
surfaces that outlive their context.
Because of context sharing, we sometimes end up with surfaces that outlive their context. To be able to destroy them later we keep a pointer to the destroy function.
---
src/gallium/auxiliary/util/u_inlines.h | 2 +-
src/gallium/drivers/i915/i915_surface.c | 1 +
src/gallium/drivers/llvmpipe/lp_texture.c | 1 +
src/gallium/include/pipe/p_state.h | 3 +++
4 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index ddb81b5..db57b83 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -109,7 +109,7 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
if (pipe_reference_described(&(*ptr)->reference, &surf->reference,
(debug_reference_descriptor)debug_describe_surface))
- old_surf->context->surface_destroy(old_surf->context, old_surf);
+ old_surf->surface_destroy(old_surf->context, old_surf);
*ptr = surf;
}
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 41146be..ccc5a7f 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -294,6 +294,7 @@ i915_create_surface(struct pipe_context *ctx,
ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
ps->usage = surf_tmpl->usage;
ps->context = ctx;
+ ps->surface_destroy = ctx->surface_destroy;
}
return ps;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index fa4ce5b..a2e657d 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -532,6 +532,7 @@ llvmpipe_create_surface(struct pipe_context *pipe,
ps->u.tex.level = surf_tmpl->u.tex.level;
ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+ ps->surface_destroy = pipe->surface_destroy;
}
return ps;
}
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 840b3ee..c81c82d 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -304,6 +304,9 @@ struct pipe_surface
unsigned last_element;
} buf;
} u;
+
+ void (*surface_destroy)(struct pipe_context *ctx,
+ struct pipe_surface *);
};
--
1.7.5.3.367.ga9930