#define RGBA ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
#define BGRA ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
+#define RGB1 ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
#define swiz_fmt(__vk_fmt, __hw_fmt, __swizzle) \
[__vk_fmt] = { \
* Exactly one bit must be set in \a aspect.
*/
struct anv_format
-anv_get_format(VkFormat vk_format, VkImageAspectFlags aspect,
- VkImageTiling tiling)
+anv_get_format(const struct brw_device_info *devinfo, VkFormat vk_format,
+ VkImageAspectFlags aspect, VkImageTiling tiling)
{
struct anv_format format = anv_formats[vk_format];
* hood.
*/
enum isl_format rgbx = isl_format_rgb_to_rgbx(format.isl_format);
- if (rgbx != ISL_FORMAT_UNSUPPORTED)
+ if (rgbx != ISL_FORMAT_UNSUPPORTED) {
format.isl_format = rgbx;
- else
+ } else {
format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
+ format.swizzle = (struct anv_format_swizzle) RGB1;
+ }
+ }
+
+ /* The B4G4R4A4 format isn't available prior to Sky Lake so we have to fall
+ * back to a format with a more complex swizzle.
+ */
+ if (vk_format == VK_FORMAT_B4G4R4A4_UNORM_PACK16 && devinfo->gen < 9) {
+ return (struct anv_format) {
+ .isl_format = ISL_FORMAT_B4G4R4A4_UNORM,
+ .swizzle = ISL_SWIZZLE(GREEN, RED, ALPHA, BLUE),
+ };
}
return format;
VK_FORMAT_FEATURE_BLIT_DST_BIT;
} else {
struct anv_format linear_fmt, tiled_fmt;
- linear_fmt = anv_get_format(format, VK_IMAGE_ASPECT_COLOR_BIT,
+ linear_fmt = anv_get_format(physical_device->info, format,
+ VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_LINEAR);
- tiled_fmt = anv_get_format(format, VK_IMAGE_ASPECT_COLOR_BIT,
+ tiled_fmt = anv_get_format(physical_device->info, format,
+ VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_OPTIMAL);
linear = get_image_format_properties(gen, linear_fmt.isl_format,