Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Marek Olšák
On Wed, Aug 24, 2016 at 7:20 PM, Rob Clark  wrote:
> On Mon, Aug 22, 2016 at 10:39 AM, Marek Olšák  wrote:
>> From: Marek Olšák 
>>
>> radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
>> interop and this is the only way to make it coherent with the current
>> context. It can optionally be set to NULL.
>
> so, random thought.. couldn't you just create your own internal
> decompression pipe_context (possibly only on-demand)?

That's what we are doing right now and it's doesn't work when the main
context is unflushed. You don't want to do decompression when you have
unflushed draw calls (with compression enabled) elsewhere. Those draw
calls would re-compress the resource.

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


Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Rob Clark
On Mon, Aug 22, 2016 at 10:39 AM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
> interop and this is the only way to make it coherent with the current
> context. It can optionally be set to NULL.

so, random thought.. couldn't you just create your own internal
decompression pipe_context (possibly only on-demand)?

BR,
-R

> ---
>  src/gallium/auxiliary/util/u_transfer.c   |  1 +
>  src/gallium/auxiliary/util/u_transfer.h   |  1 +
>  src/gallium/auxiliary/vl/vl_winsys_dri3.c |  2 +-
>  src/gallium/drivers/ddebug/dd_screen.c|  4 +++-
>  src/gallium/drivers/ilo/ilo_resource.c|  1 +
>  src/gallium/drivers/llvmpipe/lp_texture.c |  1 +
>  src/gallium/drivers/noop/noop_pipe.c  |  1 +
>  src/gallium/drivers/r300/r300_texture.c   |  1 +
>  src/gallium/drivers/r300/r300_texture.h   |  1 +
>  src/gallium/drivers/radeon/r600_texture.c |  1 +
>  src/gallium/drivers/rbug/rbug_screen.c|  5 -
>  src/gallium/drivers/softpipe/sp_texture.c |  1 +
>  src/gallium/drivers/trace/tr_screen.c |  5 -
>  src/gallium/include/pipe/p_screen.h   |  7 +++
>  src/gallium/state_trackers/dri/dri2.c | 13 +++--
>  src/gallium/state_trackers/nine/swapchain9.c  |  3 ++-
>  src/gallium/state_trackers/va/buffer.c|  3 ++-
>  src/gallium/state_trackers/vdpau/output.c |  3 ++-
>  src/gallium/state_trackers/vdpau/surface.c|  3 ++-
>  src/gallium/state_trackers/xa/xa_tracker.c|  3 ++-
>  src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
>  21 files changed, 46 insertions(+), 16 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_transfer.c 
> b/src/gallium/auxiliary/util/u_transfer.c
> index 82cf68d..ba4b9dc 100644
> --- a/src/gallium/auxiliary/util/u_transfer.c
> +++ b/src/gallium/auxiliary/util/u_transfer.c
> @@ -104,20 +104,21 @@ void u_default_transfer_unmap( struct pipe_context 
> *pipe,
>  }
>
>
>  static inline struct u_resource *
>  u_resource( struct pipe_resource *res )
>  {
> return (struct u_resource *)res;
>  }
>
>  boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
> +   struct pipe_context *ctx,
> struct pipe_resource *resource,
> struct winsys_handle *handle,
> unsigned usage)
>  {
> struct u_resource *ur = u_resource(resource);
> return ur->vtbl->resource_get_handle(screen, resource, handle);
>  }
>
>  void u_resource_destroy_vtbl(struct pipe_screen *screen,
>   struct pipe_resource *resource)
> diff --git a/src/gallium/auxiliary/util/u_transfer.h 
> b/src/gallium/auxiliary/util/u_transfer.h
> index 7f680bc..ab787ab 100644
> --- a/src/gallium/auxiliary/util/u_transfer.h
> +++ b/src/gallium/auxiliary/util/u_transfer.h
> @@ -66,20 +66,21 @@ struct u_resource_vtbl {
>  };
>
>
>  struct u_resource {
> struct pipe_resource b;
> const struct u_resource_vtbl *vtbl;
>  };
>
>
>  boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
> +   struct pipe_context *ctx,
> struct pipe_resource *resource,
> struct winsys_handle *handle,
> unsigned usage);
>
>  void u_resource_destroy_vtbl(struct pipe_screen *screen,
>   struct pipe_resource *resource);
>
>  void *u_transfer_map_vtbl(struct pipe_context *context,
>struct pipe_resource *resource,
>unsigned level,
> diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
> b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> index 61d6205..3d596a6 100644
> --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> @@ -236,21 +236,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
> templ.depth0 = 1;
> templ.array_size = 1;
> buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
>   );
> if (!buffer->texture)
>goto unmap_shm;
>
> memset(, 0, sizeof(whandle));
> whandle.type= DRM_API_HANDLE_TYPE_FD;
> usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
> -   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen,
> +   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
> buffer->texture, ,
> usage);
> buffer_fd = whandle.handle;
> buffer->pitch = whandle.stride;
> xcb_dri3_pixmap_from_buffer(scrn->conn,
> (pixmap = 

Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Marek Olšák
On Wed, Aug 24, 2016 at 5:56 PM, Roland Scheidegger  wrote:
> Am 24.08.2016 um 17:42 schrieb Marek Olšák:
>> On Wed, Aug 24, 2016 at 5:31 PM, Roland Scheidegger  
>> wrote:
>>> Am 24.08.2016 um 11:22 schrieb Marek Olšák:
 On Wed, Aug 24, 2016 at 2:02 AM, Roland Scheidegger  
 wrote:
> I admit I'm not familiar with the interopability stuff.
> But how is the coherency stuff handled after you get the handle?
> Does this also work if you've got multiple users of resource_get_handle?

 Basically, radeonsi just makes sure the resource contents are
 decompressed before sharing and flushes the context. After that, the
 resource is ready for sharing and can be re-exported any number of
 times.

>>>
>>> Ok. I was just thinking of situations where you could share the same
>>> resource between more than two contexts, and not all having the same
>>> requirements (e.g. decompression not always be necessary).
>>> But if the api is flexible enough to handle such things it should be ok.
>>
>> All resources are trivially sharable as long as they are managed by
>> the same pipe_screen. This change is for the kind of sharing that
>> involves an out-of-tree driver component (e.g. OpenCL) or a different
>> process (the EGL DMABUF extension).
>>
>
> So you always need to decompress for that?

Not always, but usually yes.

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


Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Roland Scheidegger
Am 24.08.2016 um 17:42 schrieb Marek Olšák:
> On Wed, Aug 24, 2016 at 5:31 PM, Roland Scheidegger  
> wrote:
>> Am 24.08.2016 um 11:22 schrieb Marek Olšák:
>>> On Wed, Aug 24, 2016 at 2:02 AM, Roland Scheidegger  
>>> wrote:
 I admit I'm not familiar with the interopability stuff.
 But how is the coherency stuff handled after you get the handle?
 Does this also work if you've got multiple users of resource_get_handle?
>>>
>>> Basically, radeonsi just makes sure the resource contents are
>>> decompressed before sharing and flushes the context. After that, the
>>> resource is ready for sharing and can be re-exported any number of
>>> times.
>>>
>>
>> Ok. I was just thinking of situations where you could share the same
>> resource between more than two contexts, and not all having the same
>> requirements (e.g. decompression not always be necessary).
>> But if the api is flexible enough to handle such things it should be ok.
> 
> All resources are trivially sharable as long as they are managed by
> the same pipe_screen. This change is for the kind of sharing that
> involves an out-of-tree driver component (e.g. OpenCL) or a different
> process (the EGL DMABUF extension).
> 

So you always need to decompress for that?

Roland


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


Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Marek Olšák
On Wed, Aug 24, 2016 at 5:31 PM, Roland Scheidegger  wrote:
> Am 24.08.2016 um 11:22 schrieb Marek Olšák:
>> On Wed, Aug 24, 2016 at 2:02 AM, Roland Scheidegger  
>> wrote:
>>> I admit I'm not familiar with the interopability stuff.
>>> But how is the coherency stuff handled after you get the handle?
>>> Does this also work if you've got multiple users of resource_get_handle?
>>
>> Basically, radeonsi just makes sure the resource contents are
>> decompressed before sharing and flushes the context. After that, the
>> resource is ready for sharing and can be re-exported any number of
>> times.
>>
>
> Ok. I was just thinking of situations where you could share the same
> resource between more than two contexts, and not all having the same
> requirements (e.g. decompression not always be necessary).
> But if the api is flexible enough to handle such things it should be ok.

All resources are trivially sharable as long as they are managed by
the same pipe_screen. This change is for the kind of sharing that
involves an out-of-tree driver component (e.g. OpenCL) or a different
process (the EGL DMABUF extension).

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


Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Roland Scheidegger
Am 24.08.2016 um 11:22 schrieb Marek Olšák:
> On Wed, Aug 24, 2016 at 2:02 AM, Roland Scheidegger  
> wrote:
>> I admit I'm not familiar with the interopability stuff.
>> But how is the coherency stuff handled after you get the handle?
>> Does this also work if you've got multiple users of resource_get_handle?
> 
> Basically, radeonsi just makes sure the resource contents are
> decompressed before sharing and flushes the context. After that, the
> resource is ready for sharing and can be re-exported any number of
> times.
> 

Ok. I was just thinking of situations where you could share the same
resource between more than two contexts, and not all having the same
requirements (e.g. decompression not always be necessary).
But if the api is flexible enough to handle such things it should be ok.

Roland


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


Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-24 Thread Marek Olšák
On Wed, Aug 24, 2016 at 2:02 AM, Roland Scheidegger  wrote:
> I admit I'm not familiar with the interopability stuff.
> But how is the coherency stuff handled after you get the handle?
> Does this also work if you've got multiple users of resource_get_handle?

Basically, radeonsi just makes sure the resource contents are
decompressed before sharing and flushes the context. After that, the
resource is ready for sharing and can be re-exported any number of
times.

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


Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-23 Thread Roland Scheidegger
I admit I'm not familiar with the interopability stuff.
But how is the coherency stuff handled after you get the handle?
Does this also work if you've got multiple users of resource_get_handle?

Roland

Am 22.08.2016 um 16:06 schrieb Marek Olšák:
> From: Marek Olšák 
> 
> radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
> interop and this is the only way to make it coherent with the current
> context. It can optionally be set to NULL.
> ---
>  src/gallium/auxiliary/util/u_transfer.c   |  1 +
>  src/gallium/auxiliary/util/u_transfer.h   |  1 +
>  src/gallium/auxiliary/vl/vl_winsys_dri3.c |  2 +-
>  src/gallium/drivers/ddebug/dd_screen.c|  4 +++-
>  src/gallium/drivers/ilo/ilo_resource.c|  1 +
>  src/gallium/drivers/llvmpipe/lp_texture.c |  1 +
>  src/gallium/drivers/noop/noop_pipe.c  |  1 +
>  src/gallium/drivers/r300/r300_texture.c   |  1 +
>  src/gallium/drivers/r300/r300_texture.h   |  1 +
>  src/gallium/drivers/radeon/r600_texture.c |  1 +
>  src/gallium/drivers/rbug/rbug_screen.c|  5 -
>  src/gallium/drivers/softpipe/sp_texture.c |  1 +
>  src/gallium/drivers/trace/tr_screen.c |  5 -
>  src/gallium/include/pipe/p_screen.h   |  7 +++
>  src/gallium/state_trackers/dri/dri2.c | 13 +++--
>  src/gallium/state_trackers/nine/swapchain9.c  |  3 ++-
>  src/gallium/state_trackers/va/buffer.c|  3 ++-
>  src/gallium/state_trackers/vdpau/output.c |  3 ++-
>  src/gallium/state_trackers/vdpau/surface.c|  3 ++-
>  src/gallium/state_trackers/xa/xa_tracker.c|  3 ++-
>  src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
>  21 files changed, 46 insertions(+), 16 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/util/u_transfer.c 
> b/src/gallium/auxiliary/util/u_transfer.c
> index 82cf68d..ba4b9dc 100644
> --- a/src/gallium/auxiliary/util/u_transfer.c
> +++ b/src/gallium/auxiliary/util/u_transfer.c
> @@ -104,20 +104,21 @@ void u_default_transfer_unmap( struct pipe_context 
> *pipe,
>  }
>  
>  
>  static inline struct u_resource *
>  u_resource( struct pipe_resource *res )
>  {
> return (struct u_resource *)res;
>  }
>  
>  boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
> +   struct pipe_context *ctx,
> struct pipe_resource *resource,
> struct winsys_handle *handle,
> unsigned usage)
>  {
> struct u_resource *ur = u_resource(resource);
> return ur->vtbl->resource_get_handle(screen, resource, handle);
>  }
>  
>  void u_resource_destroy_vtbl(struct pipe_screen *screen,
>   struct pipe_resource *resource)
> diff --git a/src/gallium/auxiliary/util/u_transfer.h 
> b/src/gallium/auxiliary/util/u_transfer.h
> index 7f680bc..ab787ab 100644
> --- a/src/gallium/auxiliary/util/u_transfer.h
> +++ b/src/gallium/auxiliary/util/u_transfer.h
> @@ -66,20 +66,21 @@ struct u_resource_vtbl {
>  };
>  
>  
>  struct u_resource {
> struct pipe_resource b;
> const struct u_resource_vtbl *vtbl;
>  };
>  
>  
>  boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
> +   struct pipe_context *ctx,
> struct pipe_resource *resource,
> struct winsys_handle *handle,
> unsigned usage);
>  
>  void u_resource_destroy_vtbl(struct pipe_screen *screen,
>   struct pipe_resource *resource);
>  
>  void *u_transfer_map_vtbl(struct pipe_context *context,
>struct pipe_resource *resource,
>unsigned level,
> diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
> b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> index 61d6205..3d596a6 100644
> --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> @@ -236,21 +236,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
> templ.depth0 = 1;
> templ.array_size = 1;
> buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
>   );
> if (!buffer->texture)
>goto unmap_shm;
>  
> memset(, 0, sizeof(whandle));
> whandle.type= DRM_API_HANDLE_TYPE_FD;
> usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
> -   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen,
> +   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
> buffer->texture, ,
> usage);
> buffer_fd = whandle.handle;
> buffer->pitch = whandle.stride;
> 

[Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-23 Thread Marek Olšák
From: Marek Olšák 

radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
interop and this is the only way to make it coherent with the current
context. It can optionally be set to NULL.
---
 src/gallium/auxiliary/util/u_transfer.c   |  1 +
 src/gallium/auxiliary/util/u_transfer.h   |  1 +
 src/gallium/auxiliary/vl/vl_winsys_dri3.c |  2 +-
 src/gallium/drivers/ddebug/dd_screen.c|  4 +++-
 src/gallium/drivers/ilo/ilo_resource.c|  1 +
 src/gallium/drivers/llvmpipe/lp_texture.c |  1 +
 src/gallium/drivers/noop/noop_pipe.c  |  1 +
 src/gallium/drivers/r300/r300_texture.c   |  1 +
 src/gallium/drivers/r300/r300_texture.h   |  1 +
 src/gallium/drivers/radeon/r600_texture.c |  1 +
 src/gallium/drivers/rbug/rbug_screen.c|  5 -
 src/gallium/drivers/softpipe/sp_texture.c |  1 +
 src/gallium/drivers/trace/tr_screen.c |  5 -
 src/gallium/include/pipe/p_screen.h   |  7 +++
 src/gallium/state_trackers/dri/dri2.c | 13 +++--
 src/gallium/state_trackers/nine/swapchain9.c  |  3 ++-
 src/gallium/state_trackers/va/buffer.c|  3 ++-
 src/gallium/state_trackers/vdpau/output.c |  3 ++-
 src/gallium/state_trackers/vdpau/surface.c|  3 ++-
 src/gallium/state_trackers/xa/xa_tracker.c|  3 ++-
 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
 21 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_transfer.c 
b/src/gallium/auxiliary/util/u_transfer.c
index 82cf68d..ba4b9dc 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -104,20 +104,21 @@ void u_default_transfer_unmap( struct pipe_context *pipe,
 }
 
 
 static inline struct u_resource *
 u_resource( struct pipe_resource *res )
 {
return (struct u_resource *)res;
 }
 
 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+   struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
 {
struct u_resource *ur = u_resource(resource);
return ur->vtbl->resource_get_handle(screen, resource, handle);
 }
 
 void u_resource_destroy_vtbl(struct pipe_screen *screen,
  struct pipe_resource *resource)
diff --git a/src/gallium/auxiliary/util/u_transfer.h 
b/src/gallium/auxiliary/util/u_transfer.h
index 7f680bc..ab787ab 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -66,20 +66,21 @@ struct u_resource_vtbl {
 };
 
 
 struct u_resource {
struct pipe_resource b;
const struct u_resource_vtbl *vtbl;
 };
 
 
 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+   struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage);
 
 void u_resource_destroy_vtbl(struct pipe_screen *screen,
  struct pipe_resource *resource);
 
 void *u_transfer_map_vtbl(struct pipe_context *context,
   struct pipe_resource *resource,
   unsigned level,
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 61d6205..3d596a6 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -236,21 +236,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
templ.depth0 = 1;
templ.array_size = 1;
buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
  );
if (!buffer->texture)
   goto unmap_shm;
 
memset(, 0, sizeof(whandle));
whandle.type= DRM_API_HANDLE_TYPE_FD;
usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
-   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen,
+   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
buffer->texture, ,
usage);
buffer_fd = whandle.handle;
buffer->pitch = whandle.stride;
xcb_dri3_pixmap_from_buffer(scrn->conn,
(pixmap = xcb_generate_id(scrn->conn)),
scrn->drawable,
0,
scrn->width, scrn->height, buffer->pitch,
scrn->depth, 32,
diff --git a/src/gallium/drivers/ddebug/dd_screen.c 
b/src/gallium/drivers/ddebug/dd_screen.c
index 3deba0a..4050e39 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ 

Re: [Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-22 Thread Brian Paul

On 08/22/2016 08:39 AM, Marek Olšák wrote:

From: Marek Olšák 

radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
interop and this is the only way to make it coherent with the current
context. It can optionally be set to NULL.
---
  src/gallium/auxiliary/util/u_transfer.c   |  1 +
  src/gallium/auxiliary/util/u_transfer.h   |  1 +
  src/gallium/auxiliary/vl/vl_winsys_dri3.c |  2 +-
  src/gallium/drivers/ddebug/dd_screen.c|  4 +++-
  src/gallium/drivers/ilo/ilo_resource.c|  1 +
  src/gallium/drivers/llvmpipe/lp_texture.c |  1 +
  src/gallium/drivers/noop/noop_pipe.c  |  1 +
  src/gallium/drivers/r300/r300_texture.c   |  1 +
  src/gallium/drivers/r300/r300_texture.h   |  1 +
  src/gallium/drivers/radeon/r600_texture.c |  1 +
  src/gallium/drivers/rbug/rbug_screen.c|  5 -
  src/gallium/drivers/softpipe/sp_texture.c |  1 +
  src/gallium/drivers/trace/tr_screen.c |  5 -
  src/gallium/include/pipe/p_screen.h   |  7 +++
  src/gallium/state_trackers/dri/dri2.c | 13 +++--
  src/gallium/state_trackers/nine/swapchain9.c  |  3 ++-
  src/gallium/state_trackers/va/buffer.c|  3 ++-
  src/gallium/state_trackers/vdpau/output.c |  3 ++-
  src/gallium/state_trackers/vdpau/surface.c|  3 ++-
  src/gallium/state_trackers/xa/xa_tracker.c|  3 ++-
  src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
  21 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_transfer.c 
b/src/gallium/auxiliary/util/u_transfer.c
index 82cf68d..ba4b9dc 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -104,20 +104,21 @@ void u_default_transfer_unmap( struct pipe_context *pipe,
  }


  static inline struct u_resource *
  u_resource( struct pipe_resource *res )
  {
 return (struct u_resource *)res;
  }

  boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+   struct pipe_context *ctx,
 struct pipe_resource *resource,
 struct winsys_handle *handle,
 unsigned usage)
  {
 struct u_resource *ur = u_resource(resource);
 return ur->vtbl->resource_get_handle(screen, resource, handle);
  }

  void u_resource_destroy_vtbl(struct pipe_screen *screen,
   struct pipe_resource *resource)
diff --git a/src/gallium/auxiliary/util/u_transfer.h 
b/src/gallium/auxiliary/util/u_transfer.h
index 7f680bc..ab787ab 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -66,20 +66,21 @@ struct u_resource_vtbl {
  };


  struct u_resource {
 struct pipe_resource b;
 const struct u_resource_vtbl *vtbl;
  };


  boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+   struct pipe_context *ctx,
 struct pipe_resource *resource,
 struct winsys_handle *handle,
 unsigned usage);

  void u_resource_destroy_vtbl(struct pipe_screen *screen,
   struct pipe_resource *resource);

  void *u_transfer_map_vtbl(struct pipe_context *context,
struct pipe_resource *resource,
unsigned level,
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 61d6205..3d596a6 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -236,21 +236,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
 templ.depth0 = 1;
 templ.array_size = 1;
 buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
   );
 if (!buffer->texture)
goto unmap_shm;

 memset(, 0, sizeof(whandle));
 whandle.type= DRM_API_HANDLE_TYPE_FD;
 usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
-   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen,
+   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
 buffer->texture, ,
 usage);
 buffer_fd = whandle.handle;
 buffer->pitch = whandle.stride;
 xcb_dri3_pixmap_from_buffer(scrn->conn,
 (pixmap = xcb_generate_id(scrn->conn)),
 scrn->drawable,
 0,
 scrn->width, scrn->height, buffer->pitch,
 scrn->depth, 32,
diff --git a/src/gallium/drivers/ddebug/dd_screen.c 

[Mesa-dev] [PATCH 2/3] gallium: add a pipe_context parameter to resource_get_handle

2016-08-22 Thread Marek Olšák
From: Marek Olšák 

radeonsi needs to do some operations (DCC decompression) for OpenGL-OpenCL
interop and this is the only way to make it coherent with the current
context. It can optionally be set to NULL.
---
 src/gallium/auxiliary/util/u_transfer.c   |  1 +
 src/gallium/auxiliary/util/u_transfer.h   |  1 +
 src/gallium/auxiliary/vl/vl_winsys_dri3.c |  2 +-
 src/gallium/drivers/ddebug/dd_screen.c|  4 +++-
 src/gallium/drivers/ilo/ilo_resource.c|  1 +
 src/gallium/drivers/llvmpipe/lp_texture.c |  1 +
 src/gallium/drivers/noop/noop_pipe.c  |  1 +
 src/gallium/drivers/r300/r300_texture.c   |  1 +
 src/gallium/drivers/r300/r300_texture.h   |  1 +
 src/gallium/drivers/radeon/r600_texture.c |  1 +
 src/gallium/drivers/rbug/rbug_screen.c|  5 -
 src/gallium/drivers/softpipe/sp_texture.c |  1 +
 src/gallium/drivers/trace/tr_screen.c |  5 -
 src/gallium/include/pipe/p_screen.h   |  7 +++
 src/gallium/state_trackers/dri/dri2.c | 13 +++--
 src/gallium/state_trackers/nine/swapchain9.c  |  3 ++-
 src/gallium/state_trackers/va/buffer.c|  3 ++-
 src/gallium/state_trackers/vdpau/output.c |  3 ++-
 src/gallium/state_trackers/vdpau/surface.c|  3 ++-
 src/gallium/state_trackers/xa/xa_tracker.c|  3 ++-
 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
 21 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_transfer.c 
b/src/gallium/auxiliary/util/u_transfer.c
index 82cf68d..ba4b9dc 100644
--- a/src/gallium/auxiliary/util/u_transfer.c
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -104,20 +104,21 @@ void u_default_transfer_unmap( struct pipe_context *pipe,
 }
 
 
 static inline struct u_resource *
 u_resource( struct pipe_resource *res )
 {
return (struct u_resource *)res;
 }
 
 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+   struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage)
 {
struct u_resource *ur = u_resource(resource);
return ur->vtbl->resource_get_handle(screen, resource, handle);
 }
 
 void u_resource_destroy_vtbl(struct pipe_screen *screen,
  struct pipe_resource *resource)
diff --git a/src/gallium/auxiliary/util/u_transfer.h 
b/src/gallium/auxiliary/util/u_transfer.h
index 7f680bc..ab787ab 100644
--- a/src/gallium/auxiliary/util/u_transfer.h
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -66,20 +66,21 @@ struct u_resource_vtbl {
 };
 
 
 struct u_resource {
struct pipe_resource b;
const struct u_resource_vtbl *vtbl;
 };
 
 
 boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+   struct pipe_context *ctx,
struct pipe_resource *resource,
struct winsys_handle *handle,
unsigned usage);
 
 void u_resource_destroy_vtbl(struct pipe_screen *screen,
  struct pipe_resource *resource);
 
 void *u_transfer_map_vtbl(struct pipe_context *context,
   struct pipe_resource *resource,
   unsigned level,
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 61d6205..3d596a6 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -236,21 +236,21 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
templ.depth0 = 1;
templ.array_size = 1;
buffer->texture = scrn->base.pscreen->resource_create(scrn->base.pscreen,
  );
if (!buffer->texture)
   goto unmap_shm;
 
memset(, 0, sizeof(whandle));
whandle.type= DRM_API_HANDLE_TYPE_FD;
usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
-   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen,
+   scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
buffer->texture, ,
usage);
buffer_fd = whandle.handle;
buffer->pitch = whandle.stride;
xcb_dri3_pixmap_from_buffer(scrn->conn,
(pixmap = xcb_generate_id(scrn->conn)),
scrn->drawable,
0,
scrn->width, scrn->height, buffer->pitch,
scrn->depth, 32,
diff --git a/src/gallium/drivers/ddebug/dd_screen.c 
b/src/gallium/drivers/ddebug/dd_screen.c
index 3deba0a..4050e39 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++