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 <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6326>
This commit is contained in:
Alyssa Rosenzweig 2020-08-11 22:26:03 -04:00 committed by Marge Bot
parent c5f18ce144
commit 668ec24bfd
5 changed files with 21 additions and 64 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -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. */

View File

@ -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");
}

View File

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