mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
gallium/tc: Add optional buffer replacement limit
Allow drivers to limit the amount of replacement buffers created, to avoid runaway memory scenarios. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29507>
This commit is contained in:
parent
0311ac50ad
commit
4c469b7cf0
2 changed files with 19 additions and 4 deletions
|
|
@ -579,6 +579,7 @@ tc_batch_flush(struct threaded_context *tc, bool full_copy)
|
|||
tc_batch_check(next);
|
||||
tc_debug_check(tc);
|
||||
tc->bytes_mapped_estimate = 0;
|
||||
tc->bytes_replaced_estimate = 0;
|
||||
p_atomic_add(&tc->num_offloaded_slots, next->num_total_slots);
|
||||
|
||||
if (next->token) {
|
||||
|
|
@ -755,6 +756,7 @@ _tc_sync(struct threaded_context *tc, UNUSED const char *info, UNUSED const char
|
|||
if (next->num_total_slots) {
|
||||
p_atomic_add(&tc->num_direct_slots, next->num_total_slots);
|
||||
tc->bytes_mapped_estimate = 0;
|
||||
tc->bytes_replaced_estimate = 0;
|
||||
tc_add_call_end(next);
|
||||
tc_batch_execute(next, NULL, 0);
|
||||
tc_begin_next_buffer_list(tc);
|
||||
|
|
@ -2441,6 +2443,10 @@ tc_make_image_handle_resident(struct pipe_context *_pipe, uint64_t handle,
|
|||
* transfer
|
||||
*/
|
||||
|
||||
static void
|
||||
tc_flush(struct pipe_context *_pipe, struct pipe_fence_handle **fence,
|
||||
unsigned flags);
|
||||
|
||||
struct tc_replace_buffer_storage {
|
||||
struct tc_call_base base;
|
||||
uint16_t num_rebinds;
|
||||
|
|
@ -2489,6 +2495,13 @@ tc_invalidate_buffer(struct threaded_context *tc,
|
|||
tbuf->b.flags & (PIPE_RESOURCE_FLAG_SPARSE | PIPE_RESOURCE_FLAG_UNMAPPABLE))
|
||||
return false;
|
||||
|
||||
assert(tbuf->b.target == PIPE_BUFFER);
|
||||
tc->bytes_replaced_estimate += tbuf->b.width0;
|
||||
|
||||
if (tc->bytes_replaced_limit && (tc->bytes_replaced_estimate > tc->bytes_replaced_limit)) {
|
||||
tc_flush(&tc->base, NULL, PIPE_FLUSH_ASYNC);
|
||||
}
|
||||
|
||||
/* Allocate a new one. */
|
||||
new_buf = screen->resource_create(screen, &tbuf->b);
|
||||
if (!new_buf)
|
||||
|
|
@ -2878,10 +2891,6 @@ tc_transfer_flush_region(struct pipe_context *_pipe,
|
|||
p->box = *rel_box;
|
||||
}
|
||||
|
||||
static void
|
||||
tc_flush(struct pipe_context *_pipe, struct pipe_fence_handle **fence,
|
||||
unsigned flags);
|
||||
|
||||
struct tc_buffer_unmap {
|
||||
struct tc_call_base base;
|
||||
bool was_staging_transfer;
|
||||
|
|
|
|||
|
|
@ -600,6 +600,12 @@ struct threaded_context {
|
|||
uint64_t bytes_mapped_estimate;
|
||||
uint64_t bytes_mapped_limit;
|
||||
|
||||
/* Estimation of how replacement buffer bytes are in
|
||||
* the current tc_batch.
|
||||
*/
|
||||
uint64_t bytes_replaced_estimate;
|
||||
uint64_t bytes_replaced_limit;
|
||||
|
||||
struct util_queue queue;
|
||||
struct util_queue_fence *fence;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue