2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "intel_resolve_map.h"
30 * \brief Set that the miptree slice at (level, layer) needs a resolve.
32 * \pre If a map element already exists with the given key, then
33 * the new and existing element value must be identical.
36 intel_resolve_map_set(struct intel_resolve_map
*head
,
39 enum gen6_hiz_op need
)
41 struct intel_resolve_map
**tail
= &head
->next
;
42 struct intel_resolve_map
*prev
= head
;
45 if ((*tail
)->level
== level
&& (*tail
)->layer
== layer
) {
46 assert((*tail
)->need
== need
);
50 tail
= &(*tail
)->next
;
53 *tail
= malloc(sizeof(**tail
));
56 (*tail
)->level
= level
;
57 (*tail
)->layer
= layer
;
62 * \brief Get an element from the map.
63 * \return null if element is not contained in map.
65 struct intel_resolve_map
*
66 intel_resolve_map_get(struct intel_resolve_map
*head
,
70 struct intel_resolve_map
*item
= head
->next
;
73 if (item
->level
== level
&& item
->layer
== layer
)
83 * \brief Remove and free an element from the map.
86 intel_resolve_map_remove(struct intel_resolve_map
*elem
)
89 elem
->prev
->next
= elem
->next
;
91 elem
->next
->prev
= elem
->prev
;
96 * \brief Remove and free all elements of the map.
99 intel_resolve_map_clear(struct intel_resolve_map
*head
)
101 struct intel_resolve_map
*next
= head
->next
;
102 struct intel_resolve_map
*trash
;