gallium/radeon: handle TC_TRANSFER_MAP_THREADED_UNSYNC

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
This commit is contained in:
Marek Olšák 2017-03-02 01:27:53 +01:00
parent 8b5485957e
commit e11f7e1d59
3 changed files with 14 additions and 1 deletions

View file

@ -27,6 +27,7 @@
#include "r600_cs.h"
#include "util/u_memory.h"
#include "util/u_upload_mgr.h"
#include "util/u_threaded_context.h"
#include <inttypes.h>
#include <stdio.h>
@ -292,7 +293,12 @@ static void *r600_buffer_get_transfer(struct pipe_context *ctx,
unsigned offset)
{
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_transfer *transfer = slab_alloc(&rctx->pool_transfers);
struct r600_transfer *transfer;
if (usage & TC_TRANSFER_MAP_THREADED_UNSYNC)
transfer = slab_alloc(&rctx->pool_transfers_unsync);
else
transfer = slab_alloc(&rctx->pool_transfers);
transfer->transfer.resource = NULL;
pipe_resource_reference(&transfer->transfer.resource, resource);
@ -418,6 +424,7 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx,
(rbuffer->flags & RADEON_FLAG_SPARSE)) {
struct r600_resource *staging;
assert(!(usage & TC_TRANSFER_MAP_THREADED_UNSYNC));
staging = (struct r600_resource*) pipe_buffer_create(
ctx->screen, 0, PIPE_USAGE_STAGING,
box->width + (box->x % R600_MAP_BUFFER_ALIGNMENT));
@ -507,6 +514,9 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
r600_resource_reference(&rtransfer->staging, NULL);
pipe_resource_reference(&transfer->resource, NULL);
/* Don't use pool_transfers_unsync. We are always in the driver
* thread. */
slab_free(&rctx->pool_transfers, transfer);
}

View file

@ -610,6 +610,7 @@ bool r600_common_context_init(struct r600_common_context *rctx,
unsigned context_flags)
{
slab_create_child(&rctx->pool_transfers, &rscreen->pool_transfers);
slab_create_child(&rctx->pool_transfers_unsync, &rscreen->pool_transfers);
rctx->screen = rscreen;
rctx->ws = rscreen->ws;
@ -713,6 +714,7 @@ void r600_common_context_cleanup(struct r600_common_context *rctx)
u_upload_destroy(rctx->b.const_uploader);
slab_destroy_child(&rctx->pool_transfers);
slab_destroy_child(&rctx->pool_transfers_unsync);
if (rctx->allocator_zeroed_memory) {
u_suballocator_destroy(rctx->allocator_zeroed_memory);

View file

@ -555,6 +555,7 @@ struct r600_common_context {
struct u_suballocator *allocator_zeroed_memory;
struct slab_child_pool pool_transfers;
struct slab_child_pool pool_transfers_unsync; /* for threaded_context */
/* Current unaccounted memory usage. */
uint64_t vram;