Re: [Mesa-dev] [PATCH] drisw: Fix build on Android Nougat, which lacks shm (v2)

2018-08-02 Thread David Airlie
On Tue, Jul 31, 2018 at 1:17 PM, Chad Versace 
wrote:

> In commit cf54bd5e8, dri_sw_winsys.c began using  to support
> the new functions putImageShm, getImageShm in DRI_SWRastLoader. But
> Android began supporting System V shared memory only in Oreo. Nougat has
> no shm headers.
>
> Fix the build by ifdef'ing out the shm code on Nougat.


> Fixes: cf54bd5e8 "drisw: use shared memory when possible"
> Cc: Marc-André Lureau 
> Cc: Dave Airlie 
> ---
>
> Dave, is this what you had in mind?
>

Yeah that seems a lot more acceptable.

Reviewed-by: Dave Airlie 

>
> I considered putting a check in configure.ac for HAVE_SHM, but decided
> against it because (1) another Autoconf check would slow down everyone's
> build for a niche case that only a few people care about, and (2) it
> only affected this file.
>
>  src/gallium/winsys/sw/dri/dri_sw_winsys.c | 11 +++
>  1 file changed, 11 insertions(+)
>
> diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> index 40007200a5d..d519bcfedd3 100644
> --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> @@ -26,8 +26,12 @@
>   *
>   
> **/
>
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
> +/* Android's libc began supporting shm in Oreo */
> +#define HAVE_SHM
>  #include 
>  #include 
> +#endif
>
>  #include "pipe/p_compiler.h"
>  #include "pipe/p_format.h"
> @@ -83,6 +87,7 @@ dri_sw_is_displaytarget_format_supported( struct
> sw_winsys *ws,
> return TRUE;
>  }
>
> +#ifdef HAVE_SHM
>  static char *
>  alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size)
>  {
> @@ -101,6 +106,7 @@ alloc_shm(struct dri_sw_displaytarget *dri_sw_dt,
> unsigned size)
>
> return addr;
>  }
> +#endif
>
>  static struct sw_displaytarget *
>  dri_sw_displaytarget_create(struct sw_winsys *winsys,
> @@ -131,8 +137,11 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys,
> size = dri_sw_dt->stride * nblocksy;
>
> dri_sw_dt->shmid = -1;
> +
> +#ifdef HAVE_SHM
> if (ws->lf->put_image_shm)
>dri_sw_dt->data = alloc_shm(dri_sw_dt, size);
> +#endif
>
> if(!dri_sw_dt->data)
>dri_sw_dt->data = align_malloc(size, alignment);
> @@ -156,8 +165,10 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
> struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
>
> if (dri_sw_dt->shmid >= 0) {
> +#ifdef HAVE_SHM
>shmdt(dri_sw_dt->data);
>shmctl(dri_sw_dt->shmid, IPC_RMID, 0);
> +#endif
> } else {
>align_free(dri_sw_dt->data);
> }
> --
> 2.18.0.345.g5c9ce644c3-goog
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] drisw: Fix build on Android Nougat, which lacks shm (v2)

2018-07-30 Thread Chad Versace
In commit cf54bd5e8, dri_sw_winsys.c began using  to support
the new functions putImageShm, getImageShm in DRI_SWRastLoader. But
Android began supporting System V shared memory only in Oreo. Nougat has
no shm headers.

Fix the build by ifdef'ing out the shm code on Nougat.

Fixes: cf54bd5e8 "drisw: use shared memory when possible"
Cc: Marc-André Lureau 
Cc: Dave Airlie 
---

Dave, is this what you had in mind?

I considered putting a check in configure.ac for HAVE_SHM, but decided
against it because (1) another Autoconf check would slow down everyone's
build for a niche case that only a few people care about, and (2) it
only affected this file.

 src/gallium/winsys/sw/dri/dri_sw_winsys.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c 
b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index 40007200a5d..d519bcfedd3 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -26,8 +26,12 @@
  *
  **/
 
+#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
+/* Android's libc began supporting shm in Oreo */
+#define HAVE_SHM
 #include 
 #include 
+#endif
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_format.h"
@@ -83,6 +87,7 @@ dri_sw_is_displaytarget_format_supported( struct sw_winsys 
*ws,
return TRUE;
 }
 
+#ifdef HAVE_SHM
 static char *
 alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size)
 {
@@ -101,6 +106,7 @@ alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned 
size)
 
return addr;
 }
+#endif
 
 static struct sw_displaytarget *
 dri_sw_displaytarget_create(struct sw_winsys *winsys,
@@ -131,8 +137,11 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys,
size = dri_sw_dt->stride * nblocksy;
 
dri_sw_dt->shmid = -1;
+
+#ifdef HAVE_SHM
if (ws->lf->put_image_shm)
   dri_sw_dt->data = alloc_shm(dri_sw_dt, size);
+#endif
 
if(!dri_sw_dt->data)
   dri_sw_dt->data = align_malloc(size, alignment);
@@ -156,8 +165,10 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
 
if (dri_sw_dt->shmid >= 0) {
+#ifdef HAVE_SHM
   shmdt(dri_sw_dt->data);
   shmctl(dri_sw_dt->shmid, IPC_RMID, 0);
+#endif
} else {
   align_free(dri_sw_dt->data);
}
-- 
2.18.0.345.g5c9ce644c3-goog

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


Re: [Mesa-dev] [PATCH] drisw: Fix build on Android Nougat

2018-07-24 Thread David Airlie
On Thu, Jul 19, 2018 at 10:43 AM, Chad Versace 
wrote:

> In commit cf54bd5e8, dri_sw_winsys.c began using  to support
> the new functions putImageShm, getImageShm in DRI_SWRastLoader. But
> Android began supporting System V shared memory only in Oreo. Nougat has
> no shm headers.
>
> Fix the build by ifdef'ing out the shm code on Nougat.
>

No that's horrible. At least make a HAVE_IPC define or something so
the if android horror can be hidden a bit out of the way at the top of the
file
or the build system.

Dave.


> Fixes: cf54bd5e8 "drisw: use shared memory when possible"
> Cc: Marc-André Lureau  Cc: Dave Airlie 
> ---
>  src/gallium/winsys/sw/dri/dri_sw_winsys.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> index 40007200a5d..147e0f7c430 100644
> --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> @@ -26,8 +26,10 @@
>   *
>   
> **/
>
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
>  #include 
>  #include 
> +#endif
>
>  #include "pipe/p_compiler.h"
>  #include "pipe/p_format.h"
> @@ -83,6 +85,7 @@ dri_sw_is_displaytarget_format_supported( struct
> sw_winsys *ws,
> return TRUE;
>  }
>
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
>  static char *
>  alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size)
>  {
> @@ -101,6 +104,7 @@ alloc_shm(struct dri_sw_displaytarget *dri_sw_dt,
> unsigned size)
>
> return addr;
>  }
> +#endif
>
>  static struct sw_displaytarget *
>  dri_sw_displaytarget_create(struct sw_winsys *winsys,
> @@ -131,8 +135,11 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys,
> size = dri_sw_dt->stride * nblocksy;
>
> dri_sw_dt->shmid = -1;
> +
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
> if (ws->lf->put_image_shm)
>dri_sw_dt->data = alloc_shm(dri_sw_dt, size);
> +#endif
>
> if(!dri_sw_dt->data)
>dri_sw_dt->data = align_malloc(size, alignment);
> @@ -156,8 +163,10 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
> struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
>
> if (dri_sw_dt->shmid >= 0) {
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
>shmdt(dri_sw_dt->data);
>shmctl(dri_sw_dt->shmid, IPC_RMID, 0);
> +#endif
> } else {
>align_free(dri_sw_dt->data);
> }
> --
> 2.18.0.233.g985f88cf7e-goog
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] drisw: Fix build on Android Nougat

2018-07-24 Thread Chad Versace
ping for review

On Wed 18 Jul 2018, Chad Versace wrote:
> In commit cf54bd5e8, dri_sw_winsys.c began using  to support
> the new functions putImageShm, getImageShm in DRI_SWRastLoader. But
> Android began supporting System V shared memory only in Oreo. Nougat has
> no shm headers.
> 
> Fix the build by ifdef'ing out the shm code on Nougat.
> 
> Fixes: cf54bd5e8 "drisw: use shared memory when possible"
> Cc: Marc-André Lureau  Cc: Dave Airlie 
> ---
>  src/gallium/winsys/sw/dri/dri_sw_winsys.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c 
> b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> index 40007200a5d..147e0f7c430 100644
> --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
> @@ -26,8 +26,10 @@
>   *
>   **/
>  
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
>  #include 
>  #include 
> +#endif
>  
>  #include "pipe/p_compiler.h"
>  #include "pipe/p_format.h"
> @@ -83,6 +85,7 @@ dri_sw_is_displaytarget_format_supported( struct sw_winsys 
> *ws,
> return TRUE;
>  }
>  
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
>  static char *
>  alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size)
>  {
> @@ -101,6 +104,7 @@ alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, 
> unsigned size)
>  
> return addr;
>  }
> +#endif
>  
>  static struct sw_displaytarget *
>  dri_sw_displaytarget_create(struct sw_winsys *winsys,
> @@ -131,8 +135,11 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys,
> size = dri_sw_dt->stride * nblocksy;
>  
> dri_sw_dt->shmid = -1;
> +
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
> if (ws->lf->put_image_shm)
>dri_sw_dt->data = alloc_shm(dri_sw_dt, size);
> +#endif
>  
> if(!dri_sw_dt->data)
>dri_sw_dt->data = align_malloc(size, alignment);
> @@ -156,8 +163,10 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
> struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
>  
> if (dri_sw_dt->shmid >= 0) {
> +#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
>shmdt(dri_sw_dt->data);
>shmctl(dri_sw_dt->shmid, IPC_RMID, 0);
> +#endif
> } else {
>align_free(dri_sw_dt->data);
> }
> -- 
> 2.18.0.233.g985f88cf7e-goog
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] drisw: Fix build on Android Nougat

2018-07-20 Thread Chad Versace
In commit cf54bd5e8, dri_sw_winsys.c began using  to support
the new functions putImageShm, getImageShm in DRI_SWRastLoader. But
Android began supporting System V shared memory only in Oreo. Nougat has
no shm headers.

Fix the build by ifdef'ing out the shm code on Nougat.

Fixes: cf54bd5e8 "drisw: use shared memory when possible"
Cc: Marc-André Lureau 
---
 src/gallium/winsys/sw/dri/dri_sw_winsys.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c 
b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index 40007200a5d..147e0f7c430 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -26,8 +26,10 @@
  *
  **/
 
+#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
 #include 
 #include 
+#endif
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_format.h"
@@ -83,6 +85,7 @@ dri_sw_is_displaytarget_format_supported( struct sw_winsys 
*ws,
return TRUE;
 }
 
+#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
 static char *
 alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size)
 {
@@ -101,6 +104,7 @@ alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned 
size)
 
return addr;
 }
+#endif
 
 static struct sw_displaytarget *
 dri_sw_displaytarget_create(struct sw_winsys *winsys,
@@ -131,8 +135,11 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys,
size = dri_sw_dt->stride * nblocksy;
 
dri_sw_dt->shmid = -1;
+
+#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
if (ws->lf->put_image_shm)
   dri_sw_dt->data = alloc_shm(dri_sw_dt, size);
+#endif
 
if(!dri_sw_dt->data)
   dri_sw_dt->data = align_malloc(size, alignment);
@@ -156,8 +163,10 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
 
if (dri_sw_dt->shmid >= 0) {
+#if !defined(ANDROID) || ANDROID_API_LEVEL >= 26
   shmdt(dri_sw_dt->data);
   shmctl(dri_sw_dt->shmid, IPC_RMID, 0);
+#endif
} else {
   align_free(dri_sw_dt->data);
}
-- 
2.18.0.233.g985f88cf7e-goog

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