Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mesa / src / gallium / drivers / i915 / i915_winsys.h
blob20438609e072d1219473736e2eef5a3ce2616ab5
1 /**************************************************************************
3 * Copyright © 2009 Jakob Bornecrantz
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 **************************************************************************/
26 #ifndef I915_WINSYS_H
27 #define I915_WINSYS_H
29 #include "pipe/p_compiler.h"
31 struct i915_winsys;
32 struct i915_winsys_buffer;
33 struct i915_winsys_batchbuffer;
34 struct pipe_resource;
35 struct pipe_fence_handle;
36 struct winsys_handle;
38 enum i915_winsys_buffer_usage
40 /* use on textures */
41 I915_USAGE_RENDER = 0x01,
42 I915_USAGE_SAMPLER = 0x02,
43 I915_USAGE_2D_TARGET = 0x04,
44 I915_USAGE_2D_SOURCE = 0x08,
45 /* use on vertex */
46 I915_USAGE_VERTEX = 0x10
49 enum i915_winsys_buffer_type
51 I915_NEW_TEXTURE,
52 I915_NEW_SCANOUT, /**< a texture used for scanning out from */
53 I915_NEW_VERTEX
56 /* These need to be in sync with the definitions of libdrm-intel! */
57 enum i915_winsys_buffer_tile
59 I915_TILE_NONE,
60 I915_TILE_X,
61 I915_TILE_Y
64 struct i915_winsys_batchbuffer {
66 struct i915_winsys *iws;
68 /**
69 * Values exported to speed up the writing the batchbuffer,
70 * instead of having to go trough a accesor function for
71 * each dword written.
73 /*{@*/
74 uint8_t *map;
75 uint8_t *ptr;
76 size_t size;
78 size_t relocs;
79 /*@}*/
82 struct i915_winsys {
84 unsigned pci_id; /**< PCI ID for the device */
86 /**
87 * Batchbuffer functions.
89 /*@{*/
90 /**
91 * Create a new batchbuffer.
93 struct i915_winsys_batchbuffer *
94 (*batchbuffer_create)(struct i915_winsys *iws);
96 /**
97 * Validate buffers for usage in this batchbuffer.
98 * Does space-checking and asorted other book-keeping.
100 * @batch
101 * @buffers array to buffers to validate
102 * @num_of_buffers size of the passed array
104 boolean (*validate_buffers)(struct i915_winsys_batchbuffer *batch,
105 struct i915_winsys_buffer **buffers,
106 int num_of_buffers);
109 * Emit a relocation to a buffer.
110 * Target position in batchbuffer is the same as ptr.
112 * @batch
113 * @reloc buffer address to be inserted into target.
114 * @usage how is the hardware going to use the buffer.
115 * @offset add this to the reloc buffers address
116 * @target buffer where to write the address, null for batchbuffer.
117 * @fenced relocation needs a fence.
119 int (*batchbuffer_reloc)(struct i915_winsys_batchbuffer *batch,
120 struct i915_winsys_buffer *reloc,
121 enum i915_winsys_buffer_usage usage,
122 unsigned offset, boolean fenced);
125 * Flush a bufferbatch.
127 void (*batchbuffer_flush)(struct i915_winsys_batchbuffer *batch,
128 struct pipe_fence_handle **fence);
131 * Destroy a batchbuffer.
133 void (*batchbuffer_destroy)(struct i915_winsys_batchbuffer *batch);
134 /*@}*/
138 * Buffer functions.
140 /*@{*/
142 * Create a buffer.
144 struct i915_winsys_buffer *
145 (*buffer_create)(struct i915_winsys *iws,
146 unsigned size,
147 enum i915_winsys_buffer_type type);
150 * Create a tiled buffer.
152 * *stride, height are in bytes. The winsys tries to allocate the buffer with
153 * the tiling mode provide in *tiling. If tiling is no possible, *tiling will
154 * be set to I915_TILE_NONE. The calculated stride (incorporateing hw/kernel
155 * requirements) is always returned in *stride.
157 struct i915_winsys_buffer *
158 (*buffer_create_tiled)(struct i915_winsys *iws,
159 unsigned *stride, unsigned height,
160 enum i915_winsys_buffer_tile *tiling,
161 enum i915_winsys_buffer_type type);
164 * Creates a buffer from a handle.
165 * Used to implement pipe_screen::resource_from_handle.
166 * Also provides the stride information needed for the
167 * texture via the stride argument.
169 struct i915_winsys_buffer *
170 (*buffer_from_handle)(struct i915_winsys *iws,
171 struct winsys_handle *whandle,
172 enum i915_winsys_buffer_tile *tiling,
173 unsigned *stride);
176 * Used to implement pipe_screen::resource_get_handle.
177 * The winsys might need the stride information.
179 boolean (*buffer_get_handle)(struct i915_winsys *iws,
180 struct i915_winsys_buffer *buffer,
181 struct winsys_handle *whandle,
182 unsigned stride);
185 * Map a buffer.
187 void *(*buffer_map)(struct i915_winsys *iws,
188 struct i915_winsys_buffer *buffer,
189 boolean write);
192 * Unmap a buffer.
194 void (*buffer_unmap)(struct i915_winsys *iws,
195 struct i915_winsys_buffer *buffer);
198 * Write to a buffer.
200 * Arguments follows pipe_buffer_write.
202 int (*buffer_write)(struct i915_winsys *iws,
203 struct i915_winsys_buffer *dst,
204 size_t offset,
205 size_t size,
206 const void *data);
208 void (*buffer_destroy)(struct i915_winsys *iws,
209 struct i915_winsys_buffer *buffer);
212 * Check if a buffer is busy.
214 boolean (*buffer_is_busy)(struct i915_winsys *iws,
215 struct i915_winsys_buffer *buffer);
216 /*@}*/
220 * Fence functions.
222 /*@{*/
224 * Reference fence and set ptr to fence.
226 void (*fence_reference)(struct i915_winsys *iws,
227 struct pipe_fence_handle **ptr,
228 struct pipe_fence_handle *fence);
231 * Check if a fence has finished.
233 int (*fence_signalled)(struct i915_winsys *iws,
234 struct pipe_fence_handle *fence);
237 * Wait on a fence to finish.
239 int (*fence_finish)(struct i915_winsys *iws,
240 struct pipe_fence_handle *fence);
241 /*@}*/
245 * Destroy the winsys.
247 void (*destroy)(struct i915_winsys *iws);
250 #endif