summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/virgl/virgl_resource.h
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-05-09 21:44:33 -0700
committerChia-I Wu <[email protected]>2019-06-17 09:36:31 -0700
commit1fece5fa5f8284076d923be6937d9115055a533e (patch)
tree298fa1f76de034c3b1971c80355a6fae56919bb9 /src/gallium/drivers/virgl/virgl_resource.h
parent9975a0a84ca2ee18a0f051df44932bd7b2284a02 (diff)
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 <[email protected]> Reviewed-by: Alexandros Frantzis <[email protected]>
Diffstat (limited to 'src/gallium/drivers/virgl/virgl_resource.h')
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h
index 86eb2322513..c3374fbef70 100644
--- a/src/gallium/drivers/virgl/virgl_resource.h
+++ b/src/gallium/drivers/virgl/virgl_resource.h
@@ -73,10 +73,14 @@ struct virgl_resource {
enum virgl_transfer_map_type {
VIRGL_TRANSFER_MAP_ERROR = -1,
VIRGL_TRANSFER_MAP_HW_RES,
+
/* Map a range of a staging buffer. The updated contents should be transferred
* with a copy transfer.
*/
VIRGL_TRANSFER_MAP_STAGING,
+
+ /* Reallocate the underlying virgl_hw_res. */
+ VIRGL_TRANSFER_MAP_REALLOC,
};
struct virgl_transfer {
@@ -187,4 +191,8 @@ void virgl_resource_dirty(struct virgl_resource *res, uint32_t level);
void *virgl_transfer_uploader_map(struct virgl_context *vctx,
struct virgl_transfer *vtransfer);
+bool
+virgl_resource_realloc(struct virgl_context *vctx,
+ struct virgl_resource *res);
+
#endif