From 668ec24bfdb58090b769a51327ce81dd64da5eec Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 11 Aug 2020 22:26:03 -0400 Subject: [PATCH] panfrost: Squash 22-bit format field in attr_meta This is an intermediate step to support v7 style formats. Now we don't see the mali_format alone, instead together with the swizzle (and sRGB flag, unused for attributes of course). Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 19 +++++---- src/gallium/drivers/panfrost/pan_context.c | 16 ++++---- src/panfrost/include/panfrost-job.h | 6 +-- src/panfrost/lib/decode.c | 41 +------------------- src/panfrost/lib/pan_blit.c | 3 +- 5 files changed, 21 insertions(+), 64 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 31c19679b6a..3e260bca0c6 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1657,14 +1657,14 @@ pan_emit_vary(unsigned present, enum pan_special_varying buf, unsigned offset) { unsigned nr_channels = MALI_EXTRACT_CHANNELS(format); + unsigned swizzle = quirks & HAS_SWIZZLES ? + panfrost_get_default_swizzle(nr_channels) : + panfrost_bifrost_swizzle(nr_channels); struct mali_attr_meta meta = { .index = pan_varying_index(present, buf), .unknown1 = quirks & IS_BIFROST ? 0x0 : 0x2, - .swizzle = quirks & HAS_SWIZZLES ? - panfrost_get_default_swizzle(nr_channels) : - panfrost_bifrost_swizzle(nr_channels), - .format = format, + .format = (format << 12) | swizzle, .src_offset = offset }; @@ -1718,6 +1718,10 @@ pan_emit_vary_xfb(unsigned present, enum mali_format format, struct pipe_stream_output o) { + unsigned swizzle = quirks & HAS_SWIZZLES ? + panfrost_get_default_swizzle(o.num_components) : + panfrost_bifrost_swizzle(o.num_components); + /* Otherwise construct a record for it */ struct mali_attr_meta meta = { /* XFB buffers come after everything else */ @@ -1726,13 +1730,8 @@ pan_emit_vary_xfb(unsigned present, /* As usual unknown bit */ .unknown1 = quirks & IS_BIFROST ? 0x0 : 0x2, - /* Override swizzle with number of channels */ - .swizzle = quirks & HAS_SWIZZLES ? - panfrost_get_default_swizzle(o.num_components) : - panfrost_bifrost_swizzle(o.num_components), - /* Override number of channels and precision to highp */ - .format = pan_xfb_format(format, o.num_components), + .format = (pan_xfb_format(format, o.num_components) << 12) | swizzle, /* Apply given offsets together */ .src_offset = (o.dst_offset * 4) /* dwords */ diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 0efe0a90fc3..736954745e9 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -507,28 +507,28 @@ panfrost_create_vertex_elements_state( const struct util_format_description *desc = util_format_description(fmt); so->hw[i].unknown1 = 0x2; + unsigned swizzle = 0; if (dev->quirks & HAS_SWIZZLES) - so->hw[i].swizzle = panfrost_translate_swizzle_4(desc->swizzle); + swizzle = panfrost_translate_swizzle_4(desc->swizzle); else - so->hw[i].swizzle = panfrost_bifrost_swizzle(desc->nr_channels); + swizzle = panfrost_bifrost_swizzle(desc->nr_channels); enum mali_format hw_format = panfrost_pipe_format_table[desc->format].hw; - so->hw[i].format = hw_format; + so->hw[i].format = (hw_format << 12) | swizzle; assert(hw_format); } /* Let's also prepare vertex builtins */ so->hw[PAN_VERTEX_ID].format = MALI_R32UI; if (dev->quirks & HAS_SWIZZLES) - so->hw[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1); + so->hw[PAN_VERTEX_ID].format = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1); else - so->hw[PAN_VERTEX_ID].swizzle = panfrost_bifrost_swizzle(1); + so->hw[PAN_VERTEX_ID].format = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1); - so->hw[PAN_INSTANCE_ID].format = MALI_R32UI; if (dev->quirks & HAS_SWIZZLES) - so->hw[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1); + so->hw[PAN_INSTANCE_ID].format = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1); else - so->hw[PAN_INSTANCE_ID].swizzle = panfrost_bifrost_swizzle(1); + so->hw[PAN_INSTANCE_ID].format = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1); return so; } diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 5be15a5f42f..34d3e98f5c4 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -730,11 +730,7 @@ struct mali_attr_meta { u8 index; unsigned unknown1 : 2; - unsigned swizzle : 12; - enum mali_format format : 8; - - /* Always observed to be zero at the moment */ - unsigned unknown3 : 2; + unsigned format : 22; /* When packing multiple attributes in a buffer, offset addresses by * this value. Obscurely, this is signed. */ diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index 54f84742b71..06b381626dc 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -1551,38 +1551,6 @@ pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_p attr_meta = pandecode_fetch_gpu_mem(attr_mem, p, sizeof(*attr_mem)); - /* If the record is discard, it should be zero for everything else */ - - if (attr_meta->format == MALI_VARYING_DISCARD) { - uint64_t zero = - attr_meta->index | - attr_meta->unknown1 | - attr_meta->unknown3 | - attr_meta->src_offset; - - if (zero) - pandecode_msg("XXX: expected empty record for varying discard\n"); - - /* We want to look for a literal 0000 swizzle -- this - * is not encoded with all zeroes, however */ - - enum mali_channel z = MALI_CHANNEL_ZERO; - unsigned zero_swizzle = z | (z << 3) | (z << 6) | (z << 9); - bool good_swizzle = attr_meta->swizzle == zero_swizzle; - - if (!good_swizzle) - pandecode_msg("XXX: expected zero swizzle for discard\n"); - - if (!varying) - pandecode_msg("XXX: cannot discard attribute\n"); - - /* If we're all good, omit the record */ - if (!zero && varying && good_swizzle) { - pandecode_log("/* discarded varying */\n"); - continue; - } - } - if (attr_meta->index > max_index) max_index = attr_meta->index; @@ -1591,17 +1559,12 @@ pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_p pandecode_prop("unknown1 = 0x%" PRIx64, (u64) attr_meta->unknown1); } - if (attr_meta->unknown3) { - pandecode_msg("XXX: unexpected unknown3 set\n"); - pandecode_prop("unknown3 = 0x%" PRIx64, (u64) attr_meta->unknown3); - } - - pandecode_log_cont("%s %s_%u", mali_format_as_str(attr_meta->format), prefix, attr_meta->index); + pandecode_log_cont("%s %s_%u", mali_format_as_str(attr_meta->format >> 12), prefix, attr_meta->index); if (attr_meta->src_offset) pandecode_log_cont("[%u]", attr_meta->src_offset); - pandecode_swizzle(attr_meta->swizzle, attr_meta->format); + pandecode_swizzle(attr_meta->format & ((1 << 12) - 1), attr_meta->format >> 12); pandecode_log_cont(";\n"); } diff --git a/src/panfrost/lib/pan_blit.c b/src/panfrost/lib/pan_blit.c index 836f4ad3485..fbc34600390 100644 --- a/src/panfrost/lib/pan_blit.c +++ b/src/panfrost/lib/pan_blit.c @@ -203,8 +203,7 @@ panfrost_load_midg( struct mali_attr_meta varying_meta = { .index = 0, .unknown1 = 2, - .swizzle = (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3), - .format = MALI_RGBA32F + .format = (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) | (MALI_RGBA32F << 12) }; struct mali_stencil_packed stencil; -- 2.30.2