[Mesa-dev] [PATCH 1/2] trace: fix incorrect trace_surface::base.context pointer

Brian Paul brianp at vmware.com
Fri Feb 15 09:44:23 PST 2013


When a trace_surface object is created in trace_surf_create() we
weren't correctly setting the surface's context pointer.  Instead of
it being the trace context, it was the wrapped driver's context.
This caused things to blow up sometimes during surface deallocation.
---
 src/gallium/drivers/trace/tr_context.c |    2 +-
 src/gallium/drivers/trace/tr_texture.c |    4 +++-
 src/gallium/drivers/trace/tr_texture.h |    5 +++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 9668aac..b88f379 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -897,7 +897,7 @@ trace_context_create_surface(struct pipe_context *_pipe,
 
    trace_dump_call_end();
 
-   result = trace_surf_create(tr_res, result);
+   result = trace_surf_create(tr_ctx, tr_res, result);
 
    return result;
 }
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index 81ebc9e..aae1338 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -74,7 +74,8 @@ trace_resource_destroy(struct trace_screen *tr_scr,
 
 
 struct pipe_surface *
-trace_surf_create(struct trace_resource *tr_res,
+trace_surf_create(struct trace_context *tr_ctx,
+                  struct trace_resource *tr_res,
                   struct pipe_surface *surface)
 {
    struct trace_surface *tr_surf;
@@ -89,6 +90,7 @@ trace_surf_create(struct trace_resource *tr_res,
       goto error;
 
    memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
+   tr_surf->base.context = &tr_ctx->base;
 
    pipe_reference_init(&tr_surf->base.reference, 1);
    tr_surf->base.texture = NULL;
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
index 596978a..2b4732b 100644
--- a/src/gallium/drivers/trace/tr_texture.h
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -133,8 +133,9 @@ trace_resource_destroy(struct trace_screen *tr_scr,
 		       struct trace_resource *tr_res);
 
 struct pipe_surface *
-trace_surf_create(struct trace_resource *tr_res,
-                     struct pipe_surface *surface);
+trace_surf_create(struct trace_context *tr_ctx,
+                  struct trace_resource *tr_res,
+                  struct pipe_surface *surface);
 
 void
 trace_surf_destroy(struct trace_surface *tr_surf);
-- 
1.7.3.4



More information about the mesa-dev mailing list