crocus: Add heap_memory_percent driconf support

Note: the final `video_memory` size still involves
`aperture_threshold`.

Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
This commit is contained in:
Karmjit Mahil 2026-04-28 10:51:45 +01:00
parent 00f006d841
commit 6331fedd31
3 changed files with 14 additions and 2 deletions

View file

@ -37,6 +37,7 @@
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "util/os_misc.h"
#include "util/u_debug.h"
#include "util/u_inlines.h"
#include "util/format/u_format.h"
@ -383,8 +384,9 @@ crocus_init_screen_caps(struct crocus_screen *screen)
const unsigned gpu_mappable_megabytes =
(screen->aperture_threshold) / (1024 * 1024);
uint64_t system_memory_bytes;
if (!os_get_total_physical_memory(&system_memory_bytes)) {
uint64_t system_memory_bytes =
os_get_gpu_heap_size(screen->driconf.heap_memory_percent, NULL);
if (!system_memory_bytes) {
caps->video_memory = -1;
} else {
const unsigned system_memory_megabytes =
@ -604,6 +606,11 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
screen->driconf.lower_depth_range_rate =
driQueryOptionf(config->options, "lower_depth_range_rate");
screen->driconf.heap_memory_percent =
driQueryOptionf(config->options, "heap_memory_percent");
if (screen->driconf.heap_memory_percent == OS_GPU_HEAP_SIZE_HEURISTIC)
screen->driconf.heap_memory_percent = 1.0f;
screen->precompile = debug_get_bool_option("shader_precompile", true);
isl_device_init(&screen->isl_dev, &screen->devinfo);

View file

@ -201,6 +201,7 @@ struct crocus_screen {
bool always_flush_cache;
bool limit_trig_input_range;
float lower_depth_range_rate;
float heap_memory_percent;
} driconf;
uint64_t aperture_bytes;

View file

@ -14,3 +14,7 @@ DRI_CONF_SECTION_END
DRI_CONF_SECTION_QUALITY
DRI_CONF_PP_LOWER_DEPTH_RANGE_RATE()
DRI_CONF_SECTION_END
DRI_CONF_SECTION_MISCELLANEOUS
DRI_CONF_HEAP_MEMORY_PERCENT(1.0f)
DRI_CONF_SECTION_END