grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mesa / src / gallium / auxiliary / util / u_dirty_surfaces.h
blobf3618d9be74b080cad2209e44c8adf4d76ff4b33
1 /**************************************************************************
3 * Copyright 2010 Luca Barbieri
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
27 #ifndef U_DIRTY_SURFACES_H_
28 #define U_DIRTY_SURFACES_H_
30 #include "pipe/p_state.h"
32 #include "util/u_double_list.h"
33 #include "util/u_math.h"
35 struct pipe_context;
37 typedef void (*util_dirty_surface_flush_t) (struct pipe_context *, struct pipe_surface *);
39 struct util_dirty_surfaces
41 struct list_head dirty_list;
44 struct util_dirty_surface
46 struct pipe_surface base;
47 struct list_head dirty_list;
50 static INLINE void
51 util_dirty_surfaces_init(struct util_dirty_surfaces *ds)
53 LIST_INITHEAD(&ds->dirty_list);
56 static INLINE void
57 util_dirty_surfaces_use_for_sampling(struct pipe_context *pipe, struct util_dirty_surfaces *dss, util_dirty_surface_flush_t flush)
59 struct list_head *p, *next;
60 for(p = dss->dirty_list.next; p != &dss->dirty_list; p = next)
62 struct util_dirty_surface *ds = LIST_ENTRY(struct util_dirty_surface, p, dirty_list);
63 next = p->next;
65 flush(pipe, &ds->base);
69 static INLINE void
70 util_dirty_surfaces_use_levels_for_sampling(struct pipe_context *pipe, struct util_dirty_surfaces *dss, unsigned first, unsigned last, util_dirty_surface_flush_t flush)
72 struct list_head *p, *next;
73 if(first > last)
74 return;
75 for(p = dss->dirty_list.next; p != &dss->dirty_list; p = next)
77 struct util_dirty_surface *ds = LIST_ENTRY(struct util_dirty_surface, p, dirty_list);
78 next = p->next;
80 if(ds->base.u.tex.level >= first && ds->base.u.tex.level <= last)
81 flush(pipe, &ds->base);
85 static INLINE void
86 util_dirty_surfaces_use_for_sampling_with(struct pipe_context *pipe, struct util_dirty_surfaces *dss, struct pipe_sampler_view *psv, struct pipe_sampler_state *pss, util_dirty_surface_flush_t flush)
88 if(!LIST_IS_EMPTY(&dss->dirty_list))
89 util_dirty_surfaces_use_levels_for_sampling(pipe, dss, (unsigned)pss->min_lod + psv->u.tex.first_level,
90 MIN2((unsigned)ceilf(pss->max_lod) + psv->u.tex.first_level, psv->u.tex.last_level), flush);
93 static INLINE void
94 util_dirty_surface_init(struct util_dirty_surface *ds)
96 LIST_INITHEAD(&ds->dirty_list);
99 static INLINE boolean
100 util_dirty_surface_is_dirty(struct util_dirty_surface *ds)
102 return !LIST_IS_EMPTY(&ds->dirty_list);
105 static INLINE void
106 util_dirty_surface_set_dirty(struct util_dirty_surfaces *dss, struct util_dirty_surface *ds)
108 if(LIST_IS_EMPTY(&ds->dirty_list))
109 LIST_ADDTAIL(&ds->dirty_list, &dss->dirty_list);
112 static INLINE void
113 util_dirty_surface_set_clean(struct util_dirty_surfaces *dss, struct util_dirty_surface *ds)
115 if(!LIST_IS_EMPTY(&ds->dirty_list))
116 LIST_DELINIT(&ds->dirty_list);
119 #endif