diff options
author | Bruno Jiménez <[email protected]> | 2014-07-16 23:12:44 +0200 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2014-07-23 10:29:17 -0400 |
commit | d8b6f0dacb0277dd4ae0f8152bc34a75206862c5 (patch) | |
tree | 9cff71dcf5c710d8824a8cc94348f51057320c0b /src/gallium/drivers | |
parent | 1f705b2bee4c83674593f92df81ec888e2a2e23d (diff) |
r600g/compute: Add a function for defragmenting the pool
This new function will move items forward in the pool, so that
there's no gap between them, effectively defragmenting the pool.
For now this function is a bit dumb as it just moves items
forward without trying to see if other items in the pool could
fit in the gaps.
Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/r600/compute_memory_pool.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/r600/compute_memory_pool.h | 3 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c index 0b413180851..00b28bc3249 100644 --- a/src/gallium/drivers/r600/compute_memory_pool.c +++ b/src/gallium/drivers/r600/compute_memory_pool.c @@ -302,6 +302,30 @@ int compute_memory_finalize_pending(struct compute_memory_pool* pool, return 0; } +/** + * Defragments the pool, so that there's no gap between items. + * \param pool The pool to be defragmented + */ +void compute_memory_defrag(struct compute_memory_pool *pool, + struct pipe_context *pipe) +{ + struct compute_memory_item *item; + int64_t last_pos; + + COMPUTE_DBG(pool->screen, "* compute_memory_defrag()\n"); + + last_pos = 0; + LIST_FOR_EACH_ENTRY(item, pool->item_list, link) { + if (item->start_in_dw != last_pos) { + assert(last_pos < item->start_in_dw); + + compute_memory_move_item(pool, item, last_pos, pipe); + } + + last_pos += align(item->size_in_dw, ITEM_ALIGNMENT); + } +} + int compute_memory_promote_item(struct compute_memory_pool *pool, struct compute_memory_item *item, struct pipe_context *pipe, int64_t allocated) @@ -417,6 +441,7 @@ void compute_memory_demote_item(struct compute_memory_pool *pool, * * \param item The item that will be moved * \param new_start_in_dw The new position of the item in \a item_list + * \see compute_memory_defrag */ void compute_memory_move_item(struct compute_memory_pool *pool, struct compute_memory_item *item, uint64_t new_start_in_dw, diff --git a/src/gallium/drivers/r600/compute_memory_pool.h b/src/gallium/drivers/r600/compute_memory_pool.h index 73320100dbd..5d187778d63 100644 --- a/src/gallium/drivers/r600/compute_memory_pool.h +++ b/src/gallium/drivers/r600/compute_memory_pool.h @@ -86,6 +86,9 @@ void compute_memory_shadow(struct compute_memory_pool* pool, int compute_memory_finalize_pending(struct compute_memory_pool* pool, struct pipe_context * pipe); +void compute_memory_defrag(struct compute_memory_pool *pool, + struct pipe_context *pipe); + int compute_memory_promote_item(struct compute_memory_pool *pool, struct compute_memory_item *item, struct pipe_context *pipe, int64_t allocated); |