I took a stab at fixing this too. My raw patch is attached below. Very little testing.

-Brian

On 06/07/2016 04:06 PM, Nicolai Hähnle wrote:
Scratch that, there's a good reason to try to preserve the previous
texture size... working on yet another alternative.

On 07.06.2016 23:19, Nicolai Hähnle wrote:
From: Nicolai Hähnle <nicolai.haeh...@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-sta...@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);

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index d38f24c..1bc5ae6 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -351,11 +351,27 @@ guess_base_level_size(GLenum target,
          /* We can't make a good guess here, because the base level dimensions
           * can be non-square.
           */
-         if (width == 1 || height == 1) {
+         if (width > 1 && height > 1) {
+            /* grow width and height */
+            width <<= level;
+            height <<= level;
+         }
+         else if (width == 1 && height > 1) {
+            /* grow the height */
+            width = 1;
+            height <<= level;
+         }
+         else if (width > 1 && height == 1) {
+            /* grow the width */
+            width <<= level;
+            height = 1;
+         }
+         else {
+            assert(width == 1);
+            assert(height == 1);
+            /* can't guess size */
             return GL_FALSE;
          }
-         width <<= level;
-         height <<= level;
          break;
 
       case GL_TEXTURE_CUBE_MAP:
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to