<div dir="ltr"><div>For patches 1 - 5:</div><div><br></div><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 12, 2019 at 1:33 PM Lucas Stach <<a href="mailto:l.stach@pengutronix.de">l.stach@pengutronix.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If the driver supports multi-planar formats natively we don't want to<br>
re-write the format of the planes on import. Split this out in a<br>
separate function for clarity.<br>
<br>
Signed-off-by: Lucas Stach <<a href="mailto:l.stach@pengutronix.de" target="_blank">l.stach@pengutronix.de</a>><br>
---<br>
src/gallium/state_trackers/dri/dri2.c | 32 ++++++++++++++++++---------<br>
1 file changed, 22 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c<br>
index 4243a00cb38d..38a8e28ff439 100644<br>
--- a/src/gallium/state_trackers/dri/dri2.c<br>
+++ b/src/gallium/state_trackers/dri/dri2.c<br>
@@ -776,6 +776,24 @@ dri2_update_tex_buffer(struct dri_drawable *drawable,<br>
/* no-op */<br>
}<br>
<br>
+static enum pipe_format get_plane_format(struct pipe_screen *pscreen,<br>
+ enum pipe_format pf,<br>
+ enum pipe_texture_target target,<br>
+ unsigned usage, int plane)<br>
+{<br>
+<br>
+ /* If the driver supports the format natively, no need to re-write */<br>
+ if (pscreen->is_format_supported(pscreen, pf, target, 0, 0, usage))<br>
+ return pf;<br>
+<br>
+ if (pf == PIPE_FORMAT_IYUV || (pf == PIPE_FORMAT_NV12 && plane == 0))<br>
+ return PIPE_FORMAT_R8_UNORM;<br>
+<br>
+ if (pf == PIPE_FORMAT_NV12 && plane == 1)<br>
+ return PIPE_FORMAT_RG88_UNORM;<br>
+<br>
+ return PIPE_FORMAT_NONE;<br>
+}<br>
static __DRIimage *<br>
dri2_create_image_from_winsys(__DRIscreen *_screen,<br>
int width, int height, enum pipe_format pf,<br>
@@ -800,9 +818,9 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,<br>
/* YUV format sampling can be emulated by the Mesa state tracker by<br>
* using multiple R8/RG88 samplers. So try to rewrite the pipe format.<br>
*/<br>
- pf = PIPE_FORMAT_R8_UNORM;<br>
<br>
- if (pscreen->is_format_supported(pscreen, pf, screen->target, 0, 0,<br>
+ if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_R8_UNORM,<br>
+ screen->target, 0, 0,<br>
PIPE_BIND_SAMPLER_VIEW))<br>
tex_usage |= PIPE_BIND_SAMPLER_VIEW;<br>
}<br>
@@ -829,24 +847,18 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,<br>
case 0:<br>
templ.width0 = width;<br>
templ.height0 = height;<br>
- templ.format = pf;<br>
break;<br>
case 1:<br>
- templ.width0 = width / 2;<br>
- templ.height0 = height / 2;<br>
- templ.format = (num_handles == 2) ?<br>
- PIPE_FORMAT_RG88_UNORM : /* NV12, etc */<br>
- PIPE_FORMAT_R8_UNORM; /* I420, etc */<br>
- break;<br>
case 2:<br>
templ.width0 = width / 2;<br>
templ.height0 = height / 2;<br>
- templ.format = PIPE_FORMAT_R8_UNORM;<br>
break;<br>
default:<br>
unreachable("too many planes!");<br>
}<br>
<br>
+ templ.format = get_plane_format(pscreen, pf, screen->target, tex_usage, i);<br>
+<br>
tex = pscreen->resource_from_handle(pscreen,<br>
&templ, &whandle[i], PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE);<br>
if (!tex) {<br>
-- <br>
2.20.1<br>
<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div>