diff options
author | Connor Abbott <[email protected]> | 2020-05-11 18:46:04 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-13 13:39:04 +0000 |
commit | ed79f805faf1ac5919a30d3284e37cc3f394e464 (patch) | |
tree | 36799bc05aee3196de0ca8c3ca4152eeb0afbc9a /src/freedreno/vulkan/tu_private.h | |
parent | 7ce527a4fed1706aed9ced8e5d3432cc5abfbbd3 (diff) |
tu: Add a "scratch bo" allocation mechanism
This is simpler than a full-blown memory reuse mechanism, but is good
enough to make sure that repeatedly doing a copy that requires the
linear staging buffer workaround won't use excessive memory or be slowed
down due to repeated allocations.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5007>
Diffstat (limited to 'src/freedreno/vulkan/tu_private.h')
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 99da10a568b..1c32e60000a 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -509,6 +509,17 @@ struct tu_device uint32_t vsc_draw_strm_pitch; uint32_t vsc_prim_strm_pitch; +#define MIN_SCRATCH_BO_SIZE_LOG2 12 /* A page */ + + /* Currently the kernel driver uses a 32-bit GPU address space, but it + * should be impossible to go beyond 48 bits. + */ + struct { + struct tu_bo bo; + mtx_t construct_mtx; + bool initialized; + } scratch_bos[48 - MIN_SCRATCH_BO_SIZE_LOG2]; + struct tu_bo border_color; struct list_head shader_slabs; @@ -531,6 +542,15 @@ tu_bo_finish(struct tu_device *dev, struct tu_bo *bo); VkResult tu_bo_map(struct tu_device *dev, struct tu_bo *bo); +/* Get a scratch bo for use inside a command buffer. This will always return + * the same bo given the same size or similar sizes, so only one scratch bo + * can be used at the same time. It's meant for short-lived things where we + * need to write to some piece of memory, read from it, and then immediately + * discard it. + */ +VkResult +tu_get_scratch_bo(struct tu_device *dev, uint64_t size, struct tu_bo **bo); + struct tu_cs_entry { /* No ownership */ |