2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
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:
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
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. */
23 #ifndef _NINE_SWAPCHAIN9_H_
24 #define _NINE_SWAPCHAIN9_H_
29 #include "d3dadapter/d3dadapter9.h"
31 #include "threadpool.h"
35 struct nine_winsys_swapchain
;
38 #define DRI_SWAP_FENCES_MAX 4
39 #define DRI_SWAP_FENCES_MASK 3
43 struct NineUnknown base
;
46 struct pipe_screen
*screen
;
47 struct pipe_context
*pipe
;
48 struct cso_context
*cso
;
50 /* presentation backend */
52 D3DPRESENT_PARAMETERS params
;
53 D3DDISPLAYMODEEX
*mode
;
54 struct d3dadapter9_context
*actx
;
56 unsigned num_back_buffers
;
59 struct NineSurface9
*buffers
[D3DPRESENT_BACK_BUFFERS_MAX_EX
+ 1]; /* 0 to BackBufferCount-1 : the back buffers. BackBufferCount : additional buffer */
60 struct pipe_resource
*present_buffers
[D3DPRESENT_BACK_BUFFERS_MAX_EX
+ 1];
61 D3DWindowBuffer
*present_handles
[D3DPRESENT_BACK_BUFFERS_MAX_EX
+ 1];
63 struct pipe_fence_handle
*swap_fences
[DRI_SWAP_FENCES_MAX
];
64 unsigned int cur_fences
;
67 unsigned int desired_fences
;
71 struct NineSurface9
*zsbuf
;
75 struct threadpool
*pool
;
76 struct threadpool_task
*tasks
[D3DPRESENT_BACK_BUFFERS_MAX_EX
+ 1];
77 BOOL enable_threadpool
;
80 static inline struct NineSwapChain9
*
81 NineSwapChain9( void *data
)
83 return (struct NineSwapChain9
*)data
;
87 NineSwapChain9_new( struct NineDevice9
*pDevice
,
89 ID3DPresent
*pPresent
,
90 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
91 struct d3dadapter9_context
*pCTX
,
93 struct NineSwapChain9
**ppOut
);
96 NineSwapChain9_ctor( struct NineSwapChain9
*This
,
97 struct NineUnknownParams
*pParams
,
99 ID3DPresent
*pPresent
,
100 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
101 struct d3dadapter9_context
*pCTX
,
103 D3DDISPLAYMODEEX
*mode
);
106 NineSwapChain9_dtor( struct NineSwapChain9
*This
);
109 NineSwapChain9_Resize( struct NineSwapChain9
*This
,
110 D3DPRESENT_PARAMETERS
*pParams
,
111 D3DDISPLAYMODEEX
*mode
);
114 NineSwapChain9_Present( struct NineSwapChain9
*This
,
115 const RECT
*pSourceRect
,
116 const RECT
*pDestRect
,
117 HWND hDestWindowOverride
,
118 const RGNDATA
*pDirtyRegion
,
122 NineSwapChain9_GetFrontBufferData( struct NineSwapChain9
*This
,
123 IDirect3DSurface9
*pDestSurface
);
126 NineSwapChain9_GetBackBuffer( struct NineSwapChain9
*This
,
128 D3DBACKBUFFER_TYPE Type
,
129 IDirect3DSurface9
**ppBackBuffer
);
132 NineSwapChain9_GetRasterStatus( struct NineSwapChain9
*This
,
133 D3DRASTER_STATUS
*pRasterStatus
);
136 NineSwapChain9_GetDisplayMode( struct NineSwapChain9
*This
,
137 D3DDISPLAYMODE
*pMode
);
140 NineSwapChain9_GetPresentParameters( struct NineSwapChain9
*This
,
141 D3DPRESENT_PARAMETERS
*pPresentationParameters
);
144 NineSwapChain9_GetOccluded( struct NineSwapChain9
*This
);
147 NineSwapChain9_ResolutionMismatch( struct NineSwapChain9
*This
);
150 NineSwapChain9_CreateThread( struct NineSwapChain9
*This
,
155 NineSwapChain9_WaitForThread( struct NineSwapChain9
*This
,
158 #endif /* _NINE_SWAPCHAIN9_H_ */