v3d: Add heap_memory_percent driconf support

Signed-off-by: Karmjit Mahil <karmjit.mahil@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
This commit is contained in:
Karmjit Mahil 2026-04-28 13:49:21 +01:00
parent 37384a648e
commit 57d7ce06b6
3 changed files with 14 additions and 9 deletions

View file

@ -1,5 +1,6 @@
// v3d-specific driconf options
DRI_CONF_SECTION_MISCELLANEOUS
DRI_CONF_HEAP_MEMORY_PERCENT(1.0f)
DRI_CONF_V3D_NONMSAA_TEXTURE_SIZE_LIMIT(false)
DRI_CONF_SECTION_END

View file

@ -22,8 +22,6 @@
* IN THE SOFTWARE.
*/
#include <sys/sysinfo.h>
#include "common/v3d_device_info.h"
#include "common/v3d_limits.h"
#include "util/os_misc.h"
@ -218,10 +216,10 @@ v3d_init_compute_caps(struct v3d_screen *screen)
/* GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */
caps->max_local_size = 32768;
struct sysinfo si;
sysinfo(&si);
caps->max_global_size = si.totalram;
caps->max_mem_alloc_size = MIN2(V3D_MAX_BUFFER_RANGE, si.totalram);
caps->max_global_size =
os_get_gpu_heap_size(screen->heap_memory_percent, NULL);
caps->max_mem_alloc_size =
MIN2(V3D_MAX_BUFFER_RANGE, caps->max_global_size);
caps->max_compute_units = 1;
caps->subgroup_sizes = 16;
@ -338,9 +336,8 @@ v3d_init_screen_caps(struct v3d_screen *screen)
caps->vendor_id = 0x14E4;
uint64_t system_memory;
caps->video_memory = os_get_total_physical_memory(&system_memory) ?
system_memory >> 20 : 0;
caps->video_memory =
os_get_gpu_heap_size(screen->heap_memory_percent, NULL) >> 20;
caps->uma = true;
@ -817,6 +814,11 @@ v3d_screen_create(int fd, const struct pipe_screen_config *config,
driCheckOption(config->options, nonmsaa_name, DRI_BOOL) &&
driQueryOptionb(config->options, nonmsaa_name);
screen->heap_memory_percent =
driQueryOptionf(config->options, "heap_memory_percent");
if (screen->heap_memory_percent == OS_GPU_HEAP_SIZE_HEURISTIC)
screen->heap_memory_percent = 1.0f;
slab_create_parent(&screen->transfer_pool, sizeof(struct v3d_transfer), 16);
screen->has_csd = v3d_has_feature(screen, DRM_V3D_PARAM_SUPPORTS_CSD);

View file

@ -89,6 +89,8 @@ struct v3d_screen {
bool has_cpu_queue;
bool has_multisync;
float heap_memory_percent;
#if USE_V3D_SIMULATOR
struct v3d_simulator_file *sim_file;
#endif