panfrost: Add a minus(1) modifier to the Levels field
authorBoris Brezillon <boris.brezillon@collabora.com>
Wed, 18 Nov 2020 14:22:59 +0000 (15:22 +0100)
committerBoris Brezillon <boris.brezillon@collabora.com>
Wed, 25 Nov 2020 15:22:19 +0000 (16:22 +0100)
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7653>

src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml
src/panfrost/lib/pan_texture.c

index f32b991..dd761d5 100644 (file)
@@ -719,7 +719,7 @@ pandecode_texture_payload(mali_ptr payload,
          * properties, but dump extra
          * possibilities to futureproof */
 
-        int bitmap_count = levels + 1;
+        int bitmap_count = levels;
 
         /* Miptree for each face */
         if (dim == MALI_TEXTURE_DIMENSION_CUBE)
index 5587e3e..a115fd4 100644 (file)
     <field name="Texel ordering" size="4" start="2:24" type="Texture Layout"/>
     <field name="Unknown" size="1" start="2:28" type="bool" default="true"/>
     <field name="Manual stride" size="1" start="2:29" type="bool" default="false"/>
-    <field name="Levels" size="8" start="3:24" type="uint"/>
+    <field name="Levels" size="8" start="3:24" type="uint" modifier="minus(1)" default="1"/>
     <field name="Swizzle" size="12" start="4:0" type="uint"/>
   </struct>
 
     <field name="Height" size="16" start="1:16" type="uint" modifier="minus(1)"/>
     <field name="Swizzle" size="12" start="2:0" type="uint"/>
     <field name="Texel ordering" size="4" start="2:12" type="Texture Layout"/>
-    <field name="Levels" size="5" start="2:16" type="uint"/>
+    <field name="Levels" size="5" start="2:16" type="uint" default="1" modifier="minus(1)"/>
     <field name="Minimum level" size="5" start="2:24" type="uint"/>
     <field name="Minimum LOD" size="13" start="3:0" type="uint" default="0"/>
     <field name="Sample count" size="3" start="3:13" type="uint" default="1" modifier="log2"/>
index 23f4679..38cb6aa 100644 (file)
@@ -401,7 +401,7 @@ panfrost_new_texture(
                 cfg.dimension = dim;
                 cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
                 cfg.manual_stride = manual_stride;
-                cfg.levels = last_level - first_level;
+                cfg.levels = last_level - first_level + 1;
                 cfg.swizzle = swizzle;
         };
 
@@ -480,14 +480,14 @@ panfrost_new_texture_bifrost(
                         cfg.sample_count = MAX2(nr_samples, 1);
                 cfg.swizzle = swizzle;
                 cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
-                cfg.levels = last_level - first_level;
+                cfg.levels = last_level - first_level + 1;
                 cfg.array_size = array_size;
                 cfg.surfaces = payload->gpu;
 
                 /* We specify API-level LOD clamps in the sampler descriptor
                  * and use these clamps simply for bounds checking */
                 cfg.minimum_lod = FIXED_16(0, false);
-                cfg.maximum_lod = FIXED_16(cfg.levels, false);
+                cfg.maximum_lod = FIXED_16(cfg.levels - 1, false);
         }
 }