Re: [Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-22 Thread Erik Faye-Lund
On Thu, Oct 22, 2015 at 12:18 PM, Marek Olšák  wrote:
> On Thu, Oct 22, 2015 at 10:56 AM, Erik Faye-Lund  wrote:
>> On Thu, Oct 22, 2015 at 10:54 AM, Marek Olšák  wrote:
>>> On Thu, Oct 22, 2015 at 10:22 AM, Erik Faye-Lund  
>>> wrote:
 On Wed, Oct 21, 2015 at 10:34 PM, Marek Olšák  wrote:
> On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy  wrote:
>> The PIPE_BIND_SHARED flag should be added whenever
>> the resource may be shared with another process.
>>
>> In particular if the resource is imported, or may
>> be exported, the flag should be used.
>
> This can't be enforced. EGL_MESA_image_dma_buf_export allows exporting
> any texture. Mesa can't know in advance if a texture will be exported.

 Could we not, at least in theory, crate a new texture and blit the old
 one into it behind the scenes somehow when a texture gets exported?
>>>
>>> Sharing means textures are shared. There is no blitting allowed. Other
>>> users don't have to be notified that a shared texture has been
>>> rendered to.
>>
>> Maybe I wasn't clear enough: I meant to migrate the texture data over
>> to a new shared home, not to create a copy.
>
> Ok, well, in that case it's easier to just share the texture as-is.

Sure. This was more a theoretical question than a practical one, as
your initial statement sounded a bit black-and-white. I just remember
we had to do something along these lines this in the Mali-400 driver
back when EGL_image was introduced, because the image could be
consumed by things that were unable to deal with our tiling etc (like
video encoders/decoders). I might misremember, though.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-22 Thread Marek Olšák
On Thu, Oct 22, 2015 at 10:56 AM, Erik Faye-Lund  wrote:
> On Thu, Oct 22, 2015 at 10:54 AM, Marek Olšák  wrote:
>> On Thu, Oct 22, 2015 at 10:22 AM, Erik Faye-Lund  wrote:
>>> On Wed, Oct 21, 2015 at 10:34 PM, Marek Olšák  wrote:
 On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy  wrote:
> The PIPE_BIND_SHARED flag should be added whenever
> the resource may be shared with another process.
>
> In particular if the resource is imported, or may
> be exported, the flag should be used.

 This can't be enforced. EGL_MESA_image_dma_buf_export allows exporting
 any texture. Mesa can't know in advance if a texture will be exported.
>>>
>>> Could we not, at least in theory, crate a new texture and blit the old
>>> one into it behind the scenes somehow when a texture gets exported?
>>
>> Sharing means textures are shared. There is no blitting allowed. Other
>> users don't have to be notified that a shared texture has been
>> rendered to.
>
> Maybe I wasn't clear enough: I meant to migrate the texture data over
> to a new shared home, not to create a copy.

Ok, well, in that case it's easier to just share the texture as-is.

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


Re: [Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-22 Thread Erik Faye-Lund
On Thu, Oct 22, 2015 at 10:54 AM, Marek Olšák  wrote:
> On Thu, Oct 22, 2015 at 10:22 AM, Erik Faye-Lund  wrote:
>> On Wed, Oct 21, 2015 at 10:34 PM, Marek Olšák  wrote:
>>> On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy  wrote:
 The PIPE_BIND_SHARED flag should be added whenever
 the resource may be shared with another process.

 In particular if the resource is imported, or may
 be exported, the flag should be used.
>>>
>>> This can't be enforced. EGL_MESA_image_dma_buf_export allows exporting
>>> any texture. Mesa can't know in advance if a texture will be exported.
>>
>> Could we not, at least in theory, crate a new texture and blit the old
>> one into it behind the scenes somehow when a texture gets exported?
>
> Sharing means textures are shared. There is no blitting allowed. Other
> users don't have to be notified that a shared texture has been
> rendered to.

Maybe I wasn't clear enough: I meant to migrate the texture data over
to a new shared home, not to create a copy.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-22 Thread Marek Olšák
On Thu, Oct 22, 2015 at 10:22 AM, Erik Faye-Lund  wrote:
> On Wed, Oct 21, 2015 at 10:34 PM, Marek Olšák  wrote:
>> On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy  wrote:
>>> The PIPE_BIND_SHARED flag should be added whenever
>>> the resource may be shared with another process.
>>>
>>> In particular if the resource is imported, or may
>>> be exported, the flag should be used.
>>
>> This can't be enforced. EGL_MESA_image_dma_buf_export allows exporting
>> any texture. Mesa can't know in advance if a texture will be exported.
>
> Could we not, at least in theory, crate a new texture and blit the old
> one into it behind the scenes somehow when a texture gets exported?

Sharing means textures are shared. There is no blitting allowed. Other
users don't have to be notified that a shared texture has been
rendered to.

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


Re: [Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-22 Thread Erik Faye-Lund
On Wed, Oct 21, 2015 at 10:34 PM, Marek Olšák  wrote:
> On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy  wrote:
>> The PIPE_BIND_SHARED flag should be added whenever
>> the resource may be shared with another process.
>>
>> In particular if the resource is imported, or may
>> be exported, the flag should be used.
>
> This can't be enforced. EGL_MESA_image_dma_buf_export allows exporting
> any texture. Mesa can't know in advance if a texture will be exported.

Could we not, at least in theory, crate a new texture and blit the old
one into it behind the scenes somehow when a texture gets exported?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-21 Thread Marek Olšák
On Wed, Oct 21, 2015 at 12:28 PM, Axel Davy  wrote:
> The PIPE_BIND_SHARED flag should be added whenever
> the resource may be shared with another process.
>
> In particular if the resource is imported, or may
> be exported, the flag should be used.

This can't be enforced. EGL_MESA_image_dma_buf_export allows exporting
any texture. Mesa can't know in advance if a texture will be exported.

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


[Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

2015-10-21 Thread Axel Davy
The PIPE_BIND_SHARED flag should be added whenever
the resource may be shared with another process.

In particular if the resource is imported, or may
be exported, the flag should be used.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/dri/dri2.c | 9 +++--
 src/gallium/state_trackers/dri/dri_drawable.c | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 019414b..5f5bc86 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -554,7 +554,8 @@ dri2_allocate_textures(struct dri_context *ctx,
 
  if (drawable->textures[statt]) {
 templ.format = drawable->textures[statt]->format;
-templ.bind = drawable->textures[statt]->bind & ~PIPE_BIND_SCANOUT;
+templ.bind = drawable->textures[statt]->bind &
+   ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);
 templ.nr_samples = drawable->stvis.samples;
 
 /* Try to reuse the resource.
@@ -717,7 +718,8 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
unsigned tex_usage;
enum pipe_format pf;
 
-   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
+  PIPE_BIND_SHARED;
 
switch (format) {
case __DRI_IMAGE_FORMAT_RGB565:
@@ -1089,6 +1091,9 @@ dri2_create_from_texture(__DRIcontext *context, int 
target, unsigned texture,
   return NULL;
}
 
+   /* TODO: The initial texture was not created with the PIPE_BIND_SHARED flag.
+* There should be a way to add this flag after creation. This flag is
+* needed for EGLImages. */
pipe_resource_reference(&img->texture, tex);
 
*error = __DRI_IMAGE_ERROR_SUCCESS;
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c 
b/src/gallium/state_trackers/dri/dri_drawable.c
index f0cc4a2..04041d6 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -285,7 +285,8 @@ dri_drawable_get_format(struct dri_drawable *drawable,
* to use an sRGB format here.
*/
   *format = util_format_linear(drawable->stvis.color_format);
-  *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+  *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
+ PIPE_BIND_SHARED;
   break;
case ST_ATTACHMENT_DEPTH_STENCIL:
   *format = drawable->stvis.depth_stencil_format;
-- 
2.6.1

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