summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2012-12-05 20:15:40 +0000
committerJosé Fonseca <[email protected]>2012-12-06 17:12:31 +0000
commitb79194401a944e952e3035c676d1d22df24aa2a8 (patch)
tree8aa18376a4d6b900cb4afdbfcaeb6b10e372afe5 /src/gallium/auxiliary
parent4da4e8ee2ac337a765afd828880efe5a5a168088 (diff)
util: Add util_copy_box helper.
Must users of util_copy_rect() need or should deal with volumes. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_surface.c55
-rw-r--r--src/gallium/auxiliary/util/u_surface.h10
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c28
3 files changed, 64 insertions, 29 deletions
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index b17dd74fd37..2c197c3df6a 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -168,6 +168,39 @@ util_copy_rect(ubyte * dst,
}
+/**
+ * Copy 3D box from one place to another.
+ * Position and sizes are in pixels.
+ */
+void
+util_copy_box(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride, unsigned dst_slice_stride,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned width, unsigned height, unsigned depth,
+ const ubyte * src,
+ int src_stride, unsigned src_slice_stride,
+ unsigned src_x, unsigned src_y, unsigned src_z)
+{
+ unsigned z;
+ dst += dst_z * dst_slice_stride;
+ src += src_z * src_slice_stride;
+ for (z = 0; z < depth; ++z) {
+ util_copy_rect(dst,
+ format,
+ dst_stride,
+ dst_x, dst_y,
+ width, height,
+ src,
+ src_stride,
+ src_x, src_y);
+
+ dst += dst_slice_stride;
+ src += src_slice_stride;
+ }
+}
+
+
void
util_fill_rect(ubyte * dst,
enum pipe_format format,
@@ -257,7 +290,6 @@ util_resource_copy_region(struct pipe_context *pipe,
const uint8_t *src_map;
enum pipe_format src_format, dst_format;
struct pipe_box dst_box;
- int z;
assert(src && dst);
if (!src || !dst)
@@ -305,19 +337,14 @@ util_resource_copy_region(struct pipe_context *pipe,
assert(src_box->depth == 1);
memcpy(dst_map, src_map, src_box->width);
} else {
- for (z = 0; z < src_box->depth; ++z) {
- util_copy_rect(dst_map,
- dst_format,
- dst_trans->stride,
- 0, 0,
- src_box->width, src_box->height,
- src_map,
- src_trans->stride,
- 0, 0);
-
- dst_map += dst_trans->layer_stride;
- src_map += src_trans->layer_stride;
- }
+ util_copy_box(dst_map,
+ dst_format,
+ dst_trans->stride, dst_trans->layer_stride,
+ 0, 0, 0,
+ src_box->width, src_box->height, src_box->depth,
+ src_map,
+ src_trans->stride, src_trans->layer_stride,
+ 0, 0, 0);
}
pipe->transfer_unmap(pipe, dst_trans);
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index db3fd8b11fe..dd4d5785e40 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -58,6 +58,16 @@ util_copy_rect(ubyte * dst, enum pipe_format format,
int src_stride, unsigned src_x, unsigned src_y);
extern void
+util_copy_box(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride, unsigned dst_slice_stride,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned width, unsigned height, unsigned depth,
+ const ubyte * src,
+ int src_stride, unsigned src_slice_stride,
+ unsigned src_x, unsigned src_y, unsigned src_z);
+
+extern void
util_fill_rect(ubyte * dst, enum pipe_format format,
unsigned dst_stride, unsigned dst_x, unsigned dst_y,
unsigned width, unsigned height, union util_color *uc);
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index 8b4c3659253..86168255325 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -1,5 +1,5 @@
#include "pipe/p_context.h"
-#include "util/u_rect.h"
+#include "util/u_surface.h"
#include "util/u_inlines.h"
#include "util/u_transfer.h"
#include "util/u_memory.h"
@@ -47,21 +47,19 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
}
else {
const uint8_t *src_data = data;
- unsigned i;
- for (i = 0; i < box->depth; i++) {
- util_copy_rect(map,
- resource->format,
- transfer->stride, /* bytes */
- 0, 0,
- box->width,
- box->height,
- src_data,
- stride, /* bytes */
- 0, 0);
- map += transfer->layer_stride;
- src_data += layer_stride;
- }
+ util_copy_box(map,
+ resource->format,
+ transfer->stride, /* bytes */
+ transfer->layer_stride, /* bytes */
+ 0, 0, 0,
+ box->width,
+ box->height,
+ box->depth,
+ src_data,
+ stride, /* bytes */
+ layer_stride, /* bytes */
+ 0, 0, 0);
}
pipe_transfer_unmap(pipe, transfer);