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