1 /*
2 * Copyright © 2014-2018 NVIDIA Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #ifndef TEGRA_CONTEXT_H
25 #define TEGRA_CONTEXT_H
26
27 #include "pipe/p_context.h"
28 #include "pipe/p_state.h"
29
30 struct tegra_screen;
31
32 struct tegra_context {
33 struct pipe_context base;
34 struct pipe_context *gpu;
35 };
36
37 static inline struct tegra_context *
to_tegra_context(struct pipe_context * context)38 to_tegra_context(struct pipe_context *context)
39 {
40 return (struct tegra_context *)context;
41 }
42
43 struct pipe_context *
44 tegra_screen_context_create(struct pipe_screen *pscreen, void *priv,
45 unsigned int flags);
46
47 struct tegra_sampler_view {
48 struct pipe_sampler_view base;
49 struct pipe_sampler_view *gpu;
50 unsigned int refcount;
51 };
52
53 static inline struct tegra_sampler_view *
to_tegra_sampler_view(struct pipe_sampler_view * view)54 to_tegra_sampler_view(struct pipe_sampler_view *view)
55 {
56 return (struct tegra_sampler_view *)view;
57 }
58
59 static inline struct pipe_sampler_view *
tegra_sampler_view_unwrap(struct pipe_sampler_view * view)60 tegra_sampler_view_unwrap(struct pipe_sampler_view *view)
61 {
62 if (!view)
63 return NULL;
64
65 return to_tegra_sampler_view(view)->gpu;
66 }
67
68 struct tegra_transfer {
69 struct pipe_transfer base;
70 struct pipe_transfer *gpu;
71
72 unsigned int count;
73 void *map;
74 };
75
76 static inline struct tegra_transfer *
to_tegra_transfer(struct pipe_transfer * transfer)77 to_tegra_transfer(struct pipe_transfer *transfer)
78 {
79 return (struct tegra_transfer *)transfer;
80 }
81
82 #endif /* TEGRA_SCREEN_H */
83