Re: [Mesa-dev] [PATCH] swrast: Build fix for darwin

2015-01-04 Thread kallisti5

On 2015-01-03 10:00, Emil Velikov wrote:

On 02/01/15 04:14, Jeremy Huddleston Sequoia wrote:
This is certainly not the best solution to the problem, so I'm just 
sending this patch to the list to get the discussion started on the 
best way to solve this problem.  Currently, any platform that does not 
support _SC_PHYS_PAGES and _SC_PAGESIZE will fail to build swrast.  
_SC_PHYS_PAGES is not POSIX and thus there are many platforms out 
there that don't support it (such as OS X).



With the indentation fixed and a guard around the new includes this
should be safe to go as is. Pretty sure the latter don't exist on all 
of

mesa's supported platforms. Cc'ing Alexander (Haiku).



Actually, Haiku is good to go here :-)

~ grep -R _SC_PHYS_PAGES /boot/system/develop/headers/
/boot/system/develop/headers/posix/unistd.h:#define 
_SC_PHYS_PAGES	40


~ grep -R _SC_PAGESIZE /boot/system/develop/headers/
/boot/system/develop/headers/posix/unistd.h:#define 
_SC_PAGESIZE			_SC_PAGE_SIZE


~ grep -R sysconf /boot/system/develop/headers/
.
.
/boot/system/develop/headers/posix/unistd.h:/* sysconf() constants */
/boot/system/develop/headers/posix/unistd.h:extern long		sysconf(int 
name);
/boot/system/develop/headers/private/libroot/unistd_private.h:long	__sysconf_beos(int 
name);
/boot/system/develop/headers/private/libroot/unistd_private.h:long	__sysconf(int 
name);

.
.

Thanks!

 -- Alex
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] swrast: Build fix for darwin

2015-01-03 Thread Emil Velikov
On 02/01/15 04:14, Jeremy Huddleston Sequoia wrote:
 This is certainly not the best solution to the problem, so I'm just sending 
 this patch to the list to get the discussion started on the best way to solve 
 this problem.  Currently, any platform that does not support _SC_PHYS_PAGES 
 and _SC_PAGESIZE will fail to build swrast.  _SC_PHYS_PAGES is not POSIX and 
 thus there are many platforms out there that don't support it (such as OS X).
 
With the indentation fixed and a guard around the new includes this
should be safe to go as is. Pretty sure the latter don't exist on all of
mesa's supported platforms. Cc'ing Alexander (Haiku).

 We may want to put os_get_total_physical_memory() from 
 src/gallium/auxiliary/os/os_misc.c into a more common location, so it could 
 be used here.
 
This might be a better (long term) solution indeed. The recent trend is
to move common (classic  gallium) code to src/util. I don't have a
strong opinion if you'd like to do the re-factoring or not.

 However, as the existing comment indicates, maybe we don't even want to 
 return the full size of system memory for __DRI2_RENDERER_VIDEO_MEMORY.
 
Iirc the topic of video memory and what it means has been picked upon a
couple of times already. Having this covered and added to the spec's QA
might be useful.

Ian can we bother you one final time about this ?

-Emil

 
 On Jan 1, 2015, at 20:10, Jeremy Huddleston Sequoia jerem...@apple.com 
 wrote:

 Fixes regression from commit 64b1dc44495890cbc2c7c5509cb830264020998c

 Signed-off-by: Jeremy Huddleston Sequoia jerem...@apple.com
 CC: Emil Velikov emil.l.veli...@gmail.com
 CC: jon.tur...@dronecode.org.uk
 CC: io...@macports.org
 ---
 src/mesa/drivers/dri/swrast/swrast.c | 16 
 1 file changed, 16 insertions(+)

 diff --git a/src/mesa/drivers/dri/swrast/swrast.c 
 b/src/mesa/drivers/dri/swrast/swrast.c
 index d62fed3..0b7329a 100644
 --- a/src/mesa/drivers/dri/swrast/swrast.c
 +++ b/src/mesa/drivers/dri/swrast/swrast.c
 @@ -59,6 +59,9 @@
 #include swrast_priv.h
 #include swrast/s_context.h

 +#include sys/types.h
 +#include sys/sysctl.h
 +
 const __DRIextension **__driDriverGetExtensions_swrast(void);

 const char * const swrast_vendor_string = Mesa Project;
 @@ -135,6 +138,16 @@ swrast_query_renderer_integer(__DRIscreen *psp, int 
 param,
   value[0] = 0;
   return 0;
case __DRI2_RENDERER_VIDEO_MEMORY: {
 +  /* This should probably share code with os_get_total_physical_memory()
 +   * from src/gallium/auxiliary/os/os_misc.c
 +   */
 +#if defined(CTL_HW)  defined(HW_MEMSIZE)
 +int mib[2] = { CTL_HW, HW_MEMSIZE };
 +unsigned long system_memory_bytes;
 +size_t len = sizeof(system_memory_bytes);
 +if (sysctl(mib, 2, system_memory_bytes, len, NULL, 0) != 0)
 +return -1;
 +#elif defined(_SC_PHYS_PAGES)  defined(_SC_PAGE_SIZE)
   /* XXX: Do we want to return the full amount of system memory ? */
   const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
   const long system_page_size = sysconf(_SC_PAGE_SIZE);
 @@ -144,6 +157,9 @@ swrast_query_renderer_integer(__DRIscreen *psp, int 
 param,

   const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
  * (uint64_t) system_page_size;
 +#else
 +#error Unsupported platform
 +#endif

   const unsigned system_memory_megabytes =
  (unsigned) (system_memory_bytes / (1024 * 1024));
 -- 
 2.2.1

 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] swrast: Build fix for darwin

2015-01-01 Thread Jeremy Huddleston Sequoia
This is certainly not the best solution to the problem, so I'm just sending 
this patch to the list to get the discussion started on the best way to solve 
this problem.  Currently, any platform that does not support _SC_PHYS_PAGES and 
_SC_PAGESIZE will fail to build swrast.  _SC_PHYS_PAGES is not POSIX and thus 
there are many platforms out there that don't support it (such as OS X).

We may want to put os_get_total_physical_memory() from 
src/gallium/auxiliary/os/os_misc.c into a more common location, so it could be 
used here.

However, as the existing comment indicates, maybe we don't even want to return 
the full size of system memory for __DRI2_RENDERER_VIDEO_MEMORY.


 On Jan 1, 2015, at 20:10, Jeremy Huddleston Sequoia jerem...@apple.com 
 wrote:
 
 Fixes regression from commit 64b1dc44495890cbc2c7c5509cb830264020998c
 
 Signed-off-by: Jeremy Huddleston Sequoia jerem...@apple.com
 CC: Emil Velikov emil.l.veli...@gmail.com
 CC: jon.tur...@dronecode.org.uk
 CC: io...@macports.org
 ---
 src/mesa/drivers/dri/swrast/swrast.c | 16 
 1 file changed, 16 insertions(+)
 
 diff --git a/src/mesa/drivers/dri/swrast/swrast.c 
 b/src/mesa/drivers/dri/swrast/swrast.c
 index d62fed3..0b7329a 100644
 --- a/src/mesa/drivers/dri/swrast/swrast.c
 +++ b/src/mesa/drivers/dri/swrast/swrast.c
 @@ -59,6 +59,9 @@
 #include swrast_priv.h
 #include swrast/s_context.h
 
 +#include sys/types.h
 +#include sys/sysctl.h
 +
 const __DRIextension **__driDriverGetExtensions_swrast(void);
 
 const char * const swrast_vendor_string = Mesa Project;
 @@ -135,6 +138,16 @@ swrast_query_renderer_integer(__DRIscreen *psp, int 
 param,
   value[0] = 0;
   return 0;
case __DRI2_RENDERER_VIDEO_MEMORY: {
 +  /* This should probably share code with os_get_total_physical_memory()
 +   * from src/gallium/auxiliary/os/os_misc.c
 +   */
 +#if defined(CTL_HW)  defined(HW_MEMSIZE)
 +int mib[2] = { CTL_HW, HW_MEMSIZE };
 +unsigned long system_memory_bytes;
 +size_t len = sizeof(system_memory_bytes);
 +if (sysctl(mib, 2, system_memory_bytes, len, NULL, 0) != 0)
 +return -1;
 +#elif defined(_SC_PHYS_PAGES)  defined(_SC_PAGE_SIZE)
   /* XXX: Do we want to return the full amount of system memory ? */
   const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
   const long system_page_size = sysconf(_SC_PAGE_SIZE);
 @@ -144,6 +157,9 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
 
   const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
  * (uint64_t) system_page_size;
 +#else
 +#error Unsupported platform
 +#endif
 
   const unsigned system_memory_megabytes =
  (unsigned) (system_memory_bytes / (1024 * 1024));
 -- 
 2.2.1
 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] swrast: Build fix for darwin

2015-01-01 Thread Jeremy Huddleston Sequoia
Fixes regression from commit 64b1dc44495890cbc2c7c5509cb830264020998c

Signed-off-by: Jeremy Huddleston Sequoia jerem...@apple.com
CC: Emil Velikov emil.l.veli...@gmail.com
CC: jon.tur...@dronecode.org.uk
CC: io...@macports.org
---
 src/mesa/drivers/dri/swrast/swrast.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/mesa/drivers/dri/swrast/swrast.c 
b/src/mesa/drivers/dri/swrast/swrast.c
index d62fed3..0b7329a 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -59,6 +59,9 @@
 #include swrast_priv.h
 #include swrast/s_context.h
 
+#include sys/types.h
+#include sys/sysctl.h
+
 const __DRIextension **__driDriverGetExtensions_swrast(void);
 
 const char * const swrast_vendor_string = Mesa Project;
@@ -135,6 +138,16 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
   value[0] = 0;
   return 0;
case __DRI2_RENDERER_VIDEO_MEMORY: {
+  /* This should probably share code with os_get_total_physical_memory()
+   * from src/gallium/auxiliary/os/os_misc.c
+   */
+#if defined(CTL_HW)  defined(HW_MEMSIZE)
+int mib[2] = { CTL_HW, HW_MEMSIZE };
+unsigned long system_memory_bytes;
+size_t len = sizeof(system_memory_bytes);
+if (sysctl(mib, 2, system_memory_bytes, len, NULL, 0) != 0)
+return -1;
+#elif defined(_SC_PHYS_PAGES)  defined(_SC_PAGE_SIZE)
   /* XXX: Do we want to return the full amount of system memory ? */
   const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
   const long system_page_size = sysconf(_SC_PAGE_SIZE);
@@ -144,6 +157,9 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
 
   const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
  * (uint64_t) system_page_size;
+#else
+#error Unsupported platform
+#endif
 
   const unsigned system_memory_megabytes =
  (unsigned) (system_memory_bytes / (1024 * 1024));
-- 
2.2.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev