anv: GetDeviceImageFormatProperties: fix TRANSFER formats
[mesa.git] / src / intel / vulkan / anv_formats.c
index e7e0ecac309acbf7bb73d1cb1c58b5b9ec8b4f13..b06e29baaf8e46178ce953686547474ea78ed6e3 100644 (file)
@@ -271,7 +271,7 @@ anv_get_format(const struct brw_device_info *devinfo, VkFormat vk_format,
       isl_format_get_layout(format.isl_format);
 
    if (tiling == VK_IMAGE_TILING_OPTIMAL &&
-       !util_is_power_of_two(isl_layout->bs)) {
+       !util_is_power_of_two(isl_layout->bpb)) {
       /* Tiled formats *must* be power-of-two because we need up upload
        * them with the render pipeline.  For 3-channel formats, we fix
        * this by switching them over to RGBX or RGBA formats under the
@@ -376,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;
@@ -408,7 +409,7 @@ anv_physical_device_get_format_properties(struct anv_physical_device *physical_d
        * what most clients will want.
        */
       if (linear_fmt.isl_format != ISL_FORMAT_UNSUPPORTED &&
-          !util_is_power_of_two(isl_format_layouts[linear_fmt.isl_format].bs) &&
+          !util_is_power_of_two(isl_format_layouts[linear_fmt.isl_format].bpb) &&
           isl_format_rgb_to_rgbx(linear_fmt.isl_format) == ISL_FORMAT_UNSUPPORTED) {
          tiled &= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT &
                   ~VK_FORMAT_FEATURE_BLIT_DST_BIT;
@@ -506,25 +507,15 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
       sampleCounts = isl_device_get_sample_counts(&physical_device->isl_dev);
    }
 
-   if (usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
-      /* Meta implements transfers by sampling from the source image. */
-      if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
-         goto unsupported;
-      }
-   }
-
-#if 0
-   if (usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) {
-      if (anv_format_for_vk_format(format)->has_stencil) {
-         /* Not yet implemented because copying to a W-tiled surface is crazy
-          * hard.
-          */
-         anv_finishme("support VK_IMAGE_USAGE_TRANSFER_DST_BIT for "
-                      "stencil format");
+   if (usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
+                VK_IMAGE_USAGE_TRANSFER_DST_BIT)) {
+      /* Accept transfers on anything we can sample from or renderer to. */
+      if (!(format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
+                                    VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
+                                    VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))) {
          goto unsupported;
       }
    }
-#endif
 
    if (usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
       if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {