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@collabora.com>
This commit is contained in:
Alyssa Rosenzweig 2019-06-26 16:12:28 -07:00
parent 7d30000628
commit e32af4b5c3
3 changed files with 42 additions and 8 deletions

View 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

View 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;

View 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),
}
};