#include "anv_private.h"
#include "vk_format_info.h"
-#define ISL_SWIZZLE(r, g, b, a) { \
- ISL_CHANNEL_SELECT_##r, \
- ISL_CHANNEL_SELECT_##g, \
- ISL_CHANNEL_SELECT_##b, \
- ISL_CHANNEL_SELECT_##a, \
+/*
+ * gcc-4 and earlier don't allow compound literals where a constant
+ * is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
+ * here. -std=c89/gnu89 would allow it, but we depend on c99 features
+ * so using -std=c89/gnu89 is not an option. Starting from gcc-5
+ * compound literals can also be considered constant in -std=c99/gnu99
+ * mode.
+ */
+#define _ISL_SWIZZLE(r, g, b, a) { \
+ ISL_CHANNEL_SELECT_##r, \
+ ISL_CHANNEL_SELECT_##g, \
+ ISL_CHANNEL_SELECT_##b, \
+ ISL_CHANNEL_SELECT_##a, \
}
-#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 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] = { \
fmt(VK_FORMAT_R8G8B8_SSCALED, ISL_FORMAT_R8G8B8_SSCALED),
fmt(VK_FORMAT_R8G8B8_UINT, ISL_FORMAT_R8G8B8_UINT),
fmt(VK_FORMAT_R8G8B8_SINT, ISL_FORMAT_R8G8B8_SINT),
- fmt(VK_FORMAT_R8G8B8_SRGB, ISL_FORMAT_UNSUPPORTED), /* B8G8R8A8_UNORM_SRGB */
+ fmt(VK_FORMAT_R8G8B8_SRGB, ISL_FORMAT_R8G8B8_UNORM_SRGB),
fmt(VK_FORMAT_R8G8B8A8_UNORM, ISL_FORMAT_R8G8B8A8_UNORM),
fmt(VK_FORMAT_R8G8B8A8_SNORM, ISL_FORMAT_R8G8B8A8_SNORM),
fmt(VK_FORMAT_R8G8B8A8_USCALED, ISL_FORMAT_R8G8B8A8_USCALED),
* Exactly one bit must be set in \a aspect.
*/
struct anv_format
-anv_get_format(const struct brw_device_info *devinfo, VkFormat vk_format,
+anv_get_format(const struct gen_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 &&
+ isl_format_supports_rendering(devinfo, rgbx)) {
format.isl_format = rgbx;
} else {
format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
- format.swizzle = (struct anv_format_swizzle) RGB1;
+ format.swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
}
}
// Format capabilities
static VkFormatFeatureFlags
-get_image_format_properties(const struct brw_device_info *devinfo,
+get_image_format_properties(const struct gen_device_info *devinfo,
enum isl_format base, struct anv_format format)
{
if (format.isl_format == ISL_FORMAT_UNSUPPORTED)
}
static VkFormatFeatureFlags
-get_buffer_format_properties(const struct brw_device_info *devinfo,
+get_buffer_format_properties(const struct gen_device_info *devinfo,
enum isl_format format)
{
if (format == ISL_FORMAT_UNSUPPORTED)
VkFormat format,
VkFormatProperties *out_properties)
{
- int gen = physical_device->info->gen * 10;
- if (physical_device->info->is_haswell)
+ int gen = physical_device->info.gen * 10;
+ if (physical_device->info.is_haswell)
gen += 5;
VkFormatFeatureFlags linear = 0, tiled = 0, buffer = 0;
/* Nothing to do here */
} else if (vk_format_is_depth_or_stencil(format)) {
tiled |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
- if (physical_device->info->gen >= 8)
+ if (physical_device->info.gen >= 8)
tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |
VK_FORMAT_FEATURE_BLIT_DST_BIT;
} else {
struct anv_format linear_fmt, tiled_fmt;
- linear_fmt = anv_get_format(physical_device->info, format,
+ linear_fmt = anv_get_format(&physical_device->info, format,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_LINEAR);
- tiled_fmt = anv_get_format(physical_device->info, format,
+ tiled_fmt = anv_get_format(&physical_device->info, format,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_OPTIMAL);
- linear = get_image_format_properties(physical_device->info,
+ linear = get_image_format_properties(&physical_device->info,
linear_fmt.isl_format, linear_fmt);
- tiled = get_image_format_properties(physical_device->info,
+ tiled = get_image_format_properties(&physical_device->info,
linear_fmt.isl_format, tiled_fmt);
- buffer = get_buffer_format_properties(physical_device->info,
+ buffer = get_buffer_format_properties(&physical_device->info,
linear_fmt.isl_format);
/* XXX: We handle 3-channel formats by switching them out for RGBX or
tiled &= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT &
~VK_FORMAT_FEATURE_BLIT_DST_BIT;
}
+
+ /* ASTC textures must be in Y-tiled memory */
+ if (isl_format_get_layout(linear_fmt.isl_format)->txc == ISL_TXC_ASTC)
+ linear = 0;
}
out_properties->linearTilingFeatures = linear;
uint32_t maxArraySize;
VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT;
+ if (anv_formats[format].isl_format == ISL_FORMAT_UNSUPPORTED)
+ goto unsupported;
+
anv_physical_device_get_format_properties(physical_device, format,
&format_props);
break;
}
+ /* Our hardware doesn't support 1D compressed textures.
+ * From the SKL PRM, RENDER_SURFACE_STATE::SurfaceFormat:
+ * * This field cannot be a compressed (BC*, DXT*, FXT*, ETC*, EAC*) format
+ * if the Surface Type is SURFTYPE_1D.
+ * * This field cannot be ASTC format if the Surface Type is SURFTYPE_1D.
+ */
+ if (type == VK_IMAGE_TYPE_1D &&
+ isl_format_is_compressed(anv_formats[format].isl_format)) {
+ goto unsupported;
+ }
+
if (tiling == VK_IMAGE_TILING_OPTIMAL &&
type == VK_IMAGE_TYPE_2D &&
(format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |