• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 VMware, Inc.
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * 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, sub license, 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:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 
27 #ifndef ST_SAMPLER_VIEW_H
28 #define ST_SAMPLER_VIEW_H
29 
30 #include "pipe/p_compiler.h"
31 #include "pipe/p_context.h"
32 #include "pipe/p_state.h"
33 #include "util/u_sampler.h"
34 
35 struct st_texture_object;
36 
37 
38 static inline struct pipe_sampler_view *
st_create_texture_sampler_view_format(struct pipe_context * pipe,struct pipe_resource * texture,enum pipe_format format)39 st_create_texture_sampler_view_format(struct pipe_context *pipe,
40                                       struct pipe_resource *texture,
41                                       enum pipe_format format)
42 {
43    struct pipe_sampler_view templ;
44 
45    u_sampler_view_default_template(&templ, texture, format);
46 
47    return pipe->create_sampler_view(pipe, texture, &templ);
48 }
49 
50 
51 static inline struct pipe_sampler_view *
st_create_texture_sampler_view(struct pipe_context * pipe,struct pipe_resource * texture)52 st_create_texture_sampler_view(struct pipe_context *pipe,
53                                struct pipe_resource *texture)
54 {
55    return st_create_texture_sampler_view_format(pipe, texture,
56                                                 texture->format);
57 }
58 
59 
60 extern struct pipe_sampler_view **
61 st_texture_get_sampler_view(struct st_context *st,
62                             struct st_texture_object *stObj);
63 
64 extern void
65 st_texture_release_sampler_view(struct st_context *st,
66                                 struct st_texture_object *stObj);
67 
68 extern void
69 st_texture_release_all_sampler_views(struct st_context *st,
70                                      struct st_texture_object *stObj);
71 
72 void
73 st_texture_free_sampler_views(struct st_texture_object *stObj);
74 
75 
76 struct pipe_sampler_view *
77 st_get_texture_sampler_view_from_stobj(struct st_context *st,
78                                        struct st_texture_object *stObj,
79                                        const struct gl_sampler_object *samp,
80                                        unsigned glsl_version);
81 
82 
83 #endif /* ST_SAMPLER_VIEW_H */
84