From 9ac106defe351428fbe3c62547e6be918b603d32 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Tue, 2 Jun 2020 14:13:03 +1200 Subject: [PATCH] panfrost: Decode AFBC flag bits Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_mfbd.c | 4 ++-- src/panfrost/include/panfrost-job.h | 11 ++++++++-- src/panfrost/pandecode/decode.c | 27 +++++++++++++++++-------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 552da168690..4b762d1b646 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -241,7 +241,7 @@ panfrost_mfbd_set_cbuf( rt->framebuffer = base + header_size; rt->afbc.metadata = base; rt->afbc.stride = 0; - rt->afbc.unk = 0x30009; + rt->afbc.flags = MALI_AFBC_FLAGS | MALI_AFBC_YTR; /* TODO: The blob sets this to something nonzero, but it's not * clear what/how to calculate/if it matters */ @@ -285,7 +285,7 @@ panfrost_mfbd_set_zsbuf( fbx->ds_afbc.depth_stencil_afbc_metadata = base; fbx->ds_afbc.depth_stencil_afbc_stride = 0; - fbx->ds_afbc.zero1 = 0x10009; + fbx->ds_afbc.flags = MALI_AFBC_FLAGS; fbx->ds_afbc.padding = 0x1000; } else if (rsrc->layout == MALI_TEXTURE_LINEAR || rsrc->layout == MALI_TEXTURE_TILED) { /* TODO: Z32F(S8) support, which is always linear */ diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 1edef5d2fe8..0008bb18015 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -1690,6 +1690,13 @@ struct mali_rt_format { unsigned no_preload : 1; } __attribute__((packed)); +/* Flags for afbc.flags and ds_afbc.flags */ + +#define MALI_AFBC_FLAGS 0x10009 + +/* Lossless RGB and RGBA colorspace transform */ +#define MALI_AFBC_YTR (1 << 17) + struct mali_render_target { struct mali_rt_format format; @@ -1708,7 +1715,7 @@ struct mali_render_target { mali_ptr metadata; u32 stride; // stride in units of tiles - u32 unk; // = 0x20000 + u32 flags; // = 0x20000 } afbc; mali_ptr framebuffer; @@ -1752,7 +1759,7 @@ struct mali_framebuffer_extra { struct { mali_ptr depth_stencil_afbc_metadata; u32 depth_stencil_afbc_stride; // in units of tiles - u32 zero1; + u32 flags; mali_ptr depth_stencil; diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index 8c42a575ba5..f9bfa190fbf 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -248,6 +248,13 @@ static const struct pandecode_flag_info mfbd_fmt_flag_info[] = { }; #undef FLAG_INFO +#define FLAG_INFO(flag) { MALI_AFBC_##flag, "MALI_AFBC_" #flag } +static const struct pandecode_flag_info afbc_fmt_flag_info[] = { + FLAG_INFO(YTR), + {} +}; +#undef FLAG_INFO + #define FLAG_INFO(flag) { MALI_EXTRA_##flag, "MALI_EXTRA_" #flag } static const struct pandecode_flag_info mfbd_extra_flag_hi_info[] = { FLAG_INFO(PRESENT), @@ -1056,15 +1063,18 @@ pandecode_render_target(uint64_t gpu_va, unsigned job_no, const struct mali_fram free(a); pandecode_prop("stride = %d", rt->afbc.stride); - pandecode_prop("unk = 0x%" PRIx32, rt->afbc.unk); + + pandecode_log(".flags = "); + pandecode_log_decoded_flags(afbc_fmt_flag_info, rt->afbc.flags); + pandecode_log_cont(",\n"); pandecode_indent--; pandecode_log("},\n"); - } else if (rt->afbc.metadata || rt->afbc.stride || rt->afbc.unk) { + } else if (rt->afbc.metadata || rt->afbc.stride || rt->afbc.flags) { pandecode_msg("XXX: AFBC disabled but AFBC field set (0x%lX, 0x%x, 0x%x)\n", rt->afbc.metadata, rt->afbc.stride, - rt->afbc.unk); + rt->afbc.flags); } MEMORY_PROP(rt, framebuffer); @@ -1234,12 +1244,13 @@ pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_comput fbx->ds_afbc.depth_stencil_afbc_stride); MEMORY_PROP_DIR(fbx->ds_afbc, depth_stencil); - if (fbx->ds_afbc.zero1 || fbx->ds_afbc.padding) { + pandecode_log(".flags = "); + pandecode_log_decoded_flags(afbc_fmt_flag_info, fbx->ds_afbc.flags); + pandecode_log_cont(",\n"); + + if (fbx->ds_afbc.padding) { pandecode_msg("XXX: Depth/stencil AFBC zeros tripped\n"); - pandecode_prop("zero1 = 0x%" PRIx32, - fbx->ds_afbc.zero1); - pandecode_prop("padding = 0x%" PRIx64, - fbx->ds_afbc.padding); + pandecode_prop("padding = 0x%" PRIx64, fbx->ds_afbc.padding); } pandecode_indent--; -- 2.30.2