• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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      * Note: This function waits as well that the buffer content was displayed (this
75      * can be after the release of the buffer if the window system decided to make
76      * an internal copy and release early. */
77     HRESULT (WINAPI *WaitBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer);
78     HRESULT (WINAPI *FrontBufferCopy)(ID3DPresent *This, D3DWindowBuffer *buffer);
79     /* It is possible to do partial copy, but impossible to do resizing, which must
80      * be done by the client after checking the front buffer size */
81     HRESULT (WINAPI *PresentBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer, HWND hWndOverride, const RECT *pSourceRect, const RECT *pDestRect, const RGNDATA *pDirtyRegion, DWORD Flags);
82     HRESULT (WINAPI *GetRasterStatus)(ID3DPresent *This, D3DRASTER_STATUS *pRasterStatus);
83     HRESULT (WINAPI *GetDisplayMode)(ID3DPresent *This, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation);
84     HRESULT (WINAPI *GetPresentStats)(ID3DPresent *This, D3DPRESENTSTATS *pStats);
85     HRESULT (WINAPI *GetCursorPos)(ID3DPresent *This, POINT *pPoint);
86     HRESULT (WINAPI *SetCursorPos)(ID3DPresent *This, POINT *pPoint);
87     /* Cursor size is always 32x32. pBitmap and pHotspot can be NULL. */
88     HRESULT (WINAPI *SetCursor)(ID3DPresent *This, void *pBitmap, POINT *pHotspot, BOOL bShow);
89     HRESULT (WINAPI *SetGammaRamp)(ID3DPresent *This, const D3DGAMMARAMP *pRamp, HWND hWndOverride);
90     HRESULT (WINAPI *GetWindowInfo)(ID3DPresent *This,  HWND hWnd, int *width, int *height, int *depth);
91     /* Available since version 1.1 */
92     BOOL (WINAPI *GetWindowOccluded)(ID3DPresent *This);
93     /* Available since version 1.2 */
94     BOOL (WINAPI *ResolutionMismatch)(ID3DPresent *This);
95     HANDLE (WINAPI *CreateThread)(ID3DPresent *This, void *pThreadfunc, void *pParam);
96     BOOL (WINAPI *WaitForThread)(ID3DPresent *This, HANDLE thread);
97     /* Available since version 1.3 */
98     HRESULT (WINAPI *SetPresentParameters2)(ID3DPresent *This, D3DPRESENT_PARAMETERS2 *pParameters);
99     BOOL (WINAPI *IsBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer);
100     /* Wait a buffer gets released. */
101     HRESULT (WINAPI *WaitBufferReleaseEvent)(ID3DPresent *This);
102 } ID3DPresentVtbl;
103 
104 struct ID3DPresent
105 {
106     ID3DPresentVtbl *lpVtbl;
107 };
108 
109 /* IUnknown macros */
110 #define ID3DPresent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
111 #define ID3DPresent_AddRef(p) (p)->lpVtbl->AddRef(p)
112 #define ID3DPresent_Release(p) (p)->lpVtbl->Release(p)
113 /* ID3DPresent macros */
114 #define ID3DPresent_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a)
115 #define ID3DPresent_SetPresentParameters(p,a,b) (p)->lpVtbl->SetPresentParameters(p,a,b)
116 #define ID3DPresent_NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g) (p)->lpVtbl->NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g)
117 #define ID3DPresent_DestroyD3DWindowBuffer(p,a) (p)->lpVtbl->DestroyD3DWindowBuffer(p,a)
118 #define ID3DPresent_WaitBufferReleased(p,a) (p)->lpVtbl->WaitBufferReleased(p,a)
119 #define ID3DPresent_FrontBufferCopy(p,a) (p)->lpVtbl->FrontBufferCopy(p,a)
120 #define ID3DPresent_PresentBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->PresentBuffer(p,a,b,c,d,e,f)
121 #define ID3DPresent_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a)
122 #define ID3DPresent_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b)
123 #define ID3DPresent_GetPresentStats(p,a) (p)->lpVtbl->GetPresentStats(p,a)
124 #define ID3DPresent_GetCursorPos(p,a) (p)->lpVtbl->GetCursorPos(p,a)
125 #define ID3DPresent_SetCursorPos(p,a) (p)->lpVtbl->SetCursorPos(p,a)
126 #define ID3DPresent_SetCursor(p,a,b,c) (p)->lpVtbl->SetCursor(p,a,b,c)
127 #define ID3DPresent_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b)
128 #define ID3DPresent_GetWindowInfo(p,a,b,c,d) (p)->lpVtbl->GetWindowSize(p,a,b,c,d)
129 #define ID3DPresent_GetWindowOccluded(p) (p)->lpVtbl->GetWindowOccluded(p)
130 #define ID3DPresent_ResolutionMismatch(p) (p)->lpVtbl->ResolutionMismatch(p)
131 #define ID3DPresent_CreateThread(p,a,b) (p)->lpVtbl->CreateThread(p,a,b)
132 #define ID3DPresent_WaitForThread(p,a) (p)->lpVtbl->WaitForThread(p,a)
133 #define ID3DPresent_SetPresentParameters2(p,a) (p)->lpVtbl->SetPresentParameters2(p,a)
134 #define ID3DPresent_IsBufferReleased(p,a) (p)->lpVtbl->IsBufferReleased(p,a)
135 #define ID3DPresent_WaitBufferReleaseEvent(p) (p)->lpVtbl->WaitBufferReleaseEvent(p)
136 
137 typedef struct ID3DPresentGroupVtbl
138 {
139     /* IUnknown */
140     HRESULT (WINAPI *QueryInterface)(ID3DPresentGroup *This, REFIID riid, void **ppvObject);
141     ULONG (WINAPI *AddRef)(ID3DPresentGroup *This);
142     ULONG (WINAPI *Release)(ID3DPresentGroup *This);
143 
144     /* ID3DPresentGroup */
145     /* When creating a device, it's relevant for the driver to know how many
146      * implicit swap chains to create. It has to create one per monitor in a
147      * multi-monitor setup */
148     UINT (WINAPI *GetMultiheadCount)(ID3DPresentGroup *This);
149     /* returns only the implicit present interfaces */
150     HRESULT (WINAPI *GetPresent)(ID3DPresentGroup *This, UINT Index, ID3DPresent **ppPresent);
151     /* used to create additional presentation interfaces along the way */
152     HRESULT (WINAPI *CreateAdditionalPresent)(ID3DPresentGroup *This, D3DPRESENT_PARAMETERS *pPresentationParameters, ID3DPresent **ppPresent);
153     void (WINAPI *GetVersion) (ID3DPresentGroup *This, int *major, int *minor);
154 } ID3DPresentGroupVtbl;
155 
156 struct ID3DPresentGroup
157 {
158     ID3DPresentGroupVtbl *lpVtbl;
159 };
160 
161 /* IUnknown macros */
162 #define ID3DPresentGroup_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
163 #define ID3DPresentGroup_AddRef(p) (p)->lpVtbl->AddRef(p)
164 #define ID3DPresentGroup_Release(p) (p)->lpVtbl->Release(p)
165 /* ID3DPresentGroup */
166 #define ID3DPresentGroup_GetMultiheadCount(p) (p)->lpVtbl->GetMultiheadCount(p)
167 #define ID3DPresentGroup_GetPresent(p,a,b) (p)->lpVtbl->GetPresent(p,a,b)
168 #define ID3DPresentGroup_CreateAdditionalPresent(p,a,b) (p)->lpVtbl->CreateAdditionalPresent(p,a,b)
169 #define ID3DPresentGroup_GetVersion(p,a,b) (p)->lpVtbl->GetVersion(p,a,b)
170 
171 #endif /* __cplusplus */
172 
173 #endif /* _D3DADAPTER_PRESENT_H_ */
174