Mesa (master): tunrip: Add support for VK_EXT_separate_stencil_usage.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 4 20:54:09 UTC 2021


Module: Mesa
Branch: master
Commit: 89114225b54b64546cb2b642f0b0e35e859924d3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=89114225b54b64546cb2b642f0b0e35e859924d3

Author: Eric Anholt <eric at anholt.net>
Date:   Mon May  3 11:28:50 2021 -0700

tunrip: Add support for VK_EXT_separate_stencil_usage.

We were implictly including it in exposing VK 1.2, but we weren't making
use of the supplied struct.  Actually enabling it gives us a chance to do
slightly better at Z/S UBWC, and means we won't lose the separate usage
test coverage when switching back to exposing VK 1.1.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10594>

---

 docs/features.txt                     |  2 +-
 src/freedreno/vulkan/tu_extensions.py |  1 +
 src/freedreno/vulkan/tu_formats.c     |  4 ++--
 src/freedreno/vulkan/tu_image.c       | 11 ++++++++---
 src/freedreno/vulkan/tu_private.h     |  2 +-
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 5746398d20b..3ef8fba9e2f 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -469,7 +469,7 @@ Vulkan 1.2 -- all DONE: anv, vn
   VK_EXT_host_query_reset                               DONE (anv, lvp, radv, tu, vn)
   VK_EXT_sampler_filter_minmax                          DONE (anv/gen9+, lvp, radv, tu, vn)
   VK_EXT_scalar_block_layout                            DONE (anv, lvp, radv/gfx7+, tu, vn)
-  VK_EXT_separate_stencil_usage                         DONE (anv, vn)
+  VK_EXT_separate_stencil_usage                         DONE (anv, tu, vn)
   VK_EXT_shader_viewport_index_layer                    DONE (anv, lvp, radv, tu, vn)
 
 Khronos extensions that are not part of any Vulkan version:
diff --git a/src/freedreno/vulkan/tu_extensions.py b/src/freedreno/vulkan/tu_extensions.py
index 08eb34c3576..d1c3a2f1f23 100644
--- a/src/freedreno/vulkan/tu_extensions.py
+++ b/src/freedreno/vulkan/tu_extensions.py
@@ -95,6 +95,7 @@ EXTENSIONS = [
     Extension('VK_EXT_custom_border_color',              12, True),
     Extension('VK_KHR_multiview',                         1, True),
     Extension('VK_EXT_host_query_reset',                  1, True),
+    Extension('VK_EXT_separate_stencil_usage',            1, True),
     Extension('VK_EXT_shader_viewport_index_layer',       1, True),
     Extension('VK_EXT_extended_dynamic_state',            1, True),
     Extension('VK_KHR_push_descriptor',                   1, True),
diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c
index d2e04ccfdf5..e49113669f6 100644
--- a/src/freedreno/vulkan/tu_formats.c
+++ b/src/freedreno/vulkan/tu_formats.c
@@ -499,7 +499,7 @@ tu_GetPhysicalDeviceFormatProperties2(
 
       /* note: ubwc_possible() argument values to be ignored except for format */
       if (pFormatProperties->formatProperties.optimalTilingFeatures &&
-          ubwc_possible(format, VK_IMAGE_TYPE_2D, 0, false, VK_SAMPLE_COUNT_1_BIT)) {
+          ubwc_possible(format, VK_IMAGE_TYPE_2D, 0, 0, false, VK_SAMPLE_COUNT_1_BIT)) {
          vk_outarray_append(&out, mod_props) {
             mod_props->drmFormatModifier = DRM_FORMAT_MOD_QCOM_COMPRESSED;
             mod_props->drmFormatModifierPlaneCount = 1;
@@ -547,7 +547,7 @@ tu_get_image_format_properties(
             return VK_ERROR_FORMAT_NOT_SUPPORTED;
 
 
-         if (!ubwc_possible(info->format, info->type, info->usage, physical_device->info.a6xx.has_z24uint_s8uint, sampleCounts))
+         if (!ubwc_possible(info->format, info->type, info->usage, info->usage, physical_device->info.a6xx.has_z24uint_s8uint, sampleCounts))
             return VK_ERROR_FORMAT_NOT_SUPPORTED;
 
          format_feature_flags = format_props.optimalTilingFeatures;
diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c
index 5e323f8627c..c81b028170d 100644
--- a/src/freedreno/vulkan/tu_image.c
+++ b/src/freedreno/vulkan/tu_image.c
@@ -448,7 +448,8 @@ tu_image_view_init(struct tu_image_view *iview,
 }
 
 bool
-ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, bool has_z24uint_s8uint,
+ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage,
+              VkImageUsageFlags stencil_usage, bool has_z24uint_s8uint,
               VkSampleCountFlagBits samples)
 {
    /* no UBWC with compressed formats, E5B9G9R9, S8_UINT
@@ -473,7 +474,7 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, bool h
     * UBWC-enabled mipmaps in freedreno currently.  Just match the closed GL
     * behavior of no UBWC.
    */
-   if (usage & VK_IMAGE_USAGE_STORAGE_BIT)
+   if ((usage | stencil_usage) & VK_IMAGE_USAGE_STORAGE_BIT)
       return false;
 
    /* Disable UBWC for D24S8 on A630 in some cases
@@ -489,7 +490,7 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, bool h
     */
    if (!has_z24uint_s8uint &&
        format == VK_FORMAT_D24_UNORM_S8_UINT &&
-       (usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)))
+       (stencil_usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)))
       return false;
 
    if (!has_z24uint_s8uint && samples > VK_SAMPLE_COUNT_1_BIT)
@@ -603,7 +604,11 @@ tu_CreateImage(VkDevice _device,
       ubwc_enabled = false;
    }
 
+   const VkImageStencilUsageCreateInfo *stencil_usage_info =
+      vk_find_struct_const(pCreateInfo->pNext, IMAGE_STENCIL_USAGE_CREATE_INFO);
+
    if (!ubwc_possible(image->vk_format, pCreateInfo->imageType, pCreateInfo->usage,
+                      stencil_usage_info ? stencil_usage_info->stencilUsage : pCreateInfo->usage,
                       device->physical_device->info.a6xx.has_z24uint_s8uint, pCreateInfo->samples))
       ubwc_enabled = false;
 
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 99e2f1f63e2..8fb56eaeb42 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -1417,7 +1417,7 @@ tu_image_view_init(struct tu_image_view *iview,
                    bool limited_z24s8);
 
 bool
-ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, bool limited_z24s8,
+ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, VkImageUsageFlags stencil_usage, bool limited_z24s8,
               VkSampleCountFlagBits samples);
 
 struct tu_buffer_view



More information about the mesa-commit mailing list