gallium: add target-helpers/wrap_screen.c to C_SOURCES
[mesa/mesa-lb.git] / src / gallium / drivers / svga / svga_screen_texture.h
blob96d035b12d80e75ab07201aff6b5e70107dea2c5
1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
24 **********************************************************/
26 #ifndef SVGA_TEXTURE_H
27 #define SVGA_TEXTURE_H
30 #include "pipe/p_compiler.h"
31 #include "pipe/p_state.h"
32 #include "util/u_inlines.h"
33 #include "svga_screen_cache.h"
35 struct pipe_context;
36 struct pipe_screen;
37 struct svga_context;
38 struct svga_winsys_surface;
39 enum SVGA3dSurfaceFormat;
42 #define SVGA_MAX_TEXTURE_LEVELS 16
45 /**
46 * A sampler's view into a texture
48 * We currently cache one sampler view on
49 * the texture and in there by holding a reference
50 * from the texture to the sampler view.
52 * Because of this we can not hold a refernce to the
53 * texture from the sampler view. So the user
54 * of the sampler views must make sure that the
55 * texture has a reference take for as long as
56 * the sampler view is refrenced.
58 * Just unreferencing the sampler_view before the
59 * texture is enough.
61 struct svga_sampler_view
63 struct pipe_reference reference;
65 struct pipe_texture *texture;
67 int min_lod;
68 int max_lod;
70 unsigned age;
72 struct svga_host_surface_cache_key key;
73 struct svga_winsys_surface *handle;
77 struct svga_texture
79 struct pipe_texture base;
81 boolean defined[6][SVGA_MAX_TEXTURE_LEVELS];
83 struct svga_sampler_view *cached_view;
85 unsigned view_age[SVGA_MAX_TEXTURE_LEVELS];
86 unsigned age;
88 boolean views_modified;
90 /**
91 * Creation key for the host surface handle.
93 * This structure describes all the host surface characteristics so that it
94 * can be looked up in cache, since creating a host surface is often a slow
95 * operation.
97 struct svga_host_surface_cache_key key;
99 /**
100 * Handle for the host side surface.
102 * This handle is owned by this texture. Views should hold on to a reference
103 * to this texture and never destroy this handle directly.
105 struct svga_winsys_surface *handle;
109 struct svga_surface
111 struct pipe_surface base;
113 struct svga_host_surface_cache_key key;
114 struct svga_winsys_surface *handle;
116 unsigned real_face;
117 unsigned real_level;
118 unsigned real_zslice;
120 boolean dirty;
124 struct svga_transfer
126 struct pipe_transfer base;
128 struct svga_winsys_buffer *hwbuf;
130 /* Height of the hardware buffer in pixel blocks */
131 unsigned hw_nblocksy;
133 /* Temporary malloc buffer when we can't allocate a hardware buffer
134 * big enough */
135 void *swbuf;
139 static INLINE struct svga_texture *
140 svga_texture(struct pipe_texture *texture)
142 return (struct svga_texture *)texture;
145 static INLINE struct svga_surface *
146 svga_surface(struct pipe_surface *surface)
148 assert(surface);
149 return (struct svga_surface *)surface;
152 static INLINE struct svga_transfer *
153 svga_transfer(struct pipe_transfer *transfer)
155 assert(transfer);
156 return (struct svga_transfer *)transfer;
159 extern struct svga_sampler_view *
160 svga_get_tex_sampler_view(struct pipe_context *pipe,
161 struct pipe_texture *pt,
162 unsigned min_lod, unsigned max_lod);
164 void
165 svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v);
167 void
168 svga_destroy_sampler_view_priv(struct svga_sampler_view *v);
170 static INLINE void
171 svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)
173 struct svga_sampler_view *old = *ptr;
175 if (pipe_reference(&(*ptr)->reference, &v->reference))
176 svga_destroy_sampler_view_priv(old);
177 *ptr = v;
180 extern void
181 svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf);
183 extern boolean
184 svga_surface_needs_propagation(struct pipe_surface *surf);
186 extern void
187 svga_screen_init_texture_functions(struct pipe_screen *screen);
189 void
190 svga_init_texture_functions(struct pipe_context *pipe);
192 enum SVGA3dSurfaceFormat
193 svga_translate_format(enum pipe_format format);
195 enum SVGA3dSurfaceFormat
196 svga_translate_format_render(enum pipe_format format);
199 #endif /* SVGA_TEXTURE_H */