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
35static inline struct pipe_sampler_view *
36st_create_texture_sampler_view_format(struct pipe_context *pipe,
37                                      struct pipe_resource *texture,
38                                      enum pipe_format format)
39{
40   struct pipe_sampler_view templ;
41
42   u_sampler_view_default_template(&templ, texture, format);
43
44   return pipe->create_sampler_view(pipe, texture, &templ);
45}
46
47
48static inline struct pipe_sampler_view *
49st_create_texture_sampler_view(struct pipe_context *pipe,
50                               struct pipe_resource *texture)
51{
52   return st_create_texture_sampler_view_format(pipe, texture,
53                                                texture->format);
54}
55
56
57extern void
58st_texture_release_context_sampler_view(struct st_context *st,
59                                        struct gl_texture_object *stObj);
60
61extern void
62st_texture_release_all_sampler_views(struct st_context *st,
63                                     struct gl_texture_object *stObj);
64
65void
66st_delete_texture_sampler_views(struct st_context *st,
67                                struct gl_texture_object *stObj);
68
69struct st_sampler_view *
70st_texture_get_current_sampler_view(const struct st_context *st,
71                                    const struct gl_texture_object *stObj);
72
73struct pipe_sampler_view *
74st_get_texture_sampler_view_from_stobj(struct st_context *st,
75                                       struct gl_texture_object *stObj,
76                                       const struct gl_sampler_object *samp,
77                                       bool glsl130_or_later,
78                                       bool ignore_srgb_decode,
79                                       bool get_reference);
80
81struct pipe_sampler_view *
82st_get_buffer_sampler_view_from_stobj(struct st_context *st,
83                                      struct gl_texture_object *stObj,
84                                      bool get_reference);
85
86enum pipe_format
87st_get_sampler_view_format(const struct st_context *st,
88                           const struct gl_texture_object *texObj,
89                           bool srgb_skip_decode);
90
91#endif /* ST_SAMPLER_VIEW_H */
92