<div dir="ltr"><div><div><div>Hi Christian,<br><br></div>I can try to move the bind flags to pipe_video_buffer.<br><br></div>Thx<br></div>Julien<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 November 2015 at 19:04, Christian König <span dir="ltr"><<a href="mailto:deathsimple@vodafone.de" target="_blank">deathsimple@vodafone.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 29.11.2015 18:26, Emil Velikov wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 27 November 2015 at 08:57, Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In order to do zero-copy between two different devices<br>
the memory should not be tiled.<br>
<br>
This is currently no way to set pipe_resource template's flag<br>
from pipe_video_buffer template. So disabled_tiling is added.<br>
<br>
Choosed "disable" prefix so that CALLOC keeps tiling enabled<br>
by default.<br>
<br>
Tested with GStreamer on a laptop that has 2 GPUs:<br>
1- gstvaapidecode:<br>
HW decoding and dmabuf export with nouveau driver on Nvidia GPU.<br>
2- glimagesink:<br>
EGLImage imports dmabuf on Intel GPU.<br>
<br>
Note that tiling is working if 1 and 2 are done on the same GPU.<br>
So it is up to the application to set or not the flag:<br>
VA_SURFACE_EXTBUF_DESC_ENABLE_TILING<br>
<br>
Signed-off-by: Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>><br>
---<br>
src/gallium/auxiliary/vl/vl_video_buffer.c | 3 +++<br>
src/gallium/include/pipe/p_video_codec.h | 1 +<br>
src/gallium/state_trackers/va/surface.c | 5 +++++<br>
3 files changed, 9 insertions(+)<br>
<br>
diff --git a/src/gallium/auxiliary/vl/vl_video_buffer.c b/src/gallium/auxiliary/vl/vl_video_buffer.c<br>
index 6cd2557..62f4aa9 100644<br>
--- a/src/gallium/auxiliary/vl/vl_video_buffer.c<br>
+++ b/src/gallium/auxiliary/vl/vl_video_buffer.c<br>
@@ -253,6 +253,9 @@ vl_video_buffer_template(struct pipe_resource *templ,<br>
templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;<br>
templ->usage = usage;<br>
<br>
+ if (tmpl->disable_tiling)<br>
+ templ->bind |= PIPE_BIND_LINEAR;<br>
+<br>
if (plane > 0) {<br>
if (tmpl->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {<br>
templ->width0 /= 2;<br>
diff --git a/src/gallium/include/pipe/p_video_codec.h b/src/gallium/include/pipe/p_video_codec.h<br>
index 196d00b..dbfffd9 100644<br>
--- a/src/gallium/include/pipe/p_video_codec.h<br>
+++ b/src/gallium/include/pipe/p_video_codec.h<br>
@@ -125,6 +125,7 @@ struct pipe_video_buffer<br>
enum pipe_video_chroma_format chroma_format;<br>
unsigned width;<br>
unsigned height;<br>
+ bool disable_tiling;<br>
bool interlaced;<br>
<br>
/**<br>
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c<br>
index c052c8f..f7043ad 100644<br>
--- a/src/gallium/state_trackers/va/surface.c<br>
+++ b/src/gallium/state_trackers/va/surface.c<br>
@@ -616,6 +616,11 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,<br>
<br>
switch (memory_type) {<br>
case VA_SURFACE_ATTRIB_MEM_TYPE_VA:<br>
+ /* The application will clear the TILING flag when the surface is<br>
+ * intended to be exported as dmabuf. */<br>
+ templat.disable_tiling = memory_attibute &&<br>
+ !(memory_attibute->flags & VA_SURFACE_EXTBUF_DESC_ENABLE_TILING);<br>
</blockquote>
The condition seems to be flipped, no ? Currently it's doing<br>
"disable_tiling = ENABLE_TILING_BIT_SET"<br>
<br>
Other than that, the idea is ok imho, although I'd appreciate<br>
Christian and others' feedback.<br>
<br>
A few things worth mentioning while looking around for this:<br>
- suface_from_external_memory should (must) also know about disable_tiling.<br>
- missing R in function name ^^ suRface_ ...<br>
- sometimes radeon (see r600_video_buffer_create) completely<br>
overwrites the existing flags, as opposed to just set the linear bit.<br>
Bug, intentional, worth adding a comment ?<br>
- in many cases nouveau won't create a linear surface as it's not<br>
using the above vl helper (hint, earlier suggesting about<br>
reworking/cleaning things up a bit, hint)<br>
</blockquote>
<br></div></div>
Yeah, agree deduplicating that code would probably be a good idea.<br>
<br>
I would also prefer to have all the bind flags in the pipe_video_buffer as well.<br>
<br>
Regards,<br>
Christian.<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks<br>
Emil<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div>