Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-06-19 Thread Axel Davy

On 19/06/2014 01:20, Ilia Mirkin wrote :

+static __DRIbuffer *
+dri2_allocate_buffer(__DRIscreen *sPriv,
+ unsigned attachment, unsigned format,
+ int width, int height)
+{
+   struct dri_screen *screen = dri_screen(sPriv);
+   struct dri2_buffer *buffer;
+   struct pipe_resource templ;
+   enum pipe_format pf;
+   unsigned bind = 0;
+   struct winsys_handle whandle;
+
+   switch (attachment) {
+  case __DRI_BUFFER_FRONT_LEFT:
+  case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+  case __DRI_BUFFER_BACK_LEFT:
+ bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+  case __DRI_BUFFER_DEPTH:
+  case __DRI_BUFFER_DEPTH_STENCIL:
+  case __DRI_BUFFER_STENCIL:
+bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
+ break;
+   }
+
+   /* because we get the handle and stride */
+   bind |= PIPE_BIND_SHARED;
+
+   switch (format) {
+  case 32:
+ pf = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+  case 24:
+ pf = PIPE_FORMAT_B8G8R8X8_UNORM;
+ break;
+  case 16:
+ pf = PIPE_FORMAT_Z16_UNORM;
+ break;
+  default:
+ return NULL;
+   }
+
+   buffer = CALLOC_STRUCT(dri2_buffer);
+   if (!buffer)
+  return NULL;
+
+   memset(templ, 0, sizeof(templ));
+   templ.bind = bind;
+   templ.format = pf;
+   templ.target = PIPE_TEXTURE_2D;
+   templ.last_level = 0;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+
+   buffer-resource =
+  screen-base.screen-resource_create(screen-base.screen, templ);
I believe the expectation is that before you create resources with a
certain format/bind combo, you need to check first with
-is_format_supported. For example pre-NVA0 nv50 cards don't support
Z16.



This is git format-patch noise.
I don't change anything to dri2_allocate_buffer, if you see what is 
added here is removed later.


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


[Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-06-18 Thread Axel Davy
__DRIimageDriverExtension is used by GLX DRI3 and Wayland.

This patch is a rewrite of
http://lists.freedesktop.org/archives/mesa-dev/2014-May/060318.html
and
http://lists.freedesktop.org/archives/mesa-dev/2014-May/060317.html

Signed-off-by: Axel Davy axel.d...@ens.fr
Reviewed-by: Marek Olšákmarek.ol...@amd.com

Previous patches were:
Signed-off-by: Ben Skeggs bske...@redhat.com
Signed-off-by: Keith Packard kei...@keithp.com
---
 src/gallium/state_trackers/dri/drm/dri2.c | 469 ++
 1 file changed, 286 insertions(+), 183 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 7dccc5e..124d91b 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -201,32 +201,192 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
return buffers;
 }
 
-/**
- * Process __DRIbuffer and convert them into pipe_resources.
+static bool
+dri_image_drawable_get_buffers(struct dri_drawable *drawable,
+   struct __DRIimageList *images,
+   const enum st_attachment_type *statts,
+   unsigned statts_count)
+{
+   __DRIdrawable *dPriv = drawable-dPriv;
+   __DRIscreen *sPriv = drawable-sPriv;
+   unsigned int image_format = __DRI_IMAGE_FORMAT_NONE;
+   enum pipe_format pf;
+   uint32_t buffer_mask = 0;
+   unsigned i, bind;
+
+   for (i = 0; i  statts_count; i++) {
+  dri_drawable_get_format(drawable, statts[i], pf, bind);
+  if (pf == PIPE_FORMAT_NONE)
+ continue;
+
+  switch (statts[i]) {
+  case ST_ATTACHMENT_FRONT_LEFT:
+ buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
+ break;
+  case ST_ATTACHMENT_BACK_LEFT:
+ buffer_mask |= __DRI_IMAGE_BUFFER_BACK;
+ break;
+  default:
+ continue;
+  }
+
+  switch (pf) {
+  case PIPE_FORMAT_B5G6R5_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_RGB565;
+ break;
+  case PIPE_FORMAT_B8G8R8X8_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_XRGB;
+ break;
+  case PIPE_FORMAT_B8G8R8A8_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_ARGB;
+ break;
+  case PIPE_FORMAT_R8G8B8A8_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_ABGR;
+ break;
+  default:
+ image_format = __DRI_IMAGE_FORMAT_NONE;
+ break;
+  }
+   }
+
+   return (*sPriv-image.loader-getBuffers) (dPriv, image_format,
+   (uint32_t *) drawable-base.stamp,
+   dPriv-loaderPrivate, buffer_mask,
+   images);
+}
+
+static __DRIbuffer *
+dri2_allocate_buffer(__DRIscreen *sPriv,
+ unsigned attachment, unsigned format,
+ int width, int height)
+{
+   struct dri_screen *screen = dri_screen(sPriv);
+   struct dri2_buffer *buffer;
+   struct pipe_resource templ;
+   enum pipe_format pf;
+   unsigned bind = 0;
+   struct winsys_handle whandle;
+
+   switch (attachment) {
+  case __DRI_BUFFER_FRONT_LEFT:
+  case __DRI_BUFFER_FAKE_FRONT_LEFT:
+ bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+  case __DRI_BUFFER_BACK_LEFT:
+ bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+ break;
+  case __DRI_BUFFER_DEPTH:
+  case __DRI_BUFFER_DEPTH_STENCIL:
+  case __DRI_BUFFER_STENCIL:
+bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
+ break;
+   }
+
+   /* because we get the handle and stride */
+   bind |= PIPE_BIND_SHARED;
+
+   switch (format) {
+  case 32:
+ pf = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+  case 24:
+ pf = PIPE_FORMAT_B8G8R8X8_UNORM;
+ break;
+  case 16:
+ pf = PIPE_FORMAT_Z16_UNORM;
+ break;
+  default:
+ return NULL;
+   }
+
+   buffer = CALLOC_STRUCT(dri2_buffer);
+   if (!buffer)
+  return NULL;
+
+   memset(templ, 0, sizeof(templ));
+   templ.bind = bind;
+   templ.format = pf;
+   templ.target = PIPE_TEXTURE_2D;
+   templ.last_level = 0;
+   templ.width0 = width;
+   templ.height0 = height;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+
+   buffer-resource =
+  screen-base.screen-resource_create(screen-base.screen, templ);
+   if (!buffer-resource) {
+  FREE(buffer);
+  return NULL;
+   }
+
+   memset(whandle, 0, sizeof(whandle));
+   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
+   screen-base.screen-resource_get_handle(screen-base.screen,
+ buffer-resource, whandle);
+
+   buffer-base.attachment = attachment;
+   buffer-base.name = whandle.handle;
+   buffer-base.cpp = util_format_get_blocksize(pf);
+   buffer-base.pitch = whandle.stride;
+
+   return buffer-base;
+}
+
+static void
+dri2_release_buffer(__DRIscreen *sPriv, __DRIbuffer *bPriv)
+{
+   struct dri2_buffer *buffer = dri2_buffer(bPriv);
+

Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-06-18 Thread Ben Skeggs
On Thu, Jun 19, 2014 at 1:27 PM, Axel Davy axel.d...@ens.fr wrote:
 __DRIimageDriverExtension is used by GLX DRI3 and Wayland.

 This patch is a rewrite of
 http://lists.freedesktop.org/archives/mesa-dev/2014-May/060318.html
 and
 http://lists.freedesktop.org/archives/mesa-dev/2014-May/060317.html

 Signed-off-by: Axel Davy axel.d...@ens.fr
 Reviewed-by: Marek Olšákmarek.ol...@amd.com
Good timing, I did the exact same thing myself a couple of hours ago :P

Reviewed-by: Ben Skeggs bske...@redhat.com


 Previous patches were:
 Signed-off-by: Ben Skeggs bske...@redhat.com
 Signed-off-by: Keith Packard kei...@keithp.com
 ---
  src/gallium/state_trackers/dri/drm/dri2.c | 469 
 ++
  1 file changed, 286 insertions(+), 183 deletions(-)

 diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
 b/src/gallium/state_trackers/dri/drm/dri2.c
 index 7dccc5e..124d91b 100644
 --- a/src/gallium/state_trackers/dri/drm/dri2.c
 +++ b/src/gallium/state_trackers/dri/drm/dri2.c
 @@ -201,32 +201,192 @@ dri2_drawable_get_buffers(struct dri_drawable 
 *drawable,
 return buffers;
  }

 -/**
 - * Process __DRIbuffer and convert them into pipe_resources.
 +static bool
 +dri_image_drawable_get_buffers(struct dri_drawable *drawable,
 +   struct __DRIimageList *images,
 +   const enum st_attachment_type *statts,
 +   unsigned statts_count)
 +{
 +   __DRIdrawable *dPriv = drawable-dPriv;
 +   __DRIscreen *sPriv = drawable-sPriv;
 +   unsigned int image_format = __DRI_IMAGE_FORMAT_NONE;
 +   enum pipe_format pf;
 +   uint32_t buffer_mask = 0;
 +   unsigned i, bind;
 +
 +   for (i = 0; i  statts_count; i++) {
 +  dri_drawable_get_format(drawable, statts[i], pf, bind);
 +  if (pf == PIPE_FORMAT_NONE)
 + continue;
 +
 +  switch (statts[i]) {
 +  case ST_ATTACHMENT_FRONT_LEFT:
 + buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
 + break;
 +  case ST_ATTACHMENT_BACK_LEFT:
 + buffer_mask |= __DRI_IMAGE_BUFFER_BACK;
 + break;
 +  default:
 + continue;
 +  }
 +
 +  switch (pf) {
 +  case PIPE_FORMAT_B5G6R5_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_RGB565;
 + break;
 +  case PIPE_FORMAT_B8G8R8X8_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_XRGB;
 + break;
 +  case PIPE_FORMAT_B8G8R8A8_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_ARGB;
 + break;
 +  case PIPE_FORMAT_R8G8B8A8_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_ABGR;
 + break;
 +  default:
 + image_format = __DRI_IMAGE_FORMAT_NONE;
 + break;
 +  }
 +   }
 +
 +   return (*sPriv-image.loader-getBuffers) (dPriv, image_format,
 +   (uint32_t *) drawable-base.stamp,
 +   dPriv-loaderPrivate, buffer_mask,
 +   images);
 +}
 +
 +static __DRIbuffer *
 +dri2_allocate_buffer(__DRIscreen *sPriv,
 + unsigned attachment, unsigned format,
 + int width, int height)
 +{
 +   struct dri_screen *screen = dri_screen(sPriv);
 +   struct dri2_buffer *buffer;
 +   struct pipe_resource templ;
 +   enum pipe_format pf;
 +   unsigned bind = 0;
 +   struct winsys_handle whandle;
 +
 +   switch (attachment) {
 +  case __DRI_BUFFER_FRONT_LEFT:
 +  case __DRI_BUFFER_FAKE_FRONT_LEFT:
 + bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 + break;
 +  case __DRI_BUFFER_BACK_LEFT:
 + bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 + break;
 +  case __DRI_BUFFER_DEPTH:
 +  case __DRI_BUFFER_DEPTH_STENCIL:
 +  case __DRI_BUFFER_STENCIL:
 +bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
 + break;
 +   }
 +
 +   /* because we get the handle and stride */
 +   bind |= PIPE_BIND_SHARED;
 +
 +   switch (format) {
 +  case 32:
 + pf = PIPE_FORMAT_B8G8R8A8_UNORM;
 + break;
 +  case 24:
 + pf = PIPE_FORMAT_B8G8R8X8_UNORM;
 + break;
 +  case 16:
 + pf = PIPE_FORMAT_Z16_UNORM;
 + break;
 +  default:
 + return NULL;
 +   }
 +
 +   buffer = CALLOC_STRUCT(dri2_buffer);
 +   if (!buffer)
 +  return NULL;
 +
 +   memset(templ, 0, sizeof(templ));
 +   templ.bind = bind;
 +   templ.format = pf;
 +   templ.target = PIPE_TEXTURE_2D;
 +   templ.last_level = 0;
 +   templ.width0 = width;
 +   templ.height0 = height;
 +   templ.depth0 = 1;
 +   templ.array_size = 1;
 +
 +   buffer-resource =
 +  screen-base.screen-resource_create(screen-base.screen, templ);
 +   if (!buffer-resource) {
 +  FREE(buffer);
 +  return NULL;
 +   }
 +
 +   memset(whandle, 0, sizeof(whandle));
 +   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
 +   screen-base.screen-resource_get_handle(screen-base.screen,
 + buffer-resource, whandle);
 +
 + 

Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-06-18 Thread Ilia Mirkin
On Wed, Jun 18, 2014 at 11:27 PM, Axel Davy axel.d...@ens.fr wrote:
 __DRIimageDriverExtension is used by GLX DRI3 and Wayland.

 This patch is a rewrite of
 http://lists.freedesktop.org/archives/mesa-dev/2014-May/060318.html
 and
 http://lists.freedesktop.org/archives/mesa-dev/2014-May/060317.html

 Signed-off-by: Axel Davy axel.d...@ens.fr
 Reviewed-by: Marek Olšákmarek.ol...@amd.com

 Previous patches were:
 Signed-off-by: Ben Skeggs bske...@redhat.com
 Signed-off-by: Keith Packard kei...@keithp.com
 ---
  src/gallium/state_trackers/dri/drm/dri2.c | 469 
 ++
  1 file changed, 286 insertions(+), 183 deletions(-)

 diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
 b/src/gallium/state_trackers/dri/drm/dri2.c
 index 7dccc5e..124d91b 100644
 --- a/src/gallium/state_trackers/dri/drm/dri2.c
 +++ b/src/gallium/state_trackers/dri/drm/dri2.c
 @@ -201,32 +201,192 @@ dri2_drawable_get_buffers(struct dri_drawable 
 *drawable,
 return buffers;
  }

 -/**
 - * Process __DRIbuffer and convert them into pipe_resources.
 +static bool
 +dri_image_drawable_get_buffers(struct dri_drawable *drawable,
 +   struct __DRIimageList *images,
 +   const enum st_attachment_type *statts,
 +   unsigned statts_count)
 +{
 +   __DRIdrawable *dPriv = drawable-dPriv;
 +   __DRIscreen *sPriv = drawable-sPriv;
 +   unsigned int image_format = __DRI_IMAGE_FORMAT_NONE;
 +   enum pipe_format pf;
 +   uint32_t buffer_mask = 0;
 +   unsigned i, bind;
 +
 +   for (i = 0; i  statts_count; i++) {
 +  dri_drawable_get_format(drawable, statts[i], pf, bind);
 +  if (pf == PIPE_FORMAT_NONE)
 + continue;
 +
 +  switch (statts[i]) {
 +  case ST_ATTACHMENT_FRONT_LEFT:
 + buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
 + break;
 +  case ST_ATTACHMENT_BACK_LEFT:
 + buffer_mask |= __DRI_IMAGE_BUFFER_BACK;
 + break;
 +  default:
 + continue;
 +  }
 +
 +  switch (pf) {
 +  case PIPE_FORMAT_B5G6R5_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_RGB565;
 + break;
 +  case PIPE_FORMAT_B8G8R8X8_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_XRGB;
 + break;
 +  case PIPE_FORMAT_B8G8R8A8_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_ARGB;
 + break;
 +  case PIPE_FORMAT_R8G8B8A8_UNORM:
 + image_format = __DRI_IMAGE_FORMAT_ABGR;
 + break;
 +  default:
 + image_format = __DRI_IMAGE_FORMAT_NONE;
 + break;
 +  }
 +   }
 +
 +   return (*sPriv-image.loader-getBuffers) (dPriv, image_format,
 +   (uint32_t *) drawable-base.stamp,
 +   dPriv-loaderPrivate, buffer_mask,
 +   images);
 +}
 +
 +static __DRIbuffer *
 +dri2_allocate_buffer(__DRIscreen *sPriv,
 + unsigned attachment, unsigned format,
 + int width, int height)
 +{
 +   struct dri_screen *screen = dri_screen(sPriv);
 +   struct dri2_buffer *buffer;
 +   struct pipe_resource templ;
 +   enum pipe_format pf;
 +   unsigned bind = 0;
 +   struct winsys_handle whandle;
 +
 +   switch (attachment) {
 +  case __DRI_BUFFER_FRONT_LEFT:
 +  case __DRI_BUFFER_FAKE_FRONT_LEFT:
 + bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 + break;
 +  case __DRI_BUFFER_BACK_LEFT:
 + bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 + break;
 +  case __DRI_BUFFER_DEPTH:
 +  case __DRI_BUFFER_DEPTH_STENCIL:
 +  case __DRI_BUFFER_STENCIL:
 +bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
 + break;
 +   }
 +
 +   /* because we get the handle and stride */
 +   bind |= PIPE_BIND_SHARED;
 +
 +   switch (format) {
 +  case 32:
 + pf = PIPE_FORMAT_B8G8R8A8_UNORM;
 + break;
 +  case 24:
 + pf = PIPE_FORMAT_B8G8R8X8_UNORM;
 + break;
 +  case 16:
 + pf = PIPE_FORMAT_Z16_UNORM;
 + break;
 +  default:
 + return NULL;
 +   }
 +
 +   buffer = CALLOC_STRUCT(dri2_buffer);
 +   if (!buffer)
 +  return NULL;
 +
 +   memset(templ, 0, sizeof(templ));
 +   templ.bind = bind;
 +   templ.format = pf;
 +   templ.target = PIPE_TEXTURE_2D;
 +   templ.last_level = 0;
 +   templ.width0 = width;
 +   templ.height0 = height;
 +   templ.depth0 = 1;
 +   templ.array_size = 1;
 +
 +   buffer-resource =
 +  screen-base.screen-resource_create(screen-base.screen, templ);

I believe the expectation is that before you create resources with a
certain format/bind combo, you need to check first with
-is_format_supported. For example pre-NVA0 nv50 cards don't support
Z16.

 +   if (!buffer-resource) {
 +  FREE(buffer);
 +  return NULL;
 +   }
 +
 +   memset(whandle, 0, sizeof(whandle));
 +   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
 +   

Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-06-09 Thread Michel Dänzer
On 28.05.2014 18:59, Michel Dänzer wrote:
 On 28.05.2014 09:55, Axel Davy wrote:
 From: Keith Packard kei...@keithp.com

 Provide the hook to pull textures out of __DRIimage structures and use them 
 as
 renderbuffers.

 Signed-off-by: Keith Packard kei...@keithp.com
 
 Enabling DRI3 using this change breaks a number of depth/stencil and
 multisampling related piglit tests on radeonsi compared to DRI2.

FYI, these are the tests where I'm seeing regressions with DRI3 compared
to DRI2:

all
   glx
  glx-visuals-depth
  glx-visuals-depth -pixmap
  glx-visuals-stencil
  glx-visuals-stencil -pixmap
   spec
  !OpenGL1.1
 depthstencil-default_fb-clear samples={2,4,6,8}
 draw-pixels samples={2,4,6,8}
 read-front
 read-front clear-front-first samples={2,4,6,8}
 read-front samples={2,4,6,8}
  !OpenGL 1.2
 copyteximage 3D samples={2,4,6,8}
  ARB_texture_cube_map
 copyteximage CUBE samples={2,4,6,8}
  ARB_texture_rectangle
 copyteximage RECT samples={2,4,6,8}
  EXT_texture_array
 copyteximage 1D_ARRAY samples={2,4,6,8}
 copyteximage 2D_ARRAY samples={2,4,6,8}


You should find these on the result summary problems page. There you can
click through to detailed information about each test, including the
command line to run it individually.


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-05-28 Thread Michel Dänzer
On 28.05.2014 09:55, Axel Davy wrote:
 From: Keith Packard kei...@keithp.com
 
 Provide the hook to pull textures out of __DRIimage structures and use them as
 renderbuffers.
 
 Signed-off-by: Keith Packard kei...@keithp.com

This patch breaks a number of piglit tests with DRI2, see the backtrace
below. This fixes it:

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index cd9964c..2d93686 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -761,7 +761,7 @@ dri2_flush_frontbuffer(struct dri_context *ctx,

pipe-flush(pipe, NULL, 0);

-   if (image-flushFrontBuffer) {
+   if (image) {
   image-flushFrontBuffer(dri_drawable, dri_drawable-loaderPrivate);
} else if (loader-flushFrontBuffer) {
   loader-flushFrontBuffer(dri_drawable, dri_drawable-loaderPrivate);



Program received signal SIGSEGV, Segmentation fault.
dri2_flush_frontbuffer (ctx=optimized out, drawable=0x6f60e0, 
statt=optimized out) at 
../../../../../../src/gallium/state_trackers/dri/drm/dri2.c:764
764if (image-flushFrontBuffer) {
(gdb) bt
#0  dri2_flush_frontbuffer (ctx=optimized out, drawable=0x6f60e0, 
statt=optimized out) at 
../../../../../../src/gallium/state_trackers/dri/drm/dri2.c:764
#1  0x717d6315 in dri_st_framebuffer_flush_front (stctx=optimized 
out, stfbi=optimized out, statt=optimized out)
at ../../../../../../src/gallium/state_trackers/dri/drm/dri_drawable.c:118
#2  0x77aff57e in stub_glFlush () at 
tests/util/generated_dispatch.c:8122
#3  0x00400df2 in piglit_display () at 
tests/spec/gl-1.0/front-invalidate-back.c:99
#4  0x77aed319 in process_next_event (x11_fw=0x602010) at 
tests/util/piglit-framework-gl/piglit_x11_framework.c:137
#5  0x77aed3bb in enter_event_loop (winsys_fw=0x602010) at 
tests/util/piglit-framework-gl/piglit_x11_framework.c:153
#6  0x77aec8a7 in run_test (gl_fw=0x602010, argc=1, 
argv=0x7fffe768) at 
tests/util/piglit-framework-gl/piglit_winsys_framework.c:85
#7  0x77ae8ff8 in piglit_gl_test_run (argc=1, argv=0x7fffe768, 
config=0x7fffe630) at tests/util/piglit-framework-gl.c:151
#8  0x00400cc4 in main (argc=1, argv=0x7fffe768) at 
tests/spec/gl-1.0/front-invalidate-back.c:48


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-05-28 Thread Michel Dänzer
On 28.05.2014 09:55, Axel Davy wrote:
 From: Keith Packard kei...@keithp.com
 
 Provide the hook to pull textures out of __DRIimage structures and use them as
 renderbuffers.
 
 Signed-off-by: Keith Packard kei...@keithp.com

Enabling DRI3 using this change breaks a number of depth/stencil and
multisampling related piglit tests on radeonsi compared to DRI2. No idea
yet what's wrong. Keith, I presume there's no such issue with DRI3 on intel?

(According to Tom Stellard, the same or at least a similar issue also
occurs when using this patch for running piglit without X via GBM and
DRM render nodes.)


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-05-28 Thread Axel Davy

On 28/05/2014 03:47, Michel Dänzer wrote :

On 28.05.2014 09:55, Axel Davy wrote:

From: Keith Packard kei...@keithp.com

Provide the hook to pull textures out of __DRIimage structures and use them as
renderbuffers.

Signed-off-by: Keith Packard kei...@keithp.com

This patch breaks a number of piglit tests with DRI2, see the backtrace
below. This fixes it:

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index cd9964c..2d93686 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -761,7 +761,7 @@ dri2_flush_frontbuffer(struct dri_context *ctx,

 pipe-flush(pipe, NULL, 0);

-   if (image-flushFrontBuffer) {
+   if (image) {
image-flushFrontBuffer(dri_drawable, dri_drawable-loaderPrivate);
 } else if (loader-flushFrontBuffer) {
loader-flushFrontBuffer(dri_drawable, dri_drawable-loaderPrivate);



Program received signal SIGSEGV, Segmentation fault.
dri2_flush_frontbuffer (ctx=optimized out, drawable=0x6f60e0, statt=optimized 
out) at ../../../../../../src/gallium/state_trackers/dri/drm/dri2.c:764
764if (image-flushFrontBuffer) {
(gdb) bt
#0  dri2_flush_frontbuffer (ctx=optimized out, drawable=0x6f60e0, 
statt=optimized out) at 
../../../../../../src/gallium/state_trackers/dri/drm/dri2.c:764
#1  0x717d6315 in dri_st_framebuffer_flush_front (stctx=optimized out, 
stfbi=optimized out, statt=optimized out)
 at ../../../../../../src/gallium/state_trackers/dri/drm/dri_drawable.c:118
#2  0x77aff57e in stub_glFlush () at 
tests/util/generated_dispatch.c:8122
#3  0x00400df2 in piglit_display () at 
tests/spec/gl-1.0/front-invalidate-back.c:99
#4  0x77aed319 in process_next_event (x11_fw=0x602010) at 
tests/util/piglit-framework-gl/piglit_x11_framework.c:137
#5  0x77aed3bb in enter_event_loop (winsys_fw=0x602010) at 
tests/util/piglit-framework-gl/piglit_x11_framework.c:153
#6  0x77aec8a7 in run_test (gl_fw=0x602010, argc=1, 
argv=0x7fffe768) at 
tests/util/piglit-framework-gl/piglit_winsys_framework.c:85
#7  0x77ae8ff8 in piglit_gl_test_run (argc=1, argv=0x7fffe768, 
config=0x7fffe630) at tests/util/piglit-framework-gl.c:151
#8  0x00400cc4 in main (argc=1, argv=0x7fffe768) at 
tests/spec/gl-1.0/front-invalidate-back.c:48



I agree with the fix.

However the test may be better to be 'image  image-flushFrontBuffer', 
even if for the moment the field is non-NULL for all the drivers 
defining __DRIimageLoaderExtension.


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


Re: [Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-05-28 Thread Michel Dänzer
On 28.05.2014 21:13, Axel Davy wrote:
 On 28/05/2014 03:47, Michel Dänzer wrote :
 On 28.05.2014 09:55, Axel Davy wrote:
 From: Keith Packard kei...@keithp.com

 Provide the hook to pull textures out of __DRIimage structures and
 use them as
 renderbuffers.

 Signed-off-by: Keith Packard kei...@keithp.com
 This patch breaks a number of piglit tests with DRI2, see the backtrace
 below. This fixes it:

 diff --git a/src/gallium/state_trackers/dri/drm/dri2.c
 b/src/gallium/state_trackers/dri/drm/dri2.c
 index cd9964c..2d93686 100644
 --- a/src/gallium/state_trackers/dri/drm/dri2.c
 +++ b/src/gallium/state_trackers/dri/drm/dri2.c
 @@ -761,7 +761,7 @@ dri2_flush_frontbuffer(struct dri_context *ctx,

  pipe-flush(pipe, NULL, 0);

 -   if (image-flushFrontBuffer) {
 +   if (image) {
 image-flushFrontBuffer(dri_drawable,
 dri_drawable-loaderPrivate);
  } else if (loader-flushFrontBuffer) {
 loader-flushFrontBuffer(dri_drawable,
 dri_drawable-loaderPrivate);

[...]

 I agree with the fix.
 
 However the test may be better to be 'image  image-flushFrontBuffer',
 even if for the moment the field is non-NULL for all the drivers
 defining __DRIimageLoaderExtension.

The intel drivers indeed check for it being non-NULL, but it looks like
that may just be an artifact of how it uses the same code for this and
the DRI2 loader extension.

FWIW, I think it would be better to make this hook non-optional in the
image extension: It's easy to provide a no-op hook if there are indeed
cases where nothing needs to be done. But if the hook is optional, it's
easy to accidentally fail to provide it when it's necesary.


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/11] gallium: Add __DRIimageDriverExtension support to gallium

2014-05-27 Thread Axel Davy
From: Keith Packard kei...@keithp.com

Provide the hook to pull textures out of __DRIimage structures and use them as
renderbuffers.

Signed-off-by: Keith Packard kei...@keithp.com
---
 src/gallium/state_trackers/dri/drm/dri2.c | 238 +-
 1 file changed, 230 insertions(+), 8 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index 7dccc5e..cd9964c 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -498,6 +498,219 @@ dri2_release_buffer(__DRIscreen *sPriv, __DRIbuffer 
*bPriv)
FREE(buffer);
 }
 
+static void
+dri_image_allocate_textures(struct dri_context *ctx,
+   struct dri_drawable *drawable,
+   const enum st_attachment_type *statts,
+   unsigned statts_count)
+{
+   __DRIdrawable *dPriv = drawable-dPriv;
+   __DRIscreen *sPriv = drawable-sPriv;
+   struct dri_screen *screen = dri_screen(sPriv);
+   unsigned int image_format = __DRI_IMAGE_FORMAT_NONE;
+   uint32_t buffer_mask = 0;
+   struct __DRIimageList images;
+   boolean alloc_depthstencil = FALSE;
+   int i, j;
+   struct pipe_resource templ;
+
+   /* See if we need a depth-stencil buffer. */
+   for (i = 0; i  statts_count; i++) {
+  if (statts[i] == ST_ATTACHMENT_DEPTH_STENCIL) {
+ alloc_depthstencil = TRUE;
+ break;
+  }
+   }
+
+   /* Delete the resources we won't need. */
+   for (i = 0; i  ST_ATTACHMENT_COUNT; i++) {
+  /* Don't delete the depth-stencil buffer, we can reuse it. */
+  if (i == ST_ATTACHMENT_DEPTH_STENCIL  alloc_depthstencil)
+ continue;
+
+  pipe_resource_reference(drawable-textures[i], NULL);
+   }
+
+   if (drawable-stvis.samples  1) {
+  for (i = 0; i  ST_ATTACHMENT_COUNT; i++) {
+ boolean del = TRUE;
+
+ /* Don't delete MSAA resources for the attachments which are enabled,
+  * we can reuse them. */
+ for (j = 0; j  statts_count; j++) {
+if (i == statts[j]) {
+   del = FALSE;
+   break;
+}
+ }
+
+ if (del) {
+pipe_resource_reference(drawable-msaa_textures[i], NULL);
+ }
+  }
+   }
+
+   for (i = 0; i  statts_count; i++) {
+  enum pipe_format pf;
+  unsigned bind;
+
+  dri_drawable_get_format(drawable, statts[i], pf, bind);
+  if (pf == PIPE_FORMAT_NONE)
+ continue;
+
+  switch (pf) {
+  case PIPE_FORMAT_B5G6R5_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_RGB565;
+ break;
+  case PIPE_FORMAT_B8G8R8X8_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_XRGB;
+ break;
+  case PIPE_FORMAT_B8G8R8A8_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_ARGB;
+ break;
+  case PIPE_FORMAT_R8G8B8A8_UNORM:
+ image_format = __DRI_IMAGE_FORMAT_ABGR;
+ break;
+  default:
+ image_format = __DRI_IMAGE_FORMAT_NONE;
+ break;
+  }
+
+  switch (statts[i]) {
+  case ST_ATTACHMENT_FRONT_LEFT:
+ buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
+ break;
+  case ST_ATTACHMENT_BACK_LEFT:
+ buffer_mask |= __DRI_IMAGE_BUFFER_BACK;
+ break;
+  default:
+ continue;
+  }
+   }
+
+   (*sPriv-image.loader-getBuffers) (dPriv,
+   image_format,
+   dPriv-dri2.stamp,
+   dPriv-loaderPrivate,
+   buffer_mask,
+   images);
+
+   if (images.image_mask  __DRI_IMAGE_BUFFER_FRONT) {
+  struct pipe_resource *texture = images.front-texture;
+
+  dPriv-w = texture-width0;
+  dPriv-h = texture-height0;
+
+  pipe_resource_reference(drawable-textures[ST_ATTACHMENT_FRONT_LEFT], 
texture);
+   }
+
+   if (images.image_mask  __DRI_IMAGE_BUFFER_BACK) {
+  struct pipe_resource *texture = images.back-texture;
+
+  dPriv-w = images.back-texture-width0;
+  dPriv-h = images.back-texture-height0;
+
+  pipe_resource_reference(drawable-textures[ST_ATTACHMENT_BACK_LEFT], 
texture);
+   }
+
+   memset(templ, 0, sizeof(templ));
+   templ.target = screen-target;
+   templ.last_level = 0;
+   templ.width0 = dPriv-w;
+   templ.height0 = dPriv-h;
+   templ.depth0 = 1;
+   templ.array_size = 1;
+
+   /* Allocate private MSAA colorbuffers. */
+   if (drawable-stvis.samples  1) {
+  for (i = 0; i  statts_count; i++) {
+ enum st_attachment_type att = statts[i];
+
+ if (att == ST_ATTACHMENT_DEPTH_STENCIL)
+continue;
+
+ if (drawable-textures[att]) {
+templ.format = drawable-textures[att]-format;
+templ.bind = drawable-textures[att]-bind;
+templ.nr_samples = drawable-stvis.samples;
+
+/* Try to reuse the resource.
+ * (the other resource