<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>