2 * Copyright © 2013 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 /* This file was derived from dri2_priv.h which carries the following
26 * Copyright © 2008 Red Hat, Inc.
28 * Permission is hereby granted, free of charge, to any person obtaining a
29 * copy of this software and associated documentation files (the "Soft-
30 * ware"), to deal in the Software without restriction, including without
31 * limitation the rights to use, copy, modify, merge, publish, distribute,
32 * and/or sell copies of the Software, and to permit persons to whom the
33 * Software is furnished to do so, provided that the above copyright
34 * notice(s) and this permission notice appear in all copies of the Soft-
35 * ware and that both the above copyright notice(s) and this permission
36 * notice appear in supporting documentation.
38 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
39 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
40 * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
41 * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
42 * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
43 * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
44 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
45 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
46 * MANCE OF THIS SOFTWARE.
48 * Except as contained in this notice, the name of a copyright holder shall
49 * not be used in advertising or otherwise to promote the sale, use or
50 * other dealings in this Software without prior written authorization of
51 * the copyright holder.
54 * Kristian Høgsberg (krh@redhat.com)
59 #include <xcb/present.h>
62 /* From xmlpool/options.h, user exposed so should be stable */
63 #define DRI_CONF_VBLANK_NEVER 0
64 #define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
65 #define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
66 #define DRI_CONF_VBLANK_ALWAYS_SYNC 3
68 enum dri3_buffer_type
{
77 /* Synchronization between the client and X server is done using an
78 * xshmfence that is mapped into an X server SyncFence. This lets the
79 * client check whether the X server is done using a buffer with a simple
80 * xshmfence call, rather than going to read X events from the wire.
82 * However, we can only wait for one xshmfence to be triggered at a time,
83 * so we need to know *which* buffer is going to be idle next. We do that
84 * by waiting for a PresentIdleNotify event. When that event arrives, the
85 * 'busy' flag gets cleared and the client knows that the fence has been
86 * triggered, and that the wait call will not block.
89 uint32_t sync_fence
; /* XID of X SyncFence object */
90 int32_t *shm_fence
; /* pointer to xshmfence object */
91 GLboolean busy
; /* Set on swap, cleared on IdleNotify */
98 uint32_t width
, height
;
100 enum dri3_buffer_type buffer_type
;
105 __GLXDRIdisplay base
;
107 const __DRIextension
*loader_extensions
[8];
120 struct glx_screen base
;
122 __DRIscreen
*driScreen
;
123 __GLXDRIscreen vtable
;
125 const __DRIimageExtension
*image
;
126 const __DRIimageDriverExtension
*image_driver
;
127 const __DRIcoreExtension
*core
;
128 const __DRI2flushExtension
*f
;
129 const __DRI2configQueryExtension
*config
;
130 const __DRItexBufferExtension
*texBuffer
;
131 const __DRIconfig
**driver_configs
;
141 struct glx_context base
;
142 __DRIcontext
*driContext
;
145 #define DRI3_MAX_BACK 2
146 #define DRI3_BACK_ID(i) (i)
147 #define DRI3_FRONT_ID (DRI3_MAX_BACK)
150 dri3_buf_id_next(int buf_id
)
152 if (buf_id
== DRI3_MAX_BACK
- 1)
158 dri3_buf_id_prev(int buf_id
)
161 return DRI3_MAX_BACK
- 1;
166 dri3_pixmap_buf_id(enum dri3_buffer_type buffer_type
)
168 if (buffer_type
== dri3_buffer_back
)
169 return DRI3_BACK_ID(0);
171 return DRI3_FRONT_ID
;
174 struct dri3_drawable
{
175 __GLXDRIdrawable base
;
176 __DRIdrawable
*driDrawable
;
180 uint8_t have_fake_front
;
183 uint32_t present_request_serial
;
184 uint32_t present_event_serial
;
191 uint32_t present_msc_request_serial
;
192 uint32_t present_msc_event_serial
;
194 uint64_t previous_time
;
197 struct dri3_buffer
*buffers
[1 + DRI3_MAX_BACK
];
203 xcb_present_event_t eid
;
205 xcb_special_event_t
*special_event
;
209 dri3_get_driver_for_fd(int fd
);