pvr: Cleanup compressed border colour support

To clear up the ambiguity of uncompressed/compressed formats:
  - Always use the correct enum type to refer to them, and
  - Split the border colour table into two halves so the compressed tex
    format enum can be used as an index directly without applying an
    offset.

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36412>
This commit is contained in:
Matt Coster 2023-10-25 10:13:22 +01:00 committed by Marge Bot
parent 5fd65333c2
commit c23f81cd11
3 changed files with 18 additions and 37 deletions

View file

@ -50,7 +50,8 @@ static_assert(sizeof(struct pvr_border_color_table_value) ==
"struct pvr_border_color_table_value must be 4 x u32");
struct pvr_border_color_table_entry {
struct pvr_border_color_table_value values[PVR_TEX_FORMAT_COUNT * 2];
struct pvr_border_color_table_value values[PVR_TEX_FORMAT_COUNT];
struct pvr_border_color_table_value compressed_values[PVR_TEX_FORMAT_COUNT];
} PACKED;
static inline void pvr_border_color_table_pack_single(
@ -95,6 +96,7 @@ static inline void pvr_border_color_table_pack_single_compressed(
struct pvr_border_color_table_value *const dst,
const union pipe_color_union *const color,
const struct pvr_tex_format_compressed_description *const pvr_tex_fmt_desc,
const bool is_int,
const struct pvr_device_info *const dev_info)
{
if (PVR_HAS_FEATURE(dev_info, tpu_border_colour_enhanced)) {
@ -104,7 +106,7 @@ static inline void pvr_border_color_table_pack_single_compressed(
pvr_border_color_table_pack_single(dst,
color,
pvr_tex_fmt_desc_simple,
false,
is_int,
dev_info);
return;
}
@ -146,28 +148,21 @@ pvr_border_color_table_fill_entry(struct pvr_border_color_table *const table,
{
struct pvr_border_color_table_entry *const entries = table->table->bo->map;
struct pvr_border_color_table_entry *const entry = &entries[index];
uint32_t tex_format = 0;
for (; tex_format < PVR_TEX_FORMAT_COUNT; tex_format++) {
if (!pvr_tex_format_is_supported(tex_format))
continue;
pvr_border_color_table_pack_single(
&entry->values[tex_format],
color,
pvr_get_tex_format_description(tex_format),
is_int,
dev_info);
pvr_foreach_supported_tex_format (tex_format, desc) {
pvr_border_color_table_pack_single(&entry->values[tex_format],
color,
desc,
is_int,
dev_info);
}
for (; tex_format < PVR_TEX_FORMAT_COUNT * 2; tex_format++) {
if (!pvr_tex_format_compressed_is_supported(tex_format))
continue;
pvr_foreach_supported_tex_format_compressed (tex_format, desc) {
pvr_border_color_table_pack_single_compressed(
&entry->values[tex_format],
&entry->compressed_values[tex_format],
color,
pvr_get_tex_format_compressed_description(tex_format),
desc,
is_int,
dev_info);
}
}

View file

@ -341,29 +341,15 @@ pvr_get_tex_format_description(const uint32_t tex_format)
return NULL;
}
bool pvr_tex_format_compressed_is_supported(uint32_t tex_format)
bool pvr_tex_format_compressed_is_supported(const uint32_t tex_format)
{
/* In some contexts, the sequence of compressed tex format ids are appended
* to the normal tex format ids; in that case, we need to remove that offset
* before lookup.
*/
if (tex_format >= PVR_TEX_FORMAT_COUNT)
tex_format -= PVR_TEX_FORMAT_COUNT;
return tex_format < ARRAY_SIZE(pvr_tex_format_compressed_table) &&
pvr_tex_format_compressed_table[tex_format].present;
}
const struct pvr_tex_format_compressed_description *
pvr_get_tex_format_compressed_description(uint32_t tex_format)
pvr_get_tex_format_compressed_description(const uint32_t tex_format)
{
/* In some contexts, the sequence of compressed tex format ids are appended
* to the normal tex format ids; in that case, we need to remove that offset
* before lookup.
*/
if (tex_format >= PVR_TEX_FORMAT_COUNT)
tex_format -= PVR_TEX_FORMAT_COUNT;
if (pvr_tex_format_compressed_is_supported(tex_format))
return &pvr_tex_format_compressed_table[tex_format].desc;

View file

@ -234,7 +234,7 @@ const struct pvr_tex_format_description *
pvr_get_tex_format_description(uint32_t tex_format);
#define pvr_foreach_supported_tex_format_(format) \
for (enum PVRX(TEXSTATE_FORMAT) format = 0; format < PVR_TEX_FORMAT_COUNT; \
for (enum ROGUE_TEXSTATE_FORMAT format = 0; format < PVR_TEX_FORMAT_COUNT; \
format++) \
if (pvr_tex_format_is_supported(format))
@ -251,7 +251,7 @@ const struct pvr_tex_format_compressed_description *
pvr_get_tex_format_compressed_description(uint32_t tex_format);
#define pvr_foreach_supported_tex_format_compressed_(format) \
for (enum PVRX(TEXSTATE_FORMAT_COMPRESSED) format = 0; \
for (enum ROGUE_TEXSTATE_FORMAT_COMPRESSED format = 0; \
format < PVR_TEX_FORMAT_COUNT; \
format++) \
if (pvr_tex_format_compressed_is_supported(format))