<div dir="auto">Ping</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri., Aug. 2, 2019, 19:13 Marek Olšák, <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank" rel="noreferrer">marek.olsak@amd.com</a>><br>
<br>
---<br>
src/mesa/state_tracker/st_cb_texture.c | 12 ++++++++++++<br>
1 file changed, 12 insertions(+)<br>
<br>
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c<br>
index 0edb3ea5c7e..1ace61863ff 100644<br>
--- a/src/mesa/state_tracker/st_cb_texture.c<br>
+++ b/src/mesa/state_tracker/st_cb_texture.c<br>
@@ -516,20 +516,32 @@ allocate_full_mipmap(const struct st_texture_object *stObj,<br>
return FALSE;<br>
<br>
if (stObj->base.BaseLevel == 0 && stObj->base.MaxLevel == 0)<br>
return FALSE;<br>
<br>
if (stObj->base.Sampler.MinFilter == GL_NEAREST ||<br>
stObj->base.Sampler.MinFilter == GL_LINEAR)<br>
/* not a mipmap minification filter */<br>
return FALSE;<br>
<br>
+ /* If the following sequence of GL calls is used:<br>
+ * glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, ...<br>
+ * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br>
+ *<br>
+ * we would needlessly allocate a mipmapped texture, because the initial<br>
+ * MinFilter is GL_NEAREST_MIPMAP_LINEAR. Catch this case and don't<br>
+ * allocate a mipmapped texture by default. This may cause texture<br>
+ * reallocation later, but GL_NEAREST_MIPMAP_LINEAR is pretty rare.<br>
+ */<br>
+ if (stObj->base.Sampler.MinFilter == GL_NEAREST_MIPMAP_LINEAR)<br>
+ return FALSE;<br>
+<br>
if (stObj->base.Target == GL_TEXTURE_3D)<br>
/* 3D textures are seldom mipmapped */<br>
return FALSE;<br>
<br>
return TRUE;<br>
}<br>
<br>
<br>
/**<br>
* Try to allocate a pipe_resource object for the given st_texture_object.<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>