Re: [Mesa-dev] [PATCH] egl/android: config id increase one by one

2017-06-20 Thread Liu, Zhiquan


> -Original Message-
> From: Emil Velikov [mailto:emil.l.veli...@gmail.com]
> Sent: Thursday, June 15, 2017 9:59 PM
> To: Liu, Zhiquan <zhiquan@intel.com>
> Cc: ML mesa-dev <mesa-dev@lists.freedesktop.org>; Long, Zhifang
> <zhifang.l...@intel.com>; Rob Herring <r...@kernel.org>; Tomasz Figa
> <tf...@chromium.org>
> Subject: Re: [PATCH] egl/android: config id increase one by one
> 
> On 12 January 2017 at 15:31, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> > On 12 January 2017 at 07:38, Liu Zhiquan <zhiquan@intel.com> wrote:
> >> when dri2_add_config, driver_configs may add to exist dri2_conf, the
> >> config id should not increase in this case.
> >> In the code, when ConfigID equal to count+1, it's mean a new config,
> >> config_count will increase. otherwise it's a exist config.
> >>
> > What a lovely little bug. How exactly did you spotted it - please
> > mention in the commit log.
> >
> >> Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
> >> Signed-off-by: Long, Zhifang <zhifang.l...@intel.com>
> >> ---
> >>  src/egl/drivers/dri2/platform_android.c | 11 ++-
> >>  1 file changed, 6 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/src/egl/drivers/dri2/platform_android.c
> >> b/src/egl/drivers/dri2/platform_android.c
> >> index 1c880f9..5bf6fd5 100644
> >> --- a/src/egl/drivers/dri2/platform_android.c
> >> +++ b/src/egl/drivers/dri2/platform_android.c
> >> @@ -950,9 +950,9 @@ droid_add_configs_for_visuals(_EGLDriver *drv,
> _EGLDisplay *dpy)
> >>   EGL_NONE
> >> };
> >> unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
> >> -   int count, i, j;
> >> +   int config_count, i, j;
> >>
> > Please keep the variable name as-is. With that the patch is
> > Reviewed-by: Emil Velikov <emil.veli...@collabora.com>
> >
> > Other platforms would need similar fix, can you please send patches
> > for those as well please ?
> >
> Humble poke - any update?
I find e...@engestrom.ch have made a patch (egl: properly count configs) to 
complete this patch. Please review that one.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] egl/android: config id increase one by one

2017-01-11 Thread Liu Zhiquan
when dri2_add_config, driver_configs may add to exist dri2_conf,
the config id should not increase in this case.
In the code, when ConfigID equal to count+1, it's mean a new config,
config_count will increase. otherwise it's a exist config.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Long, Zhifang <zhifang.l...@intel.com>
---
 src/egl/drivers/dri2/platform_android.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 1c880f9..5bf6fd5 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -950,9 +950,9 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay 
*dpy)
  EGL_NONE
};
unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
-   int count, i, j;
+   int config_count, i, j;
 
-   count = 0;
+   config_count = 0;
for (i = 0; dri2_dpy->driver_configs[i]; i++) {
   const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
   struct dri2_egl_config *dri2_conf;
@@ -962,9 +962,10 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay 
*dpy)
  config_attrs[3] = visuals[j].format;
 
  dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[i],
-   count + 1, surface_type, config_attrs, visuals[j].rgba_masks);
+   config_count + 1, surface_type, config_attrs, 
visuals[j].rgba_masks);
  if (dri2_conf) {
-count++;
+if (dri2_conf->base.ConfigID == (config_count + 1))
+   config_count++;
 format_count[j]++;
  }
   }
@@ -977,7 +978,7 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay 
*dpy)
   }
}
 
-   return (count != 0);
+   return (config_count != 0);
 }
 
 static int
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/2] Revert "egl: stop claiming support for pbuffer + msaa"

2017-01-11 Thread Liu Zhiquan
This reverts commit 4d6d55deef291b489af4d7870c6f5eb223c8da5d.

SurfaceType added EGL_PBUFFER_BIT when dri_single_config is null.
This will fix in "egl: correct surface_type when add config" patch.
---
 src/egl/drivers/dri2/egl_dri2.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 52fbdff..ac231d0 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -329,15 +329,6 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig 
*dri_config, int id,
   surface_type &= ~EGL_PIXMAP_BIT;
}
 
-   /* No support for pbuffer + MSAA for now.
-*
-* XXX TODO: pbuffer + MSAA does not work and causes crashes.
-* See QT bugreport: https://bugreports.qt.io/browse/QTBUG-47509
-*/
-   if (base.Samples) {
-  surface_type &= ~EGL_PBUFFER_BIT;
-   }
-
conf->base.SurfaceType |= surface_type;
 
return conf;
-- 
1.9.1

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


[Mesa-dev] [PATCH 2/2] egl: correct surface_type when add config

2017-01-11 Thread Liu Zhiquan
When add config, dri_config is double or single. Should only add
EGL_WINDOW_BIT to surface_type for double dri_config, Should only add
EGL_PBUFFER_BIT EGL_PIXMAP_BIT to surface_type for single dri_config.
This avoid crash when operate on wrong surface_type which
dri_double_config or dri_single_config is null.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Long, Zhifang <zhifang.l...@intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index ac231d0..60b24ad 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -287,6 +287,11 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig 
*dri_config, int id,
   return NULL;
}
 
+   if (surface_type & (double_buffer ? EGL_WINDOW_BIT : (EGL_PBUFFER_BIT | 
EGL_PIXMAP_BIT)))
+  surface_type &= ~(!double_buffer ? EGL_WINDOW_BIT : (EGL_PBUFFER_BIT | 
EGL_PIXMAP_BIT));
+   else
+  return NULL;
+
config_id = base.ConfigID;
base.ConfigID= EGL_DONT_CARE;
base.SurfaceType = EGL_DONT_CARE;
@@ -325,10 +330,6 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig 
*dri_config, int id,
   return NULL;
}
 
-   if (double_buffer) {
-  surface_type &= ~EGL_PIXMAP_BIT;
-   }
-
conf->base.SurfaceType |= surface_type;
 
return conf;
-- 
1.9.1

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


[Mesa-dev] [PATCH v3] EGL/android: Enhance pbuffer implementation

2016-12-09 Thread Liu Zhiquan
Some dri drivers will pass multiple bits in buffer_mask parameter
to droid_image_get_buffer(), more than the actual supported buffer
type combination. For such case, will go through all the bits, and
will not return error when unsupported buffer is requested, only
return error when the allocation for supported buffer failed.

v2: coding style and log changes
v3: coding style changes and update patch format

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Long, Zhifang <zhifang.l...@intel.com>
Reviewed-by: Tomasz Figa <tf...@chromium.org>
---
 src/egl/drivers/dri2/platform_android.c | 177 +---
 1 file changed, 96 insertions(+), 81 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 373e2c0..1c880f9 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -434,7 +434,40 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
 }
 
 static int
-get_back_bo(struct dri2_egl_surface *dri2_surf)
+get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
+{
+   struct dri2_egl_display *dri2_dpy =
+  dri2_egl_display(dri2_surf->base.Resource.Display);
+
+   if (dri2_surf->dri_image_front)
+  return 0;
+
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+  /* According current EGL spec, front buffer rendering
+   * for window surface is not supported now.
+   * and mesa doesn't have the implementation of this case.
+   * Add warning message, but not treat it as error.
+   */
+  _eglLog(_EGL_DEBUG, "DRI driver requested unsupported front buffer for 
window surface");
+   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
+  dri2_surf->dri_image_front =
+  dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+  dri2_surf->base.Width,
+  dri2_surf->base.Height,
+  format,
+  0,
+  dri2_surf);
+  if (!dri2_surf->dri_image_front) {
+ _eglLog(_EGL_WARNING, "dri2_image_front allocation failed");
+ return -1;
+  }
+   }
+
+   return 0;
+}
+
+static int
+get_back_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
 {
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
@@ -444,42 +477,68 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
if (dri2_surf->dri_image_back)
   return 0;
 
-   if (!dri2_surf->buffer)
-  return -1;
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+  if (!dri2_surf->buffer) {
+ _eglLog(_EGL_WARNING, "Could not get native buffer");
+ return -1;
+  }
 
-   fd = get_native_buffer_fd(dri2_surf->buffer);
-   if (fd < 0) {
-  _eglLog(_EGL_WARNING, "Could not get native buffer FD");
-  return -1;
-   }
+  fd = get_native_buffer_fd(dri2_surf->buffer);
+  if (fd < 0) {
+ _eglLog(_EGL_WARNING, "Could not get native buffer FD");
+ return -1;
+  }
 
-   fourcc = get_fourcc(dri2_surf->buffer->format);
+  fourcc = get_fourcc(dri2_surf->buffer->format);
 
-   pitch = dri2_surf->buffer->stride *
-  get_format_bpp(dri2_surf->buffer->format);
+  pitch = dri2_surf->buffer->stride *
+ get_format_bpp(dri2_surf->buffer->format);
 
-   if (fourcc == -1 || pitch == 0) {
-  _eglLog(_EGL_WARNING, "Invalid buffer fourcc(%x) or pitch(%d)",
-  fourcc, pitch);
-  return -1;
-   }
+  if (fourcc == -1 || pitch == 0) {
+ _eglLog(_EGL_WARNING, "Invalid buffer fourcc(%x) or pitch(%d)",
+ fourcc, pitch);
+ return -1;
+  }
 
-   dri2_surf->dri_image_back =
-  dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
-  dri2_surf->base.Width,
-  dri2_surf->base.Height,
-  fourcc,
-  ,
-  1,
-  ,
-  ,
-  dri2_surf);
-   if (!dri2_surf->dri_image_back)
-  return -1;
+  dri2_surf->dri_image_back =
+ dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
+ dri2_surf->base.Width,
+ dri2_surf->base.Height,
+ fourcc,
+ ,
+ 

Re: [Mesa-dev] [PATCH] EGL/android: Enhance pbuffer implementation

2016-12-06 Thread Liu, Zhiquan
I upload v2 version, please review.
https://patchwork.freedesktop.org/patch/125787/

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


[Mesa-dev] [PATCH v2] EGL/android: Enhance pbuffer implementation

2016-12-06 Thread Liu Zhiquan
Some dri drivers will pass multiple bits in buffer_mask parameter
to droid_image_get_buffer(), more than the actual supported buffer
type combination. For such case, will go through all the bits, and
will not return error when unsupported buffer is requested, only
return error when the allocation for supported buffer failed.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Long, Zhifang <zhifang.l...@intel.com>
---
 src/egl/drivers/dri2/platform_android.c | 180 ++--
 1 file changed, 101 insertions(+), 79 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 373e2c0..46c6efa 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -434,81 +434,92 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
 }
 
 static int
-get_back_bo(struct dri2_egl_surface *dri2_surf)
+get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
 {
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
-   int fourcc, pitch;
-   int offset = 0, fd;
 
-   if (dri2_surf->dri_image_back)
+   if (dri2_surf->dri_image_front) {
   return 0;
-
-   if (!dri2_surf->buffer)
-  return -1;
-
-   fd = get_native_buffer_fd(dri2_surf->buffer);
-   if (fd < 0) {
-  _eglLog(_EGL_WARNING, "Could not get native buffer FD");
-  return -1;
}
 
-   fourcc = get_fourcc(dri2_surf->buffer->format);
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+  /* According current EGL spec, front buffer rendering
+   * for window surface is not supported now.
+   * and mesa doesn't have the implementation of this case.
+   * Add warning message, but not treat it as error.
+   */
+  _eglLog(_EGL_DEBUG, "DRI driver requested unsupported front buffer for 
window surface");
 
-   pitch = dri2_surf->buffer->stride *
-  get_format_bpp(dri2_surf->buffer->format);
+   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
 
-   if (fourcc == -1 || pitch == 0) {
-  _eglLog(_EGL_WARNING, "Invalid buffer fourcc(%x) or pitch(%d)",
-  fourcc, pitch);
-  return -1;
+  dri2_surf->dri_image_front =
+  dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+  dri2_surf->base.Width,
+  dri2_surf->base.Height,
+  format,
+  0,
+  dri2_surf);
+  if (!dri2_surf->dri_image_front) {
+ _eglLog(_EGL_WARNING, "dri2_image_front allocation failed");
+ return -1;
+  }
}
 
-   dri2_surf->dri_image_back =
-  dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
-  dri2_surf->base.Width,
-  dri2_surf->base.Height,
-  fourcc,
-  ,
-  1,
-  ,
-  ,
-  dri2_surf);
-   if (!dri2_surf->dri_image_back)
-  return -1;
-
return 0;
 }
 
 static int
-droid_image_get_buffers(__DRIdrawable *driDrawable,
-  unsigned int format,
-  uint32_t *stamp,
-  void *loaderPrivate,
-  uint32_t buffer_mask,
-  struct __DRIimageList *images)
+get_back_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
 {
-   struct dri2_egl_surface *dri2_surf = loaderPrivate;
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
+   int fourcc, pitch;
+   int offset = 0, fd;
 
-   images->image_mask = 0;
-   images->front = NULL;
-   images->back = NULL;
-
-   if (update_buffers(dri2_surf) < 0)
+   if (dri2_surf->dri_image_back) {
   return 0;
+   }
 
-   if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
-  if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
- /* According current EGL spec,
-  * front buffer rendering for window surface is not supported now */
- _eglLog(_EGL_WARNING,
- "%s:%d front buffer rendering for window surface is not 
supported!",
- __func__, __LINE__);
- return 0;
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+  if (!dri2_surf->buffer) {
+ _eglLog(_EGL_WARNING, "Could not get native buffer");
+ return -1;
+  }
+
+  fd = get_native_buffer_fd(dri2_surf->buffer);
+  if (fd < 0) {
+ _eglLog(_EGL_WARNING, "Could not get nati

Re: [Mesa-dev] [PATCH] EGL/android: Enhance pbuffer implementation

2016-12-05 Thread Liu, Zhiquan
Hi Tomasz,

Thanks for the review.  I will change these logs and code styles errors in v2 
version.
 
> > +   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
> 
> We won't be called with anything else than window or pbuffer bit here, 
> because we don't advertise pixmap support and createPixmapSurface is 
> stubbed out. For better coding style (less indentation) it's enough to 
> just return 0 in the if above and then move the code below out of the 
> conditional block completely.
The original code (if...else if...)is very clearly to describe what will happen 
for each type(window, pbuffer, pixmap).
It's good for readability. 

> > + return -1;
> > +  }
> > +   } else {
> > +  _eglLog(_EGL_WARNING, "pixmap is not supported now !");
> > }
> 
> This else block is not needed, as I explained above.
I suggest to remove this pixmap log, and add follow description in else.
/*pixmap is not supported now, add the implementation of pixmap here in the 
future.*/

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


Re: [Mesa-dev] [PATCH] EGL/android: Enhance pbuffer implementation

2016-11-28 Thread Liu, Zhiquan
> >>> if (dri2_surf->dri_image_front) {
> >>> -  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__,
> __LINE__);
> >>> +  _eglLog(_EGL_DEBUG, "destroy dri_image_front");
> >>>dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
> >>>dri2_surf->dri_image_front = NULL;
> >>> }
> >> Unrelated changes ?
Refer to mesa code, uniform coding(log) style.
These logs were added in pbuffer implementation patch, so I changed them in 
this enhance patch.

> >> This way things would be reasonably simple and reusable.
> >> Hit I'm thinking that we want to unify much/most of the 
> >> platform_foo.c code... one of these days.
> >
> > Hmm, pbuffer handling should be mostly the same for all (I'm 
> > guessing that X11 might be doing some funky stuff, though...). I was 
> > wondering why we even need to have any pbuffer code in platform backends.
> > (Pixmaps and windows are a different, completely platform-specific 
> > thing, though...)
> >
> Roughly what I'm wondering as well ;-)

This patch mainly resolve multiple bits requirement of pbuffer implemental.
If it's correct, could you merge it ?

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


Re: [Mesa-dev] EGL/android: pbuffer implementation.

2016-11-25 Thread Liu, Zhiquan
Hi Tomasz,

I submitted a new patch to enhance the pbuffer implementation.
Please check if it satisfy your requirement.
https://patchwork.freedesktop.org/patch/123848/

Thanks,
Zhiquan,

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


[Mesa-dev] [PATCH] EGL/android: Enhance pbuffer implementation

2016-11-24 Thread Liu Zhiquan
Some dri drivers will pass multiple bits in buffer_mask parameter
to droid_image_get_buffer(), more than the actual supported buffer
type combination. For such case, will go through all the bits, and
will not return error when unsupported buffer is requested, only
return error when the allocation for supported buffer failed.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Long, Zhifang <zhifang.l...@intel.com>
---
 src/egl/drivers/dri2/platform_android.c | 209 +++-
 1 file changed, 126 insertions(+), 83 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 373e2c0..c70423d 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -392,13 +392,13 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
}
 
if (dri2_surf->dri_image_back) {
-  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", __func__, 
__LINE__);
+  _eglLog(_EGL_DEBUG, "destroy dri_image_back");
   dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
   dri2_surf->dri_image_back = NULL;
}
 
if (dri2_surf->dri_image_front) {
-  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, 
__LINE__);
+  _eglLog(_EGL_DEBUG, "destroy dri_image_front");
   dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
   dri2_surf->dri_image_front = NULL;
}
@@ -434,81 +434,98 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
 }
 
 static int
-get_back_bo(struct dri2_egl_surface *dri2_surf)
+get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
 {
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
-   int fourcc, pitch;
-   int offset = 0, fd;
 
-   if (dri2_surf->dri_image_back)
+   if (dri2_surf->dri_image_front)
+   {
+  _eglLog(_EGL_WARNING, "dri2_image_front allocated !");
   return 0;
-
-   if (!dri2_surf->buffer)
-  return -1;
-
-   fd = get_native_buffer_fd(dri2_surf->buffer);
-   if (fd < 0) {
-  _eglLog(_EGL_WARNING, "Could not get native buffer FD");
-  return -1;
}
 
-   fourcc = get_fourcc(dri2_surf->buffer->format);
-
-   pitch = dri2_surf->buffer->stride *
-  get_format_bpp(dri2_surf->buffer->format);
-
-   if (fourcc == -1 || pitch == 0) {
-  _eglLog(_EGL_WARNING, "Invalid buffer fourcc(%x) or pitch(%d)",
-  fourcc, pitch);
-  return -1;
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+  /* According current EGL spec, front buffer rendering
+   * for window surface is not supported now.
+   * and mesa doesn't have the implemetation of this case.
+   * Add warnning message, but not treat it as error.
+   */
+   _eglLog(_EGL_DEBUG, "front buffer for window surface is not supported 
now !");
+
+   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
+
+   dri2_surf->dri_image_front =
+  dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+  dri2_surf->base.Width,
+  dri2_surf->base.Height,
+  format,
+  0,
+  dri2_surf);
+  if (!dri2_surf->dri_image_front)
+  {
+ _eglLog(_EGL_WARNING, "dri2_image_front allocation failed !");
+ return -1;
+  }
+   } else {
+  _eglLog(_EGL_WARNING, "pixmap is not supported now !");
}
 
-   dri2_surf->dri_image_back =
-  dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
-  dri2_surf->base.Width,
-  dri2_surf->base.Height,
-  fourcc,
-  ,
-  1,
-  ,
-  ,
-  dri2_surf);
-   if (!dri2_surf->dri_image_back)
-  return -1;
-
return 0;
 }
 
 static int
-droid_image_get_buffers(__DRIdrawable *driDrawable,
-  unsigned int format,
-  uint32_t *stamp,
-  void *loaderPrivate,
-  uint32_t buffer_mask,
-  struct __DRIimageList *images)
+get_back_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
 {
-   struct dri2_egl_surface *dri2_surf = loaderPrivate;
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
+   int fourcc, pitch;
+   int offset = 0, fd;
 
-   images->image_mask = 0;
-

Re: [Mesa-dev] EGL/android: pbuffer implementation.

2016-11-21 Thread Liu, Zhiquan
Hi Tomasz,

Thanks for you commends.
> >
> 
> Looks like this patch has already landed, but please let me try to 
> confirm some things here anyway. Would you mind keeping me on CC for 
> any future patches for the EGL/Android module? (I believe 
> scripts/get_reviewer.pl should already include me on the list of 
> suggested reviewers, similarly for Rob Herring, who did a great job 
> before helping us with testing on platforms other than i915.)
> 
> [snip]
I just know the script, I will run next time.
> 
> > @@ -353,6 +353,18 @@ droid_destroy_surface(_EGLDriver *drv,
> _EGLDisplay *disp, _EGLSurface *surf)
> >dri2_surf->window->common.decRef(_surf->window->common);
> > }
> >
> > +   if (dri2_surf->dri_image_back) {
> > +  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", 
> > + __func__,
> __LINE__);
> > +  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
> > +  dri2_surf->dri_image_back = NULL;
> > +   }
> 
> Is this a fix for another bug by any chance? Note that we already take 
> care of dri_image_back for window surfaces in 
> droid_window_cancel_buffer(), which calls droid_window_enqueue_buffer(), 
> which does the real free on the image.
> It doesn't hurt to have it here as well, though, so treat this just as 
> a random thought of mine.
IMHO,droid_window_cancel_buffer should not call droid_window_enqueue_buffer() 
It should call dri2_surf->window->cancelBuffer, this should change in another 
patch.
So we add destroyImage here.
> 
> > +
> > +   if (dri2_surf->dri_image_front) {
> > +  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", 
> > + __func__,
> __LINE__);
> > +  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
> > +  dri2_surf->dri_image_front = NULL;
> > +   }
> > +
> > (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
> >
> > free(dri2_surf);
> 
> [snip]
> 
> > @@ -439,25 +451,75 @@ droid_image_get_buffers(__DRIdrawable
> *driDrawable,
> >struct __DRIimageList *images)  {
> > struct dri2_egl_surface *dri2_surf = loaderPrivate;
> > +   struct dri2_egl_display *dri2_dpy =
> > +  dri2_egl_display(dri2_surf->base.Resource.Display);
> >
> > images->image_mask = 0;
> > +   images->front = NULL;
> > +   images->back = NULL;
> 
> I'm not 100% sure this is the expected behavior of this function. My 
> understanding was that image_mask and error code would guard the other 
> members. It would make sense since typically if a function fails it 
> should keep the passed writable arguments unchanged. Is there a 
> precise description of the semantics used by the image loader extension 
> written down somewhere?
> 
Here, I just follow the image_mask operation.
> >
> > if (update_buffers(dri2_surf) < 0)
> >return 0;
> >
> > if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
> > -  /*
> > -   * We don't support front buffers and GLES doesn't require them for
> > -   * window surfaces, but some DRI drivers will request them anyway.
> > -   * We just ignore such request as other platforms backends do.
> > +  if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
> > + /* According current EGL spec,
> > +  * front buffer rendering for window surface is not supported now 
> > */
> > + _eglLog(_EGL_WARNING,
> > +   "%s:%d front buffer rendering for window surface is 
> > + not
> supported!\n",
> > +   __func__, __LINE__);
> > + return 0;
> 
> This is a semantic change and according to the old comment it might 
> break some drivers ("We don't support front buffers and GLES doesn't 
> require them for window surfaces, but some DRI drivers will request them 
> anyway.").
https://patchwork.freedesktop.org/patch/120682/ do you thinks this patch is 
good?
it deal pbuffer in front and back buffer.
> 
> > +  }
> > +
> > +  /* The EGL 1.5 spec states that pbuffers are single-buffered. 
> > Specifically,
> > +   * the spec states that they have a back buffer but no front buffer, 
> > in
> > +   * contrast to pixmaps, which have a front buffer but no back buffer.
> 
> [snip]
> 
> >
> > if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) {
> > -  if (get_back_bo(dri2_surf) < 0)
> > +  if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
> > + if (get_back_bo(dri2_surf) < 0)
> > +return 0;
> > +  }
> > +
> > +  if (!dri2_surf->dri_image_back) {
> > + _eglLog(_EGL_WARNING,
> > +   "%s:%d dri2_image back buffer allocation failed !\n",
> > +   __func__, __LINE__);
> 
> The error message here is inconsistent. The case of front buffer 
> requested for window surface clearly says that it's illegal, but this 
> one pretends that there was an actual allocation attempt.
I will send a follow patch fixing this.
> 
> Also (my subjective point of view) the whole code could be much more 
> readable if all the allocation of front buffer could be moved to
> get_front_bo() 

[Mesa-dev] EGL/android: pbuffer implementation.

2016-11-15 Thread Liu Zhiquan
mesa android path didn't support pbuffer, so add pbuffer support to
fix most deqp and cts pbuffer test cases fail;
add single buffer config to support pbuffer, and create image for
pbuffer when pbuffer type is front surface.
The EGL 1.5 spec states that pbuffers have a back buffer but no front
buffer, single-buffered surfaces with no front buffer confuse Mesa;
so we deviate from the spec, following the precedent of Mesa's
EGL X11 platform.

Test status: android CTS EGL pbuffer test can run without native crash.
test:[DEQP,EGL]all deqp pbuffer case passed.

V3: update commit message and code review changes.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Kalyan Kondapally <kalyan.kondapa...@intel.com>
---
 src/egl/drivers/dri2/egl_dri2.h |  3 +-
 src/egl/drivers/dri2/platform_android.c | 98 +
 2 files changed, 78 insertions(+), 23 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 3add32e..f3d09dc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -290,7 +290,8 @@ struct dri2_egl_surface
 #ifdef HAVE_ANDROID_PLATFORM
struct ANativeWindow *window;
struct ANativeWindowBuffer *buffer;
-   __DRIimage *dri_image;
+   __DRIimage *dri_image_back;
+   __DRIimage *dri_image_front;
 
/* EGL-owned buffers */
__DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index ec52a02..84ca01b 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -204,9 +204,9 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct 
dri2_egl_surface *dri2_sur
 
mtx_lock(>Mutex);
 
-   if (dri2_surf->dri_image) {
-  dri2_dpy->image->destroyImage(dri2_surf->dri_image);
-  dri2_surf->dri_image = NULL;
+   if (dri2_surf->dri_image_back) {
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
}
 
return EGL_TRUE;
@@ -295,7 +295,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
   window->query(window, NATIVE_WINDOW_HEIGHT, _surf->base.Height);
}
 
-   config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
+   config = dri2_get_dri_config(dri2_conf, type,
 dri2_surf->base.GLColorspace);
if (!config)
   goto cleanup_surface;
@@ -353,6 +353,18 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
   dri2_surf->window->common.decRef(_surf->window->common);
}
 
+   if (dri2_surf->dri_image_back) {
+  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", __func__, 
__LINE__);
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
+   }
+
+   if (dri2_surf->dri_image_front) {
+  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, 
__LINE__);
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
+  dri2_surf->dri_image_front = NULL;
+   }
+
(*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
 
free(dri2_surf);
@@ -391,8 +403,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
int fourcc, pitch;
int offset = 0, fd;
 
-   if (dri2_surf->dri_image)
-  return 0;
+   if (dri2_surf->dri_image_back)
+  return 0;
 
if (!dri2_surf->buffer)
   return -1;
@@ -414,7 +426,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
   return -1;
}
 
-   dri2_surf->dri_image =
+   dri2_surf->dri_image_back =
   dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
   dri2_surf->base.Width,
   dri2_surf->base.Height,
@@ -424,7 +436,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
   ,
   ,
   dri2_surf);
-   if (!dri2_surf->dri_image)
+   if (!dri2_surf->dri_image_back)
   return -1;
 
return 0;
@@ -439,25 +451,75 @@ droid_image_get_buffers(__DRIdrawable *driDrawable,
   struct __DRIimageList *images)
 {
struct dri2_egl_surface *dri2_surf = loaderPrivate;
+   struct dri2_egl_display *dri2_dpy =
+  dri2_egl_display(dri2_surf->base.Resource.Display);
 
images->image_mask = 0;
+   images->front = NULL;
+   images->back = NULL;
 
if (update_buffers(dri2_surf) < 0)
   return 0;
 
if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
-  /*
-   * We don't support front buffers and GLES doesn't require them for
-   * window surfaces, but some DRI drivers will request them anyway.
-   * We just ignore such request 

[Mesa-dev] EGL/android: pbuffer implementation.

2016-11-14 Thread Liu Zhiquan
mesa android path didn't support pbuffer, so add pbuffer support to
fix most deqp and cts pbuffer test cases fail;
add support of front buffer and single buffer config.

Test status: android CTS EGL pbuffer test can run without native crash.
test:[DEQP,EGL]all deqp pbuffer case passed.

V2: remove duplicate codes.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
Signed-off-by: Kalyan Kondapally <kalyan.kondapa...@intel.com>
---
 src/egl/drivers/dri2/egl_dri2.h |   3 +-
 src/egl/drivers/dri2/platform_android.c | 109 
 2 files changed, 86 insertions(+), 26 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 3add32e..f3d09dc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -290,7 +290,8 @@ struct dri2_egl_surface
 #ifdef HAVE_ANDROID_PLATFORM
struct ANativeWindow *window;
struct ANativeWindowBuffer *buffer;
-   __DRIimage *dri_image;
+   __DRIimage *dri_image_back;
+   __DRIimage *dri_image_front;
 
/* EGL-owned buffers */
__DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index ec52a02..760a45c 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -43,6 +43,20 @@
 
 #define ALIGN(val, align)  (((val) + (align) - 1) & ~((align) - 1))
 
+static __DRIimage*
+alloc_image(struct dri2_egl_display *dri2_dpy,
+  struct dri2_egl_surface *dri2_surf,
+  uint32_t format)
+{
+   return dri2_dpy->image->createImage(
+dri2_dpy->dri_screen,
+dri2_surf->base.Width,
+dri2_surf->base.Height,
+format,
+0,
+dri2_surf);
+}
+
 static int
 get_format_bpp(int native)
 {
@@ -204,9 +218,9 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct 
dri2_egl_surface *dri2_sur
 
mtx_lock(>Mutex);
 
-   if (dri2_surf->dri_image) {
-  dri2_dpy->image->destroyImage(dri2_surf->dri_image);
-  dri2_surf->dri_image = NULL;
+   if (dri2_surf->dri_image_back) {
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
}
 
return EGL_TRUE;
@@ -295,7 +309,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
   window->query(window, NATIVE_WINDOW_HEIGHT, _surf->base.Height);
}
 
-   config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
+   config = dri2_get_dri_config(dri2_conf, type,
 dri2_surf->base.GLColorspace);
if (!config)
   goto cleanup_surface;
@@ -353,6 +367,18 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
   dri2_surf->window->common.decRef(_surf->window->common);
}
 
+   if (dri2_surf->dri_image_back) {
+  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", __func__, 
__LINE__);
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
+   }
+
+   if (dri2_surf->dri_image_front) {
+  _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, 
__LINE__);
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
+  dri2_surf->dri_image_front = NULL;
+   }
+
(*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
 
free(dri2_surf);
@@ -384,15 +410,13 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
 }
 
 static int
-get_back_bo(struct dri2_egl_surface *dri2_surf)
+get_back_bo(struct dri2_egl_display *dri2_dpy, struct dri2_egl_surface 
*dri2_surf)
 {
-   struct dri2_egl_display *dri2_dpy =
-  dri2_egl_display(dri2_surf->base.Resource.Display);
int fourcc, pitch;
int offset = 0, fd;
 
-   if (dri2_surf->dri_image)
-  return 0;
+   if (dri2_surf->dri_image_back)
+  return 0;
 
if (!dri2_surf->buffer)
   return -1;
@@ -414,7 +438,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
   return -1;
}
 
-   dri2_surf->dri_image =
+   dri2_surf->dri_image_back =
   dri2_dpy->image->createImageFromFds(dri2_dpy->dri_screen,
   dri2_surf->base.Width,
   dri2_surf->base.Height,
@@ -424,7 +448,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
   ,
   ,
   dri2_surf);
-   if (!dri2_surf->dri_image)
+   if (!dri2_surf->dri_image_back)
   return -1;
 
return 0;
@@ -439,25 +463,68 @@ droid_image_get_buffers(__DRIdrawable *driDrawable,
   struct __DRIimageList *images)
 {
struct dri2_egl_surface *dri2_surf = loaderPriv

[Mesa-dev] EGL/android: pbuffer implementation.

2016-11-10 Thread Liu Zhiquan
mesa android path didn't support pbuffer, so add pbuffer support to
fix most deqp and cts pbuffer test cases fail;
add support of front buffer and single buffer config.

Test status: android CTS EGL pbuffer test can run without native crash.
test:[DEQP,EGL]all deqp pbuffer case passed.

Signed-off-by: Liu Zhiquan <zhiquan@intel.com>
---
 src/egl/drivers/dri2/egl_dri2.h |   3 +-
 src/egl/drivers/dri2/platform_android.c | 169 +++-
 2 files changed, 124 insertions(+), 48 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 3add32e..f3d09dc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -290,7 +290,8 @@ struct dri2_egl_surface
 #ifdef HAVE_ANDROID_PLATFORM
struct ANativeWindow *window;
struct ANativeWindowBuffer *buffer;
-   __DRIimage *dri_image;
+   __DRIimage *dri_image_back;
+   __DRIimage *dri_image_front;
 
/* EGL-owned buffers */
__DRIbuffer   *local_buffers[__DRI_BUFFER_COUNT];
diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index ec52a02..79fe81a 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -204,9 +204,9 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct 
dri2_egl_surface *dri2_sur
 
mtx_lock(>Mutex);
 
-   if (dri2_surf->dri_image) {
-  dri2_dpy->image->destroyImage(dri2_surf->dri_image);
-  dri2_surf->dri_image = NULL;
+   if (dri2_surf->dri_image_back) {
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
}
 
return EGL_TRUE;
@@ -295,7 +295,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, 
EGLint type,
   window->query(window, NATIVE_WINDOW_HEIGHT, _surf->base.Height);
}
 
-   config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT,
+   config = dri2_get_dri_config(dri2_conf, type,
 dri2_surf->base.GLColorspace);
if (!config)
   goto cleanup_surface;
@@ -353,6 +353,18 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, 
_EGLSurface *surf)
   dri2_surf->window->common.decRef(_surf->window->common);
}
 
+   if (dri2_surf->dri_image_back) {
+   _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_back", __func__, 
__LINE__);
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_back);
+  dri2_surf->dri_image_back = NULL;
+   }
+
+   if (dri2_surf->dri_image_front) {
+   _eglLog(_EGL_DEBUG, "%s : %d : destroy dri_image_front", __func__, 
__LINE__);
+  dri2_dpy->image->destroyImage(dri2_surf->dri_image_front);
+  dri2_surf->dri_image_front = NULL;
+   }
+
(*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable);
 
free(dri2_surf);
@@ -384,49 +396,114 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
 }
 
 static int
-get_back_bo(struct dri2_egl_surface *dri2_surf)
+droid_get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format)
 {
struct dri2_egl_display *dri2_dpy =
   dri2_egl_display(dri2_surf->base.Resource.Display);
-   int fourcc, pitch;
-   int offset = 0, fd;
 
-   if (dri2_surf->dri_image)
-  return 0;
+   if (dri2_surf->dri_image_front) {
+  _eglLog(_EGL_WARNING, "%s:%d dri2_image_front allocated !\n", __func__, 
__LINE__);
+  return 0;
+   }
 
-   if (!dri2_surf->buffer)
+   if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+   /* According current EGL spec,
+* front buffer rendering for window surface is not supported now */
+   _eglLog(_EGL_WARNING, "%s:%d front buffer rendering for window surface 
is not supported!\n",
+   __func__, __LINE__);
+   return -1;
+
+   } else if (dri2_surf->base.Type == EGL_PBUFFER_BIT) {
+   dri2_surf->dri_image_front =
+  dri2_dpy->image->createImage(dri2_dpy->dri_screen,
+  dri2_surf->base.Width,
+  dri2_surf->base.Height,
+  format,
+  0,
+  dri2_surf);
+
+
+   } else {
+  _eglLog(_EGL_WARNING, "%s:%d pixmap is not supported now !\n", __func__, 
__LINE__);
   return -1;
+   }
 
-   fd = get_native_buffer_fd(dri2_surf->buffer);
-   if (fd < 0) {
-  _eglLog(_EGL_WARNING, "Could not get native buffer FD");
+   if (!dri2_surf->dri_image_front) {
+  _eglLog(_EGL_WARNING, "%s:%d dri2_image_front allocation failed !\n", 
__func__, __LINE__);
   return -1;
}
 
-   fourcc = get_fourcc(dri2_surf->buffer->format);
+   return 0;
+}
 
-   pitch = dri2_surf->buffer->stride *
-  get_format_bpp