From 1fece5fa5f8284076d923be6937d9115055a533e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 9 May 2019 21:44:33 -0700 Subject: virgl: better support for PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE When the resource to be mapped is busy and the backing storage can be discarded, reallocate the backing storage to avoid waiting. In this new path, we allocate a new buffer, emit a state change, write, and add the transfer to the queue . In the PIPE_TRANSFER_DISCARD_RANGE path, we suballocate a staging buffer, write, and emit a copy_transfer (which may allocate, memcpy, and blit internally). The win might not always be clear. But another win comes from that the new path clears res->valid_buffer_range and does not clear res->clean_mask. This makes it much more preferable in scenarios such as access = enough_space ? GL_MAP_UNSYNCHRONIZED_BIT : GL_MAP_INVALIDATE_BUFFER_BIT; glMapBufferRange(..., GL_MAP_WRITE_BIT | access); memcpy(...); // append new data glUnmapBuffer(...); Signed-off-by: Chia-I Wu Reviewed-by: Alexandros Frantzis --- src/gallium/drivers/virgl/virgl_texture.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium/drivers/virgl/virgl_texture.c') diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c index 1de6d4f17db..3c5737c5d17 100644 --- a/src/gallium/drivers/virgl/virgl_texture.c +++ b/src/gallium/drivers/virgl/virgl_texture.c @@ -134,6 +134,13 @@ static void *texture_transfer_map_plain(struct pipe_context *ctx, map_type = virgl_resource_transfer_prepare(vctx, trans); switch (map_type) { + case VIRGL_TRANSFER_MAP_REALLOC: + if (!virgl_resource_realloc(vctx, vtex)) { + map_addr = NULL; + break; + } + vws->resource_reference(vws, &trans->hw_res, vtex->hw_res); + /* fall through */ case VIRGL_TRANSFER_MAP_HW_RES: trans->hw_res_map = vws->resource_map(vws, vtex->hw_res); if (trans->hw_res_map) -- cgit v1.2.3