glhd: Add query protection.
[mesa.git] / src / gallium / drivers / galahad / glhd_objects.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef GLHD_OBJECTS_H
29 #define GLHD_OBJECTS_H
30
31
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_state.h"
34
35 #include "glhd_screen.h"
36
37 struct galahad_context;
38
39
40 struct galahad_resource
41 {
42 struct pipe_resource base;
43
44 struct pipe_resource *resource;
45 };
46
47
48 struct galahad_sampler_view
49 {
50 struct pipe_sampler_view base;
51
52 struct pipe_sampler_view *sampler_view;
53 };
54
55
56 struct galahad_surface
57 {
58 struct pipe_surface base;
59
60 struct pipe_surface *surface;
61 };
62
63
64 struct galahad_transfer
65 {
66 struct pipe_transfer base;
67
68 struct pipe_transfer *transfer;
69 };
70
71
72 static INLINE struct galahad_resource *
73 galahad_resource(struct pipe_resource *_resource)
74 {
75 if(!_resource)
76 return NULL;
77 (void)galahad_screen(_resource->screen);
78 return (struct galahad_resource *)_resource;
79 }
80
81 static INLINE struct galahad_sampler_view *
82 galahad_sampler_view(struct pipe_sampler_view *_sampler_view)
83 {
84 if (!_sampler_view) {
85 return NULL;
86 }
87 return (struct galahad_sampler_view *)_sampler_view;
88 }
89
90 static INLINE struct galahad_surface *
91 galahad_surface(struct pipe_surface *_surface)
92 {
93 if(!_surface)
94 return NULL;
95 (void)galahad_resource(_surface->texture);
96 return (struct galahad_surface *)_surface;
97 }
98
99 static INLINE struct galahad_transfer *
100 galahad_transfer(struct pipe_transfer *_transfer)
101 {
102 if(!_transfer)
103 return NULL;
104 (void)galahad_resource(_transfer->resource);
105 return (struct galahad_transfer *)_transfer;
106 }
107
108 static INLINE struct pipe_resource *
109 galahad_resource_unwrap(struct pipe_resource *_resource)
110 {
111 if(!_resource)
112 return NULL;
113 return galahad_resource(_resource)->resource;
114 }
115
116 static INLINE struct pipe_sampler_view *
117 galahad_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)
118 {
119 if (!_sampler_view) {
120 return NULL;
121 }
122 return galahad_sampler_view(_sampler_view)->sampler_view;
123 }
124
125 static INLINE struct pipe_surface *
126 galahad_surface_unwrap(struct pipe_surface *_surface)
127 {
128 if(!_surface)
129 return NULL;
130 return galahad_surface(_surface)->surface;
131 }
132
133 static INLINE struct pipe_transfer *
134 galahad_transfer_unwrap(struct pipe_transfer *_transfer)
135 {
136 if(!_transfer)
137 return NULL;
138 return galahad_transfer(_transfer)->transfer;
139 }
140
141
142 struct pipe_resource *
143 galahad_resource_create(struct galahad_screen *glhd_screen,
144 struct pipe_resource *resource);
145
146 void
147 galahad_resource_destroy(struct galahad_resource *glhd_resource);
148
149 struct pipe_surface *
150 galahad_surface_create(struct galahad_resource *glhd_resource,
151 struct pipe_surface *surface);
152
153 void
154 galahad_surface_destroy(struct galahad_surface *glhd_surface);
155
156 struct pipe_sampler_view *
157 galahad_sampler_view_create(struct galahad_context *glhd_context,
158 struct galahad_resource *glhd_resource,
159 struct pipe_sampler_view *view);
160
161 void
162 galahad_sampler_view_destroy(struct galahad_context *glhd_context,
163 struct galahad_sampler_view *glhd_sampler_view);
164
165 struct pipe_transfer *
166 galahad_transfer_create(struct galahad_context *glhd_context,
167 struct galahad_resource *glhd_resource,
168 struct pipe_transfer *transfer);
169
170 void
171 galahad_transfer_destroy(struct galahad_context *glhd_context,
172 struct galahad_transfer *glhd_transfer);
173
174
175 #endif /* GLHD_OBJECTS_H */