asahi,ail: pull texture view logic into ail
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30981>
This commit is contained in:
committed by
Marge Bot
parent
ed08fe94d2
commit
1f45aa37e0
@@ -412,6 +412,28 @@ ail_tile_mode_uncompressed(enum pipe_format format)
|
||||
return ail_tile_mode_replicated(ail_subtile_uncompressed_mode(format));
|
||||
}
|
||||
|
||||
/*
|
||||
* For compression, compatible formats must have the same number/size/order of
|
||||
* channels, but may differ in data type. For example, R32_SINT is compatible
|
||||
* with Z32_FLOAT, but not with R16G16_SINT. This is the relation given by the
|
||||
* "channels" part of the decomposed format.
|
||||
*
|
||||
* This has not been exhaustively tested and might be missing some corner cases
|
||||
* around XR formats, but is well-motivated and seems to work.
|
||||
*/
|
||||
static inline bool
|
||||
ail_formats_compatible(enum pipe_format a, enum pipe_format b)
|
||||
{
|
||||
return ail_pixel_format[a].channels == ail_pixel_format[b].channels;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ail_is_view_compatible(struct ail_layout *layout, enum pipe_format view)
|
||||
{
|
||||
return !ail_is_compressed(layout) ||
|
||||
ail_formats_compatible(layout->format, view);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern C */
|
||||
#endif
|
||||
|
||||
@@ -74,27 +74,9 @@ void
|
||||
agx_legalize_compression(struct agx_context *ctx, struct agx_resource *rsrc,
|
||||
enum pipe_format format)
|
||||
{
|
||||
/* If the resource isn't compressed, we can reinterpret */
|
||||
if (rsrc->layout.tiling != AIL_TILING_TWIDDLED_COMPRESSED)
|
||||
return;
|
||||
|
||||
/* The physical format */
|
||||
enum pipe_format storage = rsrc->layout.format;
|
||||
|
||||
/* If the formats are compatible, we don't have to decompress. Compatible
|
||||
* formats have the same number/size/order of channels, but may differ in
|
||||
* data type. For example, R32_SINT is compatible with Z32_FLOAT, but not
|
||||
* with R16G16_SINT. This is the relation given by the "channels" part of the
|
||||
* decomposed format.
|
||||
*
|
||||
* This has not been exhaustively tested and might be missing some corner
|
||||
* cases around XR formats, but is well-motivated and seems to work.
|
||||
*/
|
||||
if (ail_pixel_format[storage].channels == ail_pixel_format[format].channels)
|
||||
return;
|
||||
|
||||
/* Otherwise, decompress. */
|
||||
agx_decompress(ctx, rsrc, "Incompatible formats");
|
||||
if (!ail_is_view_compatible(&rsrc->layout, format)) {
|
||||
agx_decompress(ctx, rsrc, "Incompatible formats");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user