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 pipe_fence_handle
;
34 /* This currently just wraps dri_bo:
36 struct brw_winsys_buffer
{
37 struct brw_winsys_screen
*sws
;
42 enum brw_buffer_usage
{
43 I915_GEM_DOMAIN_RENDER
,
44 I915_GEM_DOMAIN_SAMPLER
,
45 I915_GEM_DOMAIN_VERTEX
,
46 I915_GEM_DOMAIN_INSTRUCTION
,
49 /* XXX: migrate from domains to explicit usage cases, eg below:
53 BRW_USAGE_RENDER
= 0x01,
54 BRW_USAGE_SAMPLER
= 0x02,
55 BRW_USAGE_2D_TARGET
= 0x04,
56 BRW_USAGE_2D_SOURCE
= 0x08,
58 BRW_USAGE_VERTEX
= 0x10,
63 BRW_BUFFER_TYPE_TEXTURE
,
64 BRW_BUFFER_TYPE_SCANOUT
, /**< a texture used for scanning out from */
65 BRW_BUFFER_TYPE_VERTEX
,
69 /* AKA winsys context:
71 struct brw_batchbuffer
{
73 struct brw_winsys
*iws
;
74 struct brw_winsys_buffer
*buf
;
77 * Values exported to speed up the writing the batchbuffer,
78 * instead of having to go trough a accesor function for
91 struct brw_winsys_screen
{
94 * Batchbuffer functions.
98 * Create a new batchbuffer.
100 struct brw_batchbuffer
*(*batchbuffer_create
)(struct brw_winsys_screen
*iws
);
103 * Emit a relocation to a buffer.
104 * Target position in batchbuffer is the same as ptr.
106 int (*batchbuffer_reloc
)(struct brw_batchbuffer
*batch
,
108 struct brw_winsys_buffer
*reloc
,
110 enum brw_buffer_usage usage
);
113 * Flush a bufferbatch.
115 void (*batchbuffer_flush
)(struct brw_batchbuffer
*batch
,
116 struct pipe_fence_handle
**fence
);
119 * Destroy a batchbuffer.
121 void (*batchbuffer_destroy
)(struct brw_batchbuffer
*batch
);
132 struct brw_winsys_buffer
*(*buffer_create
)(struct brw_winsys
*iws
,
135 enum brw_buffer_type type
);
138 /* Reference and unreference buffers:
140 void (*bo_reference
)( struct brw_winsys_buffer
*buffer
);
141 void (*bo_unreference
)( struct brw_winsys_buffer
*buffer
);
142 void (*bo_emit_reloc
)( struct brw_winsys_buffer
*buffer
,
147 struct brw_winsys_buffer
*b2
);
152 void *(*buffer_map
)(struct brw_winsys
*iws
,
153 struct brw_winsys_buffer
*buffer
,
159 void (*buffer_unmap
)(struct brw_winsys
*iws
,
160 struct brw_winsys_buffer
*buffer
);
165 * Arguments follows pipe_buffer_write.
167 int (*buffer_write
)(struct brw_winsys
*iws
,
168 struct brw_winsys_buffer
*dst
,
173 void (*buffer_destroy
)(struct brw_winsys
*iws
,
174 struct brw_winsys_buffer
*buffer
);
183 * Reference fence and set ptr to fence.
185 void (*fence_reference
)(struct brw_winsys
*iws
,
186 struct pipe_fence_handle
**ptr
,
187 struct pipe_fence_handle
*fence
);
190 * Check if a fence has finished.
192 int (*fence_signalled
)(struct brw_winsys
*iws
,
193 struct pipe_fence_handle
*fence
);
196 * Wait on a fence to finish.
198 int (*fence_finish
)(struct brw_winsys
*iws
,
199 struct pipe_fence_handle
*fence
);
204 * Destroy the winsys.
206 void (*destroy
)(struct brw_winsys
*iws
);
211 * Create i915 pipe_screen.
213 struct pipe_screen
*i915_create_screen(struct brw_winsys
*iws
, unsigned pci_id
);
216 * Create a i915 pipe_context.
218 struct pipe_context
*i915_create_context(struct pipe_screen
*screen
);
221 * Get the brw_winsys buffer backing the texture.
226 boolean
i915_get_texture_buffer_brw(struct pipe_texture
*texture
,
227 struct brw_winsys_buffer
**buffer
,
231 * Wrap a brw_winsys buffer with a texture blanket.
235 struct pipe_texture
* i915_texture_blanket_brw(struct pipe_screen
*screen
,
236 struct pipe_texture
*tmplt
,
238 struct brw_winsys_buffer
*buffer
);