+void trace_dump_box_bytes(const void *data,
+ struct pipe_resource *resource,
+ const struct pipe_box *box,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ size_t size;
+
+ /*
+ * Only dump buffer transfers to avoid huge files.
+ * TODO: Make this run-time configurable
+ */
+ if (resource->target != PIPE_BUFFER) {
+ size = 0;
+ } else {
+ enum pipe_format format = resource->format;
+ if (slice_stride)
+ size = box->depth * slice_stride;
+ else if (stride)
+ size = util_format_get_nblocksy(format, box->height) * stride;
+ else {
+ size = util_format_get_nblocksx(format, box->width) * util_format_get_blocksize(format);
+ }
+ }
+
+ trace_dump_bytes(data, size);
+}
+