i965: Wholesale replace the color resolve tracking code
[mesa.git] / src / mesa / drivers / dri / i965 / intel_resolve_map.h
1 /*
2 * Copyright © 2011 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 */
23
24 #ifndef INTEL_RESLVE_MAP_H
25 #define INTEL_RESLVE_MAP_H
26
27 #include <stdint.h>
28 #include "blorp/blorp.h"
29 #include "compiler/glsl/list.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36 * \brief Map of miptree slices to needed resolves.
37 *
38 * The map is implemented as a linear doubly-linked list.
39 *
40 * In the intel_resolve_map*() functions, the \c head argument is not
41 * inspected for its data. It only serves as an anchor for the list.
42 *
43 * \par Design Discussion
44 *
45 * There are two possible ways to record which miptree slices need
46 * resolves. 1) Maintain a flag for every miptree slice in the texture,
47 * likely in intel_mipmap_level::slice, or 2) maintain a list of only
48 * those slices that need a resolve.
49 *
50 * Immediately before drawing, a full depth resolve performed on each
51 * enabled depth texture. If design 1 were chosen, then at each draw call
52 * it would be necessary to iterate over each miptree slice of each
53 * enabled depth texture in order to query if each slice needed a resolve.
54 * In the worst case, this would require 2^16 iterations: 16 texture
55 * units, 16 miplevels, and 256 depth layers (assuming maximums for OpenGL
56 * 2.1).
57 *
58 * By choosing design 2, the number of iterations is exactly the minimum
59 * necessary.
60 */
61 struct intel_resolve_map {
62 struct exec_node link;
63
64 uint32_t level;
65 uint32_t layer;
66
67 enum blorp_hiz_op need;
68 };
69
70 void
71 intel_resolve_map_set(struct exec_list *resolve_map,
72 uint32_t level,
73 uint32_t layer,
74 unsigned new_state);
75
76 const struct intel_resolve_map *
77 intel_resolve_map_find_any(const struct exec_list *resolve_map,
78 uint32_t start_level, uint32_t num_levels,
79 uint32_t start_layer, uint32_t num_layers);
80
81 static inline const struct intel_resolve_map *
82 intel_resolve_map_const_get(const struct exec_list *resolve_map,
83 uint32_t level,
84 uint32_t layer)
85 {
86 return intel_resolve_map_find_any(resolve_map, level, 1, layer, 1);
87 }
88
89 static inline struct intel_resolve_map *
90 intel_resolve_map_get(struct exec_list *resolve_map,
91 uint32_t level,
92 uint32_t layer)
93 {
94 return (struct intel_resolve_map *)intel_resolve_map_find_any(
95 resolve_map, level, 1, layer, 1);
96 }
97
98 void
99 intel_resolve_map_remove(struct intel_resolve_map *resolve_map);
100
101 void
102 intel_resolve_map_clear(struct exec_list *resolve_map);
103
104 #ifdef __cplusplus
105 } /* extern "C" */
106 #endif
107
108 #endif /* INTEL_RESLVE_MAP_H */