d3dadapter/present: Add new API to ID3DPresent
[mesa.git] / include / d3dadapter / present.h
1 /*
2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef _D3DADAPTER_PRESENT_H_
24 #define _D3DADAPTER_PRESENT_H_
25
26 #include <d3d9.h>
27
28 #ifndef D3DOK_WINDOW_OCCLUDED
29 #define D3DOK_WINDOW_OCCLUDED MAKE_D3DSTATUS(2531)
30 #endif /* D3DOK_WINDOW_OCCLUDED */
31
32 #ifndef __cplusplus
33 typedef struct ID3DPresent ID3DPresent;
34 typedef struct ID3DPresentGroup ID3DPresentGroup;
35 typedef struct ID3DAdapter9 ID3DAdapter9;
36 typedef struct D3DWindowBuffer D3DWindowBuffer;
37
38 /* Available since version 1.3 */
39 typedef struct _D3DPRESENT_PARAMETERS2_ {
40 /* Whether D3DSWAPEFFECT_DISCARD is allowed to release the
41 * D3DWindowBuffers in any order, and eventually with a delay.
42 * FALSE (Default): buffers should be released as soon as possible.
43 * TRUE: it is allowed to release some buffers with a delay, and in
44 * a random order. */
45 BOOL AllowDISCARDDelayedRelease;
46 /* User preference for D3DSWAPEFFECT_DISCARD with D3DPRESENT_INTERVAL_IMMEDIATE.
47 * FALSE (Default): User prefers presentation to occur as soon as possible,
48 * with potential tearings.
49 * TRUE: User prefers presentation to be tear free. Requires
50 * AllowDISCARDDelayedRelease to have any effect. */
51 BOOL TearFreeDISCARD;
52 } D3DPRESENT_PARAMETERS2, *PD3DPRESENT_PARAMETERS2, *LPD3DPRESENT_PARAMETERS2;
53
54 /* Presentation backend for drivers to display their brilliant work */
55 typedef struct ID3DPresentVtbl
56 {
57 /* IUnknown */
58 HRESULT (WINAPI *QueryInterface)(ID3DPresent *This, REFIID riid, void **ppvObject);
59 ULONG (WINAPI *AddRef)(ID3DPresent *This);
60 ULONG (WINAPI *Release)(ID3DPresent *This);
61
62 /* ID3DPresent */
63 /* This function initializes the screen and window provided at creation.
64 * Hence why this should always be called as the one of first things a new
65 * swap chain does */
66 HRESULT (WINAPI *SetPresentParameters)(ID3DPresent *This, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode);
67 /* Make a buffer visible to the window system via dma-buf fd.
68 * For better compatibility, it must be 32bpp and format ARGB/XRGB */
69 HRESULT (WINAPI *NewD3DWindowBufferFromDmaBuf)(ID3DPresent *This, int dmaBufFd, int width, int height, int stride, int depth, int bpp, D3DWindowBuffer **out);
70 HRESULT (WINAPI *DestroyD3DWindowBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer);
71 /* After presenting a buffer to the window system, the buffer
72 * may be used as is (no copy of the content) by the window system.
73 * You must not use a non-released buffer, else the user may see undefined content. */
74 HRESULT (WINAPI *WaitBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer);
75 HRESULT (WINAPI *FrontBufferCopy)(ID3DPresent *This, D3DWindowBuffer *buffer);
76 /* It is possible to do partial copy, but impossible to do resizing, which must
77 * be done by the client after checking the front buffer size */
78 HRESULT (WINAPI *PresentBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer, HWND hWndOverride, const RECT *pSourceRect, const RECT *pDestRect, const RGNDATA *pDirtyRegion, DWORD Flags);
79 HRESULT (WINAPI *GetRasterStatus)(ID3DPresent *This, D3DRASTER_STATUS *pRasterStatus);
80 HRESULT (WINAPI *GetDisplayMode)(ID3DPresent *This, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
81 HRESULT (WINAPI *GetPresentStats)(ID3DPresent *This, D3DPRESENTSTATS *pStats);
82 HRESULT (WINAPI *GetCursorPos)(ID3DPresent *This, POINT *pPoint);
83 HRESULT (WINAPI *SetCursorPos)(ID3DPresent *This, POINT *pPoint);
84 /* Cursor size is always 32x32. pBitmap and pHotspot can be NULL. */
85 HRESULT (WINAPI *SetCursor)(ID3DPresent *This, void *pBitmap, POINT *pHotspot, BOOL bShow);
86 HRESULT (WINAPI *SetGammaRamp)(ID3DPresent *This, const D3DGAMMARAMP *pRamp, HWND hWndOverride);
87 HRESULT (WINAPI *GetWindowInfo)(ID3DPresent *This, HWND hWnd, int *width, int *height, int *depth);
88 /* Available since version 1.1 */
89 BOOL (WINAPI *GetWindowOccluded)(ID3DPresent *This);
90 /* Available since version 1.2 */
91 BOOL (WINAPI *ResolutionMismatch)(ID3DPresent *This);
92 HANDLE (WINAPI *CreateThread)(ID3DPresent *This, void *pThreadfunc, void *pParam);
93 BOOL (WINAPI *WaitForThread)(ID3DPresent *This, HANDLE thread);
94 /* Available since version 1.3 */
95 HRESULT (WINAPI *SetPresentParameters2)(ID3DPresent *This, D3DPRESENT_PARAMETERS2 *pParameters);
96 BOOL (WINAPI *IsBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer);
97 /* Wait a buffer gets released. */
98 HRESULT (WINAPI *WaitBufferReleaseEvent)(ID3DPresent *This);
99 } ID3DPresentVtbl;
100
101 struct ID3DPresent
102 {
103 ID3DPresentVtbl *lpVtbl;
104 };
105
106 /* IUnknown macros */
107 #define ID3DPresent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
108 #define ID3DPresent_AddRef(p) (p)->lpVtbl->AddRef(p)
109 #define ID3DPresent_Release(p) (p)->lpVtbl->Release(p)
110 /* ID3DPresent macros */
111 #define ID3DPresent_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
112 #define ID3DPresent_SetPresentParameters(p,a,b) (p)->lpVtbl->SetPresentParameters(p,a,b)
113 #define ID3DPresent_NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g) (p)->lpVtbl->NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g)
114 #define ID3DPresent_DestroyD3DWindowBuffer(p,a) (p)->lpVtbl->DestroyD3DWindowBuffer(p,a)
115 #define ID3DPresent_WaitBufferReleased(p,a) (p)->lpVtbl->WaitBufferReleased(p,a)
116 #define ID3DPresent_FrontBufferCopy(p,a) (p)->lpVtbl->FrontBufferCopy(p,a)
117 #define ID3DPresent_PresentBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->PresentBuffer(p,a,b,c,d,e,f)
118 #define ID3DPresent_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
119 #define ID3DPresent_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b)
120 #define ID3DPresent_GetPresentStats(p,a) (p)->lpVtbl->GetPresentStats(p,a)
121 #define ID3DPresent_GetCursorPos(p,a) (p)->lpVtbl->GetCursorPos(p,a)
122 #define ID3DPresent_SetCursorPos(p,a) (p)->lpVtbl->SetCursorPos(p,a)
123 #define ID3DPresent_SetCursor(p,a,b,c) (p)->lpVtbl->SetCursor(p,a,b,c)
124 #define ID3DPresent_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b)
125 #define ID3DPresent_GetWindowInfo(p,a,b,c,d) (p)->lpVtbl->GetWindowSize(p,a,b,c,d)
126 #define ID3DPresent_GetWindowOccluded(p) (p)->lpVtbl->GetWindowOccluded(p)
127 #define ID3DPresent_ResolutionMismatch(p) (p)->lpVtbl->ResolutionMismatch(p)
128 #define ID3DPresent_CreateThread(p,a,b) (p)->lpVtbl->CreateThread(p,a,b)
129 #define ID3DPresent_WaitForThread(p,a) (p)->lpVtbl->WaitForThread(p,a)
130 #define ID3DPresent_SetPresentParameters2(p,a) (p)->lpVtbl->SetPresentParameters2(p,a)
131 #define ID3DPresent_IsBufferReleased(p,a) (p)->lpVtbl->IsBufferReleased(p,a)
132 #define ID3DPresent_WaitBufferReleaseEvent(p) (p)->lpVtbl->WaitBufferReleaseEvent(p)
133
134 typedef struct ID3DPresentGroupVtbl
135 {
136 /* IUnknown */
137 HRESULT (WINAPI *QueryInterface)(ID3DPresentGroup *This, REFIID riid, void **ppvObject);
138 ULONG (WINAPI *AddRef)(ID3DPresentGroup *This);
139 ULONG (WINAPI *Release)(ID3DPresentGroup *This);
140
141 /* ID3DPresentGroup */
142 /* When creating a device, it's relevant for the driver to know how many
143 * implicit swap chains to create. It has to create one per monitor in a
144 * multi-monitor setup */
145 UINT (WINAPI *GetMultiheadCount)(ID3DPresentGroup *This);
146 /* returns only the implicit present interfaces */
147 HRESULT (WINAPI *GetPresent)(ID3DPresentGroup *This, UINT Index, ID3DPresent **ppPresent);
148 /* used to create additional presentation interfaces along the way */
149 HRESULT (WINAPI *CreateAdditionalPresent)(ID3DPresentGroup *This, D3DPRESENT_PARAMETERS *pPresentationParameters, ID3DPresent **ppPresent);
150 void (WINAPI *GetVersion) (ID3DPresentGroup *This, int *major, int *minor);
151 } ID3DPresentGroupVtbl;
152
153 struct ID3DPresentGroup
154 {
155 ID3DPresentGroupVtbl *lpVtbl;
156 };
157
158 /* IUnknown macros */
159 #define ID3DPresentGroup_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
160 #define ID3DPresentGroup_AddRef(p) (p)->lpVtbl->AddRef(p)
161 #define ID3DPresentGroup_Release(p) (p)->lpVtbl->Release(p)
162 /* ID3DPresentGroup */
163 #define ID3DPresentGroup_GetMultiheadCount(p) (p)->lpVtbl->GetMultiheadCount(p)
164 #define ID3DPresentGroup_GetPresent(p,a,b) (p)->lpVtbl->GetPresent(p,a,b)
165 #define ID3DPresentGroup_CreateAdditionalPresent(p,a,b) (p)->lpVtbl->CreateAdditionalPresent(p,a,b)
166 #define ID3DPresentGroup_GetVersion(p,a,b) (p)->lpVtbl->GetVersion(p,a,b)
167
168 #endif /* __cplusplus */
169
170 #endif /* _D3DADAPTER_PRESENT_H_ */