gallium: Fix up trace driver for introduction of struct pipe_transfer.
authorMichel Dänzer <daenzer@vmware.com>
Wed, 18 Feb 2009 17:13:44 +0000 (18:13 +0100)
committerMichel Dänzer <daenzer@vmware.com>
Wed, 18 Feb 2009 17:13:44 +0000 (18:13 +0100)
src/gallium/drivers/trace/tr_screen.c
src/gallium/drivers/trace/tr_state.c
src/gallium/drivers/trace/tr_state.h
src/gallium/drivers/trace/tr_texture.c
src/gallium/drivers/trace/tr_texture.h

index 8789f86b1a83d2e6eecc057a8b5122bca8f49270..164c6bbc4d66e6e15863552a925d352333b78a67 100644 (file)
@@ -315,26 +315,101 @@ trace_screen_tex_surface_release(struct pipe_screen *_screen,
 }
 
 
+static struct pipe_transfer *
+trace_screen_get_tex_transfer(struct pipe_screen *_screen,
+                              struct pipe_texture *texture,
+                              unsigned face, unsigned level,
+                              unsigned zslice,
+                              enum pipe_transfer_usage usage,
+                              unsigned x, unsigned y, unsigned w, unsigned h)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   struct trace_texture *tr_tex;
+   struct pipe_transfer *result;
+   
+   assert(texture);
+   tr_tex = trace_texture(tr_scr, texture);
+   texture = tr_tex->texture;
+   assert(texture->screen == screen);
+   
+   trace_dump_call_begin("pipe_screen", "get_tex_transfer");
+   
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, texture);
+   trace_dump_arg(uint, face);
+   trace_dump_arg(uint, level);
+   trace_dump_arg(uint, zslice);
+   trace_dump_arg(uint, usage);
+
+   result = screen->get_tex_transfer(screen, texture, face, level, zslice, usage,
+                                     x, y, w, h);
+
+   trace_dump_ret(ptr, result);
+   
+   trace_dump_call_end();
+   
+   result = trace_transfer_create(tr_tex, result);
+
+   return result;
+}
+
+
+static void 
+trace_screen_tex_transfer_release(struct pipe_screen *_screen,
+                                 struct pipe_transfer **ptransfer)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   struct trace_texture *tr_tex;
+   struct trace_transfer *tr_trans;
+   struct pipe_transfer *transfer;
+   
+   assert(ptransfer);
+   if(*ptransfer) {
+      tr_tex = trace_texture(tr_scr, (*ptransfer)->texture);
+      tr_trans = trace_transfer(tr_tex, *ptransfer);
+      transfer = tr_trans->transfer;
+   }
+   else
+      transfer = NULL;
+   
+   if (*ptransfer) {
+      if (!--(*ptransfer)->refcount) {
+         trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
+         
+         trace_dump_arg(ptr, screen);
+         trace_dump_arg(ptr, transfer);
+
+         trace_transfer_destroy(tr_tex, *ptransfer);
+
+         trace_dump_call_end();
+      }
+   
+      *ptransfer = NULL;
+   }
+}
+
+
 static void *
-trace_screen_surface_map(struct pipe_screen *_screen,
-                         struct pipe_surface *surface,
-                         unsigned flags)
+trace_screen_transfer_map(struct pipe_screen *_screen,
+                          struct pipe_transfer *transfer)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
    struct pipe_screen *screen = tr_scr->screen;
    struct trace_texture *tr_tex;
-   struct trace_surface *tr_surf;
+   struct trace_transfer *tr_trans;
    void *map;
    
-   tr_tex = trace_texture(tr_scr, surface->texture);
-   tr_surf = trace_surface(tr_tex, surface);
-   surface = tr_surf->surface;
+   tr_tex = trace_texture(tr_scr, transfer->texture);
+   tr_trans = trace_transfer(tr_tex, transfer);
+   transfer = tr_trans->transfer;
 
-   map = screen->surface_map(screen, surface, flags);
+   map = screen->transfer_map(screen, transfer);
    if(map) {
-      if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
-         assert(!tr_surf->map);
-         tr_surf->map = map;
+      if(transfer->usage != PIPE_TRANSFER_READ) {
+         assert(!tr_trans->map);
+         tr_trans->map = map;
       }
    }
    
@@ -343,33 +418,33 @@ trace_screen_surface_map(struct pipe_screen *_screen,
 
 
 static void 
-trace_screen_surface_unmap(struct pipe_screen *_screen,
-                           struct pipe_surface *surface)
+trace_screen_transfer_unmap(struct pipe_screen *_screen,
+                           struct pipe_transfer *transfer)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
    struct pipe_screen *screen = tr_scr->screen;
    struct trace_texture *tr_tex;
-   struct trace_surface *tr_surf;
+   struct trace_transfer *tr_trans;
    
-   tr_tex = trace_texture(tr_scr, surface->texture);
-   tr_surf = trace_surface(tr_tex, surface);
-   surface = tr_surf->surface;
+   tr_tex = trace_texture(tr_scr, transfer->texture);
+   tr_trans = trace_transfer(tr_tex, transfer);
+   transfer = tr_trans->transfer;
    
-   if(tr_surf->map) {
-      size_t size = surface->nblocksy * surface->stride;
+   if(tr_trans->map) {
+      size_t size = transfer->nblocksy * transfer->stride;
       
-      trace_dump_call_begin("pipe_winsys", "surface_write");
+      trace_dump_call_begin("pipe_winsys", "transfer_write");
       
       trace_dump_arg(ptr, screen);
       
-      trace_dump_arg(ptr, surface);
+      trace_dump_arg(ptr, transfer);
       
       trace_dump_arg_begin("data");
-      trace_dump_bytes(tr_surf->map, size);
+      trace_dump_bytes(tr_trans->map, size);
       trace_dump_arg_end();
 
       trace_dump_arg_begin("stride");
-      trace_dump_uint(surface->stride);
+      trace_dump_uint(transfer->stride);
       trace_dump_arg_end();
 
       trace_dump_arg_begin("size");
@@ -378,10 +453,10 @@ trace_screen_surface_unmap(struct pipe_screen *_screen,
    
       trace_dump_call_end();
 
-      tr_surf->map = NULL;
+      tr_trans->map = NULL;
    }
 
-   screen->surface_unmap(screen, surface);
+   screen->transfer_unmap(screen, transfer);
 }
 
 
@@ -437,8 +512,10 @@ trace_screen_create(struct pipe_screen *screen)
    tr_scr->base.texture_release = trace_screen_texture_release;
    tr_scr->base.get_tex_surface = trace_screen_get_tex_surface;
    tr_scr->base.tex_surface_release = trace_screen_tex_surface_release;
-   tr_scr->base.surface_map = trace_screen_surface_map;
-   tr_scr->base.surface_unmap = trace_screen_surface_unmap;
+   tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer;
+   tr_scr->base.tex_transfer_release = trace_screen_tex_transfer_release;
+   tr_scr->base.transfer_map = trace_screen_transfer_map;
+   tr_scr->base.transfer_unmap = trace_screen_transfer_unmap;
    
    tr_scr->screen = screen;
 
index 524f2d61948326f4e7158194bc4fb7660b1dc63a..81a9e2376e008835d3d50e75701cd19f7c17aa57 100644 (file)
@@ -403,6 +403,33 @@ void trace_dump_surface(const struct pipe_surface *state)
    trace_dump_member(uint, state, width);
    trace_dump_member(uint, state, height);
 
+   trace_dump_member(uint, state, layout);
+   trace_dump_member(uint, state, offset);
+   trace_dump_member(uint, state, refcount);
+   trace_dump_member(uint, state, usage);
+
+   trace_dump_member(ptr, state, texture);
+   trace_dump_member(uint, state, face);
+   trace_dump_member(uint, state, level);
+   trace_dump_member(uint, state, zslice);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_transfer(const struct pipe_transfer *state)
+{
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_transfer");
+
+   trace_dump_member(format, state, format);
+   trace_dump_member(uint, state, width);
+   trace_dump_member(uint, state, height);
+
    trace_dump_member_begin("block");
    trace_dump_block(&state->block);
    trace_dump_member_end();
@@ -410,8 +437,6 @@ void trace_dump_surface(const struct pipe_surface *state)
    trace_dump_member(uint, state, nblocksx);
    trace_dump_member(uint, state, nblocksy);
    trace_dump_member(uint, state, stride);
-   trace_dump_member(uint, state, layout);
-   trace_dump_member(uint, state, offset);
    trace_dump_member(uint, state, refcount);
    trace_dump_member(uint, state, usage);
 
index 5ae533dc664807b289499fd3590488d352960e39..513ed0ac98d4453ba0fcedeba21908ab22a03ac4 100644 (file)
@@ -68,6 +68,8 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state);
 
 void trace_dump_surface(const struct pipe_surface *state);
 
+void trace_dump_transfer(const struct pipe_transfer *state);
+
 void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state);
 
 void trace_dump_vertex_element(const struct pipe_vertex_element *state);
index 1cc4f0bd43686f9ed84e0f225737915a11603ca0..120ba0dd3179470dc230d117aab6dc4f782e6cf9 100644 (file)
@@ -109,3 +109,43 @@ trace_surface_destroy(struct trace_texture *tr_tex,
    FREE(tr_surf);
 }
 
+
+struct pipe_transfer *
+trace_transfer_create(struct trace_texture *tr_tex, 
+                     struct pipe_transfer *transfer)
+{
+   struct trace_transfer *tr_trans;
+   
+   if(!transfer)
+      goto error;
+   
+   assert(transfer->texture == tr_tex->texture);
+   
+   tr_trans = CALLOC_STRUCT(trace_transfer);
+   if(!tr_trans)
+      goto error;
+   
+   memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer));
+   
+   tr_trans->base.texture = NULL;
+   pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base);
+   tr_trans->transfer = transfer;
+
+   return &tr_trans->base;
+   
+error:
+   pipe_transfer_reference(&transfer, NULL);
+   return NULL;
+}
+
+
+void
+trace_transfer_destroy(struct trace_texture *tr_tex, 
+                      struct pipe_transfer *transfer)
+{
+   struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer);
+   pipe_texture_reference(&tr_trans->base.texture, NULL);
+   pipe_transfer_reference(&tr_trans->transfer, NULL);
+   FREE(tr_trans);
+}
+
index 9e72edb8a3cfacd5e1a9c4661d26a685de7b5960..168cefd53d6157054d3d1e3d9167af66e3fbc034 100644 (file)
@@ -48,6 +48,14 @@ struct trace_surface
    struct pipe_surface base;
 
    struct pipe_surface *surface;
+};
+
+
+struct trace_transfer
+{
+   struct pipe_transfer base;
+
+   struct pipe_transfer *transfer;
    
    void *map;
 };
@@ -75,6 +83,17 @@ trace_surface(struct trace_texture *tr_tex,
 }
 
 
+static INLINE struct trace_transfer *
+trace_transfer(struct trace_texture *tr_tex, 
+               struct pipe_transfer *transfer)
+{
+   if(!transfer)
+      return NULL;
+   assert(transfer->texture == &tr_tex->base);
+   return (struct trace_transfer *)transfer;
+}
+
+
 struct pipe_texture *
 trace_texture_create(struct trace_screen *tr_scr, 
                      struct pipe_texture *texture);
@@ -91,5 +110,13 @@ void
 trace_surface_destroy(struct trace_texture *tr_tex,
                       struct pipe_surface *surface);
 
+struct pipe_transfer *
+trace_transfer_create(struct trace_texture *tr_tex, 
+                      struct pipe_transfer *transfer);
+
+void
+trace_transfer_destroy(struct trace_texture *tr_tex,
+                       struct pipe_transfer *transfer);
+
 
 #endif /* TR_TEXTURE_H_ */