broadcom/vc5: Fix mipmap filtering enums.
authorEric Anholt <eric@anholt.net>
Thu, 2 Nov 2017 19:19:10 +0000 (12:19 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 7 Nov 2017 17:40:25 +0000 (09:40 -0800)
The ordering of the values was even less obvious than I thought, with both
the mip filter and the min filter being in different bits depending on
whether the mip filter is none.

Fixes piglit fs-textureLod-miplevels.shader_test

src/broadcom/cle/v3d_packet_v33.xml
src/gallium/drivers/vc5/vc5_emit.c

index c5f7a3d251484260c6b18fbead2336b5c13102fa..2b0665537e88104e1c85e5f26b26f259357d90c6 100644 (file)
     <value name="TRIANGLE_FAN_TF" value="22"/>
   </enum>
 
+  <enum name="TMU Filter" prefix="V3D_TMU_FILTER">
+    <!-- Names are mip filter, min filter, mag filter -->
+    <value name="MIN_LIN_MIP_NONE_MAG_LIN" value="0"/>
+    <value name="MIN_LIN_MIP_NONE_MAG_NEAR" value="1"/>
+    <value name="MIN_NEAR_MIP_NONE_MAG_LIN" value="2"/>
+    <value name="MIN_NEAR_MIP_NONE_MAG_NEAR" value="3"/>
+
+    <value name="MIN_NEAR_MIP_NEAR_MAG_LIN" value="4"/>
+    <value name="MIN_NEAR_MIP_NEAR_MAG_NEAR" value="5"/>
+    <value name="MIN_NEAR_MIP_LIN_MAG_LIN" value="6"/>
+    <value name="MIN_NEAR_MIP_LIN_MAG_NEAR" value="7"/>
+
+    <value name="MIN_LIN_MIP_NEAR_MAG_LIN" value="8"/>
+    <value name="MIN_LIN_MIP_NEAR_MAG_NEAR" value="9"/>
+    <value name="MIN_LIN_MIP_LIN_MAG_LIN" value="10"/>
+    <value name="MIN_LIN_MIP_LIN_MAG_NEAR" value="11"/>
+
+    <value name="ANISOTROPIC_2_1" value="12"/>
+    <value name="ANISOTROPIC_4_1" value="13"/>
+    <value name="ANISOTROPIC_8_1" value="14"/>
+    <value name="ANISOTROPIC_16_1" value="15"/>
+  </enum>
+
   <packet code="0" name="Halt"/>
   <packet code="1" name="NOP"/>
   <packet code="4" name="Flush"/>
 
     <field name="Texture base pointer" size="30" start="2" type="address"/>
 
-    <field name="Minification Filter" size="3" start="1" type="uint"/>
-    <field name="Magnification Filter" size="1" start="0" type="uint"/>
+    <field name="Filter" size="4" start="0" type="TMU Filter"/>
   </struct>
 
   <enum name="Texture Data Formats">
index 8a606c4990a8d3d355ebb62fcc77c9cd00c65739..ea646e7d51041fb7b6e54628b4750ca6236425f3 100644 (file)
@@ -149,20 +149,22 @@ emit_one_texture(struct vc5_context *vc5, struct vc5_texture_stateobj *stage_tex
                 mag_img_filter = PIPE_TEX_FILTER_NEAREST;
         }
 
-        bool min_nearest = (min_img_filter == PIPE_TEX_FILTER_NEAREST);
+        bool min_nearest = min_img_filter == PIPE_TEX_FILTER_NEAREST;
         switch (min_mip_filter) {
         case PIPE_TEX_MIPFILTER_NONE:
-                unpacked.minification_filter = 0 + min_nearest;
+                unpacked.filter += min_nearest ? 2 : 0;
                 break;
         case PIPE_TEX_MIPFILTER_NEAREST:
-                unpacked.minification_filter = 2 + !min_nearest;
+                unpacked.filter += min_nearest ? 4 : 8;
                 break;
         case PIPE_TEX_MIPFILTER_LINEAR:
-                unpacked.minification_filter = 4 + !min_nearest;
+                unpacked.filter += min_nearest ? 4 : 8;
+                unpacked.filter += 2;
                 break;
         }
-        unpacked.magnification_filter = (mag_img_filter ==
-                                         PIPE_TEX_FILTER_NEAREST);
+
+        if (mag_img_filter == PIPE_TEX_FILTER_NEAREST)
+                unpacked.filter++;
 
         uint8_t packed[cl_packet_length(TEXTURE_SHADER_STATE)];
         cl_packet_pack(TEXTURE_SHADER_STATE)(&job->indirect, packed, &unpacked);