present.h revision 01e04c3f
101e04c3fSmrg/* 201e04c3fSmrg * Copyright 2011 Joakim Sindholt <opensource@zhasha.com> 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub 801e04c3fSmrg * license, and/or sell copies of the Software, and to permit persons to whom 901e04c3fSmrg * the Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice (including the next 1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the 1301e04c3fSmrg * Software. 1401e04c3fSmrg * 1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 1801e04c3fSmrg * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 1901e04c3fSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 2001e04c3fSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 2101e04c3fSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. */ 2201e04c3fSmrg 2301e04c3fSmrg#ifndef _D3DADAPTER_PRESENT_H_ 2401e04c3fSmrg#define _D3DADAPTER_PRESENT_H_ 2501e04c3fSmrg 2601e04c3fSmrg#include <d3d9.h> 2701e04c3fSmrg 2801e04c3fSmrg#ifndef D3DOK_WINDOW_OCCLUDED 2901e04c3fSmrg#define D3DOK_WINDOW_OCCLUDED MAKE_D3DSTATUS(2531) 3001e04c3fSmrg#endif /* D3DOK_WINDOW_OCCLUDED */ 3101e04c3fSmrg 3201e04c3fSmrg#ifndef __cplusplus 3301e04c3fSmrgtypedef struct ID3DPresent ID3DPresent; 3401e04c3fSmrgtypedef struct ID3DPresentGroup ID3DPresentGroup; 3501e04c3fSmrgtypedef struct ID3DAdapter9 ID3DAdapter9; 3601e04c3fSmrgtypedef struct D3DWindowBuffer D3DWindowBuffer; 3701e04c3fSmrg 3801e04c3fSmrg/* Available since version 1.3 */ 3901e04c3fSmrgtypedef struct _D3DPRESENT_PARAMETERS2_ { 4001e04c3fSmrg /* Whether D3DSWAPEFFECT_DISCARD is allowed to release the 4101e04c3fSmrg * D3DWindowBuffers in any order, and eventually with a delay. 4201e04c3fSmrg * FALSE (Default): buffers should be released as soon as possible. 4301e04c3fSmrg * TRUE: it is allowed to release some buffers with a delay, and in 4401e04c3fSmrg * a random order. */ 4501e04c3fSmrg BOOL AllowDISCARDDelayedRelease; 4601e04c3fSmrg /* User preference for D3DSWAPEFFECT_DISCARD with D3DPRESENT_INTERVAL_IMMEDIATE. 4701e04c3fSmrg * FALSE (Default): User prefers presentation to occur as soon as possible, 4801e04c3fSmrg * with potential tearings. 4901e04c3fSmrg * TRUE: User prefers presentation to be tear free. Requires 5001e04c3fSmrg * AllowDISCARDDelayedRelease to have any effect. */ 5101e04c3fSmrg BOOL TearFreeDISCARD; 5201e04c3fSmrg} D3DPRESENT_PARAMETERS2, *PD3DPRESENT_PARAMETERS2, *LPD3DPRESENT_PARAMETERS2; 5301e04c3fSmrg 5401e04c3fSmrg/* Presentation backend for drivers to display their brilliant work */ 5501e04c3fSmrgtypedef struct ID3DPresentVtbl 5601e04c3fSmrg{ 5701e04c3fSmrg /* IUnknown */ 5801e04c3fSmrg HRESULT (WINAPI *QueryInterface)(ID3DPresent *This, REFIID riid, void **ppvObject); 5901e04c3fSmrg ULONG (WINAPI *AddRef)(ID3DPresent *This); 6001e04c3fSmrg ULONG (WINAPI *Release)(ID3DPresent *This); 6101e04c3fSmrg 6201e04c3fSmrg /* ID3DPresent */ 6301e04c3fSmrg /* This function initializes the screen and window provided at creation. 6401e04c3fSmrg * Hence why this should always be called as the one of first things a new 6501e04c3fSmrg * swap chain does */ 6601e04c3fSmrg HRESULT (WINAPI *SetPresentParameters)(ID3DPresent *This, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode); 6701e04c3fSmrg /* Make a buffer visible to the window system via dma-buf fd. 6801e04c3fSmrg * For better compatibility, it must be 32bpp and format ARGB/XRGB */ 6901e04c3fSmrg HRESULT (WINAPI *NewD3DWindowBufferFromDmaBuf)(ID3DPresent *This, int dmaBufFd, int width, int height, int stride, int depth, int bpp, D3DWindowBuffer **out); 7001e04c3fSmrg HRESULT (WINAPI *DestroyD3DWindowBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer); 7101e04c3fSmrg /* After presenting a buffer to the window system, the buffer 7201e04c3fSmrg * may be used as is (no copy of the content) by the window system. 7301e04c3fSmrg * You must not use a non-released buffer, else the user may see undefined content. 7401e04c3fSmrg * Note: This function waits as well that the buffer content was displayed (this 7501e04c3fSmrg * can be after the release of the buffer if the window system decided to make 7601e04c3fSmrg * an internal copy and release early. */ 7701e04c3fSmrg HRESULT (WINAPI *WaitBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer); 7801e04c3fSmrg HRESULT (WINAPI *FrontBufferCopy)(ID3DPresent *This, D3DWindowBuffer *buffer); 7901e04c3fSmrg /* It is possible to do partial copy, but impossible to do resizing, which must 8001e04c3fSmrg * be done by the client after checking the front buffer size */ 8101e04c3fSmrg HRESULT (WINAPI *PresentBuffer)(ID3DPresent *This, D3DWindowBuffer *buffer, HWND hWndOverride, const RECT *pSourceRect, const RECT *pDestRect, const RGNDATA *pDirtyRegion, DWORD Flags); 8201e04c3fSmrg HRESULT (WINAPI *GetRasterStatus)(ID3DPresent *This, D3DRASTER_STATUS *pRasterStatus); 8301e04c3fSmrg HRESULT (WINAPI *GetDisplayMode)(ID3DPresent *This, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation); 8401e04c3fSmrg HRESULT (WINAPI *GetPresentStats)(ID3DPresent *This, D3DPRESENTSTATS *pStats); 8501e04c3fSmrg HRESULT (WINAPI *GetCursorPos)(ID3DPresent *This, POINT *pPoint); 8601e04c3fSmrg HRESULT (WINAPI *SetCursorPos)(ID3DPresent *This, POINT *pPoint); 8701e04c3fSmrg /* Cursor size is always 32x32. pBitmap and pHotspot can be NULL. */ 8801e04c3fSmrg HRESULT (WINAPI *SetCursor)(ID3DPresent *This, void *pBitmap, POINT *pHotspot, BOOL bShow); 8901e04c3fSmrg HRESULT (WINAPI *SetGammaRamp)(ID3DPresent *This, const D3DGAMMARAMP *pRamp, HWND hWndOverride); 9001e04c3fSmrg HRESULT (WINAPI *GetWindowInfo)(ID3DPresent *This, HWND hWnd, int *width, int *height, int *depth); 9101e04c3fSmrg /* Available since version 1.1 */ 9201e04c3fSmrg BOOL (WINAPI *GetWindowOccluded)(ID3DPresent *This); 9301e04c3fSmrg /* Available since version 1.2 */ 9401e04c3fSmrg BOOL (WINAPI *ResolutionMismatch)(ID3DPresent *This); 9501e04c3fSmrg HANDLE (WINAPI *CreateThread)(ID3DPresent *This, void *pThreadfunc, void *pParam); 9601e04c3fSmrg BOOL (WINAPI *WaitForThread)(ID3DPresent *This, HANDLE thread); 9701e04c3fSmrg /* Available since version 1.3 */ 9801e04c3fSmrg HRESULT (WINAPI *SetPresentParameters2)(ID3DPresent *This, D3DPRESENT_PARAMETERS2 *pParameters); 9901e04c3fSmrg BOOL (WINAPI *IsBufferReleased)(ID3DPresent *This, D3DWindowBuffer *buffer); 10001e04c3fSmrg /* Wait a buffer gets released. */ 10101e04c3fSmrg HRESULT (WINAPI *WaitBufferReleaseEvent)(ID3DPresent *This); 10201e04c3fSmrg} ID3DPresentVtbl; 10301e04c3fSmrg 10401e04c3fSmrgstruct ID3DPresent 10501e04c3fSmrg{ 10601e04c3fSmrg ID3DPresentVtbl *lpVtbl; 10701e04c3fSmrg}; 10801e04c3fSmrg 10901e04c3fSmrg/* IUnknown macros */ 11001e04c3fSmrg#define ID3DPresent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) 11101e04c3fSmrg#define ID3DPresent_AddRef(p) (p)->lpVtbl->AddRef(p) 11201e04c3fSmrg#define ID3DPresent_Release(p) (p)->lpVtbl->Release(p) 11301e04c3fSmrg/* ID3DPresent macros */ 11401e04c3fSmrg#define ID3DPresent_GetPresentParameters(p,a) (p)->lpVtbl->GetPresentParameters(p,a) 11501e04c3fSmrg#define ID3DPresent_SetPresentParameters(p,a,b) (p)->lpVtbl->SetPresentParameters(p,a,b) 11601e04c3fSmrg#define ID3DPresent_NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g) (p)->lpVtbl->NewD3DWindowBufferFromDmaBuf(p,a,b,c,d,e,f,g) 11701e04c3fSmrg#define ID3DPresent_DestroyD3DWindowBuffer(p,a) (p)->lpVtbl->DestroyD3DWindowBuffer(p,a) 11801e04c3fSmrg#define ID3DPresent_WaitBufferReleased(p,a) (p)->lpVtbl->WaitBufferReleased(p,a) 11901e04c3fSmrg#define ID3DPresent_FrontBufferCopy(p,a) (p)->lpVtbl->FrontBufferCopy(p,a) 12001e04c3fSmrg#define ID3DPresent_PresentBuffer(p,a,b,c,d,e,f) (p)->lpVtbl->PresentBuffer(p,a,b,c,d,e,f) 12101e04c3fSmrg#define ID3DPresent_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) 12201e04c3fSmrg#define ID3DPresent_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b) 12301e04c3fSmrg#define ID3DPresent_GetPresentStats(p,a) (p)->lpVtbl->GetPresentStats(p,a) 12401e04c3fSmrg#define ID3DPresent_GetCursorPos(p,a) (p)->lpVtbl->GetCursorPos(p,a) 12501e04c3fSmrg#define ID3DPresent_SetCursorPos(p,a) (p)->lpVtbl->SetCursorPos(p,a) 12601e04c3fSmrg#define ID3DPresent_SetCursor(p,a,b,c) (p)->lpVtbl->SetCursor(p,a,b,c) 12701e04c3fSmrg#define ID3DPresent_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) 12801e04c3fSmrg#define ID3DPresent_GetWindowInfo(p,a,b,c,d) (p)->lpVtbl->GetWindowInfo(p,a,b,c,d) 12901e04c3fSmrg#define ID3DPresent_GetWindowOccluded(p) (p)->lpVtbl->GetWindowOccluded(p) 13001e04c3fSmrg#define ID3DPresent_ResolutionMismatch(p) (p)->lpVtbl->ResolutionMismatch(p) 13101e04c3fSmrg#define ID3DPresent_CreateThread(p,a,b) (p)->lpVtbl->CreateThread(p,a,b) 13201e04c3fSmrg#define ID3DPresent_WaitForThread(p,a) (p)->lpVtbl->WaitForThread(p,a) 13301e04c3fSmrg#define ID3DPresent_SetPresentParameters2(p,a) (p)->lpVtbl->SetPresentParameters2(p,a) 13401e04c3fSmrg#define ID3DPresent_IsBufferReleased(p,a) (p)->lpVtbl->IsBufferReleased(p,a) 13501e04c3fSmrg#define ID3DPresent_WaitBufferReleaseEvent(p) (p)->lpVtbl->WaitBufferReleaseEvent(p) 13601e04c3fSmrg 13701e04c3fSmrgtypedef struct ID3DPresentGroupVtbl 13801e04c3fSmrg{ 13901e04c3fSmrg /* IUnknown */ 14001e04c3fSmrg HRESULT (WINAPI *QueryInterface)(ID3DPresentGroup *This, REFIID riid, void **ppvObject); 14101e04c3fSmrg ULONG (WINAPI *AddRef)(ID3DPresentGroup *This); 14201e04c3fSmrg ULONG (WINAPI *Release)(ID3DPresentGroup *This); 14301e04c3fSmrg 14401e04c3fSmrg /* ID3DPresentGroup */ 14501e04c3fSmrg /* When creating a device, it's relevant for the driver to know how many 14601e04c3fSmrg * implicit swap chains to create. It has to create one per monitor in a 14701e04c3fSmrg * multi-monitor setup */ 14801e04c3fSmrg UINT (WINAPI *GetMultiheadCount)(ID3DPresentGroup *This); 14901e04c3fSmrg /* returns only the implicit present interfaces */ 15001e04c3fSmrg HRESULT (WINAPI *GetPresent)(ID3DPresentGroup *This, UINT Index, ID3DPresent **ppPresent); 15101e04c3fSmrg /* used to create additional presentation interfaces along the way */ 15201e04c3fSmrg HRESULT (WINAPI *CreateAdditionalPresent)(ID3DPresentGroup *This, D3DPRESENT_PARAMETERS *pPresentationParameters, ID3DPresent **ppPresent); 15301e04c3fSmrg void (WINAPI *GetVersion) (ID3DPresentGroup *This, int *major, int *minor); 15401e04c3fSmrg} ID3DPresentGroupVtbl; 15501e04c3fSmrg 15601e04c3fSmrgstruct ID3DPresentGroup 15701e04c3fSmrg{ 15801e04c3fSmrg ID3DPresentGroupVtbl *lpVtbl; 15901e04c3fSmrg}; 16001e04c3fSmrg 16101e04c3fSmrg/* IUnknown macros */ 16201e04c3fSmrg#define ID3DPresentGroup_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) 16301e04c3fSmrg#define ID3DPresentGroup_AddRef(p) (p)->lpVtbl->AddRef(p) 16401e04c3fSmrg#define ID3DPresentGroup_Release(p) (p)->lpVtbl->Release(p) 16501e04c3fSmrg/* ID3DPresentGroup */ 16601e04c3fSmrg#define ID3DPresentGroup_GetMultiheadCount(p) (p)->lpVtbl->GetMultiheadCount(p) 16701e04c3fSmrg#define ID3DPresentGroup_GetPresent(p,a,b) (p)->lpVtbl->GetPresent(p,a,b) 16801e04c3fSmrg#define ID3DPresentGroup_CreateAdditionalPresent(p,a,b) (p)->lpVtbl->CreateAdditionalPresent(p,a,b) 16901e04c3fSmrg#define ID3DPresentGroup_GetVersion(p,a,b) (p)->lpVtbl->GetVersion(p,a,b) 17001e04c3fSmrg 17101e04c3fSmrg#endif /* __cplusplus */ 17201e04c3fSmrg 17301e04c3fSmrg#endif /* _D3DADAPTER_PRESENT_H_ */ 174