trace: Fix several regressions introduced by recent interface changes.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 12 Apr 2010 06:03:25 +0000 (15:03 +0900)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 12 Apr 2010 06:32:22 +0000 (15:32 +0900)
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_dump.c
src/gallium/drivers/trace/tr_dump.h
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/drivers/trace/tr_dump_state.h
src/gallium/drivers/trace/tr_screen.c

index dd0fd8ed98dc401e253390080b1c0af7ab3af4dd..9f92b4426b3d423c20553de5b01bc9c7a62b1abe 100644 (file)
@@ -1003,27 +1003,34 @@ trace_create_sampler_view(struct pipe_context *_pipe,
    struct trace_resource *tr_tex = trace_resource(_resource);
    struct pipe_context *pipe = tr_ctx->pipe;
    struct pipe_resource *texture = tr_tex->resource;
-   struct trace_sampler_view *result = CALLOC_STRUCT(trace_sampler_view);
+   struct pipe_sampler_view *result;
+   struct trace_sampler_view *tr_view;
 
    trace_dump_call_begin("pipe_context", "create_sampler_view");
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(ptr, texture);
-   trace_dump_arg(ptr, templ);
-
-   result->sampler_view = pipe->create_sampler_view(pipe, texture, templ);
+   trace_dump_arg(sampler_view_template, templ);
 
-   result->base = *templ;
-   result->base.reference.count = 1;
-   result->base.texture = NULL;
-   pipe_resource_reference(&result->base.texture, _resource);
-   result->base.context = _pipe;
+   result = pipe->create_sampler_view(pipe, texture, templ);
 
    trace_dump_ret(ptr, result);
 
    trace_dump_call_end();
 
-   return &result->base;
+   /*
+    * Wrap pipe_sampler_view
+    */
+   tr_view = CALLOC_STRUCT(trace_sampler_view);
+   tr_view->base = *templ;
+   tr_view->base.reference.count = 1;
+   tr_view->base.texture = NULL;
+   pipe_resource_reference(&tr_view->base.texture, _resource);
+   tr_view->base.context = _pipe;
+   tr_view->sampler_view = result;
+   result = &tr_view->base;
+
+   return result;
 }
 
 
@@ -1316,26 +1323,13 @@ trace_context_get_transfer(struct pipe_context *_context,
 
    assert(texture->screen == context->screen);
 
-   trace_dump_call_begin("pipe_context", "get_transfer");
-
-   trace_dump_arg(ptr, context);
-   trace_dump_arg(ptr, texture);
-   trace_dump_arg(uint, sr.face);
-   trace_dump_arg(uint, sr.level);
-   trace_dump_arg(uint, usage);
-   trace_dump_arg(uint, box->x);
-   trace_dump_arg(uint, box->y);
-   trace_dump_arg(uint, box->z);
-   trace_dump_arg(uint, box->width);
-   trace_dump_arg(uint, box->height);
-   trace_dump_arg(uint, box->depth);
+   /*
+    * Map and transfers can't be serialized so we convert all write transfers
+    * to transfer_inline_write and ignore read transfers.
+    */
 
    result = context->get_transfer(context, texture, sr, usage, box);
 
-   trace_dump_ret(ptr, result);
-
-   trace_dump_call_end();
-
    if (result)
       result = trace_transfer_create(tr_context, tr_tex, result);
 
@@ -1349,15 +1343,6 @@ trace_context_transfer_destroy(struct pipe_context *_context,
 {
    struct trace_context *tr_context = trace_context(_context);
    struct trace_transfer *tr_trans = trace_transfer(_transfer);
-   struct pipe_context *context = tr_context->pipe;
-   struct pipe_transfer *transfer = tr_trans->transfer;
-
-   trace_dump_call_begin("pipe_context", "transfer_destroy");
-
-   trace_dump_arg(ptr, context);
-   trace_dump_arg(ptr, transfer);
-
-   trace_dump_call_end();
 
    trace_transfer_destroy(tr_context, tr_trans);
 }
@@ -1399,12 +1384,7 @@ trace_context_transfer_flush_region( struct pipe_context *_context,
 
    trace_dump_arg(ptr, context);
    trace_dump_arg(ptr, transfer);
-   trace_dump_arg(uint, box->x);
-   trace_dump_arg(uint, box->y);
-   trace_dump_arg(uint, box->z);
-   trace_dump_arg(uint, box->width);
-   trace_dump_arg(uint, box->height);
-   trace_dump_arg(uint, box->depth);
+   trace_dump_arg(box, box);
    trace_dump_call_end();
 
    context->transfer_flush_region(context,
@@ -1422,27 +1402,35 @@ trace_context_transfer_unmap(struct pipe_context *_context,
    struct pipe_transfer *transfer = tr_trans->transfer;
 
    if(tr_trans->map) {
-      trace_dump_call_begin("pipe_context", "transfer_write");
+      /*
+       * Fake a transfer_inline_write
+       */
 
-      trace_dump_arg(ptr, context);
+      struct pipe_resource *resource = transfer->resource;
+      struct pipe_subresource sr = transfer->sr;
+      unsigned usage = transfer->usage;
+      const struct pipe_box *box = &transfer->box;
+      unsigned stride = transfer->stride;
+      unsigned slice_stride = transfer->slice_stride;
 
-      trace_dump_arg(ptr, transfer);
+      trace_dump_call_begin("pipe_context", "transfer_inline_write");
 
-      trace_dump_arg_begin("stride");
-      trace_dump_uint(transfer->stride);
-      trace_dump_arg_end();
+      trace_dump_arg(ptr, context);
+      trace_dump_arg(ptr, resource);
+      trace_dump_arg_struct(subresource, sr);
+      trace_dump_arg(uint, usage);
+      trace_dump_arg(box, box);
 
       trace_dump_arg_begin("data");
       trace_dump_box_bytes(tr_trans->map,
-                          transfer->resource->format,
-                          &transfer->box,
-                          transfer->stride,
-                          transfer->slice_stride);
+                           resource->format,
+                           box,
+                           stride,
+                           slice_stride);
       trace_dump_arg_end();
 
-//      trace_dump_arg_begin("size");
-//      trace_dump_uint(size);
-//      trace_dump_arg_end();
+      trace_dump_arg(uint, stride);
+      trace_dump_arg(uint, slice_stride);
 
       trace_dump_call_end();
 
@@ -1474,26 +1462,21 @@ trace_context_transfer_inline_write(struct pipe_context *_context,
 
    trace_dump_arg(ptr, context);
    trace_dump_arg(ptr, resource);
-   trace_dump_arg(uint, sr.face);
-   trace_dump_arg(uint, sr.level);
+   trace_dump_arg_struct(subresource, sr);
    trace_dump_arg(uint, usage);
-   trace_dump_arg(uint, box->x);
-   trace_dump_arg(uint, box->y);
-   trace_dump_arg(uint, box->z);
-   trace_dump_arg(uint, box->width);
-   trace_dump_arg(uint, box->height);
-   trace_dump_arg(uint, box->depth);
-   trace_dump_arg(uint, stride);
-   trace_dump_arg(uint, slice_stride);
+   trace_dump_arg(box, box);
 
    trace_dump_arg_begin("data");
    trace_dump_box_bytes(data,
-                       resource->format,
-                       box,
-                       stride,
-                       slice_stride);
+                        resource->format,
+                        box,
+                        stride,
+                        slice_stride);
    trace_dump_arg_end();
 
+   trace_dump_arg(uint, stride);
+   trace_dump_arg(uint, slice_stride);
+
    trace_dump_call_end();
 
    context->transfer_inline_write(context, resource,
index 19cf0de1d38c5d7ea156f1acd1a4861bbf6a986d..8ff25fb1e853fbd0364b064d2879b373207366a1 100644 (file)
@@ -50,6 +50,8 @@
 #include "util/u_debug.h"
 #include "util/u_memory.h"
 #include "util/u_string.h"
+#include "util/u_math.h"
+#include "util/u_format.h"
 
 #include "tr_dump.h"
 #include "tr_screen.h"
@@ -471,13 +473,14 @@ void trace_dump_bytes(const void *data,
 }
 
 void trace_dump_box_bytes(const void *data,
-                         unsigned format,
+                         enum pipe_format format,
                          const struct pipe_box *box,
                          unsigned stride,
                          unsigned slice_stride)
 {
-   //size_t size = util_format_get_nblocksy(transfer->resource->format, transfer->box.height) * transfer->stride;
-
+   size_t size = MAX2(util_format_get_nblocksy(format, box->height) * stride,
+                      box->depth * slice_stride);
+   trace_dump_bytes(data, size);
 }
 
 void trace_dump_string(const char *str)
index 9383ccdecb922c68be6e64e77aaf3a57edd44d9d..f21f72b0c7958b4710f00df24f689c0a94f6b3bd 100644 (file)
@@ -35,6 +35,7 @@
 
 
 #include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
 
 struct pipe_buffer;
 struct pipe_resource;
@@ -93,7 +94,7 @@ void trace_dump_uint(long long unsigned value);
 void trace_dump_float(double value);
 void trace_dump_bytes(const void *data, size_t size);
 void trace_dump_box_bytes(const void *data,
-                         unsigned format,
+                         enum pipe_format format,
                          const struct pipe_box *box,
                          unsigned stride,
                          unsigned slice_stride);
@@ -125,6 +126,13 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
       trace_dump_arg_end(); \
    } while(0)
 
+#define trace_dump_arg_struct(_type, _arg) \
+   do { \
+      trace_dump_arg_begin(#_arg); \
+      trace_dump_##_type(&_arg); \
+      trace_dump_arg_end(); \
+   } while(0)
+
 #define trace_dump_ret(_type, _arg) \
    do { \
       trace_dump_ret_begin(); \
index 1b917ff3fb95586ee6792b2a45f721dc00465aa2..ab347182ed9ef54553d65e302fbac17f70f4bd07 100644 (file)
@@ -44,7 +44,7 @@ void trace_dump_format(enum pipe_format format)
 }
 
 
-void trace_dump_template(const struct pipe_resource *templat)
+void trace_dump_resource_template(const struct pipe_resource *templat)
 {
    if (!trace_dumping_enabled_locked())
       return;
@@ -80,6 +80,48 @@ void trace_dump_template(const struct pipe_resource *templat)
 }
 
 
+void trace_dump_subresource(const struct pipe_subresource *subresource)
+{
+   if (!trace_dumping_enabled_locked())
+      return;
+
+   if(!subresource) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_subresource");
+
+   trace_dump_member(uint, subresource, face);
+   trace_dump_member(uint, subresource, level);
+
+   trace_dump_struct_end();
+}
+
+
+void trace_dump_box(const struct pipe_box *box)
+{
+   if (!trace_dumping_enabled_locked())
+      return;
+
+   if(!box) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_box");
+
+   trace_dump_member(uint, box, x);
+   trace_dump_member(uint, box, y);
+   trace_dump_member(uint, box, z);
+   trace_dump_member(uint, box, width);
+   trace_dump_member(uint, box, height);
+   trace_dump_member(uint, box, depth);
+
+   trace_dump_struct_end();
+}
+
+
 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
 {
    if (!trace_dumping_enabled_locked())
@@ -389,6 +431,30 @@ void trace_dump_sampler_state(const struct pipe_sampler_state *state)
 }
 
 
+void trace_dump_sampler_view_template(const struct pipe_sampler_view *state)
+{
+   if (!trace_dumping_enabled_locked())
+      return;
+
+   if(!state) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_sampler_view");
+
+   trace_dump_member(format, state, format);
+   trace_dump_member(uint, state, first_level);
+   trace_dump_member(uint, state, last_level);
+   trace_dump_member(uint, state, swizzle_r);
+   trace_dump_member(uint, state, swizzle_g);
+   trace_dump_member(uint, state, swizzle_b);
+   trace_dump_member(uint, state, swizzle_a);
+
+   trace_dump_struct_end();
+}
+
+
 void trace_dump_surface(const struct pipe_surface *state)
 {
    if (!trace_dumping_enabled_locked())
index 41f6263935f1d37dc76fc936cc3248b045c0b656..e614e8355e3f314905feca7e9122e4222c9d2029 100644 (file)
 
 void trace_dump_format(enum pipe_format format);
 
-void trace_dump_template(const struct pipe_resource *templat);
+void trace_dump_resource_template(const struct pipe_resource *templat);
+
+void trace_dump_subresource(const struct pipe_subresource *subresource);
+
+void trace_dump_box(const struct pipe_box *box);
 
 void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
 
@@ -63,6 +67,8 @@ void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state);
 
 void trace_dump_sampler_state(const struct pipe_sampler_state *state);
 
+void trace_dump_sampler_view_template(const struct pipe_sampler_view *view);
+
 void trace_dump_surface(const struct pipe_surface *state);
 
 void trace_dump_transfer(const struct pipe_transfer *state);
index 8b0715beed864b317b82c3084e1cc48b8d4bd3e3..63a45d7e512cfc11c59669023f9980e12f5896ae 100644 (file)
@@ -222,7 +222,7 @@ trace_screen_resource_create(struct pipe_screen *_screen,
    trace_dump_call_begin("pipe_screen", "resource_create");
 
    trace_dump_arg(ptr, screen);
-   trace_dump_arg(template, templat);
+   trace_dump_arg(resource_template, templat);
 
    result = screen->resource_create(screen, templat);