diff options
author | Marek Olšák <[email protected]> | 2013-11-29 17:28:23 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-12-12 18:34:11 +0100 |
commit | 91aca8c662faf0ec311968b2897a72a6d08b199d (patch) | |
tree | 97a5c26785cb01493158a8e2cb3c2c5965c5b08d /src/gallium/drivers/radeonsi | |
parent | 12806449fa35aff47ad6f4615ede55776c9f66c8 (diff) |
r600g,radeonsi: consolidate buffer code, add handling of DISCARD_RANGE for SI
This adds 2 optimizations for radeonsi:
- handling of DISCARD_RANGE
- mapping an uninitialized buffer range is automatically UNSYNCHRONIZED
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r-- | src/gallium/drivers/radeonsi/r600_buffer.c | 101 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/r600_resource.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/r600_translate.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/radeonsi_pipe.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/radeonsi_pipe.h | 5 |
5 files changed, 6 insertions, 121 deletions
diff --git a/src/gallium/drivers/radeonsi/r600_buffer.c b/src/gallium/drivers/radeonsi/r600_buffer.c index c952fe0084b..e64683d382e 100644 --- a/src/gallium/drivers/radeonsi/r600_buffer.c +++ b/src/gallium/drivers/radeonsi/r600_buffer.c @@ -35,105 +35,10 @@ #include "r600.h" #include "radeonsi_pipe.h" -static void r600_buffer_destroy(struct pipe_screen *screen, - struct pipe_resource *buf) -{ - struct r600_resource *rbuffer = r600_resource(buf); - - pb_reference(&rbuffer->buf, NULL); - FREE(rbuffer); -} - -static void *r600_buffer_transfer_map(struct pipe_context *ctx, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *box, - struct pipe_transfer **ptransfer) -{ - struct r600_context *rctx = (struct r600_context*)ctx; - struct pipe_transfer *transfer; - struct r600_resource *rbuffer = r600_resource(resource); - uint8_t *data; - - if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE && - !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) { - assert(usage & PIPE_TRANSFER_WRITE); - - /* Check if mapping this buffer would cause waiting for the GPU. */ - if (r600_rings_is_buffer_referenced(&rctx->b, rbuffer->cs_buf, RADEON_USAGE_READWRITE) || - rctx->b.ws->buffer_is_busy(rbuffer->buf, RADEON_USAGE_READWRITE)) { - rctx->b.invalidate_buffer(&rctx->b.b, &rbuffer->b.b); - } - } - - data = rctx->b.ws->buffer_map(rbuffer->cs_buf, rctx->b.rings.gfx.cs, usage); - if (!data) { - return NULL; - } - - transfer = util_slab_alloc(&rctx->pool_transfers); - transfer->resource = resource; - transfer->level = level; - transfer->usage = usage; - transfer->box = *box; - transfer->stride = 0; - transfer->layer_stride = 0; - *ptransfer = transfer; - - return (uint8_t*)data + transfer->box.x; -} - -static void r600_buffer_transfer_unmap(struct pipe_context *ctx, - struct pipe_transfer *transfer) -{ - struct r600_context *rctx = (struct r600_context*)ctx; - util_slab_free(&rctx->pool_transfers, transfer); -} - -static void r600_buffer_transfer_flush_region(struct pipe_context *pipe, - struct pipe_transfer *transfer, - const struct pipe_box *box) -{ -} - -static const struct u_resource_vtbl r600_buffer_vtbl = -{ - u_default_resource_get_handle, /* get_handle */ - r600_buffer_destroy, /* resource_destroy */ - r600_buffer_transfer_map, /* transfer_map */ - r600_buffer_transfer_flush_region, /* transfer_flush_region */ - r600_buffer_transfer_unmap, /* transfer_unmap */ - NULL /* transfer_inline_write */ -}; - -struct pipe_resource *si_buffer_create(struct pipe_screen *screen, - const struct pipe_resource *templ) -{ - struct r600_screen *rscreen = (struct r600_screen*)screen; - struct r600_resource *rbuffer; - /* XXX We probably want a different alignment for buffers and textures. */ - unsigned alignment = 4096; - - rbuffer = MALLOC_STRUCT(r600_resource); - - rbuffer->b.b = *templ; - pipe_reference_init(&rbuffer->b.b.reference, 1); - rbuffer->b.b.screen = screen; - rbuffer->b.vtbl = &r600_buffer_vtbl; - util_range_init(&rbuffer->valid_buffer_range); - - if (!r600_init_resource(&rscreen->b, rbuffer, templ->width0, alignment, TRUE, templ->usage)) { - FREE(rbuffer); - return NULL; - } - return &rbuffer->b.b; -} - void r600_upload_index_buffer(struct r600_context *rctx, struct pipe_index_buffer *ib, unsigned count) { - u_upload_data(rctx->uploader, 0, count * ib->index_size, + u_upload_data(rctx->b.uploader, 0, count * ib->index_size, ib->user_buffer, &ib->offset, &ib->buffer); } @@ -154,12 +59,12 @@ void r600_upload_const_buffer(struct r600_context *rctx, struct r600_resource ** tmpPtr[i] = util_bswap32(((uint32_t *)ptr)[i]); } - u_upload_data(rctx->uploader, 0, size, tmpPtr, const_offset, + u_upload_data(rctx->b.uploader, 0, size, tmpPtr, const_offset, (struct pipe_resource**)rbuffer); free(tmpPtr); } else { - u_upload_data(rctx->uploader, 0, size, ptr, const_offset, + u_upload_data(rctx->b.uploader, 0, size, ptr, const_offset, (struct pipe_resource**)rbuffer); } } diff --git a/src/gallium/drivers/radeonsi/r600_resource.c b/src/gallium/drivers/radeonsi/r600_resource.c index 745d3ba88c9..9a0fde430ff 100644 --- a/src/gallium/drivers/radeonsi/r600_resource.c +++ b/src/gallium/drivers/radeonsi/r600_resource.c @@ -27,7 +27,7 @@ static struct pipe_resource *r600_resource_create(struct pipe_screen *screen, const struct pipe_resource *templ) { if (templ->target == PIPE_BUFFER) { - return si_buffer_create(screen, templ); + return r600_buffer_create(screen, templ, 4096); } else { return r600_texture_create(screen, templ); } @@ -55,7 +55,7 @@ void r600_init_screen_resource_functions(struct pipe_screen *screen) void r600_init_context_resource_functions(struct r600_context *r600) { r600->b.b.transfer_map = u_transfer_map_vtbl; - r600->b.b.transfer_flush_region = u_transfer_flush_region_vtbl; + r600->b.b.transfer_flush_region = u_default_transfer_flush_region; r600->b.b.transfer_unmap = u_transfer_unmap_vtbl; r600->b.b.transfer_inline_write = u_default_transfer_inline_write; } diff --git a/src/gallium/drivers/radeonsi/r600_translate.c b/src/gallium/drivers/radeonsi/r600_translate.c index ccb72d5fca1..177a9dd7084 100644 --- a/src/gallium/drivers/radeonsi/r600_translate.c +++ b/src/gallium/drivers/radeonsi/r600_translate.c @@ -38,7 +38,7 @@ void r600_translate_index_buffer(struct r600_context *r600, switch (ib->index_size) { case 1: - u_upload_alloc(r600->uploader, 0, count * 2, + u_upload_alloc(r600->b.uploader, 0, count * 2, &out_offset, &out_buffer, &ptr); util_shorten_ubyte_elts_to_userptr( diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c index 866cc1af8d8..0fec6d56978 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c @@ -119,11 +119,6 @@ static void r600_destroy_context(struct pipe_context *context) util_blitter_destroy(rctx->blitter); - if (rctx->uploader) { - u_upload_destroy(rctx->uploader); - } - util_slab_destroy(&rctx->pool_transfers); - r600_common_context_cleanup(&rctx->b); FREE(rctx); } @@ -187,16 +182,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void rctx->b.ws->cs_set_flush_callback(rctx->b.rings.gfx.cs, r600_flush_from_winsys, rctx); - util_slab_create(&rctx->pool_transfers, - sizeof(struct pipe_transfer), 64, - UTIL_SLAB_SINGLETHREADED); - - rctx->uploader = u_upload_create(&rctx->b.b, 1024 * 1024, 256, - PIPE_BIND_INDEX_BUFFER | - PIPE_BIND_CONSTANT_BUFFER); - if (!rctx->uploader) - goto fail; - rctx->blitter = util_blitter_create(&rctx->b.b); if (rctx->blitter == NULL) goto fail; diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h index de613e0ed34..e84088f11db 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h +++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h @@ -142,9 +142,6 @@ struct r600_context { struct r600_resource *border_color_table; unsigned border_color_offset; - struct u_upload_mgr *uploader; - struct util_slab_mempool pool_transfers; - unsigned default_ps_gprs, default_vs_gprs; /* Below are variables from the old r600_context. @@ -186,8 +183,6 @@ void r600_decompress_color_textures(struct r600_context *rctx, struct r600_textures_info *textures); /* r600_buffer.c */ -struct pipe_resource *si_buffer_create(struct pipe_screen *screen, - const struct pipe_resource *templ); void r600_upload_index_buffer(struct r600_context *rctx, struct pipe_index_buffer *ib, unsigned count); |