swr: [rasterizer memory] minify texture width before alignment
authorIlia Mirkin <imirkin@alum.mit.edu>
Fri, 18 Nov 2016 03:40:29 +0000 (22:40 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 22 Nov 2016 02:11:26 +0000 (21:11 -0500)
The minification should happen before alignment, not after. See similar
logic on ComputeLODOffsetY. The current logic requires unnecessarily
large textures when there's an initial NPOT size.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tim Rowley <timothy.o.rowley@intel.com>
src/gallium/drivers/swr/rasterizer/memory/TilingFunctions.h

index 11ed4518f2efb012ca4e9ab3881253b7fce1e0bc..350e44b37b5921c5a9fdb3b1e5caf0f10de5fe22 100644 (file)
@@ -284,8 +284,8 @@ INLINE void ComputeLODOffset1D(
         offset = GFX_ALIGN(curWidth, hAlign);
         for (uint32_t l = 1; l < lod; ++l)
         {
-            curWidth = GFX_ALIGN(std::max<uint32_t>(curWidth >> 1, 1U), hAlign);
-            offset += curWidth;
+            curWidth = std::max<uint32_t>(curWidth >> 1, 1U);
+            offset += GFX_ALIGN(curWidth, hAlign);
         }
 
         if (info.isSubsampled || info.isBC)