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