Chia-I Wu | 6dacc54 | 2014-09-23 10:37:08 +0800 | [diff] [blame] | 1 | /* 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 |
| 11 | extern "C" |
| 12 | { |
| 13 | #endif // __cplusplus |
| 14 | |
| 15 | typedef 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 | |
| 21 | typedef 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 | |
| 29 | typedef 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 Wu | 6204f34 | 2014-11-07 13:33:45 +0800 | [diff] [blame] | 55 | * |
| 56 | * \p crtc can be XCB_NONE. In that case, a suitable CRTC is picked based |
| 57 | * on \p destWindow. |
Chia-I Wu | 6dacc54 | 2014-09-23 10:37:08 +0800 | [diff] [blame] | 58 | */ |
| 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 | |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame] | 83 | typedef XGL_RESULT (XGLAPI *xglWsiX11AssociateConnectionType)(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo); |
| 84 | typedef XGL_RESULT (XGLAPI *xglWsiX11GetMSCType)(XGL_DEVICE device, xcb_window_t window, xcb_randr_crtc_t crtc, XGL_UINT64* pMsc); |
| 85 | typedef XGL_RESULT (XGLAPI *xglWsiX11CreatePresentableImageType)(XGL_DEVICE device, const XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO* pCreateInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem); |
| 86 | typedef XGL_RESULT (XGLAPI *xglWsiX11QueuePresentType)(XGL_QUEUE queue, const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, XGL_FENCE fence); |
Jon Ashburn | 7e6b61d | 2014-12-02 08:59:56 -0700 | [diff] [blame] | 87 | |
Chia-I Wu | 6dacc54 | 2014-09-23 10:37:08 +0800 | [diff] [blame] | 88 | /** |
| 89 | * Associate an X11 connection with a GPU. This should be done before device |
| 90 | * creation. If the device is already created, |
| 91 | * XGL_ERROR_DEVICE_ALREADY_CREATED is returned. |
| 92 | * |
| 93 | * Truth is, given a connection, we could find the associated GPU. But |
| 94 | * without having a GPU as the first parameter, the loader could not find the |
| 95 | * dispatch table. |
| 96 | * |
| 97 | * This function is available when xglGetExtensionSupport says "XGL_WSI_X11" |
| 98 | * is supported. |
| 99 | */ |
| 100 | XGL_RESULT XGLAPI xglWsiX11AssociateConnection( |
| 101 | XGL_PHYSICAL_GPU gpu, |
| 102 | const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo); |
| 103 | |
| 104 | /** |
| 105 | * Return the current MSC (Media Stream Counter, incremented for each vblank) |
Chia-I Wu | 6204f34 | 2014-11-07 13:33:45 +0800 | [diff] [blame] | 106 | * of \p crtc. If crtc is \p XCB_NONE, a suitable CRTC is picked based on \p |
| 107 | * win. |
Chia-I Wu | 6dacc54 | 2014-09-23 10:37:08 +0800 | [diff] [blame] | 108 | */ |
| 109 | XGL_RESULT XGLAPI xglWsiX11GetMSC( |
| 110 | XGL_DEVICE device, |
Chia-I Wu | 6204f34 | 2014-11-07 13:33:45 +0800 | [diff] [blame] | 111 | xcb_window_t window, |
Chia-I Wu | 6dacc54 | 2014-09-23 10:37:08 +0800 | [diff] [blame] | 112 | xcb_randr_crtc_t crtc, |
| 113 | XGL_UINT64* pMsc); |
| 114 | |
| 115 | /** |
| 116 | * Create an XGL_IMAGE that can be presented. An XGL_GPU_MEMORY is created |
| 117 | * and bound automatically. The memory returned can only be used in |
| 118 | * XGL_MEMORY_REF. Destroying the memory or binding another memory to the |
| 119 | * image is not allowed. |
| 120 | */ |
| 121 | XGL_RESULT XGLAPI xglWsiX11CreatePresentableImage( |
| 122 | XGL_DEVICE device, |
| 123 | const XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO* pCreateInfo, |
| 124 | XGL_IMAGE* pImage, |
| 125 | XGL_GPU_MEMORY* pMem); |
| 126 | |
| 127 | /** |
| 128 | * Present an image to an X11 window. The presentation always occurs after |
| 129 | * the command buffers in the queue have been completed, subject to other |
| 130 | * parameters specified in XGL_WSI_X11_PRESENT_INFO. |
| 131 | * |
| 132 | * Fence is reached when the presentation occurs. |
| 133 | */ |
| 134 | XGL_RESULT XGLAPI xglWsiX11QueuePresent( |
| 135 | XGL_QUEUE queue, |
| 136 | const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, |
| 137 | XGL_FENCE fence); |
| 138 | |
| 139 | #ifdef __cplusplus |
| 140 | } // extern "C" |
| 141 | #endif // __cplusplus |
| 142 | |
| 143 | #endif // __XGLWSIX11EXT_H__ |