summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2016-07-16 21:19:48 +0200
committerMarek Olšák <marek.olsak@amd.com>2016-07-23 13:33:42 +0200
commit1ffe77e7bb2486ea74cda077ed2a9622b758395c (patch)
tree4a04818614fc8c4e086e9dcd32dbadecbac4b6fb /src/gallium/auxiliary/util
parent0ba7288376dc66f932336862c8a6abb629b47686 (diff)
downloadexternal_mesa3d-1ffe77e7bb2486ea74cda077ed2a9622b758395c.zip
external_mesa3d-1ffe77e7bb2486ea74cda077ed2a9622b758395c.tar.gz
external_mesa3d-1ffe77e7bb2486ea74cda077ed2a9622b758395c.tar.bz2
gallium: split transfer_inline_write into buffer and texture callbacks
to reduce the call indirections with u_resource_vtbl. The worst call tree you could get was: - u_transfer_inline_write_vtbl - u_default_transfer_inline_write - u_transfer_map_vtbl - driver_transfer_map - u_transfer_unmap_vtbl - driver_transfer_unmap That's 6 indirect calls. Some drivers only had 5. The goal is to have 1 indirect call for drivers that care. The resource type can be determined statically at most call sites. The new interface is: pipe_context::buffer_subdata(ctx, resource, usage, offset, size, data) pipe_context::texture_subdata(ctx, resource, level, usage, box, data, stride, layer_stride) v2: fix whitespace, correct ilo's behavior Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Acked-by: Roland Scheidegger <sroland@vmware.com>
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 207e2aa..07f7354 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 0610535..82cf68d 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 660dc16..7f680bc 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