From 219a1929f7a9c3fcf0fa1cdecac592cc01dc4cf3 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 21 Sep 2015 17:12:58 -0700 Subject: [PATCH] anv/util: Add helpers for getting the first and last elements of a vector --- src/vulkan/anv_private.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 6b9b12fd8ec..915460dadf4 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -200,6 +200,21 @@ anv_vector_length(struct anv_vector *queue) return (queue->head - queue->tail) / queue->element_size; } +static inline void * +anv_vector_head(struct anv_vector *vector) +{ + assert(vector->tail < vector->head); + return (void *)((char *)vector->data + + ((vector->head - vector->element_size) & + (vector->size - 1))); +} + +static inline void * +anv_vector_tail(struct anv_vector *vector) +{ + return (void *)((char *)vector->data + (vector->tail & (vector->size - 1))); +} + static inline void anv_vector_finish(struct anv_vector *queue) { -- 2.30.2