From faea84e2540810feb66ac88359b50cf69f2b3cc6 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 7 Feb 2020 04:33:19 -0600 Subject: [PATCH] anv: Add an align_down_u32 helper Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_nir_compute_push_layout.c | 2 +- src/intel/vulkan/anv_private.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/anv_nir_compute_push_layout.c b/src/intel/vulkan/anv_nir_compute_push_layout.c index 1dbfb08a100..e96ce98bde2 100644 --- a/src/intel/vulkan/anv_nir_compute_push_layout.c +++ b/src/intel/vulkan/anv_nir_compute_push_layout.c @@ -74,7 +74,7 @@ anv_nir_compute_push_layout(const struct anv_physical_device *pdevice, * push_end (no push constants is indicated by push_start = UINT_MAX). */ push_start = MIN2(push_start, push_end); - push_start &= ~31u; + push_start = align_down_u32(push_start, 32); if (has_push_intrinsic) { nir_foreach_function(function, nir) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index cdfbcb87535..8138137abf7 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -231,11 +231,18 @@ align_down_npot_u32(uint32_t v, uint32_t a) return v - (v % a); } +static inline uint32_t +align_down_u32(uint32_t v, uint32_t a) +{ + assert(a != 0 && a == (a & -a)); + return v & ~(a - 1); +} + static inline uint32_t align_u32(uint32_t v, uint32_t a) { assert(a != 0 && a == (a & -a)); - return (v + a - 1) & ~(a - 1); + return align_down_u32(v + a - 1, a); } static inline uint64_t -- 2.30.2