blob: 365a765c8275454c9329bd92e5faabc4a5d064ab [file] [log] [blame]
Chia-I Wu6dacc542014-09-23 10:37:08 +08001/* IN DEVELOPMENT. DO NOT SHIP. */
2
3#ifndef __XGLWSIX11EXT_H__
4#define __XGLWSIX11EXT_H__
5
6#include <xcb/xcb.h>
7#include <xcb/randr.h>
8#include "xgl.h"
9
10#ifdef __cplusplus
11extern "C"
12{
13#endif // __cplusplus
14
15typedef struct _XGL_WSI_X11_CONNECTION_INFO {
16 xcb_connection_t* pConnection;
17 xcb_window_t root;
18 xcb_randr_provider_t provider;
19} XGL_WSI_X11_CONNECTION_INFO;
20
21typedef struct _XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO
22{
23 XGL_FORMAT format;
24 XGL_FLAGS usage; // XGL_IMAGE_USAGE_FLAGS
25 XGL_EXTENT2D extent;
26 XGL_FLAGS flags;
27} XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO;
28
29typedef struct _XGL_WSI_X11_PRESENT_INFO
30{
31 /* which window to present to */
32 xcb_window_t destWindow;
33 XGL_IMAGE srcImage;
34
35 /**
36 * After the command buffers in the queue have been completed, if the MSC
37 * of \p crtc is less than or equal to \p target_msc, wait until it
38 * reaches \p target_msc.
39 *
40 * If the current MSC of \p crtc is greater than \p target_msc, adjust
41 * \p target_msc as following:
42 *
43 * if (divisor) {
44 * target_msc = crtc_msc - (crtc_msc % divisor) + remainder;
45 * if (target_msc < crtc_msc)
46 * target_msc += divisor;
47 * } else {
48 * target_msc = crtc_msc;
49 * }
50 *
51 * In other words, either set \p target_msc to an absolute value (require
52 * xglWsiX11GetMSC(), potentially a round-trip to the server, to get the
53 * current MSC first), or set \p target_msc to zero and set a "swap
54 * interval".
Chia-I Wu6204f342014-11-07 13:33:45 +080055 *
56 * \p crtc can be XCB_NONE. In that case, a suitable CRTC is picked based
57 * on \p destWindow.
Chia-I Wu6dacc542014-09-23 10:37:08 +080058 */
59 xcb_randr_crtc_t crtc;
60 XGL_UINT64 target_msc;
61 XGL_UINT64 divisor;
62 XGL_UINT64 remainder;
63
64 /**
65 * After waiting for the current and target MSCs to match, the
66 * presentation is scheduled. When \p async is false, it will occur the
67 * next time current MSC is incremented. When \p async is true, it will
68 * occur as soon as possible.
69 */
70 XGL_BOOL async;
71
72 /**
73 * When \p flip is false, the contents of \p srcImage are copied to
74 * \p destWindow when the presentation occurs. When \p flip is true,
75 * \p srcImage is made the front buffer of \p destWindow.
76 *
77 * An error may be returned if \p flip is true but \p destWindow can not
78 * be flipped to.
79 */
80 XGL_BOOL flip;
81} XGL_WSI_X11_PRESENT_INFO;
82
83/**
84 * Associate an X11 connection with a GPU. This should be done before device
85 * creation. If the device is already created,
86 * XGL_ERROR_DEVICE_ALREADY_CREATED is returned.
87 *
88 * Truth is, given a connection, we could find the associated GPU. But
89 * without having a GPU as the first parameter, the loader could not find the
90 * dispatch table.
91 *
92 * This function is available when xglGetExtensionSupport says "XGL_WSI_X11"
93 * is supported.
94 */
95XGL_RESULT XGLAPI xglWsiX11AssociateConnection(
96 XGL_PHYSICAL_GPU gpu,
97 const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo);
98
99/**
100 * Return the current MSC (Media Stream Counter, incremented for each vblank)
Chia-I Wu6204f342014-11-07 13:33:45 +0800101 * of \p crtc. If crtc is \p XCB_NONE, a suitable CRTC is picked based on \p
102 * win.
Chia-I Wu6dacc542014-09-23 10:37:08 +0800103 */
104XGL_RESULT XGLAPI xglWsiX11GetMSC(
105 XGL_DEVICE device,
Chia-I Wu6204f342014-11-07 13:33:45 +0800106 xcb_window_t window,
Chia-I Wu6dacc542014-09-23 10:37:08 +0800107 xcb_randr_crtc_t crtc,
108 XGL_UINT64* pMsc);
109
110/**
111 * Create an XGL_IMAGE that can be presented. An XGL_GPU_MEMORY is created
112 * and bound automatically. The memory returned can only be used in
113 * XGL_MEMORY_REF. Destroying the memory or binding another memory to the
114 * image is not allowed.
115 */
116XGL_RESULT XGLAPI xglWsiX11CreatePresentableImage(
117 XGL_DEVICE device,
118 const XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO* pCreateInfo,
119 XGL_IMAGE* pImage,
120 XGL_GPU_MEMORY* pMem);
121
122/**
123 * Present an image to an X11 window. The presentation always occurs after
124 * the command buffers in the queue have been completed, subject to other
125 * parameters specified in XGL_WSI_X11_PRESENT_INFO.
126 *
127 * Fence is reached when the presentation occurs.
128 */
129XGL_RESULT XGLAPI xglWsiX11QueuePresent(
130 XGL_QUEUE queue,
131 const XGL_WSI_X11_PRESENT_INFO* pPresentInfo,
132 XGL_FENCE fence);
133
134#ifdef __cplusplus
135} // extern "C"
136#endif // __cplusplus
137
138#endif // __XGLWSIX11EXT_H__