summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h28
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c112
-rw-r--r--src/gallium/auxiliary/util/u_transfer.h39
3 files changed, 69 insertions, 110 deletions
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 207e2aa838f..07f73546ad7 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -339,7 +339,6 @@ pipe_buffer_write(struct pipe_context *pipe,
unsigned size,
const void *data)
{
- struct pipe_box box;
unsigned access = PIPE_TRANSFER_WRITE;
if (offset == 0 && size == buf->width0) {
@@ -348,16 +347,7 @@ pipe_buffer_write(struct pipe_context *pipe,
access |= PIPE_TRANSFER_DISCARD_RANGE;
}
- u_box_1d(offset, size, &box);
-
- pipe->transfer_inline_write( pipe,
- buf,
- 0,
- access,
- &box,
- data,
- size,
- 0);
+ pipe->buffer_subdata(pipe, buf, access, offset, size, data);
}
/**
@@ -372,18 +362,10 @@ pipe_buffer_write_nooverlap(struct pipe_context *pipe,
unsigned offset, unsigned size,
const void *data)
{
- struct pipe_box box;
-
- u_box_1d(offset, size, &box);
-
- pipe->transfer_inline_write(pipe,
- buf,
- 0,
- (PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_UNSYNCHRONIZED),
- &box,
- data,
- 0, 0);
+ pipe->buffer_subdata(pipe, buf,
+ (PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_UNSYNCHRONIZED),
+ offset, size, data);
}
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
index 0610535cd2c..82cf68db958 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -4,34 +4,58 @@
#include "util/u_transfer.h"
#include "util/u_memory.h"
-/* One-shot transfer operation with data supplied in a user
- * pointer. XXX: strides??
- */
-void u_default_transfer_inline_write( struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride)
+void u_default_buffer_subdata(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned usage, unsigned offset,
+ unsigned size, const void *data)
{
struct pipe_transfer *transfer = NULL;
+ struct pipe_box box;
uint8_t *map = NULL;
assert(!(usage & PIPE_TRANSFER_READ));
- /* the write flag is implicit by the nature of transfer_inline_write */
+ /* the write flag is implicit by the nature of buffer_subdata */
usage |= PIPE_TRANSFER_WRITE;
- /* transfer_inline_write implicitly discards the rewritten buffer range */
- if (resource->target == PIPE_BUFFER &&
- box->x == 0 && box->width == resource->width0) {
+ /* buffer_subdata implicitly discards the rewritten buffer range */
+ if (offset == 0 && size == resource->width0) {
usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
} else {
usage |= PIPE_TRANSFER_DISCARD_RANGE;
}
+ u_box_1d(offset, size, &box);
+
+ map = pipe->transfer_map(pipe, resource, 0, usage, &box, &transfer);
+ if (!map)
+ return;
+
+ memcpy(map, data, size);
+ pipe_transfer_unmap(pipe, transfer);
+}
+
+void u_default_texture_subdata(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned layer_stride)
+{
+ struct pipe_transfer *transfer = NULL;
+ const uint8_t *src_data = data;
+ uint8_t *map = NULL;
+
+ assert(!(usage & PIPE_TRANSFER_READ));
+
+ /* the write flag is implicit by the nature of texture_subdata */
+ usage |= PIPE_TRANSFER_WRITE;
+
+ /* texture_subdata implicitly discards the rewritten buffer range */
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
+
map = pipe->transfer_map(pipe,
resource,
level,
@@ -40,28 +64,18 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
if (!map)
return;
- if (resource->target == PIPE_BUFFER) {
- assert(box->height == 1);
- assert(box->depth == 1);
-
- memcpy(map, data, box->width);
- }
- else {
- const uint8_t *src_data = data;
-
- 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);
- }
+ 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);
}
@@ -138,27 +152,3 @@ void u_transfer_unmap_vtbl( struct pipe_context *pipe,
struct u_resource *ur = u_resource(transfer->resource);
ur->vtbl->transfer_unmap(pipe, transfer);
}
-
-void u_transfer_inline_write_vtbl( struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride)
-{
- struct u_resource *ur = u_resource(resource);
- ur->vtbl->transfer_inline_write(pipe,
- resource,
- level,
- usage,
- box,
- data,
- stride,
- layer_stride);
-}
-
-
-
-
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
index 660dc161d33..7f680bc6582 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -14,14 +14,19 @@ boolean u_default_resource_get_handle(struct pipe_screen *screen,
struct pipe_resource *resource,
struct winsys_handle *handle);
-void u_default_transfer_inline_write( struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride);
+void u_default_buffer_subdata(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned usage, unsigned offset,
+ unsigned size, const void *data);
+
+void u_default_texture_subdata(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned layer_stride);
void u_default_transfer_flush_region( struct pipe_context *pipe,
struct pipe_transfer *transfer,
@@ -58,15 +63,6 @@ struct u_resource_vtbl {
void (*transfer_unmap)( struct pipe_context *,
struct pipe_transfer *transfer );
-
- void (*transfer_inline_write)( struct pipe_context *pipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride);
};
@@ -98,13 +94,4 @@ void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
struct pipe_transfer *transfer );
-void u_transfer_inline_write_vtbl( struct pipe_context *rm_ctx,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned layer_stride);
-
#endif