Commit d94c4790 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜
Browse files

panfrost: Use ASTC 2D enums

Rather than manipulating the bits to do the mapping, use a dead simple
switch() with the enum definition.
Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <>
parent e975e0e5
Pipeline #402824 waiting for manual action with stages
......@@ -89,26 +89,30 @@ panfrost_needs_explicit_stride(const struct panfrost_device *dev,
return false;
/* A Scalable Texture Compression (ASTC) corresponds to just a few texture type
* in the hardware, but in fact can be parametrized to have various widths and
* heights for the so-called "stretch factor". It turns out these parameters
* are stuffed in the bottom bits of the payload pointers. This functions
* computes these magic stuffing constants based on the ASTC format in use. The
* constant in a given dimension is 3-bits, and two are stored side-by-side for
* each active dimension.
/* Arm Scalable Texture Compression (ASTC) corresponds to just a few formats.
* The block dimension is not part of the format. Instead, it is encoded as a
* 6-bit tag on the payload pointer. Map the block size for a single dimension.
static unsigned
panfrost_astc_stretch(unsigned dim)
static enum mali_astc_2d_dimension
panfrost_astc_dim(unsigned dim)
assert(dim >= 4 && dim <= 12);
return MIN2(dim, 11) - 4;
switch (dim) {
case 4: return MALI_ASTC_2D_DIMENSION_4;
case 5: return MALI_ASTC_2D_DIMENSION_5;
case 6: return MALI_ASTC_2D_DIMENSION_6;
case 8: return MALI_ASTC_2D_DIMENSION_8;
case 10: return MALI_ASTC_2D_DIMENSION_10;
case 12: return MALI_ASTC_2D_DIMENSION_12;
default: unreachable("Invalid ASTC dimension");
/* Texture addresses are tagged with information about compressed formats.
* AFBC uses a bit for whether the colorspace transform is enabled (RGB and
* RGBA only).
* For ASTC, this is a "stretch factor" encoding the block size. */
* For ASTC, this encodes the block dimensions. */
static unsigned
panfrost_compression_tag(const struct panfrost_device *dev,
......@@ -140,8 +144,8 @@ panfrost_compression_tag(const struct panfrost_device *dev,
return flags;
} else if (desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
return (panfrost_astc_stretch(desc->block.height) << 3) |
return (panfrost_astc_dim(desc->block.height) << 3) |
} else {
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment