diff options
author | Tom Stellard <[email protected]> | 2013-05-06 22:11:39 -0400 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2013-06-03 14:03:08 -0400 |
commit | 3d831206a4baf2cd36e91ea81ed45ce3c24d0f88 (patch) | |
tree | 97e1f4641e8bc4264fdbd30936ea72b0bf43164b /src/gallium/drivers/radeonsi/r600_buffer.c | |
parent | 67e5c9ae0e9fd0f205d346aebd0eb4c7e53a3948 (diff) |
radeonsi/compute: Pass kernel arguments in a buffer v2
v2:
- Fix memory leak in si_set_constant_buffer()
Diffstat (limited to 'src/gallium/drivers/radeonsi/r600_buffer.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/r600_buffer.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/r600_buffer.c b/src/gallium/drivers/radeonsi/r600_buffer.c index cdf9988c6e7..3d295e8a967 100644 --- a/src/gallium/drivers/radeonsi/r600_buffer.c +++ b/src/gallium/drivers/radeonsi/r600_buffer.c @@ -25,6 +25,8 @@ * Corbin Simpson <[email protected]> */ +#include <byteswap.h> + #include "pipe/p_screen.h" #include "util/u_format.h" #include "util/u_math.h" @@ -168,3 +170,30 @@ void r600_upload_index_buffer(struct r600_context *rctx, u_upload_data(rctx->uploader, 0, count * ib->index_size, ib->user_buffer, &ib->offset, &ib->buffer); } + +void r600_upload_const_buffer(struct r600_context *rctx, struct si_resource **rbuffer, + const uint8_t *ptr, unsigned size, + uint32_t *const_offset) +{ + if (R600_BIG_ENDIAN) { + uint32_t *tmpPtr; + unsigned i; + + if (!(tmpPtr = malloc(size))) { + R600_ERR("Failed to allocate BE swap buffer.\n"); + return; + } + + for (i = 0; i < size / 4; ++i) { + tmpPtr[i] = bswap_32(((uint32_t *)ptr)[i]); + } + + u_upload_data(rctx->uploader, 0, size, tmpPtr, const_offset, + (struct pipe_resource**)rbuffer); + + free(tmpPtr); + } else { + u_upload_data(rctx->uploader, 0, size, ptr, const_offset, + (struct pipe_resource**)rbuffer); + } +} |