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 TUNGSTEN GRAPHICS 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 U_SIMPLE_SCREEN_H
29 #define U_SIMPLE_SCREEN_H
31 #include "pipe/p_format.h"
34 struct pipe_fence_handle
;
39 * Gallium3D drivers are (meant to be!) independent of both GL and the
40 * window system. The window system provides a buffer manager and a
41 * set of additional hooks for things like command buffer submission,
44 * There clearly has to be some agreement between the window system
45 * driver and the hardware driver about the format of command buffers,
50 void (*destroy
)( struct pipe_winsys
*ws
);
52 /** Returns name of this winsys interface */
53 const char *(*get_name
)( struct pipe_winsys
*ws
);
56 * Do any special operations to ensure frontbuffer contents are
57 * displayed, eg copy fake frontbuffer.
59 void (*flush_frontbuffer
)( struct pipe_winsys
*ws
,
60 struct pipe_surface
*surf
,
61 void *context_private
);
65 * Buffer management. Buffer attributes are mostly fixed over its lifetime.
67 * Remember that gallium gets to choose the interface it needs, and the
68 * window systems must then implement that interface (rather than the
69 * other way around...).
71 * usage is a bitmask of PIPE_BIND_*.
72 * All possible usages must be present.
74 * alignment indicates the client's alignment requirements, eg for
77 struct pipe_resource
*(*buffer_create
)( struct pipe_winsys
*ws
,
83 * Create a buffer that wraps user-space data.
85 * Effectively this schedules a delayed call to buffer_create
86 * followed by an upload of the data at *some point in the future*,
87 * or perhaps never. Basically the allocate/upload is delayed
88 * until the buffer is actually passed to hardware.
90 * The intention is to provide a quick way to turn regular data
91 * into a buffer, and secondly to avoid a copy operation if that
92 * data subsequently turns out to be only accessed by the CPU.
94 * Common example is OpenGL vertex buffers that are subsequently
95 * processed either by software TNL in the driver or by passing to
98 * XXX: What happens if the delayed call to buffer_create() fails?
100 * Note that ptr may be accessed at any time upto the time when the
101 * buffer is destroyed, so the data must not be freed before then.
103 struct pipe_resource
*(*user_buffer_create
)(struct pipe_winsys
*ws
,
108 * Allocate storage for a display target surface.
110 * Often surfaces which are meant to be blitted to the front screen (i.e.,
111 * display targets) must be allocated with special characteristics, memory
112 * pools, or obtained directly from the windowing system.
114 * This callback is invoked by the pipe_screen when creating a texture marked
115 * with the PIPE_BIND_DISPLAY_TARGET flag to get the underlying
118 struct pipe_resource
*(*surface_buffer_create
)(struct pipe_winsys
*ws
,
119 unsigned width
, unsigned height
,
120 enum pipe_format format
,
127 * Map the entire data store of a buffer object into the client's address.
128 * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
130 void *(*buffer_map
)( struct pipe_winsys
*ws
,
131 struct pipe_resource
*buf
,
134 void (*buffer_unmap
)( struct pipe_winsys
*ws
,
135 struct pipe_resource
*buf
);
137 void (*buffer_destroy
)( struct pipe_resource
*buf
);
140 /** Set ptr = fence, with reference counting */
141 void (*fence_reference
)( struct pipe_winsys
*ws
,
142 struct pipe_fence_handle
**ptr
,
143 struct pipe_fence_handle
*fence
);
146 * Checks whether the fence has been signalled.
147 * \param flags driver-specific meaning
148 * \return zero on success.
150 int (*fence_signalled
)( struct pipe_winsys
*ws
,
151 struct pipe_fence_handle
*fence
,
155 * Wait for the fence to finish.
156 * \param flags driver-specific meaning
157 * \return zero on success.
159 int (*fence_finish
)( struct pipe_winsys
*ws
,
160 struct pipe_fence_handle
*fence
,
166 * The following function initializes a simple passthrough screen.
168 * All the relevant screen function pointers will forwarded to the
171 void u_simple_screen_init(struct pipe_screen
*screen
);
174 * Returns the name of the winsys associated with this screen.
176 const char* u_simple_screen_winsys_name(struct pipe_screen
*screen
);