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
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 **************************************************************************/
29 #include "pipe/p_compiler.h"
32 struct i915_winsys_buffer
;
33 struct i915_winsys_batchbuffer
;
35 struct pipe_fence_handle
;
38 enum i915_winsys_buffer_usage
41 I915_USAGE_RENDER
= 0x01,
42 I915_USAGE_SAMPLER
= 0x02,
43 I915_USAGE_2D_TARGET
= 0x04,
44 I915_USAGE_2D_SOURCE
= 0x08,
46 I915_USAGE_VERTEX
= 0x10
49 enum i915_winsys_buffer_type
52 I915_NEW_SCANOUT
, /**< a texture used for scanning out from */
56 /* These need to be in sync with the definitions of libdrm-intel! */
57 enum i915_winsys_buffer_tile
64 struct i915_winsys_batchbuffer
{
66 struct i915_winsys
*iws
;
69 * Values exported to speed up the writing the batchbuffer,
70 * instead of having to go trough a accesor function for
85 unsigned pci_id
; /**< PCI ID for the device */
88 * Batchbuffer functions.
92 * Create a new batchbuffer.
94 struct i915_winsys_batchbuffer
*
95 (*batchbuffer_create
)(struct i915_winsys
*iws
);
98 * Emit a relocation to a buffer.
99 * Target position in batchbuffer is the same as ptr.
102 * @reloc buffer address to be inserted into target.
103 * @usage how is the hardware going to use the buffer.
104 * @offset add this to the reloc buffers address
105 * @target buffer where to write the address, null for batchbuffer.
106 * @fenced relocation needs a fence.
108 int (*batchbuffer_reloc
)(struct i915_winsys_batchbuffer
*batch
,
109 struct i915_winsys_buffer
*reloc
,
110 enum i915_winsys_buffer_usage usage
,
111 unsigned offset
, boolean fenced
);
114 * Flush a bufferbatch.
116 void (*batchbuffer_flush
)(struct i915_winsys_batchbuffer
*batch
,
117 struct pipe_fence_handle
**fence
);
120 * Destroy a batchbuffer.
122 void (*batchbuffer_destroy
)(struct i915_winsys_batchbuffer
*batch
);
133 struct i915_winsys_buffer
*
134 (*buffer_create
)(struct i915_winsys
*iws
,
136 enum i915_winsys_buffer_type type
);
139 * Create a tiled buffer.
141 * *stride, height are in bytes. The winsys tries to allocate the buffer with
142 * the tiling mode provide in *tiling. If tiling is no possible, *tiling will
143 * be set to I915_TILE_NONE. The calculated stride (incorporateing hw/kernel
144 * requirements) is always returned in *stride.
146 struct i915_winsys_buffer
*
147 (*buffer_create_tiled
)(struct i915_winsys
*iws
,
148 unsigned *stride
, unsigned height
,
149 enum i915_winsys_buffer_tile
*tiling
,
150 enum i915_winsys_buffer_type type
);
153 * Creates a buffer from a handle.
154 * Used to implement pipe_screen::resource_from_handle.
155 * Also provides the stride information needed for the
156 * texture via the stride argument.
158 struct i915_winsys_buffer
*
159 (*buffer_from_handle
)(struct i915_winsys
*iws
,
160 struct winsys_handle
*whandle
,
161 enum i915_winsys_buffer_tile
*tiling
,
165 * Used to implement pipe_screen::resource_get_handle.
166 * The winsys might need the stride information.
168 boolean (*buffer_get_handle
)(struct i915_winsys
*iws
,
169 struct i915_winsys_buffer
*buffer
,
170 struct winsys_handle
*whandle
,
176 void *(*buffer_map
)(struct i915_winsys
*iws
,
177 struct i915_winsys_buffer
*buffer
,
183 void (*buffer_unmap
)(struct i915_winsys
*iws
,
184 struct i915_winsys_buffer
*buffer
);
189 * Arguments follows pipe_buffer_write.
191 int (*buffer_write
)(struct i915_winsys
*iws
,
192 struct i915_winsys_buffer
*dst
,
197 void (*buffer_destroy
)(struct i915_winsys
*iws
,
198 struct i915_winsys_buffer
*buffer
);
207 * Reference fence and set ptr to fence.
209 void (*fence_reference
)(struct i915_winsys
*iws
,
210 struct pipe_fence_handle
**ptr
,
211 struct pipe_fence_handle
*fence
);
214 * Check if a fence has finished.
216 int (*fence_signalled
)(struct i915_winsys
*iws
,
217 struct pipe_fence_handle
*fence
);
220 * Wait on a fence to finish.
222 int (*fence_finish
)(struct i915_winsys
*iws
,
223 struct pipe_fence_handle
*fence
);
228 * Destroy the winsys.
230 void (*destroy
)(struct i915_winsys
*iws
);