summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-08-02 19:11:53 -0400
committerMarek Olšák <[email protected]>2019-08-12 14:52:17 -0400
commitd1ad4fda31a6883b7cb323b923b43a251b250a24 (patch)
tree9edf810600d744e5d55f7cc49d593785ce0184ba
parent5180a222c0058d0ecd23816151ffcdd158a0febc (diff)
st/mesa: don't allocate mipmapped texture for NEAREST_MIPMAP_LINEAR
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 0edb3ea5c7e..1ace61863ff 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -523,6 +523,18 @@ allocate_full_mipmap(const struct st_texture_object *stObj,
/* not a mipmap minification filter */
return FALSE;
+ /* If the following sequence of GL calls is used:
+ * glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, ...
+ * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ *
+ * we would needlessly allocate a mipmapped texture, because the initial
+ * MinFilter is GL_NEAREST_MIPMAP_LINEAR. Catch this case and don't
+ * allocate a mipmapped texture by default. This may cause texture
+ * reallocation later, but GL_NEAREST_MIPMAP_LINEAR is pretty rare.
+ */
+ if (stObj->base.Sampler.MinFilter == GL_NEAREST_MIPMAP_LINEAR)
+ return FALSE;
+
if (stObj->base.Target == GL_TEXTURE_3D)
/* 3D textures are seldom mipmapped */
return FALSE;