vc4: Fix multi-level texture setup.
authorEric Anholt <eric@anholt.net>
Mon, 18 Aug 2014 17:31:36 +0000 (10:31 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 18 Aug 2014 22:27:43 +0000 (15:27 -0700)
We weren't accounting for the level 0 offset in the texture setup (so it
only worked if it happened to be a single-level texture), and doing so
required that we get the level 0 offset page aligned so that the offset
bits don't get interpreted as the texture format and such.

src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_resource.c

index f7791abb9468df0f446c005f3e7017a03e4f747c..642595b70d7ff5dcd86e3edb51ca70da255ae1cf 100644 (file)
@@ -1403,7 +1403,7 @@ write_texture_p0(struct vc4_context *vc4,
         struct vc4_resource *rsc = vc4_resource(texture->texture);
 
         cl_reloc(vc4, &vc4->uniforms, rsc->bo,
-                 texture->u.tex.last_level);
+                 rsc->slices[0].offset | texture->u.tex.last_level);
 }
 
 static void
index 3dad566a0026d566acfecbe3214c3c3ba57621ba..e0c0c7bdd42583aec4796f4594d8ae4d6496839c 100644 (file)
@@ -147,7 +147,17 @@ vc4_setup_slices(struct vc4_resource *rsc)
                  */
                 offset += slice->size0 * depth;
         }
-        /* XXX: align level 0 offset? */
+
+        /* The texture base pointer that has to point to level 0 doesn't have
+         * intra-page bits, so we have to align it, and thus shift up all the
+         * smaller slices.
+         */
+        uint32_t page_align_offset = (align(rsc->slices[0].offset, 4096) -
+                                      rsc->slices[0].offset);
+        if (page_align_offset) {
+                for (int i = 0; i <= prsc->last_level; i++)
+                        rsc->slices[i].offset += page_align_offset;
+        }
 }
 
 static struct vc4_resource *