panfrost/midgard: Implement integer sampler
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 26 Jun 2019 23:12:28 +0000 (16:12 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 28 Jun 2019 22:09:07 +0000 (15:09 -0700)
Turns out one of the magic bits in the texture instruction meant
'float'. Different magic bits mean int and uint then :)

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/midgard/disassemble.c
src/gallium/drivers/panfrost/midgard/midgard.h
src/gallium/drivers/panfrost/midgard/midgard_compile.c

index ee1634430a1247833d57b0359dca3fc66aec289a..f82f34978214bc56c5dbcf96f6290dc3b8c75a98 100644 (file)
@@ -1083,6 +1083,22 @@ texture_op_takes_bias(unsigned op)
         return op == TEXTURE_OP_NORMAL;
 }
 
+static char
+sampler_type_name(enum mali_sampler_type t)
+{
+        switch (t) {
+                case MALI_SAMPLER_FLOAT:
+                        return 'f';
+                case MALI_SAMPLER_UNSIGNED:
+                        return 'u';
+                case MALI_SAMPLER_SIGNED:
+                        return 'i';
+                default:
+                        return '?';
+        }
+
+}
+
 #undef DEFINE_CASE
 
 static void
@@ -1117,6 +1133,8 @@ print_texture_word(uint32_t *word, unsigned tabs)
 
         printf("texture%d, ", texture->texture_handle);
 
+        /* Print the type, GL style */
+        printf("%c", sampler_type_name(texture->sampler_type));
         printf("sampler%d", texture->sampler_handle);
         print_swizzle_vec4(texture->swizzle, false, false);
         printf(", ");
@@ -1233,10 +1251,6 @@ print_texture_word(uint32_t *word, unsigned tabs)
                 printf("// unknownA = 0x%x\n", texture->unknownA);
                 printf("// unknown8 = 0x%x\n", texture->unknown8);
         }
-
-        /* Don't blow up */
-        if (texture->unknown7 != 0x1)
-                printf("// (!) unknown7 = %d\n", texture->unknown7);
 }
 
 void
index 3d11126d95348141581ea857e5a24d2f731667d7..0a121c3a5b40ca1e4abdf9a648cef12f510984b1 100644 (file)
@@ -544,6 +544,13 @@ __attribute__((__packed__))
 #define TEXTURE_OP_LOD 0x12             /* textureLod */
 #define TEXTURE_OP_TEXEL_FETCH 0x14     /* texelFetch */
 
+enum mali_sampler_type {
+        MALI_SAMPLER_UNK        = 0x0,
+        MALI_SAMPLER_FLOAT      = 0x1, /* sampler */
+        MALI_SAMPLER_UNSIGNED   = 0x2, /* usampler */
+        MALI_SAMPLER_SIGNED     = 0x3, /* isampler */
+};
+
 typedef struct
 __attribute__((__packed__))
 {
@@ -586,8 +593,7 @@ __attribute__((__packed__))
 
         unsigned out_full  : 1;
 
-        /* Always 1 afaict... */
-        unsigned unknown7  : 2;
+        enum mali_sampler_type sampler_type : 2;
 
         unsigned out_reg_select : 1;
         unsigned out_upper : 1;
index 9e6ba5d39cf0acee5181b8185c625df4f73fdc5e..da01c9d67809e643206fe998eb476ef48686aca2 100644 (file)
@@ -1455,6 +1455,21 @@ pan_attach_constant_bias(
         return true;
 }
 
+static enum mali_sampler_type
+midgard_sampler_type(nir_alu_type t)
+{
+        switch (nir_alu_type_get_base_type(t)) {
+                case nir_type_float:
+                        return MALI_SAMPLER_FLOAT;
+                case nir_type_int:
+                        return MALI_SAMPLER_SIGNED;
+                case nir_type_uint:
+                        return MALI_SAMPLER_UNSIGNED;
+                default:
+                        unreachable("Unknown sampler type");
+        }
+}
+
 static void
 emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
                  unsigned midgard_texop)
@@ -1492,8 +1507,7 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
                         .in_reg_full = 1,
                         .out_full = 1,
 
-                        /* Always 1 */
-                        .unknown7 = 1,
+                        .sampler_type = midgard_sampler_type(instr->dest_type),
                 }
         };