Mesa (main): vulkan/wsi: Use ALIGN_POT() instead of open-coding it

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


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

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

vulkan/wsi: Use ALIGN_POT() instead of open-coding it

align_u32() and ALIGN_POT() are doing the same thing.
Replace align_u32() calls by ALIGN_POT() ones and get rid
of align_u32().

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/wsi_common_drm.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c
index 0643a04a18b..ec822d3f00f 100644
--- a/src/vulkan/wsi/wsi_common_drm.c
+++ b/src/vulkan/wsi/wsi_common_drm.c
@@ -419,13 +419,6 @@ wsi_create_native_image_mem(const struct wsi_swapchain *chain,
    return VK_SUCCESS;
 }
 
-static inline uint32_t
-align_u32(uint32_t v, uint32_t a)
-{
-   assert(a != 0 && a == (a & -a));
-   return (v + a - 1) & ~(a - 1);
-}
-
 #define WSI_PRIME_LINEAR_STRIDE_ALIGN 256
 
 static VkResult
@@ -437,7 +430,7 @@ wsi_create_prime_image_mem(const struct wsi_swapchain *chain,
    VkResult result;
 
    uint32_t linear_size = info->linear_stride * info->create.extent.height;
-   linear_size = align_u32(linear_size, 4096);
+   linear_size = ALIGN_POT(linear_size, 4096);
 
    const VkExternalMemoryBufferCreateInfo prime_buffer_external_info = {
       .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO,
@@ -611,7 +604,7 @@ wsi_configure_prime_image(UNUSED const struct wsi_swapchain *chain,
    info->prime_use_linear_modifier = use_modifier;
 
    const uint32_t cpp = vk_format_size(info->create.format);
-   info->linear_stride = align_u32(info->create.extent.width * cpp,
+   info->linear_stride = ALIGN_POT(info->create.extent.width * cpp,
                                    WSI_PRIME_LINEAR_STRIDE_ALIGN);
 
    info->create_mem = wsi_create_prime_image_mem;



More information about the mesa-commit mailing list