v3dv: support VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR

VK_KHR_maintenance5 adds two new optional formats:
- VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR
- VK_FORMAT_A8_UNORM_KHR

The former we support natively, the latter we don't. We could
try to implement A8 with some effort by mapping it to R8 with
a 000X swizzle but that alone won't be enough, some issues we
would have to solve include:

- Border colors won't work because the texture shader state
swizzle also applies to these, so our 000X swizzle would mess
things up for them and since we don't know the format used with
the sampler in the general case, we would have always have to
create two samplers internally, one adequate for A8 and one for
the rest of formats and choose one or the other at run time.
- We would have to convert the A8 format to a compatible
R8 format but most of the transfer operations. This should be
fairly trivial since we already have infrastructure for this.
- At rendering time we would need to ensure we make our writes
from the alpha channel. This would probably require that we
use the color_fmt from the fs_key to swizzle color writes in
shaders.
- We would probably also need to special case the format for
color clears, etc

So for now, we don't support it.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29643>
This commit is contained in:
Iago Toral Quiroga 2024-06-10 07:43:33 +02:00 committed by Marge Bot
parent 9995f336e6
commit e7615a612f

View file

@ -242,6 +242,14 @@ static const struct v3dv_format format_table_4444[] = {
FORMAT(A4R4G4B4_UNORM_PACK16, ABGR4444, RGBA4, SWIZ_YZWX, 16, true), /* Reverse + RB swap */
};
/* VK_KHR_maintenance5 introduces A1B5G5R5 and A8 but we only support the
* former. It might be possible to support A8 as R8 with special casing
* in a number of places but it would probably take some effort.
*/
static const struct v3dv_format format_table_maintenance5[] = {
FORMAT(A1B5G5R5_UNORM_PACK16_KHR, RGBA5551, A1_RGB5, SWIZ_XYZW, 16, true),
};
static const struct v3dv_format format_table_ycbcr[] = {
YCBCR_FORMAT(G8_B8R8_2PLANE_420_UNORM, false, 2,
PLANE(R8, R8, SWIZ(X, 0, 0, 1), 16),
@ -275,6 +283,11 @@ v3dX(get_format)(VkFormat format)
return &format_table_ycbcr[enum_offset];
else
return NULL;
case _VK_KHR_maintenance5_number:
if (enum_offset < ARRAY_SIZE(format_table_maintenance5))
return &format_table_maintenance5[enum_offset];
else
return NULL;
default:
return NULL;
}