panfrost: Treat texture dimension as first-class
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 5 Aug 2020 22:11:15 +0000 (18:11 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 6 Aug 2020 23:54:24 +0000 (23:54 +0000)
Instead of hiding behind a cmdstream enum. The raw values have a very
simple interpretation as dimension.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6196>

src/panfrost/midgard/disassemble.c
src/panfrost/midgard/midgard.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_derivatives.c

index 9ffbf4956185d27a499b4a05b8417262b053ce87..4e54f280c844d5cb007da2947c9d529eabba9c0c 100644 (file)
@@ -1282,10 +1282,10 @@ print_texture_format(FILE *fp, int format)
         fprintf(fp, ".");
 
         switch (format) {
-                DEFINE_CASE(MALI_TEX_1D, "1d");
-                DEFINE_CASE(MALI_TEX_2D, "2d");
-                DEFINE_CASE(MALI_TEX_3D, "3d");
-                DEFINE_CASE(MALI_TEX_CUBE, "cube");
+                DEFINE_CASE(1, "1d");
+                DEFINE_CASE(2, "2d");
+                DEFINE_CASE(3, "3d");
+                DEFINE_CASE(0, "cube");
 
         default:
                 unreachable("Bad format");
index d93b845098b32f0ef086f36a697eebe0a6e5d743..bcda23262f0c671048832d875eceb0b9bd451923 100644 (file)
@@ -679,7 +679,7 @@ __attribute__((__packed__))
         unsigned cont  : 1;
         unsigned last  : 1;
 
-        enum mali_texture_type format : 2;
+        unsigned format : 2;
 
         /* Are sampler_handle/texture_handler respectively set by registers? If
          * true, the lower 8-bits of the respective field is a register word.
index 174013f42fa62a0f9516850a4175650da47da59f..50260d577d2d0bb037754de80345d5f475039e1b 100644 (file)
@@ -1973,25 +1973,26 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
         }
 }
 
+/* Returns dimension with 0 special casing cubemaps */
 static unsigned
 midgard_tex_format(enum glsl_sampler_dim dim)
 {
         switch (dim) {
         case GLSL_SAMPLER_DIM_1D:
         case GLSL_SAMPLER_DIM_BUF:
-                return MALI_TEX_1D;
+                return 1;
 
         case GLSL_SAMPLER_DIM_2D:
         case GLSL_SAMPLER_DIM_MS:
         case GLSL_SAMPLER_DIM_EXTERNAL:
         case GLSL_SAMPLER_DIM_RECT:
-                return MALI_TEX_2D;
+                return 2;
 
         case GLSL_SAMPLER_DIM_3D:
-                return MALI_TEX_3D;
+                return 3;
 
         case GLSL_SAMPLER_DIM_CUBE:
-                return MALI_TEX_CUBE;
+                return 0;
 
         default:
                 DBG("Unknown sampler dim type\n");
index ca31f0a37ce58e0318187972e130b8f150e78847..29f459418e18a09cc16f85b1abcdddbdaf91b7a2 100644 (file)
@@ -108,7 +108,7 @@ midgard_emit_derivatives(compiler_context *ctx, nir_alu_instr *instr)
                 .src_types = { nir_type_float32, nir_type_float32 },
                 .op = mir_derivative_op(instr->op),
                 .texture = {
-                        .format = MALI_TEX_2D,
+                        .format = 2,
                         .in_reg_full = 1,
                         .out_full = 1,
                         .sampler_type = MALI_SAMPLER_FLOAT,