tegra_context.h revision b8e80941
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
30struct tegra_screen;
31
32struct tegra_context {
33   struct pipe_context base;
34   struct pipe_context *gpu;
35};
36
37static inline struct tegra_context *
38to_tegra_context(struct pipe_context *context)
39{
40   return (struct tegra_context *)context;
41}
42
43struct pipe_context *
44tegra_screen_context_create(struct pipe_screen *pscreen, void *priv,
45                            unsigned int flags);
46
47struct tegra_sampler_view {
48   struct pipe_sampler_view base;
49   struct pipe_sampler_view *gpu;
50};
51
52static inline struct tegra_sampler_view *
53to_tegra_sampler_view(struct pipe_sampler_view *view)
54{
55   return (struct tegra_sampler_view *)view;
56}
57
58static inline struct pipe_sampler_view *
59tegra_sampler_view_unwrap(struct pipe_sampler_view *view)
60{
61   if (!view)
62      return NULL;
63
64   return to_tegra_sampler_view(view)->gpu;
65}
66
67struct tegra_transfer {
68   struct pipe_transfer base;
69   struct pipe_transfer *gpu;
70
71   unsigned int count;
72   void *map;
73};
74
75static inline struct tegra_transfer *
76to_tegra_transfer(struct pipe_transfer *transfer)
77{
78   return (struct tegra_transfer *)transfer;
79}
80
81#endif /* TEGRA_SCREEN_H */
82