From 671d579b46d79905a4daa2e3e59ee0d29a95708e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 14 Jul 2021 13:43:13 -0400 Subject: [PATCH] util/tc: add a util function for setting bytes_mapped_limit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tc drivers set this based on os_get_total_physical_memory()/divisor, which is going to be totally wrong for 32bit processes and explode the address space this util function can be used to handle per-platform clamping Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 11 +++++++++++ src/gallium/auxiliary/util/u_threaded_context.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 543662f0429..8e9898310ab 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -4207,3 +4207,14 @@ fail: tc_destroy(&tc->base); return NULL; } + +void +threaded_context_init_bytes_mapped_limit(struct threaded_context *tc, unsigned divisor) +{ + uint64_t total_ram; + if (os_get_total_physical_memory(&total_ram)) { + tc->bytes_mapped_limit = total_ram / divisor; + if (sizeof(void*) == 4) + tc->bytes_mapped_limit = MIN2(tc->bytes_mapped_limit, 512*1024*1024UL); + } +} diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h index 952429d74ff..04088166248 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.h +++ b/src/gallium/auxiliary/util/u_threaded_context.h @@ -504,6 +504,9 @@ threaded_context_create(struct pipe_context *pipe, bool driver_calls_flush_notify, struct threaded_context **out); +void +threaded_context_init_bytes_mapped_limit(struct threaded_context *tc, unsigned divisor); + void threaded_context_flush(struct pipe_context *_pipe, struct tc_unflushed_batch_token *token,