<div dir="ltr"><div>I guess I should follow up with that I don't really care how the patch ends up or which six colors of the bikeshed we end up choosing. I just want you to be aware of why that patch fixes the bug,  why Eric is saying that we don't need MAX_LEVEL, and why GL is surprisingly difficult to get right.<br><br>Patch, as-is, is Reviewed-by: Jasper St. Pierre <<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 9, 2015 at 6:20 PM, Jasper St. Pierre <span dir="ltr"><<a href="mailto:jstpierre@mecheye.net" target="_blank">jstpierre@mecheye.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Well, either MAX_LEVEL / BASE_LEVEL or MIN_FILTER / MAG_FILTER will fix it.<br><br>Basically, a texture is only considered complete [0] when all of its usable mipmap levels have been defined. Either you set MAX_LEVEL to say it has 0 mipmaps (by default MAX_LEVEL is 1000), or you set MIN_FILTER / MAG_FILTER to say it doesn't use any mipmaps when sampling from it.<br><br></div>Another solution is to use glTexStorage2D to specify the number of mipmaps directly when defining internal texture storage.<br></div><div><br></div>[0] See 8.17, "TEXTURE COMPLETENESS", in the GL specification: <a href="https://www.opengl.org/registry/#apispecs" target="_blank">https://www.opengl.org/registry/#apispecs</a><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, Jan 9, 2015 at 5:39 PM, Keith Packard <span dir="ltr"><<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><span>Axel Davy <<a href="mailto:axel.davy@ens.fr" target="_blank">axel.davy@ens.fr</a>> writes:<br>
<br>
> Actually we went up with a solution, the final patch wasn't sent to ml<br>
> for a reason<br>
> I don't know or remember.<br>
><br>
> Recently someone else complaint of the bug and I linked him to a<br>
> preliminary patch we had,<br>
> and it fixed it for him.<br>
> The preliminary patch was<br>
> <a href="http://markus.members.selfnet.de/xorg/xwayland.patch" target="_blank">http://markus.members.selfnet.de/xorg/xwayland.patch</a><br>
><br>
<br>
</span>That's this patch:<br>
<br>
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c<br>
index 54af275..b127b96 100644<br>
--- a/glamor/glamor_egl.c<br>
+++ b/glamor/glamor_egl.c<br>
@@ -170,6 +170,7 @@ glamor_create_texture_from_image(ScreenPtr screen,<br>
     glBindTexture(GL_TEXTURE_2D, *texture);<br>
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);<br>
<br>
     glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);<br>
     glBindTexture(GL_TEXTURE_2D, 0);<br>
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c<br>
index 4be883f..7c2bd08 100644<br>
--- a/hw/xwayland/xwayland-glamor.c<br>
+++ b/hw/xwayland/xwayland-glamor.c<br>
@@ -137,6 +137,10 @@ xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, int depth)<br>
<br>
     glGenTextures(1, &xwl_pixmap->texture);<br>
     glBindTexture(GL_TEXTURE_2D, xwl_pixmap->texture);<br>
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);<br>
+<br>
     glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image);<br>
     glBindTexture(GL_TEXTURE_2D, 0);<br>
<br>
Eric says that we probably need the MIN_FILTER and MAG_FILTER bits, or<br>
you'll probably get black, but the MAX_LEVEL changes aren't necessary.<br>
<span><br>
> I think there was a more recent one, but I couldn't find it.<br>
<br>
</span>Let me know.<br>
<span><font color="#888888"><br>
--<br>
-keith<br>
</font></span><br></div></div><span class="">_______________________________________________<br>
<a href="mailto:xorg-devel@lists.x.org" target="_blank">xorg-devel@lists.x.org</a>: X.Org development<br>
Archives: <a href="http://lists.x.org/archives/xorg-devel" target="_blank">http://lists.x.org/archives/xorg-devel</a><br>
Info: <a href="http://lists.x.org/mailman/listinfo/xorg-devel" target="_blank">http://lists.x.org/mailman/listinfo/xorg-devel</a><br></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div>  Jasper<br></div>
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">  Jasper<br></div>
</div>