Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5564 serge 1
/*
2
 * Copyright 2011 Joakim Sindholt 
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
#include "device9ex.h"
24
#include "swapchain9ex.h"
25
 
26
#include "nine_helpers.h"
27
 
28
#define DBG_CHANNEL DBG_DEVICE
29
 
30
static HRESULT
31
NineDevice9Ex_ctor( struct NineDevice9Ex *This,
32
                    struct NineUnknownParams *pParams,
33
                    struct pipe_screen *pScreen,
34
                    D3DDEVICE_CREATION_PARAMETERS *pCreationParameters,
35
                    D3DCAPS9 *pCaps,
36
                    D3DPRESENT_PARAMETERS *pPresentationParameters,
37
                    D3DDISPLAYMODEEX *pFullscreenDisplayMode,
38
                    IDirect3D9Ex *pD3D9Ex,
39
                    ID3DPresentGroup *pPresentationGroup,
40
                    struct d3dadapter9_context *pCTX )
41
{
42
    DBG("This=%p pParams=%p pScreen=%p pCreationParameters=%p pCaps=%p "
43
        "pPresentationParameters=%p pFullscreenDisplayMode=%p "
44
        "pD3D9Ex=%p pPresentationGroup=%p pCTX=%p\n",
45
        This, pParams, pScreen, pCreationParameters, pCaps,
46
        pPresentationParameters, pFullscreenDisplayMode,
47
        pD3D9Ex, pPresentationGroup, pCTX);
48
 
49
    return NineDevice9_ctor(&This->base, pParams,
50
                            pScreen, pCreationParameters, pCaps,
51
                            pPresentationParameters,
52
                            (IDirect3D9 *)pD3D9Ex, pPresentationGroup, pCTX,
53
                            TRUE, pFullscreenDisplayMode);
54
}
55
 
56
static void
57
NineDevice9Ex_dtor( struct NineDevice9Ex *This )
58
{
59
    NineDevice9_dtor(&This->base);
60
}
61
 
62
HRESULT WINAPI
63
NineDevice9Ex_SetConvolutionMonoKernel( struct NineDevice9Ex *This,
64
                                        UINT width,
65
                                        UINT height,
66
                                        float *rows,
67
                                        float *columns )
68
{
69
    STUB(D3DERR_INVALIDCALL);
70
}
71
 
72
HRESULT WINAPI
73
NineDevice9Ex_ComposeRects( struct NineDevice9Ex *This,
74
                            IDirect3DSurface9 *pSrc,
75
                            IDirect3DSurface9 *pDst,
76
                            IDirect3DVertexBuffer9 *pSrcRectDescs,
77
                            UINT NumRects,
78
                            IDirect3DVertexBuffer9 *pDstRectDescs,
79
                            D3DCOMPOSERECTSOP Operation,
80
                            int Xoffset,
81
                            int Yoffset )
82
{
83
    STUB(D3DERR_INVALIDCALL);
84
}
85
 
86
HRESULT WINAPI
87
NineDevice9Ex_PresentEx( struct NineDevice9Ex *This,
88
                         const RECT *pSourceRect,
89
                         const RECT *pDestRect,
90
                         HWND hDestWindowOverride,
91
                         const RGNDATA *pDirtyRegion,
92
                         DWORD dwFlags )
93
{
94
    unsigned i;
95
    HRESULT hr;
96
 
97
    DBG("This=%p pSourceRect=%p pDestRect=%p hDestWindowOverride=%p "
98
        "pDirtyRegion=%p dwFlags=%d\n",
99
        This, pSourceRect, pDestRect, hDestWindowOverride,
100
        pDirtyRegion, dwFlags);
101
 
102
    for (i = 0; i < This->base.nswapchains; i++) {
103
        hr = NineSwapChain9_Present(This->base.swapchains[i], pSourceRect, pDestRect,
104
                                    hDestWindowOverride, pDirtyRegion, dwFlags);
105
        if (FAILED(hr)) { return hr; }
106
    }
107
 
108
    return D3D_OK;
109
}
110
 
111
HRESULT WINAPI
112
NineDevice9Ex_GetGPUThreadPriority( struct NineDevice9Ex *This,
113
                                    INT *pPriority )
114
{
115
    STUB(D3DERR_INVALIDCALL);
116
}
117
 
118
HRESULT WINAPI
119
NineDevice9Ex_SetGPUThreadPriority( struct NineDevice9Ex *This,
120
                                    INT Priority )
121
{
122
    STUB(D3DERR_INVALIDCALL);
123
}
124
 
125
HRESULT WINAPI
126
NineDevice9Ex_WaitForVBlank( struct NineDevice9Ex *This,
127
                             UINT iSwapChain )
128
{
129
    STUB(D3DERR_INVALIDCALL);
130
}
131
 
132
HRESULT WINAPI
133
NineDevice9Ex_CheckResourceResidency( struct NineDevice9Ex *This,
134
                                      IDirect3DResource9 **pResourceArray,
135
                                      UINT32 NumResources )
136
{
137
    STUB(D3DERR_INVALIDCALL);
138
}
139
 
140
HRESULT WINAPI
141
NineDevice9Ex_SetMaximumFrameLatency( struct NineDevice9Ex *This,
142
                                      UINT MaxLatency )
143
{
144
    STUB(D3DERR_INVALIDCALL);
145
}
146
 
147
HRESULT WINAPI
148
NineDevice9Ex_GetMaximumFrameLatency( struct NineDevice9Ex *This,
149
                                      UINT *pMaxLatency )
150
{
151
    STUB(D3DERR_INVALIDCALL);
152
}
153
 
154
HRESULT WINAPI
155
NineDevice9Ex_CheckDeviceState( struct NineDevice9Ex *This,
156
                                HWND hDestinationWindow )
157
{
158
    DBG("This=%p hDestinationWindow=%p\n",
159
        This, hDestinationWindow);
160
 
161
    /* TODO: handle the other return values */
162
    return D3D_OK;
163
}
164
 
165
HRESULT WINAPI
166
NineDevice9Ex_CreateRenderTargetEx( struct NineDevice9Ex *This,
167
                                    UINT Width,
168
                                    UINT Height,
169
                                    D3DFORMAT Format,
170
                                    D3DMULTISAMPLE_TYPE MultiSample,
171
                                    DWORD MultisampleQuality,
172
                                    BOOL Lockable,
173
                                    IDirect3DSurface9 **ppSurface,
174
                                    HANDLE *pSharedHandle,
175
                                    DWORD Usage )
176
{
177
    STUB(D3DERR_INVALIDCALL);
178
}
179
 
180
HRESULT WINAPI
181
NineDevice9Ex_CreateOffscreenPlainSurfaceEx( struct NineDevice9Ex *This,
182
                                             UINT Width,
183
                                             UINT Height,
184
                                             D3DFORMAT Format,
185
                                             D3DPOOL Pool,
186
                                             IDirect3DSurface9 **ppSurface,
187
                                             HANDLE *pSharedHandle,
188
                                             DWORD Usage )
189
{
190
    STUB(D3DERR_INVALIDCALL);
191
}
192
 
193
HRESULT WINAPI
194
NineDevice9Ex_CreateDepthStencilSurfaceEx( struct NineDevice9Ex *This,
195
                                           UINT Width,
196
                                           UINT Height,
197
                                           D3DFORMAT Format,
198
                                           D3DMULTISAMPLE_TYPE MultiSample,
199
                                           DWORD MultisampleQuality,
200
                                           BOOL Discard,
201
                                           IDirect3DSurface9 **ppSurface,
202
                                           HANDLE *pSharedHandle,
203
                                           DWORD Usage )
204
{
205
    STUB(D3DERR_INVALIDCALL);
206
}
207
 
208
HRESULT WINAPI
209
NineDevice9Ex_ResetEx( struct NineDevice9Ex *This,
210
                       D3DPRESENT_PARAMETERS *pPresentationParameters,
211
                       D3DDISPLAYMODEEX *pFullscreenDisplayMode )
212
{
213
    HRESULT hr = D3D_OK;
214
    unsigned i;
215
 
216
    DBG("This=%p pPresentationParameters=%p pFullscreenDisplayMode=%p\n", This, pPresentationParameters, pFullscreenDisplayMode);
217
 
218
    for (i = 0; i < This->base.nswapchains; ++i) {
219
        D3DDISPLAYMODEEX *mode = NULL;
220
        D3DPRESENT_PARAMETERS *params = &pPresentationParameters[i];
221
        if (pFullscreenDisplayMode) mode = &(pFullscreenDisplayMode[i]);
222
        hr = NineSwapChain9_Resize(This->base.swapchains[i], params, mode);
223
        if (FAILED(hr))
224
            return (hr == D3DERR_OUTOFVIDEOMEMORY) ? hr : D3DERR_DEVICELOST;
225
    }
226
 
227
    NineDevice9_SetRenderTarget(
228
        (struct NineDevice9 *)This, 0, (IDirect3DSurface9 *)This->base.swapchains[0]->buffers[0]);
229
 
230
 
231
    return hr;
232
}
233
 
234
HRESULT WINAPI
235
NineDevice9Ex_GetDisplayModeEx( struct NineDevice9Ex *This,
236
                                UINT iSwapChain,
237
                                D3DDISPLAYMODEEX *pMode,
238
                                D3DDISPLAYROTATION *pRotation )
239
{
240
    struct NineSwapChain9Ex *swapchain;
241
 
242
    DBG("This=%p iSwapChain=%u pMode=%p pRotation=%p\n",
243
        This, iSwapChain, pMode, pRotation);
244
 
245
    user_assert(iSwapChain < This->base.nswapchains, D3DERR_INVALIDCALL);
246
 
247
    swapchain = NineSwapChain9Ex(This->base.swapchains[iSwapChain]);
248
    return NineSwapChain9Ex_GetDisplayModeEx(swapchain, pMode, pRotation);
249
}
250
 
251
IDirect3DDevice9ExVtbl NineDevice9Ex_vtable = {
252
    (void *)NineUnknown_QueryInterface,
253
    (void *)NineUnknown_AddRef,
254
    (void *)NineUnknown_Release,
255
    (void *)NineDevice9_TestCooperativeLevel,
256
    (void *)NineDevice9_GetAvailableTextureMem,
257
    (void *)NineDevice9_EvictManagedResources,
258
    (void *)NineDevice9_GetDirect3D,
259
    (void *)NineDevice9_GetDeviceCaps,
260
    (void *)NineDevice9_GetDisplayMode,
261
    (void *)NineDevice9_GetCreationParameters,
262
    (void *)NineDevice9_SetCursorProperties,
263
    (void *)NineDevice9_SetCursorPosition,
264
    (void *)NineDevice9_ShowCursor,
265
    (void *)NineDevice9_CreateAdditionalSwapChain,
266
    (void *)NineDevice9_GetSwapChain,
267
    (void *)NineDevice9_GetNumberOfSwapChains,
268
    (void *)NineDevice9_Reset,
269
    (void *)NineDevice9_Present,
270
    (void *)NineDevice9_GetBackBuffer,
271
    (void *)NineDevice9_GetRasterStatus,
272
    (void *)NineDevice9_SetDialogBoxMode,
273
    (void *)NineDevice9_SetGammaRamp,
274
    (void *)NineDevice9_GetGammaRamp,
275
    (void *)NineDevice9_CreateTexture,
276
    (void *)NineDevice9_CreateVolumeTexture,
277
    (void *)NineDevice9_CreateCubeTexture,
278
    (void *)NineDevice9_CreateVertexBuffer,
279
    (void *)NineDevice9_CreateIndexBuffer,
280
    (void *)NineDevice9_CreateRenderTarget,
281
    (void *)NineDevice9_CreateDepthStencilSurface,
282
    (void *)NineDevice9_UpdateSurface,
283
    (void *)NineDevice9_UpdateTexture,
284
    (void *)NineDevice9_GetRenderTargetData,
285
    (void *)NineDevice9_GetFrontBufferData,
286
    (void *)NineDevice9_StretchRect,
287
    (void *)NineDevice9_ColorFill,
288
    (void *)NineDevice9_CreateOffscreenPlainSurface,
289
    (void *)NineDevice9_SetRenderTarget,
290
    (void *)NineDevice9_GetRenderTarget,
291
    (void *)NineDevice9_SetDepthStencilSurface,
292
    (void *)NineDevice9_GetDepthStencilSurface,
293
    (void *)NineDevice9_BeginScene,
294
    (void *)NineDevice9_EndScene,
295
    (void *)NineDevice9_Clear,
296
    (void *)NineDevice9_SetTransform,
297
    (void *)NineDevice9_GetTransform,
298
    (void *)NineDevice9_MultiplyTransform,
299
    (void *)NineDevice9_SetViewport,
300
    (void *)NineDevice9_GetViewport,
301
    (void *)NineDevice9_SetMaterial,
302
    (void *)NineDevice9_GetMaterial,
303
    (void *)NineDevice9_SetLight,
304
    (void *)NineDevice9_GetLight,
305
    (void *)NineDevice9_LightEnable,
306
    (void *)NineDevice9_GetLightEnable,
307
    (void *)NineDevice9_SetClipPlane,
308
    (void *)NineDevice9_GetClipPlane,
309
    (void *)NineDevice9_SetRenderState,
310
    (void *)NineDevice9_GetRenderState,
311
    (void *)NineDevice9_CreateStateBlock,
312
    (void *)NineDevice9_BeginStateBlock,
313
    (void *)NineDevice9_EndStateBlock,
314
    (void *)NineDevice9_SetClipStatus,
315
    (void *)NineDevice9_GetClipStatus,
316
    (void *)NineDevice9_GetTexture,
317
    (void *)NineDevice9_SetTexture,
318
    (void *)NineDevice9_GetTextureStageState,
319
    (void *)NineDevice9_SetTextureStageState,
320
    (void *)NineDevice9_GetSamplerState,
321
    (void *)NineDevice9_SetSamplerState,
322
    (void *)NineDevice9_ValidateDevice,
323
    (void *)NineDevice9_SetPaletteEntries,
324
    (void *)NineDevice9_GetPaletteEntries,
325
    (void *)NineDevice9_SetCurrentTexturePalette,
326
    (void *)NineDevice9_GetCurrentTexturePalette,
327
    (void *)NineDevice9_SetScissorRect,
328
    (void *)NineDevice9_GetScissorRect,
329
    (void *)NineDevice9_SetSoftwareVertexProcessing,
330
    (void *)NineDevice9_GetSoftwareVertexProcessing,
331
    (void *)NineDevice9_SetNPatchMode,
332
    (void *)NineDevice9_GetNPatchMode,
333
    (void *)NineDevice9_DrawPrimitive,
334
    (void *)NineDevice9_DrawIndexedPrimitive,
335
    (void *)NineDevice9_DrawPrimitiveUP,
336
    (void *)NineDevice9_DrawIndexedPrimitiveUP,
337
    (void *)NineDevice9_ProcessVertices,
338
    (void *)NineDevice9_CreateVertexDeclaration,
339
    (void *)NineDevice9_SetVertexDeclaration,
340
    (void *)NineDevice9_GetVertexDeclaration,
341
    (void *)NineDevice9_SetFVF,
342
    (void *)NineDevice9_GetFVF,
343
    (void *)NineDevice9_CreateVertexShader,
344
    (void *)NineDevice9_SetVertexShader,
345
    (void *)NineDevice9_GetVertexShader,
346
    (void *)NineDevice9_SetVertexShaderConstantF,
347
    (void *)NineDevice9_GetVertexShaderConstantF,
348
    (void *)NineDevice9_SetVertexShaderConstantI,
349
    (void *)NineDevice9_GetVertexShaderConstantI,
350
    (void *)NineDevice9_SetVertexShaderConstantB,
351
    (void *)NineDevice9_GetVertexShaderConstantB,
352
    (void *)NineDevice9_SetStreamSource,
353
    (void *)NineDevice9_GetStreamSource,
354
    (void *)NineDevice9_SetStreamSourceFreq,
355
    (void *)NineDevice9_GetStreamSourceFreq,
356
    (void *)NineDevice9_SetIndices,
357
    (void *)NineDevice9_GetIndices,
358
    (void *)NineDevice9_CreatePixelShader,
359
    (void *)NineDevice9_SetPixelShader,
360
    (void *)NineDevice9_GetPixelShader,
361
    (void *)NineDevice9_SetPixelShaderConstantF,
362
    (void *)NineDevice9_GetPixelShaderConstantF,
363
    (void *)NineDevice9_SetPixelShaderConstantI,
364
    (void *)NineDevice9_GetPixelShaderConstantI,
365
    (void *)NineDevice9_SetPixelShaderConstantB,
366
    (void *)NineDevice9_GetPixelShaderConstantB,
367
    (void *)NineDevice9_DrawRectPatch,
368
    (void *)NineDevice9_DrawTriPatch,
369
    (void *)NineDevice9_DeletePatch,
370
    (void *)NineDevice9_CreateQuery,
371
    (void *)NineDevice9Ex_SetConvolutionMonoKernel,
372
    (void *)NineDevice9Ex_ComposeRects,
373
    (void *)NineDevice9Ex_PresentEx,
374
    (void *)NineDevice9Ex_GetGPUThreadPriority,
375
    (void *)NineDevice9Ex_SetGPUThreadPriority,
376
    (void *)NineDevice9Ex_WaitForVBlank,
377
    (void *)NineDevice9Ex_CheckResourceResidency,
378
    (void *)NineDevice9Ex_SetMaximumFrameLatency,
379
    (void *)NineDevice9Ex_GetMaximumFrameLatency,
380
    (void *)NineDevice9Ex_CheckDeviceState,
381
    (void *)NineDevice9Ex_CreateRenderTargetEx,
382
    (void *)NineDevice9Ex_CreateOffscreenPlainSurfaceEx,
383
    (void *)NineDevice9Ex_CreateDepthStencilSurfaceEx,
384
    (void *)NineDevice9Ex_ResetEx,
385
    (void *)NineDevice9Ex_GetDisplayModeEx
386
};
387
 
388
static const GUID *NineDevice9Ex_IIDs[] = {
389
    &IID_IDirect3DDevice9Ex,
390
    &IID_IDirect3DDevice9,
391
    &IID_IUnknown,
392
    NULL
393
};
394
 
395
HRESULT
396
NineDevice9Ex_new( struct pipe_screen *pScreen,
397
                   D3DDEVICE_CREATION_PARAMETERS *pCreationParameters,
398
                   D3DCAPS9 *pCaps,
399
                   D3DPRESENT_PARAMETERS *pPresentationParameters,
400
                   D3DDISPLAYMODEEX *pFullscreenDisplayMode,
401
                   IDirect3D9Ex *pD3D9Ex,
402
                   ID3DPresentGroup *pPresentationGroup,
403
                   struct d3dadapter9_context *pCTX,
404
                   struct NineDevice9Ex **ppOut )
405
{
406
    BOOL lock;
407
    lock = !!(pCreationParameters->BehaviorFlags & D3DCREATE_MULTITHREADED);
408
 
409
    NINE_NEW(Device9Ex, ppOut, lock,
410
             pScreen, pCreationParameters, pCaps, pPresentationParameters,
411
             pFullscreenDisplayMode, pD3D9Ex, pPresentationGroup, pCTX);
412
}
413