anv/pipeline: Silently pass tests if depth or stencil is missing
[mesa.git] / src / intel / vulkan / anv_formats.c
index a0fa976da9f7cadb312590d6d8f12c2206c04b57..457e82003d69dfe967d8aeae85b29674fb93a065 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 #include "anv_private.h"
-#include "brw_surface_formats.h"
 #include "vk_format_info.h"
 
 #define ISL_SWIZZLE(r, g, b, a) { \
@@ -51,7 +50,7 @@
  * bspec) names are in LSB -> MSB order while VK formats are MSB -> LSB.
  */
 static const struct anv_format anv_formats[] = {
-   fmt(VK_FORMAT_UNDEFINED,               ISL_FORMAT_RAW),
+   fmt(VK_FORMAT_UNDEFINED,               ISL_FORMAT_UNSUPPORTED),
    fmt(VK_FORMAT_R4G4_UNORM_PACK8,        ISL_FORMAT_UNSUPPORTED),
    fmt(VK_FORMAT_R4G4B4A4_UNORM_PACK16,   ISL_FORMAT_A4B4G4R4_UNORM),
    swiz_fmt(VK_FORMAT_B4G4R4A4_UNORM_PACK16,   ISL_FORMAT_A4B4G4R4_UNORM,  BGRA),
@@ -303,21 +302,18 @@ anv_get_format(const struct brw_device_info *devinfo, VkFormat vk_format,
 // Format capabilities
 
 static VkFormatFeatureFlags
-get_image_format_properties(int gen, enum isl_format base,
-                            struct anv_format format)
+get_image_format_properties(const struct brw_device_info *devinfo,
+                            enum isl_format base, struct anv_format format)
 {
-   const struct brw_surface_format_info *info =
-      &surface_formats[format.isl_format];
-
-   if (format.isl_format == ISL_FORMAT_UNSUPPORTED || !info->exists)
+   if (format.isl_format == ISL_FORMAT_UNSUPPORTED)
       return 0;
 
    VkFormatFeatureFlags flags = 0;
-   if (info->sampling <= gen) {
+   if (isl_format_supports_sampling(devinfo, format.isl_format)) {
       flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
                VK_FORMAT_FEATURE_BLIT_SRC_BIT;
 
-      if (info->filtering <= gen)
+      if (isl_format_supports_filtering(devinfo, format.isl_format))
          flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
    }
 
@@ -325,12 +321,12 @@ get_image_format_properties(int gen, enum isl_format base,
     * moved, then blending won't work correctly.  The PRM tells us
     * straight-up not to render to such a surface.
     */
-   if (info->render_target <= gen &&
+   if (isl_format_supports_rendering(devinfo, format.isl_format) &&
        format.swizzle.a == ISL_CHANNEL_SELECT_ALPHA) {
       flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
                VK_FORMAT_FEATURE_BLIT_DST_BIT;
 
-      if (info->alpha_blend <= gen)
+      if (isl_format_supports_alpha_blending(devinfo, format.isl_format))
          flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
    }
 
@@ -347,18 +343,18 @@ get_image_format_properties(int gen, enum isl_format base,
 }
 
 static VkFormatFeatureFlags
-get_buffer_format_properties(int gen, enum isl_format format)
+get_buffer_format_properties(const struct brw_device_info *devinfo,
+                             enum isl_format format)
 {
-   const struct brw_surface_format_info *info = &surface_formats[format];
-
-   if (format == ISL_FORMAT_UNSUPPORTED || !info->exists)
+   if (format == ISL_FORMAT_UNSUPPORTED)
       return 0;
 
    VkFormatFeatureFlags flags = 0;
-   if (info->sampling <= gen && !isl_format_is_compressed(format))
+   if (isl_format_supports_sampling(devinfo, format) &&
+       !isl_format_is_compressed(format))
       flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
 
-   if (info->input_vb <= gen)
+   if (isl_format_supports_vertex_fetch(devinfo, format))
       flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
 
    if (isl_is_storage_image_format(format))
@@ -380,8 +376,9 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d
       gen += 5;
 
    VkFormatFeatureFlags linear = 0, tiled = 0, buffer = 0;
-   if (anv_formats[format].isl_format != ISL_FORMAT_UNSUPPORTED &&
-       vk_format_is_depth_or_stencil(format)) {
+   if (anv_formats[format].isl_format == ISL_FORMAT_UNSUPPORTED) {
+      /* 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)
          tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
@@ -397,11 +394,12 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d
                                  VK_IMAGE_ASPECT_COLOR_BIT,
                                  VK_IMAGE_TILING_OPTIMAL);
 
-      linear = get_image_format_properties(gen, linear_fmt.isl_format,
-                                           linear_fmt);
-      tiled = get_image_format_properties(gen, linear_fmt.isl_format,
-                                          tiled_fmt);
-      buffer = get_buffer_format_properties(gen, linear_fmt.isl_format);
+      linear = get_image_format_properties(physical_device->info,
+                                           linear_fmt.isl_format, linear_fmt);
+      tiled = get_image_format_properties(physical_device->info,
+                                          linear_fmt.isl_format, tiled_fmt);
+      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
        * RGBA formats behind-the-scenes.  This works fine for textures