<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 6, 2017 at 10:18 AM, Daniel Stone <span dir="ltr"><<a href="mailto:daniels@collabora.com" target="_blank">daniels@collabora.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Varad Gautam <<a href="mailto:varad.gautam@collabora.com">varad.gautam@collabora.com</a>><br>
<br>
v2: Rebase and reuse tiling/modifier map. (Daniel Stone)<br>
v3: bump DRIimageExtension to version 15, fill external_only array.<br>
<br>
Signed-off-by: Varad Gautam <<a href="mailto:varadgautam@gmail.com">varadgautam@gmail.com</a>><br>
Signed-off-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/<wbr>intel_screen.c | 76 ++++++++++++++++++++++++++++++<wbr>--<br>
 1 file changed, 72 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
index e7d2af7852..10835f991a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
@@ -294,14 +294,15 @@ static struct intel_image_format intel_image_formats[] = {<br>
 static const struct {<br>
  Â  uint32_t tiling;<br>
  Â  uint64_t modifier;<br>
+  Â unsigned since_gen;<br>
  Â  unsigned height_align;<br>
 } tiling_modifier_map[] = {<br>
  Â  { .tiling = I915_TILING_NONE, .modifier = DRM_FORMAT_MOD_LINEAR,<br>
-  Â  Â .height_align = 1 },<br>
+  Â  Â .since_gen = 1, .height_align = 1 },<br>
  Â  { .tiling = I915_TILING_X, .modifier = I915_FORMAT_MOD_X_TILED,<br>
-  Â  Â .height_align = 8 },<br>
+  Â  Â .since_gen = 1, .height_align = 8 },<br>
  Â  { .tiling = I915_TILING_Y, .modifier = I915_FORMAT_MOD_Y_TILED,<br>
-  Â  Â .height_align = 32 },<br>
+  Â  Â .since_gen = 9, .height_align = 32 },<br></blockquote><div><br></div><div>This is wrong.  Scanout may only support the Y-tiling modifier on gen9+ but mesa should support it on at least gen6+.  (We could probably support it all the way back to gen4 eventually but that's tricky with the number of blitter paths we have.)  We very badly want Y-tiling for windowed surfaces.  With since_gen changed to 6 for Y_TILED, the series is<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 };<br>
<br>
 static bool<br>
@@ -1014,6 +1015,71 @@ intel_create_image_from_dma_<wbr>bufs(__DRIscreen *dri_screen,<br>
  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â loaderPrivate);<br>
 }<br>
<br>
+static GLboolean<br>
+intel_query_dma_buf_formats(_<wbr>_DRIscreen *screen, int max,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  int *formats, int *count)<br>
+{<br>
+  Â int i, j = 0;<br>
+<br>
+  Â if (max == 0) {<br>
+  Â  Â  *count = ARRAY_SIZE(intel_image_<wbr>formats) - 1; /* not SARGB */<br>
+  Â  Â  return true;<br>
+  Â }<br>
+<br>
+  Â for (i = 0; i < (ARRAY_SIZE(intel_image_<wbr>formats)) && j < max; i++) {<br>
+  Â  Â if (intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SARGB8888)<br>
+  Â  Â  Â continue;<br>
+  Â  Â formats[j++] = intel_image_formats[i].fourcc;<br>
+  Â }<br>
+<br>
+  Â *count = j;<br>
+  Â return true;<br>
+}<br>
+<br>
+static GLboolean<br>
+intel_query_dma_buf_<wbr>modifiers(__DRIscreen *_screen, int fourcc, int max,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  uint64_t *modifiers,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  unsigned int *external_only,<br>
+  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  int *count)<br>
+{<br>
+  Â struct intel_screen *screen = _screen->driverPrivate;<br>
+  Â struct intel_image_format *f;<br>
+  Â int num_mods = 0, i;<br>
+<br>
+  Â f = intel_image_format_lookup(<wbr>fourcc);<br>
+  Â if (f == NULL)<br>
+  Â  Â  return false;<br>
+<br>
+  Â for (i = 0; i < ARRAY_SIZE(tiling_modifier_<wbr>map); i++) {<br>
+  Â  Â  if (screen->devinfo.gen < tiling_modifier_map[i].since_<wbr>gen)<br>
+  Â  Â  Â  Â continue;<br>
+<br>
+  Â  Â  num_mods++;<br>
+  Â  Â  if (max == 0)<br>
+  Â  Â  Â  Â continue;<br>
+<br>
+  Â  Â  modifiers[num_mods - 1] = tiling_modifier_map[i].<wbr>modifier;<br>
+  Â  Â  if (num_mods >= max)<br>
+  Â  Â  Â  break;<br>
+  Â }<br>
+<br>
+  Â if (external_only != NULL) {<br>
+  Â  Â  for (i = 0; i < num_mods && i < max; i++) {<br>
+  Â  Â  Â  Â if (f->components == __DRI_IMAGE_COMPONENTS_Y_U_V ||<br>
+  Â  Â  Â  Â  Â  Â f->components == __DRI_IMAGE_COMPONENTS_Y_UV ||<br>
+  Â  Â  Â  Â  Â  Â f->components == __DRI_IMAGE_COMPONENTS_Y_XUXV) {<br>
+  Â  Â  Â  Â  Â  external_only[i] = GL_TRUE;<br>
+  Â  Â  Â  Â }<br>
+  Â  Â  Â  Â else {<br>
+  Â  Â  Â  Â  Â  external_only[i] = GL_FALSE;<br>
+  Â  Â  Â  Â }<br>
+  Â  Â  }<br>
+  Â }<br>
+<br>
+  Â *count = num_mods;<br>
+  Â return true;<br>
+}<br>
+<br>
 static __DRIimage *<br>
 intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)<br>
 {<br>
@@ -1061,7 +1127,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)<br>
 }<br>
<br>
 static const __DRIimageExtension intelImageExtension = {<br>
-  Â  .base = { __DRI_IMAGE, 14 },<br>
+  Â  .base = { __DRI_IMAGE, 15 },<br>
<br>
  Â  Â .createImageFromName  Â  Â  Â  Â  Â  Â  Â  = intel_create_image_from_name,<br>
  Â  Â .createImageFromRenderbuffer  Â  Â  Â  = intel_create_image_from_<wbr>renderbuffer,<br>
@@ -1081,6 +1147,8 @@ static const __DRIimageExtension intelImageExtension = {<br>
  Â  Â .unmapImage  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â = NULL,<br>
  Â  Â .createImageWithModifiers  Â  Â  Â  Â  Â = intel_create_image_with_<wbr>modifiers,<br>
  Â  Â .createImageFromDmaBufs2  Â  Â  Â  Â  Â  = intel_create_image_from_dma_<wbr>bufs2,<br>
+  Â  .queryDmaBufFormats  Â  Â  Â  Â  Â  Â  Â  Â = intel_query_dma_buf_formats,<br>
+  Â  .queryDmaBufModifiers  Â  Â  Â  Â  Â  Â  Â = intel_query_dma_buf_modifiers,<br>
 };<br>
<br>
 static uint64_t<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
</font></span></blockquote></div><br></div></div>