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 **************************************************************************/
26 #ifndef INTEL_WINSYS_H
27 #define INTEL_WINSYS_H
29 #include "pipe/p_compiler.h"
33 struct intel_batchbuffer
;
35 struct pipe_fence_handle
;
37 enum intel_buffer_usage
40 INTEL_USAGE_RENDER
= 0x01,
41 INTEL_USAGE_SAMPLER
= 0x02,
42 INTEL_USAGE_2D_TARGET
= 0x04,
43 INTEL_USAGE_2D_SOURCE
= 0x08,
45 INTEL_USAGE_VERTEX
= 0x10
48 enum intel_buffer_type
51 INTEL_NEW_SCANOUT
, /**< a texture used for scanning out from */
55 enum intel_buffer_tile
62 struct intel_batchbuffer
{
64 struct intel_winsys
*iws
;
67 * Values exported to speed up the writing the batchbuffer,
68 * instead of having to go trough a accesor function for
84 * Batchbuffer functions.
88 * Create a new batchbuffer.
90 struct intel_batchbuffer
*(*batchbuffer_create
)(struct intel_winsys
*iws
);
93 * Emit a relocation to a buffer.
94 * Target position in batchbuffer is the same as ptr.
97 * @reloc buffer address to be inserted into target.
98 * @usage how is the hardware going to use the buffer.
99 * @offset add this to the reloc buffers address
100 * @target buffer where to write the address, null for batchbuffer.
102 int (*batchbuffer_reloc
)(struct intel_batchbuffer
*batch
,
103 struct intel_buffer
*reloc
,
104 enum intel_buffer_usage usage
,
108 * Flush a bufferbatch.
110 void (*batchbuffer_flush
)(struct intel_batchbuffer
*batch
,
111 struct pipe_fence_handle
**fence
);
114 * Destroy a batchbuffer.
116 void (*batchbuffer_destroy
)(struct intel_batchbuffer
*batch
);
127 struct intel_buffer
*(*buffer_create
)(struct intel_winsys
*iws
,
128 unsigned size
, unsigned alignment
,
129 enum intel_buffer_type type
);
132 * Fence a buffer with a fence reg.
133 * Not to be confused with pipe_fence_handle.
135 int (*buffer_set_fence_reg
)(struct intel_winsys
*iws
,
136 struct intel_buffer
*buffer
,
138 enum intel_buffer_tile tile
);
143 void *(*buffer_map
)(struct intel_winsys
*iws
,
144 struct intel_buffer
*buffer
,
150 void (*buffer_unmap
)(struct intel_winsys
*iws
,
151 struct intel_buffer
*buffer
);
156 * Arguments follows pipe_buffer_write.
158 int (*buffer_write
)(struct intel_winsys
*iws
,
159 struct intel_buffer
*dst
,
164 void (*buffer_destroy
)(struct intel_winsys
*iws
,
165 struct intel_buffer
*buffer
);
174 * Reference fence and set ptr to fence.
176 void (*fence_reference
)(struct intel_winsys
*iws
,
177 struct pipe_fence_handle
**ptr
,
178 struct pipe_fence_handle
*fence
);
181 * Check if a fence has finished.
183 int (*fence_signalled
)(struct intel_winsys
*iws
,
184 struct pipe_fence_handle
*fence
);
187 * Wait on a fence to finish.
189 int (*fence_finish
)(struct intel_winsys
*iws
,
190 struct pipe_fence_handle
*fence
);
195 * Destroy the winsys.
197 void (*destroy
)(struct intel_winsys
*iws
);
202 * Create i915 pipe_screen.
204 struct pipe_screen
*i915_create_screen(struct intel_winsys
*iws
, unsigned pci_id
);
207 * Create a i915 pipe_context.
209 struct pipe_context
*i915_create_context(struct pipe_screen
*screen
);
212 * Get the intel_winsys buffer backing the texture.
216 boolean
i915_get_texture_buffer_intel(struct pipe_texture
*texture
,
217 struct intel_buffer
**buffer
,
221 * Wrap a intel_winsys buffer with a texture blanket.
225 struct pipe_texture
* i915_texture_blanket_intel(struct pipe_screen
*screen
,
226 struct pipe_texture
*tmplt
,
228 struct intel_buffer
*buffer
);