From dced0d0d588a1c6b9e2dcc7285b759ec4e0356c3 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Wed, 22 Apr 2015 23:15:24 +0100 Subject: [PATCH] swrast: can retrieve system memory on osx https://bugs.freedesktop.org/show_bug.cgi?id=90147 --- src/mesa/drivers/dri/swrast/swrast.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index d1bb721..3e8d518 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -61,6 +61,11 @@ #include "swrast_priv.h" #include "swrast/s_context.h" +#ifdef __APPLE__ +#include +#include +#endif + const __DRIextension **__driDriverGetExtensions_swrast(void); const char * const swrast_vendor_string = "Mesa Project"; @@ -138,6 +143,17 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param, return 0; case __DRI2_RENDERER_VIDEO_MEMORY: { /* XXX: Do we want to return the full amount of system memory ? */ +#ifdef __APPLE__ + struct host_basic_info hostinfo; + mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; + int result = host_info(mach_host_self(), + HOST_BASIC_INFO, + (host_info_t)&hostinfo, + &count); + if (result != KERN_SUCCESS) + return -1; + const uint64_t system_memory_bytes = hostinfo.max_mem; +#else const long system_memory_pages = sysconf(_SC_PHYS_PAGES); const long system_page_size = sysconf(_SC_PAGE_SIZE); @@ -146,7 +162,7 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param, const uint64_t system_memory_bytes = (uint64_t) system_memory_pages * (uint64_t) system_page_size; - +#endif const unsigned system_memory_megabytes = (unsigned) (system_memory_bytes / (1024 * 1024)); -- 2.3.2 (Apple Git-55)