Mesa (main): util/tc: add a util function for setting bytes_mapped_limit
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 20 14:06:53 UTC 2021
Module: Mesa
Branch: main
Commit: 671d579b46d79905a4daa2e3e59ee0d29a95708e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=671d579b46d79905a4daa2e3e59ee0d29a95708e
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Jul 14 13:43:13 2021 -0400
util/tc: add a util function for setting bytes_mapped_limit
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 <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11853>
---
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,
More information about the mesa-commit
mailing list