diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-23 05:33:34 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-05-23 05:33:34 +0000 |
commit | 9886815a25d84be79f51e65ebd8e458bb5d26ca8 (patch) | |
tree | a65edf018dd992543337433f7303fb29a6c8e8cf /lib/mesa/src/util | |
parent | e2a3acb64af2657b1181806818eacad061103c23 (diff) |
Merge Mesa 19.0.5
Diffstat (limited to 'lib/mesa/src/util')
-rw-r--r-- | lib/mesa/src/util/Makefile.in | 5 | ||||
-rw-r--r-- | lib/mesa/src/util/Makefile.sources | 5 | ||||
-rw-r--r-- | lib/mesa/src/util/hash_table.c | 49 | ||||
-rw-r--r-- | lib/mesa/src/util/hash_table.h | 11 | ||||
-rw-r--r-- | lib/mesa/src/util/ralloc.c | 18 | ||||
-rw-r--r-- | lib/mesa/src/util/set.c | 11 | ||||
-rw-r--r-- | lib/mesa/src/util/slab.c | 20 | ||||
-rw-r--r-- | lib/mesa/src/util/u_cpu_detect.c | 15 |
8 files changed, 93 insertions, 41 deletions
diff --git a/lib/mesa/src/util/Makefile.in b/lib/mesa/src/util/Makefile.in index 93429f039..6746bce97 100644 --- a/lib/mesa/src/util/Makefile.in +++ b/lib/mesa/src/util/Makefile.in @@ -657,6 +657,11 @@ MESA_UTIL_FILES := \ u_debug.h \ u_cpu_detect.c \ u_cpu_detect.h \ + os_memory_aligned.h \ + os_memory_debug.h \ + os_memory_stdc.h \ + os_memory.h \ + u_memory.h \ vma.c \ vma.h diff --git a/lib/mesa/src/util/Makefile.sources b/lib/mesa/src/util/Makefile.sources index b4d23947a..f09b89b3b 100644 --- a/lib/mesa/src/util/Makefile.sources +++ b/lib/mesa/src/util/Makefile.sources @@ -72,6 +72,11 @@ MESA_UTIL_FILES := \ u_debug.h \ u_cpu_detect.c \ u_cpu_detect.h \ + os_memory_aligned.h \ + os_memory_debug.h \ + os_memory_stdc.h \ + os_memory.h \ + u_memory.h \ vma.c \ vma.h diff --git a/lib/mesa/src/util/hash_table.c b/lib/mesa/src/util/hash_table.c index fc152f84a..57a5f247e 100644 --- a/lib/mesa/src/util/hash_table.c +++ b/lib/mesa/src/util/hash_table.c @@ -110,6 +110,27 @@ entry_is_present(const struct hash_table *ht, struct hash_entry *entry) return entry->key != NULL && entry->key != ht->deleted_key; } +bool +_mesa_hash_table_init(struct hash_table *ht, + void *mem_ctx, + uint32_t (*key_hash_function)(const void *key), + bool (*key_equals_function)(const void *a, + const void *b)) +{ + ht->size_index = 0; + ht->size = hash_sizes[ht->size_index].size; + ht->rehash = hash_sizes[ht->size_index].rehash; + ht->max_entries = hash_sizes[ht->size_index].max_entries; + ht->key_hash_function = key_hash_function; + ht->key_equals_function = key_equals_function; + ht->table = rzalloc_array(mem_ctx, struct hash_entry, ht->size); + ht->entries = 0; + ht->deleted_entries = 0; + ht->deleted_key = &deleted_key_value; + + return ht->table != NULL; +} + struct hash_table * _mesa_hash_table_create(void *mem_ctx, uint32_t (*key_hash_function)(const void *key), @@ -118,22 +139,14 @@ _mesa_hash_table_create(void *mem_ctx, { struct hash_table *ht; + /* mem_ctx is used to allocate the hash table, but the hash table is used + * to allocate all of the suballocations. + */ ht = ralloc(mem_ctx, struct hash_table); if (ht == NULL) return NULL; - ht->size_index = 0; - ht->size = hash_sizes[ht->size_index].size; - ht->rehash = hash_sizes[ht->size_index].rehash; - ht->max_entries = hash_sizes[ht->size_index].max_entries; - ht->key_hash_function = key_hash_function; - ht->key_equals_function = key_equals_function; - ht->table = rzalloc_array(ht, struct hash_entry, ht->size); - ht->entries = 0; - ht->deleted_entries = 0; - ht->deleted_key = &deleted_key_value; - - if (ht->table == NULL) { + if (!_mesa_hash_table_init(ht, ht, key_hash_function, key_equals_function)) { ralloc_free(ht); return NULL; } @@ -287,7 +300,7 @@ _mesa_hash_table_rehash(struct hash_table *ht, unsigned new_size_index) if (new_size_index >= ARRAY_SIZE(hash_sizes)) return; - table = rzalloc_array(ht, struct hash_entry, + table = rzalloc_array(ralloc_parent(ht->table), struct hash_entry, hash_sizes[new_size_index].size); if (table == NULL) return; @@ -535,6 +548,16 @@ _mesa_key_pointer_equal(const void *a, const void *b) } /** + * Helper to create a hash table with pointer keys. + */ +struct hash_table * +_mesa_pointer_hash_table_create(void *mem_ctx) +{ + return _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer, + _mesa_key_pointer_equal); +} + +/** * Hash table wrapper which supports 64-bit keys. * * TODO: unify all hash table implementations. diff --git a/lib/mesa/src/util/hash_table.h b/lib/mesa/src/util/hash_table.h index d89fc1dc1..e451bd7c2 100644 --- a/lib/mesa/src/util/hash_table.h +++ b/lib/mesa/src/util/hash_table.h @@ -62,6 +62,14 @@ _mesa_hash_table_create(void *mem_ctx, uint32_t (*key_hash_function)(const void *key), bool (*key_equals_function)(const void *a, const void *b)); + +bool +_mesa_hash_table_init(struct hash_table *ht, + void *mem_ctx, + uint32_t (*key_hash_function)(const void *key), + bool (*key_equals_function)(const void *a, + const void *b)); + struct hash_table * _mesa_hash_table_clone(struct hash_table *src, void *dst_mem_ctx); void _mesa_hash_table_destroy(struct hash_table *ht, @@ -113,6 +121,9 @@ static inline uint32_t _mesa_hash_pointer(const void *pointer) return (uint32_t) ((num >> 2) ^ (num >> 6) ^ (num >> 10) ^ (num >> 14)); } +struct hash_table * +_mesa_pointer_hash_table_create(void *mem_ctx); + enum { _mesa_fnv32_1a_offset_bias = 2166136261u, }; diff --git a/lib/mesa/src/util/ralloc.c b/lib/mesa/src/util/ralloc.c index 5a7fa7e84..fc3566199 100644 --- a/lib/mesa/src/util/ralloc.c +++ b/lib/mesa/src/util/ralloc.c @@ -61,7 +61,7 @@ struct #endif ralloc_header { -#ifdef DEBUG +#ifndef NDEBUG /* A canary value used to determine whether a pointer is ralloc'd. */ unsigned canary; #endif @@ -88,9 +88,7 @@ get_header(const void *ptr) { ralloc_header *info = (ralloc_header *) (((char *) ptr) - sizeof(ralloc_header)); -#ifdef DEBUG assert(info->canary == CANARY); -#endif return info; } @@ -140,7 +138,7 @@ ralloc_size(const void *ctx, size_t size) add_child(parent, info); -#ifdef DEBUG +#ifndef NDEBUG info->canary = CANARY; #endif @@ -566,7 +564,7 @@ struct __attribute__((aligned(8))) #endif linear_header { -#ifdef DEBUG +#ifndef NDEBUG unsigned magic; /* for debugging */ #endif unsigned offset; /* points to the first unused byte in the buffer */ @@ -616,7 +614,7 @@ create_linear_node(void *ralloc_ctx, unsigned min_size) if (unlikely(!node)) return NULL; -#ifdef DEBUG +#ifndef NDEBUG node->magic = LMAGIC; #endif node->offset = 0; @@ -636,9 +634,7 @@ linear_alloc_child(void *parent, unsigned size) linear_size_chunk *ptr; unsigned full_size; -#ifdef DEBUG assert(first->magic == LMAGIC); -#endif assert(!latest->next); size = ALIGN_POT(size, SUBALLOC_ALIGNMENT); @@ -712,9 +708,7 @@ linear_free_parent(void *ptr) return; node = LINEAR_PARENT_TO_HEADER(ptr); -#ifdef DEBUG assert(node->magic == LMAGIC); -#endif while (node) { void *ptr = node; @@ -733,9 +727,7 @@ ralloc_steal_linear_parent(void *new_ralloc_ctx, void *ptr) return; node = LINEAR_PARENT_TO_HEADER(ptr); -#ifdef DEBUG assert(node->magic == LMAGIC); -#endif while (node) { ralloc_steal(new_ralloc_ctx, node); @@ -748,9 +740,7 @@ void * ralloc_parent_of_linear_parent(void *ptr) { linear_header *node = LINEAR_PARENT_TO_HEADER(ptr); -#ifdef DEBUG assert(node->magic == LMAGIC); -#endif return node->ralloc_parent; } diff --git a/lib/mesa/src/util/set.c b/lib/mesa/src/util/set.c index fe5b10f0f..18f1262e3 100644 --- a/lib/mesa/src/util/set.c +++ b/lib/mesa/src/util/set.c @@ -36,6 +36,7 @@ #include <assert.h> #include <string.h> +#include "hash_table.h" #include "macros.h" #include "ralloc.h" #include "set.h" @@ -437,3 +438,13 @@ _mesa_set_random_entry(struct set *ht, return NULL; } + +/** + * Helper to create a set with pointer keys. + */ +struct set * +_mesa_pointer_set_create(void *mem_ctx) +{ + return _mesa_set_create(mem_ctx, _mesa_hash_pointer, + _mesa_key_pointer_equal); +} diff --git a/lib/mesa/src/util/slab.c b/lib/mesa/src/util/slab.c index 5f048666b..5477c75d4 100644 --- a/lib/mesa/src/util/slab.c +++ b/lib/mesa/src/util/slab.c @@ -280,25 +280,25 @@ void slab_free(struct slab_child_pool *pool, void *ptr) * Allocate an object from the slab. Single-threaded (no mutex). */ void * -slab_alloc_st(struct slab_mempool *pool) +slab_alloc_st(struct slab_mempool *mempool) { - return slab_alloc(&pool->child); + return slab_alloc(&mempool->child); } /** * Free an object allocated from the slab. Single-threaded (no mutex). */ void -slab_free_st(struct slab_mempool *pool, void *ptr) +slab_free_st(struct slab_mempool *mempool, void *ptr) { - slab_free(&pool->child, ptr); + slab_free(&mempool->child, ptr); } void -slab_destroy(struct slab_mempool *pool) +slab_destroy(struct slab_mempool *mempool) { - slab_destroy_child(&pool->child); - slab_destroy_parent(&pool->parent); + slab_destroy_child(&mempool->child); + slab_destroy_parent(&mempool->parent); } /** @@ -308,10 +308,10 @@ slab_destroy(struct slab_mempool *pool) * \param num_items Number of objects to allocate at once. */ void -slab_create(struct slab_mempool *pool, +slab_create(struct slab_mempool *mempool, unsigned item_size, unsigned num_items) { - slab_create_parent(&pool->parent, item_size, num_items); - slab_create_child(&pool->child, &pool->parent); + slab_create_parent(&mempool->parent, item_size, num_items); + slab_create_child(&mempool->child, &mempool->parent); } diff --git a/lib/mesa/src/util/u_cpu_detect.c b/lib/mesa/src/util/u_cpu_detect.c index f38ceacb8..c632059c2 100644 --- a/lib/mesa/src/util/u_cpu_detect.c +++ b/lib/mesa/src/util/u_cpu_detect.c @@ -368,19 +368,26 @@ check_os_arm_support(void) } #endif /* PIPE_OS_LINUX */ } -#endif /* PIPE_ARCH_ARM */ +#elif defined(PIPE_ARCH_AARCH64) static void -get_cpu_topology(void) +check_os_arm_support(void) { - uint32_t regs[4]; + util_cpu_caps.has_neon = true; +} +#endif /* PIPE_ARCH_ARM || PIPE_ARCH_AARCH64 */ +static void +get_cpu_topology(void) +{ /* Default. This is correct if L3 is not present or there is only one. */ util_cpu_caps.cores_per_L3 = util_cpu_caps.nr_cpus; #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) /* AMD Zen */ if (util_cpu_caps.x86_cpu_type == 0x17) { + uint32_t regs[4]; + /* Query the L3 cache topology information. */ cpuid_count(0x8000001D, 3, regs); unsigned cache_level = (regs[0] >> 5) & 0x7; @@ -537,7 +544,7 @@ util_cpu_detect_once(void) } #endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */ -#if defined(PIPE_ARCH_ARM) +#if defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64) check_os_arm_support(); #endif |