panfrost: Add ASTC texture formats
Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3414>
This commit is contained in:

committed by
Alyssa Rosenzweig

parent
960fe9daea
commit
31bd3b5279
@@ -601,7 +601,7 @@ panfrost_upload_tex(
|
||||
for (unsigned f = first_face; f <= last_face; ++f) {
|
||||
pointers_and_strides[idx++] =
|
||||
panfrost_get_texture_address(rsrc, l, w*face_mult + f)
|
||||
+ afbc_bit;
|
||||
+ afbc_bit + view->astc_stretch;
|
||||
|
||||
if (has_manual_stride) {
|
||||
pointers_and_strides[idx++] =
|
||||
@@ -2124,6 +2124,21 @@ panfrost_translate_texture_type(enum pipe_texture_target t) {
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
panfrost_compute_astc_stretch(
|
||||
const struct util_format_description *desc)
|
||||
{
|
||||
unsigned width = desc->block.width;
|
||||
unsigned height = desc->block.height;
|
||||
assert(width >= 4 && width <= 12);
|
||||
assert(height >= 4 && height <= 12);
|
||||
if (width == 12)
|
||||
width = 11;
|
||||
if (height == 12)
|
||||
height = 11;
|
||||
return ((height - 4) * 8) + (width - 4);
|
||||
}
|
||||
|
||||
static struct pipe_sampler_view *
|
||||
panfrost_create_sampler_view(
|
||||
struct pipe_context *pctx,
|
||||
@@ -2158,6 +2173,9 @@ panfrost_create_sampler_view(
|
||||
|
||||
enum mali_format format = panfrost_find_format(desc);
|
||||
|
||||
if (format == MALI_ASTC_HDR_SUPP || format == MALI_ASTC_SRGB_SUPP)
|
||||
so->astc_stretch = panfrost_compute_astc_stretch(desc);
|
||||
|
||||
/* Check if we need to set a custom stride by computing the "expected"
|
||||
* stride and comparing it to what the BO actually wants. Only applies
|
||||
* to linear textures, since tiled/compressed textures have strict
|
||||
|
@@ -273,6 +273,7 @@ struct panfrost_sampler_state {
|
||||
struct panfrost_sampler_view {
|
||||
struct pipe_sampler_view base;
|
||||
struct mali_texture_descriptor hw;
|
||||
uint8_t astc_stretch;
|
||||
bool manual_stride;
|
||||
};
|
||||
|
||||
|
@@ -245,6 +245,13 @@ panfrost_find_format(const struct util_format_description *desc) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
|
||||
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
|
||||
return MALI_ASTC_SRGB_SUPP;
|
||||
else
|
||||
return MALI_ASTC_HDR_SUPP;
|
||||
}
|
||||
|
||||
/* Formats must match in channel count */
|
||||
assert(desc->nr_channels >= 1 && desc->nr_channels <= 4);
|
||||
unsigned format = MALI_NR_CHANNELS(desc->nr_channels);
|
||||
|
@@ -464,6 +464,7 @@ panfrost_is_format_supported( struct pipe_screen *screen,
|
||||
case UTIL_FORMAT_LAYOUT_OTHER:
|
||||
break;
|
||||
case UTIL_FORMAT_LAYOUT_ETC:
|
||||
case UTIL_FORMAT_LAYOUT_ASTC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@@ -283,6 +283,8 @@ enum mali_format {
|
||||
MALI_ETC2_R11_SNORM = MALI_FORMAT_COMPRESSED | 0x11,
|
||||
MALI_ETC2_RG11_SNORM = MALI_FORMAT_COMPRESSED | 0x12,
|
||||
MALI_ETC2_RGB8A1 = MALI_FORMAT_COMPRESSED | 0x13,
|
||||
MALI_ASTC_SRGB_SUPP = MALI_FORMAT_COMPRESSED | 0x16,
|
||||
MALI_ASTC_HDR_SUPP = MALI_FORMAT_COMPRESSED | 0x17,
|
||||
|
||||
MALI_RGB565 = MALI_FORMAT_SPECIAL | 0x0,
|
||||
MALI_RGB5_A1_UNORM = MALI_FORMAT_SPECIAL | 0x2,
|
||||
|
Reference in New Issue
Block a user