diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c index e0e91aab462..c0b4d9406a5 100644 --- a/src/gallium/auxiliary/util/u_helpers.c +++ b/src/gallium/auxiliary/util/u_helpers.c @@ -460,6 +460,21 @@ util_throttle_memory_usage(struct pipe_context *pipe, t->ring[t->flush_index].mem_usage += memory_size; } +void +util_sw_query_memory_info(struct pipe_screen *pscreen, + struct pipe_memory_info *info) +{ + /* Provide query_memory_info from CPU reported memory */ + uint64_t size; + + if (!os_get_available_system_memory(&size)) + return; + info->avail_staging_memory = size / 1024; + if (!os_get_total_physical_memory(&size)) + return; + info->total_staging_memory = size / 1024; +} + bool util_lower_clearsize_to_dword(const void *clearValue, int *clearValueSize, uint32_t *clamped) { diff --git a/src/gallium/auxiliary/util/u_helpers.h b/src/gallium/auxiliary/util/u_helpers.h index 299c6798088..2d12d6f17da 100644 --- a/src/gallium/auxiliary/util/u_helpers.h +++ b/src/gallium/auxiliary/util/u_helpers.h @@ -117,6 +117,8 @@ void util_throttle_init(struct util_throttle *t, uint64_t max_mem_usage); void util_throttle_deinit(struct pipe_screen *screen, struct util_throttle *t); void util_throttle_memory_usage(struct pipe_context *pipe, struct util_throttle *t, uint64_t memory_size); +void util_sw_query_memory_info(struct pipe_screen *pscreen, + struct pipe_memory_info *info); bool util_lower_clearsize_to_dword(const void *clearValue, int *clearValueSize, uint32_t *clamped); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index f8e85c01aae..40b41af2457 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -41,6 +41,7 @@ #include "util/disk_cache.h" #include "util/os_misc.h" #include "util/os_time.h" +#include "util/u_helpers.h" #include "lp_texture.h" #include "lp_fence.h" #include "lp_jit.h" @@ -284,6 +285,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) } case PIPE_CAP_UMA: return 1; + case PIPE_CAP_QUERY_MEMORY_INFO: + return 1; case PIPE_CAP_CLIP_HALFZ: return 1; case PIPE_CAP_POLYGON_OFFSET_CLAMP: @@ -1073,6 +1076,8 @@ llvmpipe_create_screen(struct sw_winsys *winsys) screen->base.get_timestamp = u_default_get_timestamp; + screen->base.query_memory_info = util_sw_query_memory_info; + screen->base.get_driver_uuid = llvmpipe_get_driver_uuid; screen->base.get_device_uuid = llvmpipe_get_device_uuid; diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 50f14a0bd55..7af49a89058 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -27,6 +27,7 @@ #include "compiler/nir/nir.h" +#include "util/u_helpers.h" #include "util/u_memory.h" #include "util/format/u_format.h" #include "util/format/u_format_s3tc.h" @@ -282,6 +283,8 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) } case PIPE_CAP_UMA: return 0; + case PIPE_CAP_QUERY_MEMORY_INFO: + return 1; case PIPE_CAP_CONDITIONAL_RENDER_INVERTED: return 1; case PIPE_CAP_CLIP_HALFZ: @@ -594,6 +597,7 @@ softpipe_create_screen(struct sw_winsys *winsys) screen->base.get_shader_param = softpipe_get_shader_param; screen->base.get_paramf = softpipe_get_paramf; screen->base.get_timestamp = u_default_get_timestamp; + screen->base.query_memory_info = util_sw_query_memory_info; screen->base.is_format_supported = softpipe_is_format_supported; screen->base.context_create = softpipe_create_context; screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;