[Mesa-stable] [PATCH 1/2] st/mesa: directly compute level=0 texture size in st_finalize_texture
Nicolai Hähnle
nhaehnle at gmail.com
Tue Jun 7 21:19:47 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
The width0/height0/depth0 on stObj may not have been set at this point.
Observed in a trace that set up levels 2..9 of a 2d texture, and set the base
level to 2, with height 1. This made the guess logic always bail.
Originally investigated by Ilia Mirkin, this patch makes sure we always get a
pipe texture whose level=0 dimensions are compatible with the base level image
of the texture.
Fixes the gl-1.2-texture-base-level piglit test provided by Brian Paul.
Cc: "12.0" <mesa-stable at lists.freedesktop.org>
---
src/mesa/state_tracker/st_cb_texture.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 44e21b1..1604993 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -2478,22 +2478,21 @@ st_finalize_texture(struct gl_context *ctx,
/* Find size of level=0 Gallium mipmap image, plus number of texture layers */
{
GLuint width, height, depth;
- if (!guess_base_level_size(stObj->base.Target,
- firstImage->base.Width2,
- firstImage->base.Height2,
- firstImage->base.Depth2,
- firstImage->base.Level,
- &width, &height, &depth)) {
- width = stObj->width0;
- height = stObj->height0;
- depth = stObj->depth0;
- } else {
- /* The width/height/depth may have been previously reset in
- * guess_and_alloc_texture. */
- stObj->width0 = width;
- stObj->height0 = height;
- stObj->depth0 = depth;
- }
+
+ width = firstImage->base.Width2;
+ if (width > 1)
+ width <<= firstImage->base.Level;
+ height = firstImage->base.Height2;
+ if (stObj->base.Target != GL_TEXTURE_1D_ARRAY && height > 1)
+ height <<= firstImage->base.Level;
+ depth = firstImage->base.Depth2;
+ if (stObj->base.Target == GL_TEXTURE_3D && depth > 1)
+ depth <<= firstImage->base.Level;
+
+ stObj->width0 = width;
+ stObj->height0 = height;
+ stObj->depth0 = depth;
+
/* convert GL dims to Gallium dims */
st_gl_texture_dims_to_pipe_dims(stObj->base.Target, width, height, depth,
&ptWidth, &ptHeight, &ptDepth, &ptLayers);
--
2.7.4
More information about the mesa-stable
mailing list