diff --git a/src/gallium/drivers/v3d/driinfo_v3d.h b/src/gallium/drivers/v3d/driinfo_v3d.h index 147ad0b49bd..72c3f5dbd75 100644 --- a/src/gallium/drivers/v3d/driinfo_v3d.h +++ b/src/gallium/drivers/v3d/driinfo_v3d.h @@ -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 diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index f2a979ee9a6..93d7e0ba5c7 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -22,8 +22,6 @@ * IN THE SOFTWARE. */ -#include - #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); diff --git a/src/gallium/drivers/v3d/v3d_screen.h b/src/gallium/drivers/v3d/v3d_screen.h index 831ce8d7213..4f6a7d1fb6a 100644 --- a/src/gallium/drivers/v3d/v3d_screen.h +++ b/src/gallium/drivers/v3d/v3d_screen.h @@ -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