Mesa (master): panfrost/midgard: Implement integer sampler
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 28 22:10:48 UTC 2019
Module: Mesa
Branch: master
Commit: e32af4b5c360cd12771cd73001415c5f16fa40f7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e32af4b5c360cd12771cd73001415c5f16fa40f7
Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date: Wed Jun 26 16:12:28 2019 -0700
panfrost/midgard: Implement integer sampler
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 at collabora.com>
---
src/gallium/drivers/panfrost/midgard/disassemble.c | 22 ++++++++++++++++++----
src/gallium/drivers/panfrost/midgard/midgard.h | 10 ++++++++--
.../drivers/panfrost/midgard/midgard_compile.c | 18 ++++++++++++++++--
3 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/panfrost/midgard/disassemble.c b/src/gallium/drivers/panfrost/midgard/disassemble.c
index ee1634430a1..f82f3497821 100644
--- a/src/gallium/drivers/panfrost/midgard/disassemble.c
+++ b/src/gallium/drivers/panfrost/midgard/disassemble.c
@@ -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
diff --git a/src/gallium/drivers/panfrost/midgard/midgard.h b/src/gallium/drivers/panfrost/midgard/midgard.h
index 3d11126d953..0a121c3a5b4 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard.h
+++ b/src/gallium/drivers/panfrost/midgard/midgard.h
@@ -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;
diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index 9e6ba5d39cf..da01c9d6780 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -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),
}
};
More information about the mesa-commit
mailing list