trace: Move buffer functions from winsys to screen
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 11 Mar 2009 21:45:48 +0000 (22:45 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Wed, 11 Mar 2009 21:47:15 +0000 (22:47 +0100)
src/gallium/drivers/trace/Makefile
src/gallium/drivers/trace/SConscript
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_dump.c
src/gallium/drivers/trace/tr_screen.c
src/gallium/drivers/trace/tr_screen.h
src/gallium/drivers/trace/tr_winsys.c [deleted file]
src/gallium/drivers/trace/tr_winsys.h [deleted file]

index e1bd9709373aa23d906a495f31fcddd0845b52cc..7c570bf7a58b0d229e5d8bbd05e5ab7653b144f2 100644 (file)
@@ -8,7 +8,6 @@ C_SOURCES = \
        tr_dump.c \
        tr_screen.c \
        tr_state.c \
-       tr_texture.c \
-       tr_winsys.c
+       tr_texture.c
 
 include ../../Makefile.template
index 0a6bfb8f4c73e9a4040a53c4f44be9e0ddb4668e..45e5ef6868d4520e7fa08192dbc654c98feddc2a 100644 (file)
@@ -10,7 +10,6 @@ trace = env.ConvenienceLibrary(
         'tr_screen.c',
         'tr_state.c',
         'tr_texture.c',
-        'tr_winsys.c',
     ])
 
-Export('trace')
\ No newline at end of file
+Export('trace')
index 42146daf7a0839c0728f7a532fd46d4157a73056..6e367af57ae25d6c734b2657e0652291b54dfbb5 100644 (file)
@@ -32,7 +32,6 @@
 #include "tr_state.h"
 #include "tr_screen.h"
 #include "tr_texture.h"
-#include "tr_winsys.h"
 #include "tr_context.h"
 
 
@@ -132,7 +131,7 @@ trace_context_draw_elements(struct pipe_context *_pipe,
    struct pipe_context *pipe = tr_ctx->pipe;
    boolean result;
 
-   trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+   trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
 
    trace_dump_call_begin("pipe_context", "draw_elements");
 
@@ -167,7 +166,7 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
    struct pipe_context *pipe = tr_ctx->pipe;
    boolean result;
 
-   trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+   trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
 
    trace_dump_call_begin("pipe_context", "draw_range_elements");
 
@@ -696,7 +695,7 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct pipe_context *pipe = tr_ctx->pipe;
 
-   trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer);
+   trace_screen_user_buffer_update(_pipe->screen, (struct pipe_buffer *)buffer);
 
    trace_dump_call_begin("pipe_context", "set_constant_buffer");
 
@@ -830,7 +829,7 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
    unsigned i;
 
    for(i = 0; i < num_buffers; ++i)
-      trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer);
+      trace_screen_user_buffer_update(_pipe->screen, buffers[i].buffer);
 
    trace_dump_call_begin("pipe_context", "set_vertex_buffers");
 
@@ -996,10 +995,12 @@ trace_context_destroy(struct pipe_context *_pipe)
 
 
 struct pipe_context *
-trace_context_create(struct pipe_screen *screen,
+trace_context_create(struct pipe_screen *_screen,
                      struct pipe_context *pipe)
 {
+   struct trace_screen *tr_scr = trace_screen(_screen);
    struct trace_context *tr_ctx;
+   struct pipe_screen *screen = tr_scr->screen;
 
    if(!pipe)
       goto error1;
@@ -1011,8 +1012,8 @@ trace_context_create(struct pipe_screen *screen,
    if(!tr_ctx)
       goto error1;
 
-   tr_ctx->base.winsys = screen->winsys;
-   tr_ctx->base.screen = screen;
+   tr_ctx->base.winsys = _screen->winsys;
+   tr_ctx->base.screen = _screen;
    tr_ctx->base.destroy = trace_context_destroy;
    tr_ctx->base.set_edgeflags = trace_context_set_edgeflags;
    tr_ctx->base.draw_arrays = trace_context_draw_arrays;
@@ -1059,9 +1060,7 @@ trace_context_create(struct pipe_screen *screen,
    tr_ctx->pipe = pipe;
 
    trace_dump_call_begin("", "pipe_context_create");
-   trace_dump_arg_begin("screen");
-   trace_dump_ptr(pipe->screen);
-   trace_dump_arg_end();
+   trace_dump_arg(ptr, screen);
    trace_dump_ret(ptr, pipe);
    trace_dump_call_end();
 
index ec8f8cd62e1286665ccc2a7ca2fc92304b662b21..0f29ba7e7e556e667872e8a297f5882cae770bde 100644 (file)
@@ -51,6 +51,7 @@
 #include "util/u_stream.h"
 
 #include "tr_dump.h"
+#include "tr_screen.h"
 
 
 static struct util_stream *stream = NULL;
index e370f09fff9b0cc03c4b7ac4fd35ed04e255835b..8e7e033d5145317b8a7853fbdf8eb481486b5b60 100644 (file)
 
 #include "tr_dump.h"
 #include "tr_state.h"
-#include "tr_winsys.h"
 #include "tr_texture.h"
 #include "tr_screen.h"
 
+#include "pipe/p_inlines.h"
 
 static const char *
 trace_screen_get_name(struct pipe_screen *_screen)
@@ -151,6 +151,36 @@ trace_screen_is_format_supported(struct pipe_screen *_screen,
 }
 
 
+static void
+trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
+                               struct pipe_surface *_surface,
+                               void *context_private)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
+   struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+   struct pipe_screen *screen = tr_scr->screen;
+   struct pipe_surface *surface = tr_surf->surface;
+
+   trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, surface);
+   /* XXX: hide, as there is nothing we can do with this
+   trace_dump_arg(ptr, context_private);
+   */
+
+   screen->flush_frontbuffer(screen, surface, context_private);
+
+   trace_dump_call_end();
+}
+
+
+/********************************************************************
+ * texture
+ */
+
+
 static struct pipe_texture *
 trace_screen_texture_create(struct pipe_screen *_screen,
                             const struct pipe_texture *templat)
@@ -223,10 +253,15 @@ trace_screen_texture_destroy(struct pipe_texture *_texture)
 
    trace_dump_call_end();
 
-   trace_texture_destroy(trace_screen(screen), texture);
+   trace_texture_destroy(tr_scr, _texture);
 }
 
 
+/********************************************************************
+ * surface
+ */
+
+
 static struct pipe_surface *
 trace_screen_get_tex_surface(struct pipe_screen *_screen,
                              struct pipe_texture *_texture,
@@ -283,6 +318,11 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
 }
 
 
+/********************************************************************
+ * transfer
+ */
+
+
 static struct pipe_transfer *
 trace_screen_get_tex_transfer(struct pipe_screen *_screen,
                               struct pipe_texture *_texture,
@@ -409,6 +449,379 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen,
 }
 
 
+/********************************************************************
+ * buffer
+ */
+
+
+static struct pipe_buffer *
+trace_screen_surface_buffer_create(struct pipe_screen *_screen,
+                                   unsigned width, unsigned height,
+                                   enum pipe_format format,
+                                   unsigned usage,
+                                   unsigned *pstride)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   unsigned stride;
+   struct pipe_buffer *result;
+
+   trace_dump_call_begin("pipe_screen", "surface_buffer_create");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(uint, width);
+   trace_dump_arg(uint, height);
+   trace_dump_arg(format, format);
+   trace_dump_arg(uint, usage);
+
+   result = screen->surface_buffer_create(screen,
+                                          width, height,
+                                          format,
+                                          usage,
+                                          pstride);
+
+   stride = *pstride;
+
+   trace_dump_arg(uint, stride);
+
+   trace_dump_ret(ptr, result);
+
+   trace_dump_call_end();
+
+   return result;
+}
+
+
+static struct pipe_buffer *
+trace_screen_buffer_create(struct pipe_screen *_screen,
+                           unsigned alignment,
+                           unsigned usage,
+                           unsigned size)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   struct pipe_buffer *result;
+
+   trace_dump_call_begin("pipe_screen", "buffer_create");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(uint, alignment);
+   trace_dump_arg(uint, usage);
+   trace_dump_arg(uint, size);
+
+   result = screen->buffer_create(screen, alignment, usage, size);
+
+   trace_dump_ret(ptr, result);
+
+   trace_dump_call_end();
+
+   /* Zero the buffer to avoid dumping uninitialized memory */
+   if(result->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
+      void *map;
+      map = pipe_buffer_map(screen, result, PIPE_BUFFER_USAGE_CPU_WRITE);
+      if(map) {
+         memset(map, 0, result->size);
+         screen->buffer_unmap(screen, result);
+      }
+   }
+
+   return result;
+}
+
+
+static struct pipe_buffer *
+trace_screen_user_buffer_create(struct pipe_screen *_screen,
+                                void *data,
+                                unsigned size)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   struct pipe_buffer *result;
+
+   trace_dump_call_begin("pipe_screen", "user_buffer_create");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg_begin("data");
+   trace_dump_bytes(data, size);
+   trace_dump_arg_end();
+   trace_dump_arg(uint, size);
+
+   result = screen->user_buffer_create(screen, data, size);
+
+   trace_dump_ret(ptr, result);
+
+   trace_dump_call_end();
+
+   /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is
+    * impossible to do so while texture-less surfaces are still around */
+   if(result) {
+      assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
+      result->usage |= TRACE_BUFFER_USAGE_USER;
+   }
+
+   return result;
+}
+
+
+/**
+ * This function is used to track if data has been changed on a user buffer
+ * without map/unmap being called.
+ */
+void
+trace_screen_user_buffer_update(struct pipe_screen *_screen,
+                                struct pipe_buffer *buffer)
+{
+#if 0
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   const void *map;
+
+   if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
+      map = screen->buffer_map(screen, buffer, PIPE_BUFFER_USAGE_CPU_READ);
+      if(map) {
+         trace_dump_call_begin("pipe_winsys", "buffer_write");
+
+         trace_dump_arg(ptr, screen);
+
+         trace_dump_arg(ptr, buffer);
+
+         trace_dump_arg_begin("data");
+         trace_dump_bytes(map, buffer->size);
+         trace_dump_arg_end();
+
+         trace_dump_arg_begin("size");
+         trace_dump_uint(buffer->size);
+         trace_dump_arg_end();
+
+         trace_dump_call_end();
+
+         screen->buffer_unmap(screen, buffer);
+      }
+   }
+#endif
+}
+
+
+static void *
+trace_screen_buffer_map(struct pipe_screen *_screen,
+                        struct pipe_buffer *buffer,
+                        unsigned usage)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   void *map;
+
+   trace_dump_call_begin("pipe_screen", "buffer_map");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, buffer);
+   trace_dump_arg(uint, usage);
+
+   assert(screen->buffer_map);
+   map = screen->buffer_map(screen, buffer, usage);
+
+   trace_dump_ret(ptr, map);
+#if 0
+   if(map) {
+      if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
+         assert(!hash_table_get(tr_ws->buffer_maps, buffer));
+         hash_table_set(tr_ws->buffer_maps, buffer, map);
+      }
+   }
+#endif
+
+   return map;
+}
+
+
+static void *
+trace_screen_buffer_map_range(struct pipe_screen *_screen,
+                              struct pipe_buffer *buffer,
+                              unsigned offset,
+                              unsigned length,
+                              unsigned usage)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   void *map;
+
+   trace_dump_call_begin("pipe_screen", "buffer_map_range");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, buffer);
+   trace_dump_arg(uint, offset);
+   trace_dump_arg(uint, length);
+   trace_dump_arg(uint, usage);
+
+   assert(screen->buffer_map_range);
+   map = screen->buffer_map_range(screen, buffer, offset, length, usage);
+
+   trace_dump_ret(ptr, map);
+
+   trace_dump_call_end();
+
+   return map;
+}
+
+
+static void
+trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen,
+                                       struct pipe_buffer *buffer,
+                                       unsigned offset,
+                                       unsigned length)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+
+   trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, buffer);
+   trace_dump_arg(uint, offset);
+   trace_dump_arg(uint, length);
+
+   assert(screen->buffer_flush_mapped_range);
+   screen->buffer_flush_mapped_range(screen, buffer, offset, length);
+
+   trace_dump_call_end();
+}
+
+
+static void
+trace_screen_buffer_unmap(struct pipe_screen *_screen,
+                          struct pipe_buffer *buffer)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+#if 0
+   const void *map;
+
+   map = hash_table_get(tr_ws->buffer_maps, buffer);
+   if(map) {
+      trace_dump_call_begin("pipe_winsys", "buffer_write");
+
+      trace_dump_arg(ptr, winsys);
+
+      trace_dump_arg(ptr, buffer);
+
+      trace_dump_arg_begin("data");
+      trace_dump_bytes(map, buffer->size);
+      trace_dump_arg_end();
+
+      trace_dump_arg_begin("size");
+      trace_dump_uint(buffer->size);
+      trace_dump_arg_end();
+
+      trace_dump_call_end();
+
+      hash_table_remove(tr_ws->buffer_maps, buffer);
+   }
+#endif
+
+   trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, buffer);
+
+   assert(screen->buffer_unmap);
+   screen->buffer_unmap(screen, buffer);
+
+   trace_dump_call_end();
+}
+
+
+static void
+trace_screen_buffer_destroy(struct pipe_buffer *buffer)
+{
+   struct trace_screen *tr_scr = trace_screen(buffer->screen);
+   struct pipe_screen *screen = tr_scr->screen;
+
+   trace_dump_call_begin("pipe_screen", "buffer_destroy");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, buffer);
+
+   assert(screen->buffer_destroy);
+   screen->buffer_destroy(buffer);
+
+   trace_dump_call_end();
+}
+
+
+static void
+trace_screen_fence_reference(struct pipe_screen *_screen,
+                             struct pipe_fence_handle **dst,
+                             struct pipe_fence_handle *src)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+
+   trace_dump_call_begin("pipe_screen", "fence_reference");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, dst);
+   trace_dump_arg(ptr, src);
+
+   screen->fence_reference(screen, dst, src);
+
+   trace_dump_call_end();
+}
+
+
+static int
+trace_screen_fence_signalled(struct pipe_screen *_screen,
+                             struct pipe_fence_handle *fence,
+                             unsigned flag)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   int result;
+
+   trace_dump_call_begin("pipe_screen", "fence_signalled");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, fence);
+   trace_dump_arg(uint, flag);
+
+   result = screen->fence_signalled(screen, fence, flag);
+
+   trace_dump_ret(int, result);
+
+   trace_dump_call_end();
+
+   return result;
+}
+
+
+static int
+trace_screen_fence_finish(struct pipe_screen *_screen,
+                          struct pipe_fence_handle *fence,
+                          unsigned flag)
+{
+   struct trace_screen *tr_scr = trace_screen(_screen);
+   struct pipe_screen *screen = tr_scr->screen;
+   int result;
+
+   trace_dump_call_begin("pipe_screen", "fence_finish");
+
+   trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, fence);
+   trace_dump_arg(uint, flag);
+
+   result = screen->fence_finish(screen, fence, flag);
+
+   trace_dump_ret(int, result);
+
+   trace_dump_call_end();
+
+   return result;
+}
+
+
+/********************************************************************
+ * screen
+ */
+
 static void
 trace_screen_destroy(struct pipe_screen *_screen)
 {
@@ -442,12 +855,6 @@ trace_screen_create(struct pipe_screen *screen)
       goto error1;
 
    trace_dump_call_begin("", "pipe_screen_create");
-   trace_dump_arg_begin("screen");
-   trace_dump_ptr(screen);
-   trace_dump_arg_end();
-   trace_dump_arg_begin("screen->winsys");
-   trace_dump_ptr(screen->winsys);
-   trace_dump_arg_end();
 
    tr_scr = CALLOC_STRUCT(trace_screen);
    if(!tr_scr)
@@ -477,9 +884,25 @@ trace_screen_create(struct pipe_screen *screen)
    tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy;
    tr_scr->base.transfer_map = trace_screen_transfer_map;
    tr_scr->base.transfer_unmap = trace_screen_transfer_unmap;
+   tr_scr->base.buffer_create = trace_screen_buffer_create;
+   tr_scr->base.user_buffer_create = trace_screen_user_buffer_create;
+   tr_scr->base.surface_buffer_create = trace_screen_surface_buffer_create;
+   if (screen->buffer_map)
+      tr_scr->base.buffer_map = trace_screen_buffer_map;
+   if (screen->buffer_map_range)
+      tr_scr->base.buffer_map_range = trace_screen_buffer_map_range;
+   if (screen->buffer_flush_mapped_range)
+      tr_scr->base.buffer_flush_mapped_range = trace_screen_buffer_flush_mapped_range;
+   if (screen->buffer_unmap)
+      tr_scr->base.buffer_unmap = trace_screen_buffer_unmap;
+   tr_scr->base.buffer_destroy = trace_screen_buffer_destroy;
+   tr_scr->base.fence_reference = trace_screen_fence_reference;
+   tr_scr->base.fence_signalled = trace_screen_fence_signalled;
+   tr_scr->base.fence_finish = trace_screen_fence_finish;
+   tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer;
    tr_scr->screen = screen;
 
-   trace_dump_ret(ptr, &tr_scr->base);
+   trace_dump_ret(ptr, screen);
    trace_dump_call_end();
 
    return &tr_scr->base;
index 15fe1bc0154dd6f217963eca0c5eb795122d626b..8c65516b509731829b30445d981235321ca3cd08 100644 (file)
@@ -37,6 +37,14 @@ extern "C" {
 #endif
 
 
+/**
+ * It often happens that new data is written directly to the user buffers
+ * without mapping/unmapping. This flag marks user buffers, so that their
+ * contents can be dumpped before being used by the pipe context.
+ */
+#define TRACE_BUFFER_USAGE_USER  (1 << 31)
+
+
 struct trace_screen
 {
    struct pipe_screen base;
@@ -53,6 +61,11 @@ struct pipe_screen *
 trace_screen_create(struct pipe_screen *screen);
 
 
+void
+trace_screen_user_buffer_update(struct pipe_screen *screen,
+                                struct pipe_buffer *buffer);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/gallium/drivers/trace/tr_winsys.c b/src/gallium/drivers/trace/tr_winsys.c
deleted file mode 100644 (file)
index 1031ec7..0000000
+++ /dev/null
@@ -1,448 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "util/u_memory.h"
-#include "util/u_hash_table.h"
-
-#include "tr_dump.h"
-#include "tr_state.h"
-#include "tr_screen.h"
-#include "tr_texture.h"
-#include "tr_winsys.h"
-
-
-static unsigned trace_buffer_hash(void *buffer)
-{
-   return (unsigned)(uintptr_t)buffer;
-}
-
-
-static int trace_buffer_compare(void *buffer1, void *buffer2)
-{
-   return (char *)buffer2 - (char *)buffer1;
-}
-
-
-static const char *
-trace_winsys_get_name(struct pipe_winsys *_winsys)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   const char *result;
-
-   trace_dump_call_begin("pipe_winsys", "get_name");
-
-   trace_dump_arg(ptr, winsys);
-
-   result = winsys->get_name(winsys);
-
-   trace_dump_ret(string, result);
-
-   trace_dump_call_end();
-
-   return result;
-}
-
-
-static void
-trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
-                               struct pipe_surface *surface,
-                               void *context_private)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-
-   assert(surface);
-   if(surface->texture) {
-      struct trace_screen *tr_scr = trace_screen(surface->texture->screen);
-      struct trace_texture *tr_tex = trace_texture(tr_scr, surface->texture);
-      struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
-      surface = tr_surf->surface;
-   }
-
-   trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(ptr, surface);
-   /* XXX: hide, as there is nothing we can do with this
-   trace_dump_arg(ptr, context_private);
-   */
-
-   winsys->flush_frontbuffer(winsys, surface, context_private);
-
-   trace_dump_call_end();
-}
-
-
-static struct pipe_buffer *
-trace_winsys_surface_buffer_create(struct pipe_winsys *_winsys,
-                                   unsigned width, unsigned height,
-                                   enum pipe_format format,
-                                   unsigned usage,
-                                   unsigned *pstride)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   unsigned stride;
-   struct pipe_buffer *result;
-
-   trace_dump_call_begin("pipe_winsys", "surface_buffer_create");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(uint, width);
-   trace_dump_arg(uint, height);
-   trace_dump_arg(format, format);
-   trace_dump_arg(uint, usage);
-
-   result = winsys->surface_buffer_create(winsys,
-                                          width, height,
-                                          format,
-                                          usage,
-                                          pstride);
-
-   stride = *pstride;
-
-   trace_dump_arg(uint, stride);
-
-   trace_dump_ret(ptr, result);
-
-   trace_dump_call_end();
-
-   return result;
-}
-
-
-static struct pipe_buffer *
-trace_winsys_buffer_create(struct pipe_winsys *_winsys,
-                           unsigned alignment,
-                           unsigned usage,
-                           unsigned size)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   struct pipe_buffer *buffer;
-
-   trace_dump_call_begin("pipe_winsys", "buffer_create");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(uint, alignment);
-   trace_dump_arg(uint, usage);
-   trace_dump_arg(uint, size);
-
-   buffer = winsys->buffer_create(winsys, alignment, usage, size);
-
-   trace_dump_ret(ptr, buffer);
-
-   trace_dump_call_end();
-
-   /* Zero the buffer to avoid dumping uninitialized memory */
-   if(buffer->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
-      void *map;
-      map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
-      if(map) {
-         memset(map, 0, buffer->size);
-         winsys->buffer_unmap(winsys, buffer);
-      }
-   }
-
-   return buffer;
-}
-
-
-static struct pipe_buffer *
-trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
-                                void *data,
-                                unsigned size)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   struct pipe_buffer *result;
-
-   trace_dump_call_begin("pipe_winsys", "user_buffer_create");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg_begin("data");
-   trace_dump_bytes(data, size);
-   trace_dump_arg_end();
-   trace_dump_arg(uint, size);
-
-   result = winsys->user_buffer_create(winsys, data, size);
-
-   trace_dump_ret(ptr, result);
-
-   trace_dump_call_end();
-
-   /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is
-    * impossible to do so while texture-less surfaces are still around */
-   if(result) {
-      assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
-      result->usage |= TRACE_BUFFER_USAGE_USER;
-   }
-
-   return result;
-}
-
-
-void
-trace_winsys_user_buffer_update(struct pipe_winsys *_winsys,
-                                struct pipe_buffer *buffer)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   const void *map;
-
-   if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
-      map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_READ);
-      if(map) {
-         trace_dump_call_begin("pipe_winsys", "buffer_write");
-
-         trace_dump_arg(ptr, winsys);
-
-         trace_dump_arg(ptr, buffer);
-
-         trace_dump_arg_begin("data");
-         trace_dump_bytes(map, buffer->size);
-         trace_dump_arg_end();
-
-         trace_dump_arg_begin("size");
-         trace_dump_uint(buffer->size);
-         trace_dump_arg_end();
-
-         trace_dump_call_end();
-
-         winsys->buffer_unmap(winsys, buffer);
-      }
-   }
-}
-
-
-static void *
-trace_winsys_buffer_map(struct pipe_winsys *_winsys,
-                        struct pipe_buffer *buffer,
-                        unsigned usage)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   void *map;
-
-   map = winsys->buffer_map(winsys, buffer, usage);
-   if(map) {
-      if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
-         assert(!hash_table_get(tr_ws->buffer_maps, buffer));
-         hash_table_set(tr_ws->buffer_maps, buffer, map);
-      }
-   }
-
-   return map;
-}
-
-
-static void
-trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
-                          struct pipe_buffer *buffer)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   const void *map;
-
-   map = hash_table_get(tr_ws->buffer_maps, buffer);
-   if(map) {
-      trace_dump_call_begin("pipe_winsys", "buffer_write");
-
-      trace_dump_arg(ptr, winsys);
-
-      trace_dump_arg(ptr, buffer);
-
-      trace_dump_arg_begin("data");
-      trace_dump_bytes(map, buffer->size);
-      trace_dump_arg_end();
-
-      trace_dump_arg_begin("size");
-      trace_dump_uint(buffer->size);
-      trace_dump_arg_end();
-
-      trace_dump_call_end();
-
-      hash_table_remove(tr_ws->buffer_maps, buffer);
-   }
-
-   winsys->buffer_unmap(winsys, buffer);
-}
-
-
-static void
-trace_winsys_buffer_destroy(struct pipe_buffer *buffer)
-{
-   struct pipe_winsys *winsys = buffer->screen->winsys;
-
-   trace_dump_call_begin("pipe_winsys", "buffer_destroy");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(ptr, buffer);
-
-   winsys->buffer_destroy(buffer);
-
-   trace_dump_call_end();
-}
-
-
-static void
-trace_winsys_fence_reference(struct pipe_winsys *_winsys,
-                             struct pipe_fence_handle **pdst,
-                             struct pipe_fence_handle *src)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   struct pipe_fence_handle *dst = *pdst;
-
-   trace_dump_call_begin("pipe_winsys", "fence_reference");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(ptr, dst);
-   trace_dump_arg(ptr, src);
-
-   winsys->fence_reference(winsys, pdst, src);
-
-   trace_dump_call_end();
-}
-
-
-static int
-trace_winsys_fence_signalled(struct pipe_winsys *_winsys,
-                             struct pipe_fence_handle *fence,
-                             unsigned flag)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   int result;
-
-   trace_dump_call_begin("pipe_winsys", "fence_signalled");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(ptr, fence);
-   trace_dump_arg(uint, flag);
-
-   result = winsys->fence_signalled(winsys, fence, flag);
-
-   trace_dump_ret(int, result);
-
-   trace_dump_call_end();
-
-   return result;
-}
-
-
-static int
-trace_winsys_fence_finish(struct pipe_winsys *_winsys,
-                          struct pipe_fence_handle *fence,
-                          unsigned flag)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-   int result;
-
-   trace_dump_call_begin("pipe_winsys", "fence_finish");
-
-   trace_dump_arg(ptr, winsys);
-   trace_dump_arg(ptr, fence);
-   trace_dump_arg(uint, flag);
-
-   result = winsys->fence_finish(winsys, fence, flag);
-
-   trace_dump_ret(int, result);
-
-   trace_dump_call_end();
-
-   return result;
-}
-
-
-static void
-trace_winsys_destroy(struct pipe_winsys *_winsys)
-{
-   struct trace_winsys *tr_ws = trace_winsys(_winsys);
-   struct pipe_winsys *winsys = tr_ws->winsys;
-
-   trace_dump_call_begin("pipe_winsys", "destroy");
-
-   trace_dump_arg(ptr, winsys);
-
-   /*
-   winsys->destroy(winsys);
-   */
-
-   trace_dump_call_end();
-
-   hash_table_destroy(tr_ws->buffer_maps);
-
-   FREE(tr_ws);
-}
-
-
-struct pipe_winsys *
-trace_winsys_create(struct pipe_winsys *winsys)
-{
-   struct trace_winsys *tr_ws;
-
-   if(!winsys)
-      goto error1;
-
-   tr_ws = CALLOC_STRUCT(trace_winsys);
-   if(!tr_ws)
-      goto error1;
-
-   tr_ws->base.destroy = trace_winsys_destroy;
-   tr_ws->base.get_name = trace_winsys_get_name;
-   tr_ws->base.flush_frontbuffer = trace_winsys_flush_frontbuffer;
-   tr_ws->base.surface_buffer_create = trace_winsys_surface_buffer_create;
-   tr_ws->base.buffer_create = trace_winsys_buffer_create;
-   tr_ws->base.user_buffer_create = trace_winsys_user_buffer_create;
-   tr_ws->base.buffer_map = trace_winsys_buffer_map;
-   tr_ws->base.buffer_unmap = trace_winsys_buffer_unmap;
-   tr_ws->base.buffer_destroy = trace_winsys_buffer_destroy;
-   tr_ws->base.fence_reference = trace_winsys_fence_reference;
-   tr_ws->base.fence_signalled = trace_winsys_fence_signalled;
-   tr_ws->base.fence_finish = trace_winsys_fence_finish;
-
-   tr_ws->winsys = winsys;
-
-   tr_ws->buffer_maps = hash_table_create(trace_buffer_hash,
-                                          trace_buffer_compare);
-   if(!tr_ws->buffer_maps)
-      goto error2;
-
-   trace_dump_call_begin("", "pipe_winsys_create");
-   trace_dump_ret(ptr, winsys);
-   trace_dump_call_end();
-
-   return &tr_ws->base;
-
-error2:
-   FREE(tr_ws);
-error1:
-   return winsys;
-}
diff --git a/src/gallium/drivers/trace/tr_winsys.h b/src/gallium/drivers/trace/tr_winsys.h
deleted file mode 100644 (file)
index f1837c7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef TR_WINSYS_H_
-#define TR_WINSYS_H_
-
-
-#include "pipe/p_compiler.h"
-#include "util/u_debug.h"
-#include "pipe/internal/p_winsys_screen.h"
-
-
-/**
- * It often happens that new data is written directly to the user buffers
- * without mapping/unmapping. This flag marks user buffers, so that their
- * contents can be dumpped before being used by the pipe context.
- */
-#define TRACE_BUFFER_USAGE_USER  (1 << 31)
-
-
-struct hash_table;
-
-
-struct trace_winsys
-{
-   struct pipe_winsys base;
-
-   struct pipe_winsys *winsys;
-
-   struct hash_table *buffer_maps;
-};
-
-
-static INLINE struct trace_winsys *
-trace_winsys(struct pipe_winsys *winsys)
-{
-   assert(winsys);
-   return (struct trace_winsys *)winsys;
-}
-
-
-
-struct pipe_winsys *
-trace_winsys_create(struct pipe_winsys *winsys);
-
-
-void
-trace_winsys_user_buffer_update(struct pipe_winsys *winsys,
-                                struct pipe_buffer *buffer);
-
-
-#endif /* TR_WINSYS_H_ */