1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef GLHD_OBJECTS_H
29 #define GLHD_OBJECTS_H
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_state.h"
35 #include "glhd_screen.h"
37 struct galahad_context
;
40 struct galahad_resource
42 struct pipe_resource base
;
44 struct pipe_resource
*resource
;
50 struct galahad_sampler_view
52 struct pipe_sampler_view base
;
54 struct pipe_sampler_view
*sampler_view
;
58 struct galahad_surface
60 struct pipe_surface base
;
62 struct pipe_surface
*surface
;
66 struct galahad_transfer
68 struct pipe_transfer base
;
70 struct pipe_transfer
*transfer
;
74 static INLINE
struct galahad_resource
*
75 galahad_resource(struct pipe_resource
*_resource
)
79 (void)galahad_screen(_resource
->screen
);
80 return (struct galahad_resource
*)_resource
;
83 static INLINE
struct galahad_sampler_view
*
84 galahad_sampler_view(struct pipe_sampler_view
*_sampler_view
)
89 return (struct galahad_sampler_view
*)_sampler_view
;
92 static INLINE
struct galahad_surface
*
93 galahad_surface(struct pipe_surface
*_surface
)
97 (void)galahad_resource(_surface
->texture
);
98 return (struct galahad_surface
*)_surface
;
101 static INLINE
struct galahad_transfer
*
102 galahad_transfer(struct pipe_transfer
*_transfer
)
106 (void)galahad_resource(_transfer
->resource
);
107 return (struct galahad_transfer
*)_transfer
;
110 static INLINE
struct pipe_resource
*
111 galahad_resource_unwrap(struct pipe_resource
*_resource
)
115 return galahad_resource(_resource
)->resource
;
118 static INLINE
struct pipe_sampler_view
*
119 galahad_sampler_view_unwrap(struct pipe_sampler_view
*_sampler_view
)
121 if (!_sampler_view
) {
124 return galahad_sampler_view(_sampler_view
)->sampler_view
;
127 static INLINE
struct pipe_surface
*
128 galahad_surface_unwrap(struct pipe_surface
*_surface
)
132 return galahad_surface(_surface
)->surface
;
135 static INLINE
struct pipe_transfer
*
136 galahad_transfer_unwrap(struct pipe_transfer
*_transfer
)
140 return galahad_transfer(_transfer
)->transfer
;
144 struct pipe_resource
*
145 galahad_resource_create(struct galahad_screen
*glhd_screen
,
146 struct pipe_resource
*resource
);
149 galahad_resource_destroy(struct galahad_resource
*glhd_resource
);
151 struct pipe_surface
*
152 galahad_surface_create(struct galahad_context
*glhd_context
,
153 struct galahad_resource
*glhd_resource
,
154 struct pipe_surface
*surface
);
157 galahad_surface_destroy(struct galahad_context
*glhd_context
,
158 struct galahad_surface
*glhd_surface
);
160 struct pipe_sampler_view
*
161 galahad_sampler_view_create(struct galahad_context
*glhd_context
,
162 struct galahad_resource
*glhd_resource
,
163 struct pipe_sampler_view
*view
);
166 galahad_sampler_view_destroy(struct galahad_context
*glhd_context
,
167 struct galahad_sampler_view
*glhd_sampler_view
);
169 struct pipe_transfer
*
170 galahad_transfer_create(struct galahad_context
*glhd_context
,
171 struct galahad_resource
*glhd_resource
,
172 struct pipe_transfer
*transfer
);
175 galahad_transfer_destroy(struct galahad_context
*glhd_context
,
176 struct galahad_transfer
*glhd_transfer
);
179 #endif /* GLHD_OBJECTS_H */