From 65d451d9fa1192c386301ca0b84b6c5cd369f92d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 26 Apr 2012 13:39:19 +0200 Subject: [PATCH] radeonsi: don't create temporary user buffer for r600_upload_const_buffer --- src/gallium/drivers/radeonsi/r600_buffer.c | 42 ++++++++----------- src/gallium/drivers/radeonsi/r600_resource.h | 4 +- .../drivers/radeonsi/r600_state_common.c | 11 ++--- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/radeonsi/r600_buffer.c b/src/gallium/drivers/radeonsi/r600_buffer.c index 7e8e2ca6887..d21b5b61147 100644 --- a/src/gallium/drivers/radeonsi/r600_buffer.c +++ b/src/gallium/drivers/radeonsi/r600_buffer.c @@ -216,36 +216,30 @@ void r600_upload_index_buffer(struct r600_context *rctx, } void r600_upload_const_buffer(struct r600_context *rctx, struct r600_resource **rbuffer, - uint32_t *const_offset) + const uint8_t *ptr, unsigned size, + uint32_t *const_offset) { - if ((*rbuffer)->b.b.user_ptr) { - uint8_t *ptr = (*rbuffer)->b.b.user_ptr; - unsigned size = (*rbuffer)->b.b.width0; + *rbuffer = NULL; - *rbuffer = NULL; + if (R600_BIG_ENDIAN) { + uint32_t *tmpPtr; + unsigned i; - if (R600_BIG_ENDIAN) { - uint32_t *tmpPtr; - unsigned i; - - if (!(tmpPtr = malloc(size))) { - R600_ERR("Failed to allocate BE swap buffer.\n"); - return; - } + 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]); - } + 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); + 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); - } + free(tmpPtr); } else { - *const_offset = 0; + u_upload_data(rctx->uploader, 0, size, ptr, const_offset, + (struct pipe_resource**)rbuffer); } } diff --git a/src/gallium/drivers/radeonsi/r600_resource.h b/src/gallium/drivers/radeonsi/r600_resource.h index e81a2ed4675..6926d764cbe 100644 --- a/src/gallium/drivers/radeonsi/r600_resource.h +++ b/src/gallium/drivers/radeonsi/r600_resource.h @@ -99,6 +99,8 @@ void r600_texture_transfer_unmap(struct pipe_context *ctx, struct r600_context; -void r600_upload_const_buffer(struct r600_context *rctx, struct r600_resource **rbuffer, uint32_t *offset); +void r600_upload_const_buffer(struct r600_context *rctx, struct r600_resource **rbuffer, + const uint8_t *ptr, unsigned size, + uint32_t *const_offset); #endif diff --git a/src/gallium/drivers/radeonsi/r600_state_common.c b/src/gallium/drivers/radeonsi/r600_state_common.c index 63c07420915..53a34ef519c 100644 --- a/src/gallium/drivers/radeonsi/r600_state_common.c +++ b/src/gallium/drivers/radeonsi/r600_state_common.c @@ -439,15 +439,12 @@ void r600_set_constant_buffer(struct pipe_context *ctx, uint shader, uint index, return; } - if (cb->user_buffer) { - rbuffer = pipe_user_buffer_create(ctx->screen, cb->user_buffer, - cb->buffer_size, - PIPE_BIND_CONSTANT_BUFFER); - } - r600_inval_shader_cache(rctx); - r600_upload_const_buffer(rctx, &rbuffer, &offset); + if (cb->user_buffer) + r600_upload_const_buffer(rctx, &rbuffer, cb->user_buffer, cb->buffer_size, &offset); + else + offset = 0; va_offset = r600_resource_va(ctx->screen, (void*)rbuffer); va_offset += offset; //va_offset >>= 8; -- 2.30.2