Re: [Mesa-dev] [PATCH v3 3/3] Add a new capabilities for drivers that can't share buffers

2014-06-19 Thread Axel Davy

On 15/06/2014 07:49, Giovanni Campagna wrote :

From: Giovanni Campagna gcampa...@src.gnome.org

The kms-dri swrast driver cannot share buffers using the GEM,
so it must tell the loader to disable extensions relying on
that, without disabling the image DRI extension altogheter
(which would prevent the loader from working at all).
This requires a new gallium capability (which is queried on
the pipe_screen and for swrast drivers it's forwared to the
winsys), and requires a new version of the DRI image extension.


Why does this require a new version of the DRI image extension ?
Could you just set createImageFromName and CreateImageFromNames to NULL, 
and add checks for that (instead of checking the capability ?
It's what is done to check if we can import dma-bufs (check if 
createImageFromFds is not NULL).


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


Re: [Mesa-dev] [PATCH v3 3/3] Add a new capabilities for drivers that can't share buffers

2014-06-19 Thread Axel Davy

On 19/06/2014 15:56, Giovanni Campagna wrote :

2014-06-19 16:16 GMT+02:00 Axel Davy axel.d...@ens.fr:

On 15/06/2014 07:49, Giovanni Campagna wrote :


From: Giovanni Campagna gcampa...@src.gnome.org

The kms-dri swrast driver cannot share buffers using the GEM,
so it must tell the loader to disable extensions relying on
that, without disabling the image DRI extension altogheter
(which would prevent the loader from working at all).
This requires a new gallium capability (which is queried on
the pipe_screen and for swrast drivers it's forwared to the
winsys), and requires a new version of the DRI image extension.


Why does this require a new version of the DRI image extension ?
Could you just set createImageFromName and CreateImageFromNames to NULL, and
add checks for that (instead of checking the capability ?
It's what is done to check if we can import dma-bufs (check if
createImageFromFds is not NULL).

Yes, but in my opinion a generic getCapabilities() that returns a
bitmask is more flexible, and will allow avoiding version increases
and new vfuncs, should negotiation for new features be needed in the
future.

Giovanni

I have no opinion on which solution is better (checking if the DRIimage 
function is non null, or checking capability), but if we opt for 
capability, then the locations at which we check createImageFromFds 
against NULL should be modified to use getCapabilities. Also perhaps 
there's similar things happening for other DRIimage functions.


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


Re: [Mesa-dev] [PATCH v3 3/3] Add a new capabilities for drivers that can't share buffers

2014-06-19 Thread Giovanni Campagna
2014-06-19 16:16 GMT+02:00 Axel Davy axel.d...@ens.fr:
 On 15/06/2014 07:49, Giovanni Campagna wrote :

 From: Giovanni Campagna gcampa...@src.gnome.org

 The kms-dri swrast driver cannot share buffers using the GEM,
 so it must tell the loader to disable extensions relying on
 that, without disabling the image DRI extension altogheter
 (which would prevent the loader from working at all).
 This requires a new gallium capability (which is queried on
 the pipe_screen and for swrast drivers it's forwared to the
 winsys), and requires a new version of the DRI image extension.

 Why does this require a new version of the DRI image extension ?
 Could you just set createImageFromName and CreateImageFromNames to NULL, and
 add checks for that (instead of checking the capability ?
 It's what is done to check if we can import dma-bufs (check if
 createImageFromFds is not NULL).

Yes, but in my opinion a generic getCapabilities() that returns a
bitmask is more flexible, and will allow avoiding version increases
and new vfuncs, should negotiation for new features be needed in the
future.

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


Re: [Mesa-dev] [PATCH v3 3/3] Add a new capabilities for drivers that can't share buffers

2014-06-16 Thread Marek Olšák
Does the new CAP cover resource_from_handle or resource_get_handle or both?

Marek

On Sun, Jun 15, 2014 at 1:49 PM, Giovanni Campagna
scampa.giova...@gmail.com wrote:
 From: Giovanni Campagna gcampa...@src.gnome.org

 The kms-dri swrast driver cannot share buffers using the GEM,
 so it must tell the loader to disable extensions relying on
 that, without disabling the image DRI extension altogheter
 (which would prevent the loader from working at all).
 This requires a new gallium capability (which is queried on
 the pipe_screen and for swrast drivers it's forwared to the
 winsys), and requires a new version of the DRI image extension.
 ---
  include/GL/internal/dri_interface.h| 17 +-
  src/egl/drivers/dri2/egl_dri2.c| 10 -
  src/egl/drivers/dri2/platform_drm.c| 17 +++---
  src/gallium/docs/source/screen.rst |  5 -
  src/gallium/drivers/freedreno/freedreno_screen.c   |  1 +
  src/gallium/drivers/i915/i915_screen.c |  1 +
  src/gallium/drivers/ilo/ilo_screen.c   |  2 ++
  src/gallium/drivers/llvmpipe/lp_screen.c   |  7 ++
  src/gallium/drivers/nouveau/nv30/nv30_screen.c |  1 +
  src/gallium/drivers/nouveau/nv50/nv50_screen.c |  2 ++
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  2 ++
  src/gallium/drivers/r300/r300_screen.c |  1 +
  src/gallium/drivers/r600/r600_pipe.c   |  1 +
  src/gallium/drivers/radeonsi/si_pipe.c |  1 +
  src/gallium/drivers/softpipe/sp_screen.c   |  7 ++
  src/gallium/drivers/svga/svga_screen.c |  2 ++
  src/gallium/include/pipe/p_defines.h   |  3 ++-
  src/gallium/include/state_tracker/sw_winsys.h  |  5 +
  src/gallium/state_trackers/dri/common/dri_screen.h |  1 +
  src/gallium/state_trackers/dri/drm/dri2.c  | 23 +++
  src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c  | 26 
 +++---
  21 files changed, 121 insertions(+), 14 deletions(-)

 diff --git a/include/GL/internal/dri_interface.h 
 b/include/GL/internal/dri_interface.h
 index 4d57d0b..fba1cac 100644
 --- a/include/GL/internal/dri_interface.h
 +++ b/include/GL/internal/dri_interface.h
 @@ -1005,7 +1005,7 @@ struct __DRIdri2ExtensionRec {
   * extensions.
   */
  #define __DRI_IMAGE DRI_IMAGE
 -#define __DRI_IMAGE_VERSION 8
 +#define __DRI_IMAGE_VERSION 9

  /**
   * These formats correspond to the similarly named MESA_FORMAT_*
 @@ -1133,6 +1133,13 @@ enum __DRIChromaSiting {
  #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
  /*@}*/

 +/**
 + * \name Capabilities that might be returned by 
 __DRIimageExtensionRec::getCapabilities
 + */
 +/*@{*/
 +#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
 +/*@}*/
 +
  typedef struct __DRIimageRec  __DRIimage;
  typedef struct __DRIimageExtensionRec __DRIimageExtension;
  struct __DRIimageExtensionRec {
 @@ -1239,6 +1246,14 @@ struct __DRIimageExtensionRec {
   enum __DRIChromaSiting vert_siting,
   unsigned *error,
   void *loaderPrivate);
 +
 +   /**
 +* Query for general capabilities of the driver that concern
 +* buffer sharing and image importing.
 +*
 +* \since 9
 +*/
 +   int (*getCapabilities)(__DRIscreen *screen);
  };


 diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
 index eb6abfd..132ebff 100644
 --- a/src/egl/drivers/dri2/egl_dri2.c
 +++ b/src/egl/drivers/dri2/egl_dri2.c
 @@ -520,7 +520,15 @@ dri2_setup_screen(_EGLDisplay *disp)
 }

 if (dri2_dpy-image) {
 -  disp-Extensions.MESA_drm_image = EGL_TRUE;
 +  if (dri2_dpy-image-base.version = 9 
 +  dri2_dpy-image-getCapabilities != NULL) {
 + int capabilities;
 +
 + capabilities = 
 dri2_dpy-image-getCapabilities(dri2_dpy-dri_screen);
 + disp-Extensions.MESA_drm_image = (capabilities  
 __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
 +  } else
 + disp-Extensions.MESA_drm_image = EGL_TRUE;
 +
disp-Extensions.KHR_image_base = EGL_TRUE;
disp-Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
if (dri2_dpy-image-base.version = 5 
 diff --git a/src/egl/drivers/dri2/platform_drm.c 
 b/src/egl/drivers/dri2/platform_drm.c
 index 6a0dcd3..633b2ab 100644
 --- a/src/egl/drivers/dri2/platform_drm.c
 +++ b/src/egl/drivers/dri2/platform_drm.c
 @@ -270,7 +270,10 @@ back_bo_to_dri_buffer(struct dri2_egl_surface 
 *dri2_surf, __DRIbuffer *buffer)

 bo = (struct gbm_dri_bo *) dri2_surf-back-bo;

 -   dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME, name);
 +   if (dri2_surf-base.Resource.Display-Extensions.MESA_drm_image)
 +  dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME, name);
 +   else
 +  dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_HANDLE, 
 name);
 dri2_dpy-image-queryImage(bo-image, 

Re: [Mesa-dev] [PATCH v3 3/3] Add a new capabilities for drivers that can't share buffers

2014-06-16 Thread Giovanni Campagna
2014-06-16 14:47 GMT+02:00 Marek Olšák mar...@gmail.com:
 Does the new CAP cover resource_from_handle or resource_get_handle or both?

It covers both.

Giovanni

 Marek

 On Sun, Jun 15, 2014 at 1:49 PM, Giovanni Campagna
 scampa.giova...@gmail.com wrote:
 From: Giovanni Campagna gcampa...@src.gnome.org

 The kms-dri swrast driver cannot share buffers using the GEM,
 so it must tell the loader to disable extensions relying on
 that, without disabling the image DRI extension altogheter
 (which would prevent the loader from working at all).
 This requires a new gallium capability (which is queried on
 the pipe_screen and for swrast drivers it's forwared to the
 winsys), and requires a new version of the DRI image extension.
 ---
  include/GL/internal/dri_interface.h| 17 +-
  src/egl/drivers/dri2/egl_dri2.c| 10 -
  src/egl/drivers/dri2/platform_drm.c| 17 +++---
  src/gallium/docs/source/screen.rst |  5 -
  src/gallium/drivers/freedreno/freedreno_screen.c   |  1 +
  src/gallium/drivers/i915/i915_screen.c |  1 +
  src/gallium/drivers/ilo/ilo_screen.c   |  2 ++
  src/gallium/drivers/llvmpipe/lp_screen.c   |  7 ++
  src/gallium/drivers/nouveau/nv30/nv30_screen.c |  1 +
  src/gallium/drivers/nouveau/nv50/nv50_screen.c |  2 ++
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  2 ++
  src/gallium/drivers/r300/r300_screen.c |  1 +
  src/gallium/drivers/r600/r600_pipe.c   |  1 +
  src/gallium/drivers/radeonsi/si_pipe.c |  1 +
  src/gallium/drivers/softpipe/sp_screen.c   |  7 ++
  src/gallium/drivers/svga/svga_screen.c |  2 ++
  src/gallium/include/pipe/p_defines.h   |  3 ++-
  src/gallium/include/state_tracker/sw_winsys.h  |  5 +
  src/gallium/state_trackers/dri/common/dri_screen.h |  1 +
  src/gallium/state_trackers/dri/drm/dri2.c  | 23 +++
  src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c  | 26 
 +++---
  21 files changed, 121 insertions(+), 14 deletions(-)

 diff --git a/include/GL/internal/dri_interface.h 
 b/include/GL/internal/dri_interface.h
 index 4d57d0b..fba1cac 100644
 --- a/include/GL/internal/dri_interface.h
 +++ b/include/GL/internal/dri_interface.h
 @@ -1005,7 +1005,7 @@ struct __DRIdri2ExtensionRec {
   * extensions.
   */
  #define __DRI_IMAGE DRI_IMAGE
 -#define __DRI_IMAGE_VERSION 8
 +#define __DRI_IMAGE_VERSION 9

  /**
   * These formats correspond to the similarly named MESA_FORMAT_*
 @@ -1133,6 +1133,13 @@ enum __DRIChromaSiting {
  #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
  /*@}*/

 +/**
 + * \name Capabilities that might be returned by 
 __DRIimageExtensionRec::getCapabilities
 + */
 +/*@{*/
 +#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
 +/*@}*/
 +
  typedef struct __DRIimageRec  __DRIimage;
  typedef struct __DRIimageExtensionRec __DRIimageExtension;
  struct __DRIimageExtensionRec {
 @@ -1239,6 +1246,14 @@ struct __DRIimageExtensionRec {
   enum __DRIChromaSiting vert_siting,
   unsigned *error,
   void *loaderPrivate);
 +
 +   /**
 +* Query for general capabilities of the driver that concern
 +* buffer sharing and image importing.
 +*
 +* \since 9
 +*/
 +   int (*getCapabilities)(__DRIscreen *screen);
  };


 diff --git a/src/egl/drivers/dri2/egl_dri2.c 
 b/src/egl/drivers/dri2/egl_dri2.c
 index eb6abfd..132ebff 100644
 --- a/src/egl/drivers/dri2/egl_dri2.c
 +++ b/src/egl/drivers/dri2/egl_dri2.c
 @@ -520,7 +520,15 @@ dri2_setup_screen(_EGLDisplay *disp)
 }

 if (dri2_dpy-image) {
 -  disp-Extensions.MESA_drm_image = EGL_TRUE;
 +  if (dri2_dpy-image-base.version = 9 
 +  dri2_dpy-image-getCapabilities != NULL) {
 + int capabilities;
 +
 + capabilities = 
 dri2_dpy-image-getCapabilities(dri2_dpy-dri_screen);
 + disp-Extensions.MESA_drm_image = (capabilities  
 __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
 +  } else
 + disp-Extensions.MESA_drm_image = EGL_TRUE;
 +
disp-Extensions.KHR_image_base = EGL_TRUE;
disp-Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
if (dri2_dpy-image-base.version = 5 
 diff --git a/src/egl/drivers/dri2/platform_drm.c 
 b/src/egl/drivers/dri2/platform_drm.c
 index 6a0dcd3..633b2ab 100644
 --- a/src/egl/drivers/dri2/platform_drm.c
 +++ b/src/egl/drivers/dri2/platform_drm.c
 @@ -270,7 +270,10 @@ back_bo_to_dri_buffer(struct dri2_egl_surface 
 *dri2_surf, __DRIbuffer *buffer)

 bo = (struct gbm_dri_bo *) dri2_surf-back-bo;

 -   dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME, name);
 +   if (dri2_surf-base.Resource.Display-Extensions.MESA_drm_image)
 +  dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME, 
 name);
 +   else
 +  

[Mesa-dev] [PATCH v3 3/3] Add a new capabilities for drivers that can't share buffers

2014-06-15 Thread Giovanni Campagna
From: Giovanni Campagna gcampa...@src.gnome.org

The kms-dri swrast driver cannot share buffers using the GEM,
so it must tell the loader to disable extensions relying on
that, without disabling the image DRI extension altogheter
(which would prevent the loader from working at all).
This requires a new gallium capability (which is queried on
the pipe_screen and for swrast drivers it's forwared to the
winsys), and requires a new version of the DRI image extension.
---
 include/GL/internal/dri_interface.h| 17 +-
 src/egl/drivers/dri2/egl_dri2.c| 10 -
 src/egl/drivers/dri2/platform_drm.c| 17 +++---
 src/gallium/docs/source/screen.rst |  5 -
 src/gallium/drivers/freedreno/freedreno_screen.c   |  1 +
 src/gallium/drivers/i915/i915_screen.c |  1 +
 src/gallium/drivers/ilo/ilo_screen.c   |  2 ++
 src/gallium/drivers/llvmpipe/lp_screen.c   |  7 ++
 src/gallium/drivers/nouveau/nv30/nv30_screen.c |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c |  2 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  2 ++
 src/gallium/drivers/r300/r300_screen.c |  1 +
 src/gallium/drivers/r600/r600_pipe.c   |  1 +
 src/gallium/drivers/radeonsi/si_pipe.c |  1 +
 src/gallium/drivers/softpipe/sp_screen.c   |  7 ++
 src/gallium/drivers/svga/svga_screen.c |  2 ++
 src/gallium/include/pipe/p_defines.h   |  3 ++-
 src/gallium/include/state_tracker/sw_winsys.h  |  5 +
 src/gallium/state_trackers/dri/common/dri_screen.h |  1 +
 src/gallium/state_trackers/dri/drm/dri2.c  | 23 +++
 src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c  | 26 +++---
 21 files changed, 121 insertions(+), 14 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index 4d57d0b..fba1cac 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1005,7 +1005,7 @@ struct __DRIdri2ExtensionRec {
  * extensions.
  */
 #define __DRI_IMAGE DRI_IMAGE
-#define __DRI_IMAGE_VERSION 8
+#define __DRI_IMAGE_VERSION 9
 
 /**
  * These formats correspond to the similarly named MESA_FORMAT_*
@@ -1133,6 +1133,13 @@ enum __DRIChromaSiting {
 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
 /*@}*/
 
+/**
+ * \name Capabilities that might be returned by 
__DRIimageExtensionRec::getCapabilities
+ */
+/*@{*/
+#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
+/*@}*/
+
 typedef struct __DRIimageRec  __DRIimage;
 typedef struct __DRIimageExtensionRec __DRIimageExtension;
 struct __DRIimageExtensionRec {
@@ -1239,6 +1246,14 @@ struct __DRIimageExtensionRec {
  enum __DRIChromaSiting vert_siting,
  unsigned *error,
  void *loaderPrivate);
+
+   /**
+* Query for general capabilities of the driver that concern
+* buffer sharing and image importing.
+*
+* \since 9
+*/
+   int (*getCapabilities)(__DRIscreen *screen);
 };
 
 
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index eb6abfd..132ebff 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -520,7 +520,15 @@ dri2_setup_screen(_EGLDisplay *disp)
}
 
if (dri2_dpy-image) {
-  disp-Extensions.MESA_drm_image = EGL_TRUE;
+  if (dri2_dpy-image-base.version = 9 
+  dri2_dpy-image-getCapabilities != NULL) {
+ int capabilities;
+
+ capabilities = dri2_dpy-image-getCapabilities(dri2_dpy-dri_screen);
+ disp-Extensions.MESA_drm_image = (capabilities  
__DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
+  } else
+ disp-Extensions.MESA_drm_image = EGL_TRUE;
+
   disp-Extensions.KHR_image_base = EGL_TRUE;
   disp-Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
   if (dri2_dpy-image-base.version = 5 
diff --git a/src/egl/drivers/dri2/platform_drm.c 
b/src/egl/drivers/dri2/platform_drm.c
index 6a0dcd3..633b2ab 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -270,7 +270,10 @@ back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, 
__DRIbuffer *buffer)
 
bo = (struct gbm_dri_bo *) dri2_surf-back-bo;
 
-   dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME, name);
+   if (dri2_surf-base.Resource.Display-Extensions.MESA_drm_image)
+  dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_NAME, name);
+   else
+  dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_HANDLE, name);
dri2_dpy-image-queryImage(bo-image, __DRI_IMAGE_ATTRIB_STRIDE, pitch);
 
buffer-attachment = __DRI_BUFFER_BACK_LEFT;
@@ -690,8 +693,16 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
   disp-Extensions.EXT_buffer_age = EGL_TRUE;
 
 #ifdef HAVE_WAYLAND_PLATFORM
-   if (dri2_dpy-image)
-