Tizen 2.1 base
[sdk/emulator/qemu.git] / gl / mesa / src / mesa / drivers / dri / intel / 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 #pragma once
25
26 #include <stdint.h>
27
28 enum intel_need_resolve {
29    INTEL_NEED_HIZ_RESOLVE,
30    INTEL_NEED_DEPTH_RESOLVE,
31 };
32
33 /**
34  * \brief Map of miptree slices to needed resolves.
35  *
36  * The map is implemented as a linear doubly-linked list.
37  *
38  * In the intel_resolve_map*() functions, the \c head argument is not
39  * inspected for its data. It only serves as an anchor for the list.
40  *
41  * \par Design Discussion
42  *
43  *     There are two possible ways to record which miptree slices need
44  *     resolves. 1) Maintain a flag for every miptree slice in the texture,
45  *     likely in intel_mipmap_level::slice, or 2) maintain a list of only
46  *     those slices that need a resolve.
47  *
48  *     Immediately before drawing, a full depth resolve performed on each
49  *     enabled depth texture. If design 1 were chosen, then at each draw call
50  *     it would be necessary to iterate over each miptree slice of each
51  *     enabled depth texture in order to query if each slice needed a resolve.
52  *     In the worst case, this would require 2^16 iterations: 16 texture
53  *     units, 16 miplevels, and 256 depth layers (assuming maximums for OpenGL
54  *     2.1).
55  *
56  *     By choosing design 2, the number of iterations is exactly the minimum
57  *     necessary.
58  */
59 struct intel_resolve_map {
60    uint32_t level;
61    uint32_t layer;
62    enum intel_need_resolve need;
63
64    struct intel_resolve_map *next;
65    struct intel_resolve_map *prev;
66 };
67
68 void
69 intel_resolve_map_set(struct intel_resolve_map *head,
70                       uint32_t level,
71                       uint32_t layer,
72                       enum intel_need_resolve need);
73
74 struct intel_resolve_map*
75 intel_resolve_map_get(struct intel_resolve_map *head,
76                       uint32_t level,
77                       uint32_t layer);
78
79 void
80 intel_resolve_map_remove(struct intel_resolve_map *elem);
81
82 void
83 intel_resolve_map_clear(struct intel_resolve_map *head);