diff options
author | Matt Turner <[email protected]> | 2014-06-10 02:08:10 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2014-06-10 13:05:51 -0700 |
commit | 4787c25a604fbbebaf7777655e0134e39bbb0a06 (patch) | |
tree | 75ae0b424123523e233871dbf8d94b808bfd9f91 | |
parent | 195141803872b3b1b6cb073cb4a95de784412506 (diff) |
i965: Replace open-coded linked list with exec_list.
Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 29 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_resolve_map.c | 60 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_resolve_map.h | 16 |
4 files changed, 45 insertions, 62 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index dd7e57aea84..a0e637a9095 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -261,6 +261,7 @@ intel_miptree_create_layout(struct brw_context *brw, mt->logical_height0 = height0; mt->logical_depth0 = depth0; mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_NO_MCS; + exec_list_make_empty(&mt->hiz_map); /* The cpp is bytes per (1, blockheight)-sized block for compressed * textures. This is why you'll see divides by blockheight all over @@ -1400,20 +1401,18 @@ intel_miptree_alloc_hiz(struct brw_context *brw, return false; /* Mark that all slices need a HiZ resolve. */ - struct intel_resolve_map *head = &mt->hiz_map; for (int level = mt->first_level; level <= mt->last_level; ++level) { if (!intel_miptree_level_enable_hiz(brw, mt, level)) continue; for (int layer = 0; layer < mt->level[level].depth; ++layer) { - head->next = malloc(sizeof(*head->next)); - head->next->prev = head; - head->next->next = NULL; - head = head->next; - - head->level = level; - head->layer = layer; - head->need = GEN6_HIZ_OP_HIZ_RESOLVE; + struct intel_resolve_map *m = malloc(sizeof(struct intel_resolve_map)); + exec_node_init(&m->link); + m->level = level; + m->layer = layer; + m->need = GEN6_HIZ_OP_HIZ_RESOLVE; + + exec_list_push_tail(&mt->hiz_map, &m->link); } } @@ -1513,15 +1512,15 @@ intel_miptree_all_slices_resolve(struct brw_context *brw, enum gen6_hiz_op need) { bool did_resolve = false; - struct intel_resolve_map *i, *next; - for (i = mt->hiz_map.next; i; i = next) { - next = i->next; - if (i->need != need) + foreach_list_safe(node, &mt->hiz_map) { + struct intel_resolve_map *map = (struct intel_resolve_map *)node; + + if (map->need != need) continue; - intel_hiz_exec(brw, mt, i->level, i->layer, need); - intel_resolve_map_remove(i); + intel_hiz_exec(brw, mt, map->level, map->layer, need); + intel_resolve_map_remove(map); did_resolve = true; } diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h index 6a918848de2..bb040845d51 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h @@ -381,7 +381,7 @@ struct intel_mipmap_tree * \c mt->hiz_map. The resolve map of the child HiZ miptree, \c * mt->hiz_mt->hiz_map, is unused. */ - struct intel_resolve_map hiz_map; + struct exec_list hiz_map; /* List of intel_resolve_map. */ /** * \brief Stencil miptree for depthstencil textures. diff --git a/src/mesa/drivers/dri/i965/intel_resolve_map.c b/src/mesa/drivers/dri/i965/intel_resolve_map.c index 04b5c942432..a37afa684dd 100644 --- a/src/mesa/drivers/dri/i965/intel_resolve_map.c +++ b/src/mesa/drivers/dri/i965/intel_resolve_map.c @@ -33,50 +33,42 @@ * changed to the given value of \c need. */ void -intel_resolve_map_set(struct intel_resolve_map *head, +intel_resolve_map_set(struct exec_list *resolve_map, uint32_t level, uint32_t layer, enum gen6_hiz_op need) { - struct intel_resolve_map **tail = &head->next; - struct intel_resolve_map *prev = head; - - while (*tail) { - if ((*tail)->level == level && (*tail)->layer == layer) { - (*tail)->need = need; + foreach_list_typed(struct intel_resolve_map, map, link, resolve_map) { + if (map->level == level && map->layer == layer) { + map->need = need; return; } - prev = *tail; - tail = &(*tail)->next; } - *tail = malloc(sizeof(**tail)); - (*tail)->prev = prev; - (*tail)->next = NULL; - (*tail)->level = level; - (*tail)->layer = layer; - (*tail)->need = need; + struct intel_resolve_map *m = malloc(sizeof(struct intel_resolve_map)); + exec_node_init(&m->link); + m->level = level; + m->layer = layer; + m->need = need; + + exec_list_push_tail(resolve_map, &m->link); } /** * \brief Get an element from the map. * \return null if element is not contained in map. */ -struct intel_resolve_map* -intel_resolve_map_get(struct intel_resolve_map *head, +struct intel_resolve_map * +intel_resolve_map_get(struct exec_list *resolve_map, uint32_t level, uint32_t layer) { - struct intel_resolve_map *item = head->next; - - while (item) { - if (item->level == level && item->layer == layer) - break; - else - item = item->next; + foreach_list_typed(struct intel_resolve_map, map, link, resolve_map) { + if (map->level == level && map->layer == layer) + return map; } - return item; + return NULL; } /** @@ -85,10 +77,7 @@ intel_resolve_map_get(struct intel_resolve_map *head, void intel_resolve_map_remove(struct intel_resolve_map *elem) { - if (elem->prev) - elem->prev->next = elem->next; - if (elem->next) - elem->next->prev = elem->prev; + exec_node_remove(&elem->link); free(elem); } @@ -96,16 +85,11 @@ intel_resolve_map_remove(struct intel_resolve_map *elem) * \brief Remove and free all elements of the map. */ void -intel_resolve_map_clear(struct intel_resolve_map *head) +intel_resolve_map_clear(struct exec_list *resolve_map) { - struct intel_resolve_map *next = head->next; - struct intel_resolve_map *trash; - - while (next) { - trash = next; - next = next->next; - free(trash); + foreach_list_safe(node, resolve_map) { + free(node); } - head->next = NULL; + exec_list_make_empty(resolve_map); } diff --git a/src/mesa/drivers/dri/i965/intel_resolve_map.h b/src/mesa/drivers/dri/i965/intel_resolve_map.h index 8504271f5cb..9bb9fca0455 100644 --- a/src/mesa/drivers/dri/i965/intel_resolve_map.h +++ b/src/mesa/drivers/dri/i965/intel_resolve_map.h @@ -24,6 +24,7 @@ #pragma once #include <stdint.h> +#include "glsl/list.h" #ifdef __cplusplus extern "C" { @@ -73,30 +74,29 @@ enum gen6_hiz_op { * necessary. */ struct intel_resolve_map { + struct exec_node link; + uint32_t level; uint32_t layer; enum gen6_hiz_op need; - - struct intel_resolve_map *next; - struct intel_resolve_map *prev; }; void -intel_resolve_map_set(struct intel_resolve_map *head, +intel_resolve_map_set(struct exec_list *resolve_map, uint32_t level, uint32_t layer, enum gen6_hiz_op need); -struct intel_resolve_map* -intel_resolve_map_get(struct intel_resolve_map *head, +struct intel_resolve_map * +intel_resolve_map_get(struct exec_list *resolve_map, uint32_t level, uint32_t layer); void -intel_resolve_map_remove(struct intel_resolve_map *elem); +intel_resolve_map_remove(struct intel_resolve_map *resolve_map); void -intel_resolve_map_clear(struct intel_resolve_map *head); +intel_resolve_map_clear(struct exec_list *resolve_map); #ifdef __cplusplus } /* extern "C" */ |