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
24 **********************************************************/
26 #ifndef SVGA_SAMPLER_VIEW_H
27 #define SVGA_SAMPLER_VIEW_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"
38 struct svga_winsys_surface
;
40 enum SVGA3dSurfaceFormat
;
44 * A sampler's view into a texture
46 * We currently cache one sampler view on
47 * the texture and in there by holding a reference
48 * from the texture to the sampler view.
50 * Because of this we can not hold a refernce to the
51 * texture from the sampler view. So the user
52 * of the sampler views must make sure that the
53 * texture has a reference take for as long as
54 * the sampler view is refrenced.
56 * Just unreferencing the sampler_view before the
59 struct svga_sampler_view
61 struct pipe_reference reference
;
63 struct pipe_resource
*texture
;
70 struct svga_host_surface_cache_key key
;
71 struct svga_winsys_surface
*handle
;
76 extern struct svga_sampler_view
*
77 svga_get_tex_sampler_view(struct pipe_context
*pipe
,
78 struct pipe_resource
*pt
,
79 unsigned min_lod
, unsigned max_lod
);
82 svga_validate_sampler_view(struct svga_context
*svga
, struct svga_sampler_view
*v
);
85 svga_destroy_sampler_view_priv(struct svga_sampler_view
*v
);
88 svga_debug_describe_sampler_view(char *buf
, const struct svga_sampler_view
*sv
);
91 svga_sampler_view_reference(struct svga_sampler_view
**ptr
, struct svga_sampler_view
*v
)
93 struct svga_sampler_view
*old
= *ptr
;
95 if (pipe_reference_described(&(*ptr
)->reference
, &v
->reference
,
96 (debug_reference_descriptor
)svga_debug_describe_sampler_view
))
97 svga_destroy_sampler_view_priv(old
);
102 svga_check_sampler_view_resource_collision(struct svga_context
*svga
,
103 struct svga_winsys_surface
*res
,