[Mesa-stable] [PATCH] anv: Round u_vector element sizes to a power of two

Jason Ekstrand jason at jlekstrand.net
Wed Jul 12 02:09:32 UTC 2017


This fixes 32-bit builds of the driver.

Fixes: 08413a81b93dc537fb0c34327ad162f07e8c3427
Cc: Mark Janes <mark.a.janes at intel.com>
Cc: mesa-stable at lists.freedesktop.org
---
 src/intel/vulkan/anv_batch_chain.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 47fee739..c895848 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -672,6 +672,15 @@ anv_cmd_buffer_new_binding_table_block(struct anv_cmd_buffer *cmd_buffer)
    return VK_SUCCESS;
 }
 
+static inline uint32_t
+round_up_to_power_of_two(uint32_t value)
+{
+   if (value <= 1)
+      return value;
+
+   return 1 << (32 - __builtin_clz(value - 1));
+}
+
 VkResult
 anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
 {
@@ -706,9 +715,11 @@ anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
 
    *(struct anv_batch_bo **)u_vector_add(&cmd_buffer->seen_bbos) = batch_bo;
 
+   /* u_vector requires power-of-two size elements */
+   uint32_t pow2_state_size =
+      round_up_to_power_of_two(sizeof(struct anv_state));
    success = u_vector_init(&cmd_buffer->bt_block_states,
-                           sizeof(struct anv_state),
-                           8 * sizeof(struct anv_state));
+                           pow2_state_size, 8 * pow2_state_size);
    if (!success)
       goto fail_seen_bbos;
 
-- 
2.5.0.400.gff86faf



More information about the mesa-stable mailing list