Mesa (main): vulkan/wsi: Don't open-code vk_format_get_blocksize()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 22 10:54:58 UTC 2022


Module: Mesa
Branch: main
Commit: 32c2db1b25ccb1af615e3d1a91a61f2af86f142b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=32c2db1b25ccb1af615e3d1a91a61f2af86f142b

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Fri Feb 18 09:28:49 2022 +0100

vulkan/wsi: Don't open-code vk_format_get_blocksize()

We already have a standard helper to retrieve the texel block size from
a VkFormat, let's use it instead of adding a new helper.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Suggested-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12210>

---

 src/vulkan/wsi/meson.build      |  2 +-
 src/vulkan/wsi/wsi_common_drm.c | 17 +++--------------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/vulkan/wsi/meson.build b/src/vulkan/wsi/meson.build
index d35a3626a77..e234e31d340 100644
--- a/src/vulkan/wsi/meson.build
+++ b/src/vulkan/wsi/meson.build
@@ -58,7 +58,7 @@ wsi_entrypoints = custom_target(
 libvulkan_wsi = static_library(
   'vulkan_wsi',
   [files_vulkan_wsi, wsi_entrypoints],
-  include_directories : [inc_include, inc_src],
+  include_directories : [inc_include, inc_src, inc_gallium],
   dependencies : [
     vulkan_wsi_deps, dep_libdrm, dep_libudev, idep_vulkan_util_headers,
     idep_vulkan_runtime_headers, idep_xmlconfig,
diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c
index ec822d3f00f..8982ba225f2 100644
--- a/src/vulkan/wsi/wsi_common_drm.c
+++ b/src/vulkan/wsi/wsi_common_drm.c
@@ -26,6 +26,7 @@
 #include "util/macros.h"
 #include "util/os_file.h"
 #include "util/xmlconfig.h"
+#include "vk_format.h"
 #include "vk_util.h"
 #include "drm-uapi/drm_fourcc.h"
 
@@ -114,18 +115,6 @@ select_memory_type(const struct wsi_device *wsi,
    unreachable("No memory type found");
 }
 
-static uint32_t
-vk_format_size(VkFormat format)
-{
-   switch (format) {
-   case VK_FORMAT_B8G8R8A8_UNORM:
-   case VK_FORMAT_B8G8R8A8_SRGB:
-      return 4;
-   default:
-      unreachable("Unknown WSI Format");
-   }
-}
-
 static const struct VkDrmFormatModifierPropertiesEXT *
 get_modifier_props(const struct wsi_image_info *info, uint64_t modifier)
 {
@@ -563,7 +552,7 @@ wsi_finish_create_prime_image(const struct wsi_swapchain *chain,
       struct VkBufferImageCopy buffer_image_copy = {
          .bufferOffset = 0,
          .bufferRowLength = info->linear_stride /
-                            vk_format_size(info->create.format),
+                            vk_format_get_blocksize(info->create.format),
          .bufferImageHeight = 0,
          .imageSubresource = {
             .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
@@ -603,7 +592,7 @@ wsi_configure_prime_image(UNUSED const struct wsi_swapchain *chain,
    info->wsi.prime_blit_src = true,
    info->prime_use_linear_modifier = use_modifier;
 
-   const uint32_t cpp = vk_format_size(info->create.format);
+   const uint32_t cpp = vk_format_get_blocksize(info->create.format);
    info->linear_stride = ALIGN_POT(info->create.extent.width * cpp,
                                    WSI_PRIME_LINEAR_STRIDE_ALIGN);
 



More information about the mesa-commit mailing list