1 /*
2  * Copyright 2013 Joakim Sindholt <opensource@zhasha.com>
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 "authenticatedchannel9.h"
24 #include "basetexture9.h"
25 #include "cryptosession9.h"
26 #include "cubetexture9.h"
27 #include "device9.h"
28 #include "device9ex.h"
29 #include "device9video.h"
30 #include "indexbuffer9.h"
31 #include "pixelshader9.h"
32 #include "query9.h"
33 #include "resource9.h"
34 #include "stateblock9.h"
35 #include "surface9.h"
36 #include "swapchain9.h"
37 #include "swapchain9ex.h"
38 #include "texture9.h"
39 #include "vertexbuffer9.h"
40 #include "vertexdeclaration9.h"
41 #include "vertexshader9.h"
42 #include "volume9.h"
43 #include "volumetexture9.h"
44 
45 #include "d3d9.h"
46 #include "nine_lock.h"
47 
48 #include "os/os_thread.h"
49 
50 /* Global mutex as described by MSDN */
51 static mtx_t d3dlock_global = _MTX_INITIALIZER_NP;
52 
53 void
NineLockGlobalMutex()54 NineLockGlobalMutex()
55 {
56     mtx_lock(&d3dlock_global);
57 }
58 
59 void
NineUnlockGlobalMutex()60 NineUnlockGlobalMutex()
61 {
62     mtx_unlock(&d3dlock_global);
63 }
64 
65 static HRESULT NINE_WINAPI
LockAuthenticatedChannel9_GetCertificateSize(struct NineAuthenticatedChannel9 * This,UINT * pCertificateSize)66 LockAuthenticatedChannel9_GetCertificateSize( struct NineAuthenticatedChannel9 *This,
67                                               UINT *pCertificateSize )
68 {
69     HRESULT r;
70     mtx_lock(&d3dlock_global);
71     r = NineAuthenticatedChannel9_GetCertificateSize(This, pCertificateSize);
72     mtx_unlock(&d3dlock_global);
73     return r;
74 }
75 
76 static HRESULT NINE_WINAPI
LockAuthenticatedChannel9_GetCertificate(struct NineAuthenticatedChannel9 * This,UINT CertifacteSize,BYTE * ppCertificate)77 LockAuthenticatedChannel9_GetCertificate( struct NineAuthenticatedChannel9 *This,
78                                           UINT CertifacteSize,
79                                           BYTE *ppCertificate )
80 {
81     HRESULT r;
82     mtx_lock(&d3dlock_global);
83     r = NineAuthenticatedChannel9_GetCertificate(This, CertifacteSize, ppCertificate);
84     mtx_unlock(&d3dlock_global);
85     return r;
86 }
87 
88 static HRESULT NINE_WINAPI
LockAuthenticatedChannel9_NegotiateKeyExchange(struct NineAuthenticatedChannel9 * This,UINT DataSize,void * pData)89 LockAuthenticatedChannel9_NegotiateKeyExchange( struct NineAuthenticatedChannel9 *This,
90                                                 UINT DataSize,
91                                                 void *pData )
92 {
93     HRESULT r;
94     mtx_lock(&d3dlock_global);
95     r = NineAuthenticatedChannel9_NegotiateKeyExchange(This, DataSize, pData);
96     mtx_unlock(&d3dlock_global);
97     return r;
98 }
99 
100 static HRESULT NINE_WINAPI
LockAuthenticatedChannel9_Query(struct NineAuthenticatedChannel9 * This,UINT InputSize,const void * pInput,UINT OutputSize,void * pOutput)101 LockAuthenticatedChannel9_Query( struct NineAuthenticatedChannel9 *This,
102                                  UINT InputSize,
103                                  const void *pInput,
104                                  UINT OutputSize,
105                                  void *pOutput )
106 {
107     HRESULT r;
108     mtx_lock(&d3dlock_global);
109     r = NineAuthenticatedChannel9_Query(This, InputSize, pInput, OutputSize, pOutput);
110     mtx_unlock(&d3dlock_global);
111     return r;
112 }
113 
114 static HRESULT NINE_WINAPI
LockAuthenticatedChannel9_Configure(struct NineAuthenticatedChannel9 * This,UINT InputSize,const void * pInput,D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT * pOutput)115 LockAuthenticatedChannel9_Configure( struct NineAuthenticatedChannel9 *This,
116                                      UINT InputSize,
117                                      const void *pInput,
118                                      D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT *pOutput )
119 {
120     HRESULT r;
121     mtx_lock(&d3dlock_global);
122     r = NineAuthenticatedChannel9_Configure(This, InputSize, pInput, pOutput);
123     mtx_unlock(&d3dlock_global);
124     return r;
125 }
126 
127 IDirect3DAuthenticatedChannel9Vtbl LockAuthenticatedChannel9_vtable = {
128     (void *)NineUnknown_QueryInterface,
129     (void *)NineUnknown_AddRef,
130     (void *)NineUnknown_ReleaseWithDtorLock,
131     (void *)LockAuthenticatedChannel9_GetCertificateSize,
132     (void *)LockAuthenticatedChannel9_GetCertificate,
133     (void *)LockAuthenticatedChannel9_NegotiateKeyExchange,
134     (void *)LockAuthenticatedChannel9_Query,
135     (void *)LockAuthenticatedChannel9_Configure
136 };
137 
138 static HRESULT NINE_WINAPI
LockUnknown_SetPrivateData(struct NineUnknown * This,REFGUID refguid,const void * pData,DWORD SizeOfData,DWORD Flags)139 LockUnknown_SetPrivateData( struct NineUnknown *This,
140                             REFGUID refguid,
141                             const void *pData,
142                             DWORD SizeOfData,
143                             DWORD Flags )
144 {
145     HRESULT r;
146     mtx_lock(&d3dlock_global);
147     r = NineUnknown_SetPrivateData(This, refguid, pData, SizeOfData, Flags);
148     mtx_unlock(&d3dlock_global);
149     return r;
150 }
151 
152 static HRESULT NINE_WINAPI
LockUnknown_GetPrivateData(struct NineUnknown * This,REFGUID refguid,void * pData,DWORD * pSizeOfData)153 LockUnknown_GetPrivateData( struct NineUnknown *This,
154                             REFGUID refguid,
155                             void *pData,
156                             DWORD *pSizeOfData )
157 {
158     HRESULT r;
159     mtx_lock(&d3dlock_global);
160     r = NineUnknown_GetPrivateData(This, refguid, pData, pSizeOfData);
161     mtx_unlock(&d3dlock_global);
162     return r;
163 }
164 
165 static HRESULT NINE_WINAPI
LockUnknown_FreePrivateData(struct NineUnknown * This,REFGUID refguid)166 LockUnknown_FreePrivateData( struct NineUnknown *This,
167                              REFGUID refguid )
168 {
169     HRESULT r;
170     mtx_lock(&d3dlock_global);
171     r = NineUnknown_FreePrivateData(This, refguid);
172     mtx_unlock(&d3dlock_global);
173     return r;
174 }
175 
176 #if 0
177 static HRESULT NINE_WINAPI
178 LockResource9_GetDevice( struct NineResource9 *This,
179                          IDirect3DDevice9 **ppDevice )
180 {
181     HRESULT r;
182     mtx_lock(&d3dlock_global);
183     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
184     mtx_unlock(&d3dlock_global);
185     return r;
186 }
187 #endif
188 
189 static DWORD NINE_WINAPI
LockResource9_SetPriority(struct NineResource9 * This,DWORD PriorityNew)190 LockResource9_SetPriority( struct NineResource9 *This,
191                            DWORD PriorityNew )
192 {
193     DWORD r;
194     mtx_lock(&d3dlock_global);
195     r = NineResource9_SetPriority(This, PriorityNew);
196     mtx_unlock(&d3dlock_global);
197     return r;
198 }
199 
200 static DWORD NINE_WINAPI
LockResource9_GetPriority(struct NineResource9 * This)201 LockResource9_GetPriority( struct NineResource9 *This )
202 {
203     DWORD r;
204     mtx_lock(&d3dlock_global);
205     r = NineResource9_GetPriority(This);
206     mtx_unlock(&d3dlock_global);
207     return r;
208 }
209 
210 #if 0
211 static void NINE_WINAPI
212 LockResource9_PreLoad( struct NineResource9 *This )
213 {
214     mtx_lock(&d3dlock_global);
215     NineResource9_PreLoad(This);
216     mtx_unlock(&d3dlock_global);
217 }
218 #endif
219 
220 #if 0
221 static D3DRESOURCETYPE NINE_WINAPI
222 LockResource9_GetType( struct NineResource9 *This )
223 {
224     D3DRESOURCETYPE r;
225     mtx_lock(&d3dlock_global);
226     r = NineResource9_GetType(This);
227     mtx_unlock(&d3dlock_global);
228     return r;
229 }
230 #endif
231 
232 static DWORD NINE_WINAPI
LockBaseTexture9_SetLOD(struct NineBaseTexture9 * This,DWORD LODNew)233 LockBaseTexture9_SetLOD( struct NineBaseTexture9 *This,
234                          DWORD LODNew )
235 {
236     DWORD r;
237     mtx_lock(&d3dlock_global);
238     r = NineBaseTexture9_SetLOD(This, LODNew);
239     mtx_unlock(&d3dlock_global);
240     return r;
241 }
242 
243 static DWORD NINE_WINAPI
LockBaseTexture9_GetLOD(struct NineBaseTexture9 * This)244 LockBaseTexture9_GetLOD( struct NineBaseTexture9 *This )
245 {
246     DWORD r;
247     mtx_lock(&d3dlock_global);
248     r = NineBaseTexture9_GetLOD(This);
249     mtx_unlock(&d3dlock_global);
250     return r;
251 }
252 
253 static DWORD NINE_WINAPI
LockBaseTexture9_GetLevelCount(struct NineBaseTexture9 * This)254 LockBaseTexture9_GetLevelCount( struct NineBaseTexture9 *This )
255 {
256     DWORD r;
257     mtx_lock(&d3dlock_global);
258     r = NineBaseTexture9_GetLevelCount(This);
259     mtx_unlock(&d3dlock_global);
260     return r;
261 }
262 
263 static HRESULT NINE_WINAPI
LockBaseTexture9_SetAutoGenFilterType(struct NineBaseTexture9 * This,D3DTEXTUREFILTERTYPE FilterType)264 LockBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This,
265                                        D3DTEXTUREFILTERTYPE FilterType )
266 {
267     HRESULT r;
268     mtx_lock(&d3dlock_global);
269     r = NineBaseTexture9_SetAutoGenFilterType(This, FilterType);
270     mtx_unlock(&d3dlock_global);
271     return r;
272 }
273 
274 static D3DTEXTUREFILTERTYPE NINE_WINAPI
LockBaseTexture9_GetAutoGenFilterType(struct NineBaseTexture9 * This)275 LockBaseTexture9_GetAutoGenFilterType( struct NineBaseTexture9 *This )
276 {
277     D3DTEXTUREFILTERTYPE r;
278     mtx_lock(&d3dlock_global);
279     r = NineBaseTexture9_GetAutoGenFilterType(This);
280     mtx_unlock(&d3dlock_global);
281     return r;
282 }
283 
284 static void NINE_WINAPI
LockBaseTexture9_PreLoad(struct NineBaseTexture9 * This)285 LockBaseTexture9_PreLoad( struct NineBaseTexture9 *This )
286 {
287     mtx_lock(&d3dlock_global);
288     NineBaseTexture9_PreLoad(This);
289     mtx_unlock(&d3dlock_global);
290 }
291 
292 static void NINE_WINAPI
LockBaseTexture9_GenerateMipSubLevels(struct NineBaseTexture9 * This)293 LockBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
294 {
295     mtx_lock(&d3dlock_global);
296     NineBaseTexture9_GenerateMipSubLevels(This);
297     mtx_unlock(&d3dlock_global);
298 }
299 
300 static HRESULT NINE_WINAPI
LockCryptoSession9_GetCertificateSize(struct NineCryptoSession9 * This,UINT * pCertificateSize)301 LockCryptoSession9_GetCertificateSize( struct NineCryptoSession9 *This,
302                                        UINT *pCertificateSize )
303 {
304     HRESULT r;
305     mtx_lock(&d3dlock_global);
306     r = NineCryptoSession9_GetCertificateSize(This, pCertificateSize);
307     mtx_unlock(&d3dlock_global);
308     return r;
309 }
310 
311 static HRESULT NINE_WINAPI
LockCryptoSession9_GetCertificate(struct NineCryptoSession9 * This,UINT CertifacteSize,BYTE * ppCertificate)312 LockCryptoSession9_GetCertificate( struct NineCryptoSession9 *This,
313                                    UINT CertifacteSize,
314                                    BYTE *ppCertificate )
315 {
316     HRESULT r;
317     mtx_lock(&d3dlock_global);
318     r = NineCryptoSession9_GetCertificate(This, CertifacteSize, ppCertificate);
319     mtx_unlock(&d3dlock_global);
320     return r;
321 }
322 
323 static HRESULT NINE_WINAPI
LockCryptoSession9_NegotiateKeyExchange(struct NineCryptoSession9 * This,UINT DataSize,void * pData)324 LockCryptoSession9_NegotiateKeyExchange( struct NineCryptoSession9 *This,
325                                          UINT DataSize,
326                                          void *pData )
327 {
328     HRESULT r;
329     mtx_lock(&d3dlock_global);
330     r = NineCryptoSession9_NegotiateKeyExchange(This, DataSize, pData);
331     mtx_unlock(&d3dlock_global);
332     return r;
333 }
334 
335 static HRESULT NINE_WINAPI
LockCryptoSession9_EncryptionBlt(struct NineCryptoSession9 * This,IDirect3DSurface9 * pSrcSurface,IDirect3DSurface9 * pDstSurface,UINT DstSurfaceSize,void * pIV)336 LockCryptoSession9_EncryptionBlt( struct NineCryptoSession9 *This,
337                                   IDirect3DSurface9 *pSrcSurface,
338                                   IDirect3DSurface9 *pDstSurface,
339                                   UINT DstSurfaceSize,
340                                   void *pIV )
341 {
342     HRESULT r;
343     mtx_lock(&d3dlock_global);
344     r = NineCryptoSession9_EncryptionBlt(This, pSrcSurface, pDstSurface, DstSurfaceSize, pIV);
345     mtx_unlock(&d3dlock_global);
346     return r;
347 }
348 
349 static HRESULT NINE_WINAPI
LockCryptoSession9_DecryptionBlt(struct NineCryptoSession9 * This,IDirect3DSurface9 * pSrcSurface,IDirect3DSurface9 * pDstSurface,UINT SrcSurfaceSize,D3DENCRYPTED_BLOCK_INFO * pEncryptedBlockInfo,void * pContentKey,void * pIV)350 LockCryptoSession9_DecryptionBlt( struct NineCryptoSession9 *This,
351                                   IDirect3DSurface9 *pSrcSurface,
352                                   IDirect3DSurface9 *pDstSurface,
353                                   UINT SrcSurfaceSize,
354                                   D3DENCRYPTED_BLOCK_INFO *pEncryptedBlockInfo,
355                                   void *pContentKey,
356                                   void *pIV )
357 {
358     HRESULT r;
359     mtx_lock(&d3dlock_global);
360     r = NineCryptoSession9_DecryptionBlt(This, pSrcSurface, pDstSurface, SrcSurfaceSize, pEncryptedBlockInfo, pContentKey, pIV);
361     mtx_unlock(&d3dlock_global);
362     return r;
363 }
364 
365 static HRESULT NINE_WINAPI
LockCryptoSession9_GetSurfacePitch(struct NineCryptoSession9 * This,IDirect3DSurface9 * pSrcSurface,UINT * pSurfacePitch)366 LockCryptoSession9_GetSurfacePitch( struct NineCryptoSession9 *This,
367                                     IDirect3DSurface9 *pSrcSurface,
368                                     UINT *pSurfacePitch )
369 {
370     HRESULT r;
371     mtx_lock(&d3dlock_global);
372     r = NineCryptoSession9_GetSurfacePitch(This, pSrcSurface, pSurfacePitch);
373     mtx_unlock(&d3dlock_global);
374     return r;
375 }
376 
377 static HRESULT NINE_WINAPI
LockCryptoSession9_StartSessionKeyRefresh(struct NineCryptoSession9 * This,void * pRandomNumber,UINT RandomNumberSize)378 LockCryptoSession9_StartSessionKeyRefresh( struct NineCryptoSession9 *This,
379                                            void *pRandomNumber,
380                                            UINT RandomNumberSize )
381 {
382     HRESULT r;
383     mtx_lock(&d3dlock_global);
384     r = NineCryptoSession9_StartSessionKeyRefresh(This, pRandomNumber, RandomNumberSize);
385     mtx_unlock(&d3dlock_global);
386     return r;
387 }
388 
389 static HRESULT NINE_WINAPI
LockCryptoSession9_FinishSessionKeyRefresh(struct NineCryptoSession9 * This)390 LockCryptoSession9_FinishSessionKeyRefresh( struct NineCryptoSession9 *This )
391 {
392     HRESULT r;
393     mtx_lock(&d3dlock_global);
394     r = NineCryptoSession9_FinishSessionKeyRefresh(This);
395     mtx_unlock(&d3dlock_global);
396     return r;
397 }
398 
399 static HRESULT NINE_WINAPI
LockCryptoSession9_GetEncryptionBltKey(struct NineCryptoSession9 * This,void * pReadbackKey,UINT KeySize)400 LockCryptoSession9_GetEncryptionBltKey( struct NineCryptoSession9 *This,
401                                         void *pReadbackKey,
402                                         UINT KeySize )
403 {
404     HRESULT r;
405     mtx_lock(&d3dlock_global);
406     r = NineCryptoSession9_GetEncryptionBltKey(This, pReadbackKey, KeySize);
407     mtx_unlock(&d3dlock_global);
408     return r;
409 }
410 
411 IDirect3DCryptoSession9Vtbl LockCryptoSession9_vtable = {
412     (void *)NineUnknown_QueryInterface,
413     (void *)NineUnknown_AddRef,
414     (void *)NineUnknown_ReleaseWithDtorLock,
415     (void *)LockCryptoSession9_GetCertificateSize,
416     (void *)LockCryptoSession9_GetCertificate,
417     (void *)LockCryptoSession9_NegotiateKeyExchange,
418     (void *)LockCryptoSession9_EncryptionBlt,
419     (void *)LockCryptoSession9_DecryptionBlt,
420     (void *)LockCryptoSession9_GetSurfacePitch,
421     (void *)LockCryptoSession9_StartSessionKeyRefresh,
422     (void *)LockCryptoSession9_FinishSessionKeyRefresh,
423     (void *)LockCryptoSession9_GetEncryptionBltKey
424 };
425 
426 #if 0
427 static HRESULT NINE_WINAPI
428 LockCubeTexture9_GetLevelDesc( struct NineCubeTexture9 *This,
429                                UINT Level,
430                                D3DSURFACE_DESC *pDesc )
431 {
432     HRESULT r;
433     mtx_lock(&d3dlock_global);
434     r = NineCubeTexture9_GetLevelDesc(This, Level, pDesc);
435     mtx_unlock(&d3dlock_global);
436     return r;
437 }
438 #endif
439 
440 #if 0
441 static HRESULT NINE_WINAPI
442 LockCubeTexture9_GetCubeMapSurface( struct NineCubeTexture9 *This,
443                                     D3DCUBEMAP_FACES FaceType,
444                                     UINT Level,
445                                     IDirect3DSurface9 **ppCubeMapSurface )
446 {
447     HRESULT r;
448     mtx_lock(&d3dlock_global);
449     r = NineCubeTexture9_GetCubeMapSurface(This, FaceType, Level, ppCubeMapSurface);
450     mtx_unlock(&d3dlock_global);
451     return r;
452 }
453 #endif
454 
455 static HRESULT NINE_WINAPI
LockCubeTexture9_LockRect(struct NineCubeTexture9 * This,D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT * pLockedRect,const RECT * pRect,DWORD Flags)456 LockCubeTexture9_LockRect( struct NineCubeTexture9 *This,
457                            D3DCUBEMAP_FACES FaceType,
458                            UINT Level,
459                            D3DLOCKED_RECT *pLockedRect,
460                            const RECT *pRect,
461                            DWORD Flags )
462 {
463     HRESULT r;
464     mtx_lock(&d3dlock_global);
465     r = NineCubeTexture9_LockRect(This, FaceType, Level, pLockedRect, pRect, Flags);
466     mtx_unlock(&d3dlock_global);
467     return r;
468 }
469 
470 static HRESULT NINE_WINAPI
LockCubeTexture9_UnlockRect(struct NineCubeTexture9 * This,D3DCUBEMAP_FACES FaceType,UINT Level)471 LockCubeTexture9_UnlockRect( struct NineCubeTexture9 *This,
472                              D3DCUBEMAP_FACES FaceType,
473                              UINT Level )
474 {
475     HRESULT r;
476     mtx_lock(&d3dlock_global);
477     r = NineCubeTexture9_UnlockRect(This, FaceType, Level);
478     mtx_unlock(&d3dlock_global);
479     return r;
480 }
481 
482 static HRESULT NINE_WINAPI
LockCubeTexture9_AddDirtyRect(struct NineCubeTexture9 * This,D3DCUBEMAP_FACES FaceType,const RECT * pDirtyRect)483 LockCubeTexture9_AddDirtyRect( struct NineCubeTexture9 *This,
484                                D3DCUBEMAP_FACES FaceType,
485                                const RECT *pDirtyRect )
486 {
487     HRESULT r;
488     mtx_lock(&d3dlock_global);
489     r = NineCubeTexture9_AddDirtyRect(This, FaceType, pDirtyRect);
490     mtx_unlock(&d3dlock_global);
491     return r;
492 }
493 
494 IDirect3DCubeTexture9Vtbl LockCubeTexture9_vtable = {
495     (void *)NineUnknown_QueryInterface,
496     (void *)NineUnknown_AddRef,
497     (void *)NineUnknown_ReleaseWithDtorLock,
498     (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
499     (void *)LockUnknown_SetPrivateData,
500     (void *)LockUnknown_GetPrivateData,
501     (void *)LockUnknown_FreePrivateData,
502     (void *)LockResource9_SetPriority,
503     (void *)LockResource9_GetPriority,
504     (void *)LockBaseTexture9_PreLoad,
505     (void *)NineResource9_GetType, /* immutable */
506     (void *)LockBaseTexture9_SetLOD,
507     (void *)LockBaseTexture9_GetLOD,
508     (void *)LockBaseTexture9_GetLevelCount,
509     (void *)LockBaseTexture9_SetAutoGenFilterType,
510     (void *)LockBaseTexture9_GetAutoGenFilterType,
511     (void *)LockBaseTexture9_GenerateMipSubLevels,
512     (void *)NineCubeTexture9_GetLevelDesc, /* immutable */
513     (void *)NineCubeTexture9_GetCubeMapSurface, /* AddRef */
514     (void *)LockCubeTexture9_LockRect,
515     (void *)LockCubeTexture9_UnlockRect,
516     (void *)LockCubeTexture9_AddDirtyRect
517 };
518 
519 static HRESULT NINE_WINAPI
LockDevice9_TestCooperativeLevel(struct NineDevice9 * This)520 LockDevice9_TestCooperativeLevel( struct NineDevice9 *This )
521 {
522     HRESULT r;
523     mtx_lock(&d3dlock_global);
524     r = NineDevice9_TestCooperativeLevel(This);
525     mtx_unlock(&d3dlock_global);
526     return r;
527 }
528 
529 static UINT NINE_WINAPI
LockDevice9_GetAvailableTextureMem(struct NineDevice9 * This)530 LockDevice9_GetAvailableTextureMem( struct NineDevice9 *This )
531 {
532     UINT r;
533     mtx_lock(&d3dlock_global);
534     r = NineDevice9_GetAvailableTextureMem(This);
535     mtx_unlock(&d3dlock_global);
536     return r;
537 }
538 
539 static HRESULT NINE_WINAPI
LockDevice9_EvictManagedResources(struct NineDevice9 * This)540 LockDevice9_EvictManagedResources( struct NineDevice9 *This )
541 {
542     HRESULT r;
543     mtx_lock(&d3dlock_global);
544     r = NineDevice9_EvictManagedResources(This);
545     mtx_unlock(&d3dlock_global);
546     return r;
547 }
548 
549 static HRESULT NINE_WINAPI
LockDevice9_GetDirect3D(struct NineDevice9 * This,IDirect3D9 ** ppD3D9)550 LockDevice9_GetDirect3D( struct NineDevice9 *This,
551                          IDirect3D9 **ppD3D9 )
552 {
553     HRESULT r;
554     mtx_lock(&d3dlock_global);
555     r = NineDevice9_GetDirect3D(This, ppD3D9);
556     mtx_unlock(&d3dlock_global);
557     return r;
558 }
559 
560 #if 0
561 static HRESULT NINE_WINAPI
562 LockDevice9_GetDeviceCaps( struct NineDevice9 *This,
563                            D3DCAPS9 *pCaps )
564 {
565     HRESULT r;
566     mtx_lock(&d3dlock_global);
567     r = NineDevice9_GetDeviceCaps(This, pCaps);
568     mtx_unlock(&d3dlock_global);
569     return r;
570 }
571 #endif
572 
573 static HRESULT NINE_WINAPI
LockDevice9_GetDisplayMode(struct NineDevice9 * This,UINT iSwapChain,D3DDISPLAYMODE * pMode)574 LockDevice9_GetDisplayMode( struct NineDevice9 *This,
575                             UINT iSwapChain,
576                             D3DDISPLAYMODE *pMode )
577 {
578     HRESULT r;
579     mtx_lock(&d3dlock_global);
580     r = NineDevice9_GetDisplayMode(This, iSwapChain, pMode);
581     mtx_unlock(&d3dlock_global);
582     return r;
583 }
584 
585 #if 0
586 static HRESULT NINE_WINAPI
587 LockDevice9_GetCreationParameters( struct NineDevice9 *This,
588                                    D3DDEVICE_CREATION_PARAMETERS *pParameters )
589 {
590     HRESULT r;
591     mtx_lock(&d3dlock_global);
592     r = NineDevice9_GetCreationParameters(This, pParameters);
593     mtx_unlock(&d3dlock_global);
594     return r;
595 }
596 #endif
597 
598 static HRESULT NINE_WINAPI
LockDevice9_SetCursorProperties(struct NineDevice9 * This,UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9 * pCursorBitmap)599 LockDevice9_SetCursorProperties( struct NineDevice9 *This,
600                                  UINT XHotSpot,
601                                  UINT YHotSpot,
602                                  IDirect3DSurface9 *pCursorBitmap )
603 {
604     HRESULT r;
605     mtx_lock(&d3dlock_global);
606     r = NineDevice9_SetCursorProperties(This, XHotSpot, YHotSpot, pCursorBitmap);
607     mtx_unlock(&d3dlock_global);
608     return r;
609 }
610 
611 static void NINE_WINAPI
LockDevice9_SetCursorPosition(struct NineDevice9 * This,int X,int Y,DWORD Flags)612 LockDevice9_SetCursorPosition( struct NineDevice9 *This,
613                                int X,
614                                int Y,
615                                DWORD Flags )
616 {
617     mtx_lock(&d3dlock_global);
618     NineDevice9_SetCursorPosition(This, X, Y, Flags);
619     mtx_unlock(&d3dlock_global);
620 }
621 
622 static BOOL NINE_WINAPI
LockDevice9_ShowCursor(struct NineDevice9 * This,BOOL bShow)623 LockDevice9_ShowCursor( struct NineDevice9 *This,
624                         BOOL bShow )
625 {
626     BOOL r;
627     mtx_lock(&d3dlock_global);
628     r = NineDevice9_ShowCursor(This, bShow);
629     mtx_unlock(&d3dlock_global);
630     return r;
631 }
632 
633 static HRESULT NINE_WINAPI
LockDevice9_CreateAdditionalSwapChain(struct NineDevice9 * This,D3DPRESENT_PARAMETERS * pPresentationParameters,IDirect3DSwapChain9 ** pSwapChain)634 LockDevice9_CreateAdditionalSwapChain( struct NineDevice9 *This,
635                                        D3DPRESENT_PARAMETERS *pPresentationParameters,
636                                        IDirect3DSwapChain9 **pSwapChain )
637 {
638     HRESULT r;
639     mtx_lock(&d3dlock_global);
640     r = NineDevice9_CreateAdditionalSwapChain(This, pPresentationParameters, pSwapChain);
641     mtx_unlock(&d3dlock_global);
642     return r;
643 }
644 
645 static HRESULT NINE_WINAPI
LockDevice9_GetSwapChain(struct NineDevice9 * This,UINT iSwapChain,IDirect3DSwapChain9 ** pSwapChain)646 LockDevice9_GetSwapChain( struct NineDevice9 *This,
647                           UINT iSwapChain,
648                           IDirect3DSwapChain9 **pSwapChain )
649 {
650     HRESULT r;
651     mtx_lock(&d3dlock_global);
652     r = NineDevice9_GetSwapChain(This, iSwapChain, pSwapChain);
653     mtx_unlock(&d3dlock_global);
654     return r;
655 }
656 
657 static UINT NINE_WINAPI
LockDevice9_GetNumberOfSwapChains(struct NineDevice9 * This)658 LockDevice9_GetNumberOfSwapChains( struct NineDevice9 *This )
659 {
660     UINT r;
661     mtx_lock(&d3dlock_global);
662     r = NineDevice9_GetNumberOfSwapChains(This);
663     mtx_unlock(&d3dlock_global);
664     return r;
665 }
666 
667 static HRESULT NINE_WINAPI
LockDevice9_Reset(struct NineDevice9 * This,D3DPRESENT_PARAMETERS * pPresentationParameters)668 LockDevice9_Reset( struct NineDevice9 *This,
669                    D3DPRESENT_PARAMETERS *pPresentationParameters )
670 {
671     HRESULT r;
672     mtx_lock(&d3dlock_global);
673     r = NineDevice9_Reset(This, pPresentationParameters);
674     mtx_unlock(&d3dlock_global);
675     return r;
676 }
677 
678 static HRESULT NINE_WINAPI
LockDevice9_Present(struct NineDevice9 * This,const RECT * pSourceRect,const RECT * pDestRect,HWND hDestWindowOverride,const RGNDATA * pDirtyRegion)679 LockDevice9_Present( struct NineDevice9 *This,
680                      const RECT *pSourceRect,
681                      const RECT *pDestRect,
682                      HWND hDestWindowOverride,
683                      const RGNDATA *pDirtyRegion )
684 {
685     HRESULT r;
686     mtx_lock(&d3dlock_global);
687     r = NineDevice9_Present(This, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
688     mtx_unlock(&d3dlock_global);
689     return r;
690 }
691 
692 static HRESULT NINE_WINAPI
LockDevice9_GetBackBuffer(struct NineDevice9 * This,UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9 ** ppBackBuffer)693 LockDevice9_GetBackBuffer( struct NineDevice9 *This,
694                            UINT iSwapChain,
695                            UINT iBackBuffer,
696                            D3DBACKBUFFER_TYPE Type,
697                            IDirect3DSurface9 **ppBackBuffer )
698 {
699     HRESULT r;
700     mtx_lock(&d3dlock_global);
701     r = NineDevice9_GetBackBuffer(This, iSwapChain, iBackBuffer, Type, ppBackBuffer);
702     mtx_unlock(&d3dlock_global);
703     return r;
704 }
705 
706 static HRESULT NINE_WINAPI
LockDevice9_GetRasterStatus(struct NineDevice9 * This,UINT iSwapChain,D3DRASTER_STATUS * pRasterStatus)707 LockDevice9_GetRasterStatus( struct NineDevice9 *This,
708                              UINT iSwapChain,
709                              D3DRASTER_STATUS *pRasterStatus )
710 {
711     HRESULT r;
712     mtx_lock(&d3dlock_global);
713     r = NineDevice9_GetRasterStatus(This, iSwapChain, pRasterStatus);
714     mtx_unlock(&d3dlock_global);
715     return r;
716 }
717 
718 static HRESULT NINE_WINAPI
LockDevice9_SetDialogBoxMode(struct NineDevice9 * This,BOOL bEnableDialogs)719 LockDevice9_SetDialogBoxMode( struct NineDevice9 *This,
720                               BOOL bEnableDialogs )
721 {
722     HRESULT r;
723     mtx_lock(&d3dlock_global);
724     r = NineDevice9_SetDialogBoxMode(This, bEnableDialogs);
725     mtx_unlock(&d3dlock_global);
726     return r;
727 }
728 
729 static void NINE_WINAPI
LockDevice9_SetGammaRamp(struct NineDevice9 * This,UINT iSwapChain,DWORD Flags,const D3DGAMMARAMP * pRamp)730 LockDevice9_SetGammaRamp( struct NineDevice9 *This,
731                           UINT iSwapChain,
732                           DWORD Flags,
733                           const D3DGAMMARAMP *pRamp )
734 {
735     mtx_lock(&d3dlock_global);
736     NineDevice9_SetGammaRamp(This, iSwapChain, Flags, pRamp);
737     mtx_unlock(&d3dlock_global);
738 }
739 
740 static void NINE_WINAPI
LockDevice9_GetGammaRamp(struct NineDevice9 * This,UINT iSwapChain,D3DGAMMARAMP * pRamp)741 LockDevice9_GetGammaRamp( struct NineDevice9 *This,
742                           UINT iSwapChain,
743                           D3DGAMMARAMP *pRamp )
744 {
745     mtx_lock(&d3dlock_global);
746     NineDevice9_GetGammaRamp(This, iSwapChain, pRamp);
747     mtx_unlock(&d3dlock_global);
748 }
749 
750 static HRESULT NINE_WINAPI
LockDevice9_CreateTexture(struct NineDevice9 * This,UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9 ** ppTexture,HANDLE * pSharedHandle)751 LockDevice9_CreateTexture( struct NineDevice9 *This,
752                            UINT Width,
753                            UINT Height,
754                            UINT Levels,
755                            DWORD Usage,
756                            D3DFORMAT Format,
757                            D3DPOOL Pool,
758                            IDirect3DTexture9 **ppTexture,
759                            HANDLE *pSharedHandle )
760 {
761     HRESULT r;
762     mtx_lock(&d3dlock_global);
763     r = NineDevice9_CreateTexture(This, Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle);
764     mtx_unlock(&d3dlock_global);
765     return r;
766 }
767 
768 static HRESULT NINE_WINAPI
LockDevice9_CreateVolumeTexture(struct NineDevice9 * This,UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9 ** ppVolumeTexture,HANDLE * pSharedHandle)769 LockDevice9_CreateVolumeTexture( struct NineDevice9 *This,
770                                  UINT Width,
771                                  UINT Height,
772                                  UINT Depth,
773                                  UINT Levels,
774                                  DWORD Usage,
775                                  D3DFORMAT Format,
776                                  D3DPOOL Pool,
777                                  IDirect3DVolumeTexture9 **ppVolumeTexture,
778                                  HANDLE *pSharedHandle )
779 {
780     HRESULT r;
781     mtx_lock(&d3dlock_global);
782     r = NineDevice9_CreateVolumeTexture(This, Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle);
783     mtx_unlock(&d3dlock_global);
784     return r;
785 }
786 
787 static HRESULT NINE_WINAPI
LockDevice9_CreateCubeTexture(struct NineDevice9 * This,UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9 ** ppCubeTexture,HANDLE * pSharedHandle)788 LockDevice9_CreateCubeTexture( struct NineDevice9 *This,
789                                UINT EdgeLength,
790                                UINT Levels,
791                                DWORD Usage,
792                                D3DFORMAT Format,
793                                D3DPOOL Pool,
794                                IDirect3DCubeTexture9 **ppCubeTexture,
795                                HANDLE *pSharedHandle )
796 {
797     HRESULT r;
798     mtx_lock(&d3dlock_global);
799     r = NineDevice9_CreateCubeTexture(This, EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle);
800     mtx_unlock(&d3dlock_global);
801     return r;
802 }
803 
804 static HRESULT NINE_WINAPI
LockDevice9_CreateVertexBuffer(struct NineDevice9 * This,UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9 ** ppVertexBuffer,HANDLE * pSharedHandle)805 LockDevice9_CreateVertexBuffer( struct NineDevice9 *This,
806                                 UINT Length,
807                                 DWORD Usage,
808                                 DWORD FVF,
809                                 D3DPOOL Pool,
810                                 IDirect3DVertexBuffer9 **ppVertexBuffer,
811                                 HANDLE *pSharedHandle )
812 {
813     HRESULT r;
814     mtx_lock(&d3dlock_global);
815     r = NineDevice9_CreateVertexBuffer(This, Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle);
816     mtx_unlock(&d3dlock_global);
817     return r;
818 }
819 
820 static HRESULT NINE_WINAPI
LockDevice9_CreateIndexBuffer(struct NineDevice9 * This,UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9 ** ppIndexBuffer,HANDLE * pSharedHandle)821 LockDevice9_CreateIndexBuffer( struct NineDevice9 *This,
822                                UINT Length,
823                                DWORD Usage,
824                                D3DFORMAT Format,
825                                D3DPOOL Pool,
826                                IDirect3DIndexBuffer9 **ppIndexBuffer,
827                                HANDLE *pSharedHandle )
828 {
829     HRESULT r;
830     mtx_lock(&d3dlock_global);
831     r = NineDevice9_CreateIndexBuffer(This, Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle);
832     mtx_unlock(&d3dlock_global);
833     return r;
834 }
835 
836 static HRESULT NINE_WINAPI
LockDevice9_CreateRenderTarget(struct NineDevice9 * This,UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9 ** ppSurface,HANDLE * pSharedHandle)837 LockDevice9_CreateRenderTarget( struct NineDevice9 *This,
838                                 UINT Width,
839                                 UINT Height,
840                                 D3DFORMAT Format,
841                                 D3DMULTISAMPLE_TYPE MultiSample,
842                                 DWORD MultisampleQuality,
843                                 BOOL Lockable,
844                                 IDirect3DSurface9 **ppSurface,
845                                 HANDLE *pSharedHandle )
846 {
847     HRESULT r;
848     mtx_lock(&d3dlock_global);
849     r = NineDevice9_CreateRenderTarget(This, Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle);
850     mtx_unlock(&d3dlock_global);
851     return r;
852 }
853 
854 static HRESULT NINE_WINAPI
LockDevice9_CreateDepthStencilSurface(struct NineDevice9 * This,UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9 ** ppSurface,HANDLE * pSharedHandle)855 LockDevice9_CreateDepthStencilSurface( struct NineDevice9 *This,
856                                        UINT Width,
857                                        UINT Height,
858                                        D3DFORMAT Format,
859                                        D3DMULTISAMPLE_TYPE MultiSample,
860                                        DWORD MultisampleQuality,
861                                        BOOL Discard,
862                                        IDirect3DSurface9 **ppSurface,
863                                        HANDLE *pSharedHandle )
864 {
865     HRESULT r;
866     mtx_lock(&d3dlock_global);
867     r = NineDevice9_CreateDepthStencilSurface(This, Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle);
868     mtx_unlock(&d3dlock_global);
869     return r;
870 }
871 
872 static HRESULT NINE_WINAPI
LockDevice9_UpdateSurface(struct NineDevice9 * This,IDirect3DSurface9 * pSourceSurface,const RECT * pSourceRect,IDirect3DSurface9 * pDestinationSurface,const POINT * pDestPoint)873 LockDevice9_UpdateSurface( struct NineDevice9 *This,
874                            IDirect3DSurface9 *pSourceSurface,
875                            const RECT *pSourceRect,
876                            IDirect3DSurface9 *pDestinationSurface,
877                            const POINT *pDestPoint )
878 {
879     HRESULT r;
880     mtx_lock(&d3dlock_global);
881     r = NineDevice9_UpdateSurface(This, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
882     mtx_unlock(&d3dlock_global);
883     return r;
884 }
885 
886 static HRESULT NINE_WINAPI
LockDevice9_UpdateTexture(struct NineDevice9 * This,IDirect3DBaseTexture9 * pSourceTexture,IDirect3DBaseTexture9 * pDestinationTexture)887 LockDevice9_UpdateTexture( struct NineDevice9 *This,
888                            IDirect3DBaseTexture9 *pSourceTexture,
889                            IDirect3DBaseTexture9 *pDestinationTexture )
890 {
891     HRESULT r;
892     mtx_lock(&d3dlock_global);
893     r = NineDevice9_UpdateTexture(This, pSourceTexture, pDestinationTexture);
894     mtx_unlock(&d3dlock_global);
895     return r;
896 }
897 
898 static HRESULT NINE_WINAPI
LockDevice9_GetRenderTargetData(struct NineDevice9 * This,IDirect3DSurface9 * pRenderTarget,IDirect3DSurface9 * pDestSurface)899 LockDevice9_GetRenderTargetData( struct NineDevice9 *This,
900                                  IDirect3DSurface9 *pRenderTarget,
901                                  IDirect3DSurface9 *pDestSurface )
902 {
903     HRESULT r;
904     mtx_lock(&d3dlock_global);
905     r = NineDevice9_GetRenderTargetData(This, pRenderTarget, pDestSurface);
906     mtx_unlock(&d3dlock_global);
907     return r;
908 }
909 
910 static HRESULT NINE_WINAPI
LockDevice9_GetFrontBufferData(struct NineDevice9 * This,UINT iSwapChain,IDirect3DSurface9 * pDestSurface)911 LockDevice9_GetFrontBufferData( struct NineDevice9 *This,
912                                 UINT iSwapChain,
913                                 IDirect3DSurface9 *pDestSurface )
914 {
915     HRESULT r;
916     mtx_lock(&d3dlock_global);
917     r = NineDevice9_GetFrontBufferData(This, iSwapChain, pDestSurface);
918     mtx_unlock(&d3dlock_global);
919     return r;
920 }
921 
922 static HRESULT NINE_WINAPI
LockDevice9_StretchRect(struct NineDevice9 * This,IDirect3DSurface9 * pSourceSurface,const RECT * pSourceRect,IDirect3DSurface9 * pDestSurface,const RECT * pDestRect,D3DTEXTUREFILTERTYPE Filter)923 LockDevice9_StretchRect( struct NineDevice9 *This,
924                          IDirect3DSurface9 *pSourceSurface,
925                          const RECT *pSourceRect,
926                          IDirect3DSurface9 *pDestSurface,
927                          const RECT *pDestRect,
928                          D3DTEXTUREFILTERTYPE Filter )
929 {
930     HRESULT r;
931     mtx_lock(&d3dlock_global);
932     r = NineDevice9_StretchRect(This, pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter);
933     mtx_unlock(&d3dlock_global);
934     return r;
935 }
936 
937 static HRESULT NINE_WINAPI
LockDevice9_ColorFill(struct NineDevice9 * This,IDirect3DSurface9 * pSurface,const RECT * pRect,D3DCOLOR color)938 LockDevice9_ColorFill( struct NineDevice9 *This,
939                        IDirect3DSurface9 *pSurface,
940                        const RECT *pRect,
941                        D3DCOLOR color )
942 {
943     HRESULT r;
944     mtx_lock(&d3dlock_global);
945     r = NineDevice9_ColorFill(This, pSurface, pRect, color);
946     mtx_unlock(&d3dlock_global);
947     return r;
948 }
949 
950 static HRESULT NINE_WINAPI
LockDevice9_CreateOffscreenPlainSurface(struct NineDevice9 * This,UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9 ** ppSurface,HANDLE * pSharedHandle)951 LockDevice9_CreateOffscreenPlainSurface( struct NineDevice9 *This,
952                                          UINT Width,
953                                          UINT Height,
954                                          D3DFORMAT Format,
955                                          D3DPOOL Pool,
956                                          IDirect3DSurface9 **ppSurface,
957                                          HANDLE *pSharedHandle )
958 {
959     HRESULT r;
960     mtx_lock(&d3dlock_global);
961     r = NineDevice9_CreateOffscreenPlainSurface(This, Width, Height, Format, Pool, ppSurface, pSharedHandle);
962     mtx_unlock(&d3dlock_global);
963     return r;
964 }
965 
966 static HRESULT NINE_WINAPI
LockDevice9_SetRenderTarget(struct NineDevice9 * This,DWORD RenderTargetIndex,IDirect3DSurface9 * pRenderTarget)967 LockDevice9_SetRenderTarget( struct NineDevice9 *This,
968                              DWORD RenderTargetIndex,
969                              IDirect3DSurface9 *pRenderTarget )
970 {
971     HRESULT r;
972     mtx_lock(&d3dlock_global);
973     r = NineDevice9_SetRenderTarget(This, RenderTargetIndex, pRenderTarget);
974     mtx_unlock(&d3dlock_global);
975     return r;
976 }
977 
978 static HRESULT NINE_WINAPI
LockDevice9_GetRenderTarget(struct NineDevice9 * This,DWORD RenderTargetIndex,IDirect3DSurface9 ** ppRenderTarget)979 LockDevice9_GetRenderTarget( struct NineDevice9 *This,
980                              DWORD RenderTargetIndex,
981                              IDirect3DSurface9 **ppRenderTarget )
982 {
983     HRESULT r;
984     mtx_lock(&d3dlock_global);
985     r = NineDevice9_GetRenderTarget(This, RenderTargetIndex, ppRenderTarget);
986     mtx_unlock(&d3dlock_global);
987     return r;
988 }
989 
990 static HRESULT NINE_WINAPI
LockDevice9_SetDepthStencilSurface(struct NineDevice9 * This,IDirect3DSurface9 * pNewZStencil)991 LockDevice9_SetDepthStencilSurface( struct NineDevice9 *This,
992                                     IDirect3DSurface9 *pNewZStencil )
993 {
994     HRESULT r;
995     mtx_lock(&d3dlock_global);
996     r = NineDevice9_SetDepthStencilSurface(This, pNewZStencil);
997     mtx_unlock(&d3dlock_global);
998     return r;
999 }
1000 
1001 static HRESULT NINE_WINAPI
LockDevice9_GetDepthStencilSurface(struct NineDevice9 * This,IDirect3DSurface9 ** ppZStencilSurface)1002 LockDevice9_GetDepthStencilSurface( struct NineDevice9 *This,
1003                                     IDirect3DSurface9 **ppZStencilSurface )
1004 {
1005     HRESULT r;
1006     mtx_lock(&d3dlock_global);
1007     r = NineDevice9_GetDepthStencilSurface(This, ppZStencilSurface);
1008     mtx_unlock(&d3dlock_global);
1009     return r;
1010 }
1011 
1012 static HRESULT NINE_WINAPI
LockDevice9_BeginScene(struct NineDevice9 * This)1013 LockDevice9_BeginScene( struct NineDevice9 *This )
1014 {
1015     HRESULT r;
1016     mtx_lock(&d3dlock_global);
1017     r = NineDevice9_BeginScene(This);
1018     mtx_unlock(&d3dlock_global);
1019     return r;
1020 }
1021 
1022 static HRESULT NINE_WINAPI
LockDevice9_EndScene(struct NineDevice9 * This)1023 LockDevice9_EndScene( struct NineDevice9 *This )
1024 {
1025     HRESULT r;
1026     mtx_lock(&d3dlock_global);
1027     r = NineDevice9_EndScene(This);
1028     mtx_unlock(&d3dlock_global);
1029     return r;
1030 }
1031 
1032 static HRESULT NINE_WINAPI
LockDevice9_Clear(struct NineDevice9 * This,DWORD Count,const D3DRECT * pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil)1033 LockDevice9_Clear( struct NineDevice9 *This,
1034                    DWORD Count,
1035                    const D3DRECT *pRects,
1036                    DWORD Flags,
1037                    D3DCOLOR Color,
1038                    float Z,
1039                    DWORD Stencil )
1040 {
1041     HRESULT r;
1042     mtx_lock(&d3dlock_global);
1043     r = NineDevice9_Clear(This, Count, pRects, Flags, Color, Z, Stencil);
1044     mtx_unlock(&d3dlock_global);
1045     return r;
1046 }
1047 
1048 static HRESULT NINE_WINAPI
LockDevice9_SetTransform(struct NineDevice9 * This,D3DTRANSFORMSTATETYPE State,const D3DMATRIX * pMatrix)1049 LockDevice9_SetTransform( struct NineDevice9 *This,
1050                           D3DTRANSFORMSTATETYPE State,
1051                           const D3DMATRIX *pMatrix )
1052 {
1053     HRESULT r;
1054     mtx_lock(&d3dlock_global);
1055     r = NineDevice9_SetTransform(This, State, pMatrix);
1056     mtx_unlock(&d3dlock_global);
1057     return r;
1058 }
1059 
1060 static HRESULT NINE_WINAPI
LockDevice9_GetTransform(struct NineDevice9 * This,D3DTRANSFORMSTATETYPE State,D3DMATRIX * pMatrix)1061 LockDevice9_GetTransform( struct NineDevice9 *This,
1062                           D3DTRANSFORMSTATETYPE State,
1063                           D3DMATRIX *pMatrix )
1064 {
1065     HRESULT r;
1066     mtx_lock(&d3dlock_global);
1067     r = NineDevice9_GetTransform(This, State, pMatrix);
1068     mtx_unlock(&d3dlock_global);
1069     return r;
1070 }
1071 
1072 static HRESULT NINE_WINAPI
LockDevice9_MultiplyTransform(struct NineDevice9 * This,D3DTRANSFORMSTATETYPE State,const D3DMATRIX * pMatrix)1073 LockDevice9_MultiplyTransform( struct NineDevice9 *This,
1074                                D3DTRANSFORMSTATETYPE State,
1075                                const D3DMATRIX *pMatrix )
1076 {
1077     HRESULT r;
1078     mtx_lock(&d3dlock_global);
1079     r = NineDevice9_MultiplyTransform(This, State, pMatrix);
1080     mtx_unlock(&d3dlock_global);
1081     return r;
1082 }
1083 
1084 static HRESULT NINE_WINAPI
LockDevice9_SetViewport(struct NineDevice9 * This,const D3DVIEWPORT9 * pViewport)1085 LockDevice9_SetViewport( struct NineDevice9 *This,
1086                          const D3DVIEWPORT9 *pViewport )
1087 {
1088     HRESULT r;
1089     mtx_lock(&d3dlock_global);
1090     r = NineDevice9_SetViewport(This, pViewport);
1091     mtx_unlock(&d3dlock_global);
1092     return r;
1093 }
1094 
1095 static HRESULT NINE_WINAPI
LockDevice9_GetViewport(struct NineDevice9 * This,D3DVIEWPORT9 * pViewport)1096 LockDevice9_GetViewport( struct NineDevice9 *This,
1097                          D3DVIEWPORT9 *pViewport )
1098 {
1099     HRESULT r;
1100     mtx_lock(&d3dlock_global);
1101     r = NineDevice9_GetViewport(This, pViewport);
1102     mtx_unlock(&d3dlock_global);
1103     return r;
1104 }
1105 
1106 static HRESULT NINE_WINAPI
LockDevice9_SetMaterial(struct NineDevice9 * This,const D3DMATERIAL9 * pMaterial)1107 LockDevice9_SetMaterial( struct NineDevice9 *This,
1108                          const D3DMATERIAL9 *pMaterial )
1109 {
1110     HRESULT r;
1111     mtx_lock(&d3dlock_global);
1112     r = NineDevice9_SetMaterial(This, pMaterial);
1113     mtx_unlock(&d3dlock_global);
1114     return r;
1115 }
1116 
1117 static HRESULT NINE_WINAPI
LockDevice9_GetMaterial(struct NineDevice9 * This,D3DMATERIAL9 * pMaterial)1118 LockDevice9_GetMaterial( struct NineDevice9 *This,
1119                          D3DMATERIAL9 *pMaterial )
1120 {
1121     HRESULT r;
1122     mtx_lock(&d3dlock_global);
1123     r = NineDevice9_GetMaterial(This, pMaterial);
1124     mtx_unlock(&d3dlock_global);
1125     return r;
1126 }
1127 
1128 static HRESULT NINE_WINAPI
LockDevice9_SetLight(struct NineDevice9 * This,DWORD Index,const D3DLIGHT9 * pLight)1129 LockDevice9_SetLight( struct NineDevice9 *This,
1130                       DWORD Index,
1131                       const D3DLIGHT9 *pLight )
1132 {
1133     HRESULT r;
1134     mtx_lock(&d3dlock_global);
1135     r = NineDevice9_SetLight(This, Index, pLight);
1136     mtx_unlock(&d3dlock_global);
1137     return r;
1138 }
1139 
1140 static HRESULT NINE_WINAPI
LockDevice9_GetLight(struct NineDevice9 * This,DWORD Index,D3DLIGHT9 * pLight)1141 LockDevice9_GetLight( struct NineDevice9 *This,
1142                       DWORD Index,
1143                       D3DLIGHT9 *pLight )
1144 {
1145     HRESULT r;
1146     mtx_lock(&d3dlock_global);
1147     r = NineDevice9_GetLight(This, Index, pLight);
1148     mtx_unlock(&d3dlock_global);
1149     return r;
1150 }
1151 
1152 static HRESULT NINE_WINAPI
LockDevice9_LightEnable(struct NineDevice9 * This,DWORD Index,BOOL Enable)1153 LockDevice9_LightEnable( struct NineDevice9 *This,
1154                          DWORD Index,
1155                          BOOL Enable )
1156 {
1157     HRESULT r;
1158     mtx_lock(&d3dlock_global);
1159     r = NineDevice9_LightEnable(This, Index, Enable);
1160     mtx_unlock(&d3dlock_global);
1161     return r;
1162 }
1163 
1164 static HRESULT NINE_WINAPI
LockDevice9_GetLightEnable(struct NineDevice9 * This,DWORD Index,BOOL * pEnable)1165 LockDevice9_GetLightEnable( struct NineDevice9 *This,
1166                             DWORD Index,
1167                             BOOL *pEnable )
1168 {
1169     HRESULT r;
1170     mtx_lock(&d3dlock_global);
1171     r = NineDevice9_GetLightEnable(This, Index, pEnable);
1172     mtx_unlock(&d3dlock_global);
1173     return r;
1174 }
1175 
1176 static HRESULT NINE_WINAPI
LockDevice9_SetClipPlane(struct NineDevice9 * This,DWORD Index,const float * pPlane)1177 LockDevice9_SetClipPlane( struct NineDevice9 *This,
1178                           DWORD Index,
1179                           const float *pPlane )
1180 {
1181     HRESULT r;
1182     mtx_lock(&d3dlock_global);
1183     r = NineDevice9_SetClipPlane(This, Index, pPlane);
1184     mtx_unlock(&d3dlock_global);
1185     return r;
1186 }
1187 
1188 static HRESULT NINE_WINAPI
LockDevice9_GetClipPlane(struct NineDevice9 * This,DWORD Index,float * pPlane)1189 LockDevice9_GetClipPlane( struct NineDevice9 *This,
1190                           DWORD Index,
1191                           float *pPlane )
1192 {
1193     HRESULT r;
1194     mtx_lock(&d3dlock_global);
1195     r = NineDevice9_GetClipPlane(This, Index, pPlane);
1196     mtx_unlock(&d3dlock_global);
1197     return r;
1198 }
1199 
1200 static HRESULT NINE_WINAPI
LockDevice9_SetRenderState(struct NineDevice9 * This,D3DRENDERSTATETYPE State,DWORD Value)1201 LockDevice9_SetRenderState( struct NineDevice9 *This,
1202                             D3DRENDERSTATETYPE State,
1203                             DWORD Value )
1204 {
1205     HRESULT r;
1206     mtx_lock(&d3dlock_global);
1207     r = NineDevice9_SetRenderState(This, State, Value);
1208     mtx_unlock(&d3dlock_global);
1209     return r;
1210 }
1211 
1212 static HRESULT NINE_WINAPI
LockDevice9_GetRenderState(struct NineDevice9 * This,D3DRENDERSTATETYPE State,DWORD * pValue)1213 LockDevice9_GetRenderState( struct NineDevice9 *This,
1214                             D3DRENDERSTATETYPE State,
1215                             DWORD *pValue )
1216 {
1217     HRESULT r;
1218     mtx_lock(&d3dlock_global);
1219     r = NineDevice9_GetRenderState(This, State, pValue);
1220     mtx_unlock(&d3dlock_global);
1221     return r;
1222 }
1223 
1224 static HRESULT NINE_WINAPI
LockDevice9_CreateStateBlock(struct NineDevice9 * This,D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9 ** ppSB)1225 LockDevice9_CreateStateBlock( struct NineDevice9 *This,
1226                               D3DSTATEBLOCKTYPE Type,
1227                               IDirect3DStateBlock9 **ppSB )
1228 {
1229     HRESULT r;
1230     mtx_lock(&d3dlock_global);
1231     r = NineDevice9_CreateStateBlock(This, Type, ppSB);
1232     mtx_unlock(&d3dlock_global);
1233     return r;
1234 }
1235 
1236 static HRESULT NINE_WINAPI
LockDevice9_BeginStateBlock(struct NineDevice9 * This)1237 LockDevice9_BeginStateBlock( struct NineDevice9 *This )
1238 {
1239     HRESULT r;
1240     mtx_lock(&d3dlock_global);
1241     r = NineDevice9_BeginStateBlock(This);
1242     mtx_unlock(&d3dlock_global);
1243     return r;
1244 }
1245 
1246 static HRESULT NINE_WINAPI
LockDevice9_EndStateBlock(struct NineDevice9 * This,IDirect3DStateBlock9 ** ppSB)1247 LockDevice9_EndStateBlock( struct NineDevice9 *This,
1248                            IDirect3DStateBlock9 **ppSB )
1249 {
1250     HRESULT r;
1251     mtx_lock(&d3dlock_global);
1252     r = NineDevice9_EndStateBlock(This, ppSB);
1253     mtx_unlock(&d3dlock_global);
1254     return r;
1255 }
1256 
1257 static HRESULT NINE_WINAPI
LockDevice9_SetClipStatus(struct NineDevice9 * This,const D3DCLIPSTATUS9 * pClipStatus)1258 LockDevice9_SetClipStatus( struct NineDevice9 *This,
1259                            const D3DCLIPSTATUS9 *pClipStatus )
1260 {
1261     HRESULT r;
1262     mtx_lock(&d3dlock_global);
1263     r = NineDevice9_SetClipStatus(This, pClipStatus);
1264     mtx_unlock(&d3dlock_global);
1265     return r;
1266 }
1267 
1268 static HRESULT NINE_WINAPI
LockDevice9_GetClipStatus(struct NineDevice9 * This,D3DCLIPSTATUS9 * pClipStatus)1269 LockDevice9_GetClipStatus( struct NineDevice9 *This,
1270                            D3DCLIPSTATUS9 *pClipStatus )
1271 {
1272     HRESULT r;
1273     mtx_lock(&d3dlock_global);
1274     r = NineDevice9_GetClipStatus(This, pClipStatus);
1275     mtx_unlock(&d3dlock_global);
1276     return r;
1277 }
1278 
1279 static HRESULT NINE_WINAPI
LockDevice9_GetTexture(struct NineDevice9 * This,DWORD Stage,IDirect3DBaseTexture9 ** ppTexture)1280 LockDevice9_GetTexture( struct NineDevice9 *This,
1281                         DWORD Stage,
1282                         IDirect3DBaseTexture9 **ppTexture )
1283 {
1284     HRESULT r;
1285     mtx_lock(&d3dlock_global);
1286     r = NineDevice9_GetTexture(This, Stage, ppTexture);
1287     mtx_unlock(&d3dlock_global);
1288     return r;
1289 }
1290 
1291 static HRESULT NINE_WINAPI
LockDevice9_SetTexture(struct NineDevice9 * This,DWORD Stage,IDirect3DBaseTexture9 * pTexture)1292 LockDevice9_SetTexture( struct NineDevice9 *This,
1293                         DWORD Stage,
1294                         IDirect3DBaseTexture9 *pTexture )
1295 {
1296     HRESULT r;
1297     mtx_lock(&d3dlock_global);
1298     r = NineDevice9_SetTexture(This, Stage, pTexture);
1299     mtx_unlock(&d3dlock_global);
1300     return r;
1301 }
1302 
1303 static HRESULT NINE_WINAPI
LockDevice9_GetTextureStageState(struct NineDevice9 * This,DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD * pValue)1304 LockDevice9_GetTextureStageState( struct NineDevice9 *This,
1305                                   DWORD Stage,
1306                                   D3DTEXTURESTAGESTATETYPE Type,
1307                                   DWORD *pValue )
1308 {
1309     HRESULT r;
1310     mtx_lock(&d3dlock_global);
1311     r = NineDevice9_GetTextureStageState(This, Stage, Type, pValue);
1312     mtx_unlock(&d3dlock_global);
1313     return r;
1314 }
1315 
1316 static HRESULT NINE_WINAPI
LockDevice9_SetTextureStageState(struct NineDevice9 * This,DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value)1317 LockDevice9_SetTextureStageState( struct NineDevice9 *This,
1318                                   DWORD Stage,
1319                                   D3DTEXTURESTAGESTATETYPE Type,
1320                                   DWORD Value )
1321 {
1322     HRESULT r;
1323     mtx_lock(&d3dlock_global);
1324     r = NineDevice9_SetTextureStageState(This, Stage, Type, Value);
1325     mtx_unlock(&d3dlock_global);
1326     return r;
1327 }
1328 
1329 static HRESULT NINE_WINAPI
LockDevice9_GetSamplerState(struct NineDevice9 * This,DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD * pValue)1330 LockDevice9_GetSamplerState( struct NineDevice9 *This,
1331                              DWORD Sampler,
1332                              D3DSAMPLERSTATETYPE Type,
1333                              DWORD *pValue )
1334 {
1335     HRESULT r;
1336     mtx_lock(&d3dlock_global);
1337     r = NineDevice9_GetSamplerState(This, Sampler, Type, pValue);
1338     mtx_unlock(&d3dlock_global);
1339     return r;
1340 }
1341 
1342 static HRESULT NINE_WINAPI
LockDevice9_SetSamplerState(struct NineDevice9 * This,DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value)1343 LockDevice9_SetSamplerState( struct NineDevice9 *This,
1344                              DWORD Sampler,
1345                              D3DSAMPLERSTATETYPE Type,
1346                              DWORD Value )
1347 {
1348     HRESULT r;
1349     mtx_lock(&d3dlock_global);
1350     r = NineDevice9_SetSamplerState(This, Sampler, Type, Value);
1351     mtx_unlock(&d3dlock_global);
1352     return r;
1353 }
1354 
1355 static HRESULT NINE_WINAPI
LockDevice9_ValidateDevice(struct NineDevice9 * This,DWORD * pNumPasses)1356 LockDevice9_ValidateDevice( struct NineDevice9 *This,
1357                             DWORD *pNumPasses )
1358 {
1359     HRESULT r;
1360     mtx_lock(&d3dlock_global);
1361     r = NineDevice9_ValidateDevice(This, pNumPasses);
1362     mtx_unlock(&d3dlock_global);
1363     return r;
1364 }
1365 
1366 static HRESULT NINE_WINAPI
LockDevice9_SetPaletteEntries(struct NineDevice9 * This,UINT PaletteNumber,const PALETTEENTRY * pEntries)1367 LockDevice9_SetPaletteEntries( struct NineDevice9 *This,
1368                                UINT PaletteNumber,
1369                                const PALETTEENTRY *pEntries )
1370 {
1371     HRESULT r;
1372     mtx_lock(&d3dlock_global);
1373     r = NineDevice9_SetPaletteEntries(This, PaletteNumber, pEntries);
1374     mtx_unlock(&d3dlock_global);
1375     return r;
1376 }
1377 
1378 static HRESULT NINE_WINAPI
LockDevice9_GetPaletteEntries(struct NineDevice9 * This,UINT PaletteNumber,PALETTEENTRY * pEntries)1379 LockDevice9_GetPaletteEntries( struct NineDevice9 *This,
1380                                UINT PaletteNumber,
1381                                PALETTEENTRY *pEntries )
1382 {
1383     HRESULT r;
1384     mtx_lock(&d3dlock_global);
1385     r = NineDevice9_GetPaletteEntries(This, PaletteNumber, pEntries);
1386     mtx_unlock(&d3dlock_global);
1387     return r;
1388 }
1389 
1390 static HRESULT NINE_WINAPI
LockDevice9_SetCurrentTexturePalette(struct NineDevice9 * This,UINT PaletteNumber)1391 LockDevice9_SetCurrentTexturePalette( struct NineDevice9 *This,
1392                                       UINT PaletteNumber )
1393 {
1394     HRESULT r;
1395     mtx_lock(&d3dlock_global);
1396     r = NineDevice9_SetCurrentTexturePalette(This, PaletteNumber);
1397     mtx_unlock(&d3dlock_global);
1398     return r;
1399 }
1400 
1401 static HRESULT NINE_WINAPI
LockDevice9_GetCurrentTexturePalette(struct NineDevice9 * This,UINT * PaletteNumber)1402 LockDevice9_GetCurrentTexturePalette( struct NineDevice9 *This,
1403                                       UINT *PaletteNumber )
1404 {
1405     HRESULT r;
1406     mtx_lock(&d3dlock_global);
1407     r = NineDevice9_GetCurrentTexturePalette(This, PaletteNumber);
1408     mtx_unlock(&d3dlock_global);
1409     return r;
1410 }
1411 
1412 static HRESULT NINE_WINAPI
LockDevice9_SetScissorRect(struct NineDevice9 * This,const RECT * pRect)1413 LockDevice9_SetScissorRect( struct NineDevice9 *This,
1414                             const RECT *pRect )
1415 {
1416     HRESULT r;
1417     mtx_lock(&d3dlock_global);
1418     r = NineDevice9_SetScissorRect(This, pRect);
1419     mtx_unlock(&d3dlock_global);
1420     return r;
1421 }
1422 
1423 static HRESULT NINE_WINAPI
LockDevice9_GetScissorRect(struct NineDevice9 * This,RECT * pRect)1424 LockDevice9_GetScissorRect( struct NineDevice9 *This,
1425                             RECT *pRect )
1426 {
1427     HRESULT r;
1428     mtx_lock(&d3dlock_global);
1429     r = NineDevice9_GetScissorRect(This, pRect);
1430     mtx_unlock(&d3dlock_global);
1431     return r;
1432 }
1433 
1434 static HRESULT NINE_WINAPI
LockDevice9_SetSoftwareVertexProcessing(struct NineDevice9 * This,BOOL bSoftware)1435 LockDevice9_SetSoftwareVertexProcessing( struct NineDevice9 *This,
1436                                          BOOL bSoftware )
1437 {
1438     HRESULT r;
1439     mtx_lock(&d3dlock_global);
1440     r = NineDevice9_SetSoftwareVertexProcessing(This, bSoftware);
1441     mtx_unlock(&d3dlock_global);
1442     return r;
1443 }
1444 
1445 static BOOL NINE_WINAPI
LockDevice9_GetSoftwareVertexProcessing(struct NineDevice9 * This)1446 LockDevice9_GetSoftwareVertexProcessing( struct NineDevice9 *This )
1447 {
1448     BOOL r;
1449     mtx_lock(&d3dlock_global);
1450     r = NineDevice9_GetSoftwareVertexProcessing(This);
1451     mtx_unlock(&d3dlock_global);
1452     return r;
1453 }
1454 
1455 static HRESULT NINE_WINAPI
LockDevice9_SetNPatchMode(struct NineDevice9 * This,float nSegments)1456 LockDevice9_SetNPatchMode( struct NineDevice9 *This,
1457                            float nSegments )
1458 {
1459     HRESULT r;
1460     mtx_lock(&d3dlock_global);
1461     r = NineDevice9_SetNPatchMode(This, nSegments);
1462     mtx_unlock(&d3dlock_global);
1463     return r;
1464 }
1465 
1466 static float NINE_WINAPI
LockDevice9_GetNPatchMode(struct NineDevice9 * This)1467 LockDevice9_GetNPatchMode( struct NineDevice9 *This )
1468 {
1469     float r;
1470     mtx_lock(&d3dlock_global);
1471     r = NineDevice9_GetNPatchMode(This);
1472     mtx_unlock(&d3dlock_global);
1473     return r;
1474 }
1475 
1476 static HRESULT NINE_WINAPI
LockDevice9_DrawPrimitive(struct NineDevice9 * This,D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount)1477 LockDevice9_DrawPrimitive( struct NineDevice9 *This,
1478                            D3DPRIMITIVETYPE PrimitiveType,
1479                            UINT StartVertex,
1480                            UINT PrimitiveCount )
1481 {
1482     HRESULT r;
1483     mtx_lock(&d3dlock_global);
1484     r = NineDevice9_DrawPrimitive(This, PrimitiveType, StartVertex, PrimitiveCount);
1485     mtx_unlock(&d3dlock_global);
1486     return r;
1487 }
1488 
1489 static HRESULT NINE_WINAPI
LockDevice9_DrawIndexedPrimitive(struct NineDevice9 * This,D3DPRIMITIVETYPE PrimitiveType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)1490 LockDevice9_DrawIndexedPrimitive( struct NineDevice9 *This,
1491                                   D3DPRIMITIVETYPE PrimitiveType,
1492                                   INT BaseVertexIndex,
1493                                   UINT MinVertexIndex,
1494                                   UINT NumVertices,
1495                                   UINT startIndex,
1496                                   UINT primCount )
1497 {
1498     HRESULT r;
1499     mtx_lock(&d3dlock_global);
1500     r = NineDevice9_DrawIndexedPrimitive(This, PrimitiveType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
1501     mtx_unlock(&d3dlock_global);
1502     return r;
1503 }
1504 
1505 static HRESULT NINE_WINAPI
LockDevice9_DrawPrimitiveUP(struct NineDevice9 * This,D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,const void * pVertexStreamZeroData,UINT VertexStreamZeroStride)1506 LockDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
1507                              D3DPRIMITIVETYPE PrimitiveType,
1508                              UINT PrimitiveCount,
1509                              const void *pVertexStreamZeroData,
1510                              UINT VertexStreamZeroStride )
1511 {
1512     HRESULT r;
1513     mtx_lock(&d3dlock_global);
1514     r = NineDevice9_DrawPrimitiveUP(This, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
1515     mtx_unlock(&d3dlock_global);
1516     return r;
1517 }
1518 
1519 static HRESULT NINE_WINAPI
LockDevice9_DrawIndexedPrimitiveUP(struct NineDevice9 * This,D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,const void * pIndexData,D3DFORMAT IndexDataFormat,const void * pVertexStreamZeroData,UINT VertexStreamZeroStride)1520 LockDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
1521                                     D3DPRIMITIVETYPE PrimitiveType,
1522                                     UINT MinVertexIndex,
1523                                     UINT NumVertices,
1524                                     UINT PrimitiveCount,
1525                                     const void *pIndexData,
1526                                     D3DFORMAT IndexDataFormat,
1527                                     const void *pVertexStreamZeroData,
1528                                     UINT VertexStreamZeroStride )
1529 {
1530     HRESULT r;
1531     mtx_lock(&d3dlock_global);
1532     r = NineDevice9_DrawIndexedPrimitiveUP(This, PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
1533     mtx_unlock(&d3dlock_global);
1534     return r;
1535 }
1536 
1537 static HRESULT NINE_WINAPI
LockDevice9_ProcessVertices(struct NineDevice9 * This,UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9 * pDestBuffer,IDirect3DVertexDeclaration9 * pVertexDecl,DWORD Flags)1538 LockDevice9_ProcessVertices( struct NineDevice9 *This,
1539                              UINT SrcStartIndex,
1540                              UINT DestIndex,
1541                              UINT VertexCount,
1542                              IDirect3DVertexBuffer9 *pDestBuffer,
1543                              IDirect3DVertexDeclaration9 *pVertexDecl,
1544                              DWORD Flags )
1545 {
1546     HRESULT r;
1547     mtx_lock(&d3dlock_global);
1548     r = NineDevice9_ProcessVertices(This, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
1549     mtx_unlock(&d3dlock_global);
1550     return r;
1551 }
1552 
1553 static HRESULT NINE_WINAPI
LockDevice9_CreateVertexDeclaration(struct NineDevice9 * This,const D3DVERTEXELEMENT9 * pVertexElements,IDirect3DVertexDeclaration9 ** ppDecl)1554 LockDevice9_CreateVertexDeclaration( struct NineDevice9 *This,
1555                                      const D3DVERTEXELEMENT9 *pVertexElements,
1556                                      IDirect3DVertexDeclaration9 **ppDecl )
1557 {
1558     HRESULT r;
1559     mtx_lock(&d3dlock_global);
1560     r = NineDevice9_CreateVertexDeclaration(This, pVertexElements, ppDecl);
1561     mtx_unlock(&d3dlock_global);
1562     return r;
1563 }
1564 
1565 static HRESULT NINE_WINAPI
LockDevice9_SetVertexDeclaration(struct NineDevice9 * This,IDirect3DVertexDeclaration9 * pDecl)1566 LockDevice9_SetVertexDeclaration( struct NineDevice9 *This,
1567                                   IDirect3DVertexDeclaration9 *pDecl )
1568 {
1569     HRESULT r;
1570     mtx_lock(&d3dlock_global);
1571     r = NineDevice9_SetVertexDeclaration(This, pDecl);
1572     mtx_unlock(&d3dlock_global);
1573     return r;
1574 }
1575 
1576 static HRESULT NINE_WINAPI
LockDevice9_GetVertexDeclaration(struct NineDevice9 * This,IDirect3DVertexDeclaration9 ** ppDecl)1577 LockDevice9_GetVertexDeclaration( struct NineDevice9 *This,
1578                                   IDirect3DVertexDeclaration9 **ppDecl )
1579 {
1580     HRESULT r;
1581     mtx_lock(&d3dlock_global);
1582     r = NineDevice9_GetVertexDeclaration(This, ppDecl);
1583     mtx_unlock(&d3dlock_global);
1584     return r;
1585 }
1586 
1587 static HRESULT NINE_WINAPI
LockDevice9_SetFVF(struct NineDevice9 * This,DWORD FVF)1588 LockDevice9_SetFVF( struct NineDevice9 *This,
1589                     DWORD FVF )
1590 {
1591     HRESULT r;
1592     mtx_lock(&d3dlock_global);
1593     r = NineDevice9_SetFVF(This, FVF);
1594     mtx_unlock(&d3dlock_global);
1595     return r;
1596 }
1597 
1598 static HRESULT NINE_WINAPI
LockDevice9_GetFVF(struct NineDevice9 * This,DWORD * pFVF)1599 LockDevice9_GetFVF( struct NineDevice9 *This,
1600                     DWORD *pFVF )
1601 {
1602     HRESULT r;
1603     mtx_lock(&d3dlock_global);
1604     r = NineDevice9_GetFVF(This, pFVF);
1605     mtx_unlock(&d3dlock_global);
1606     return r;
1607 }
1608 
1609 static HRESULT NINE_WINAPI
LockDevice9_CreateVertexShader(struct NineDevice9 * This,const DWORD * pFunction,IDirect3DVertexShader9 ** ppShader)1610 LockDevice9_CreateVertexShader( struct NineDevice9 *This,
1611                                 const DWORD *pFunction,
1612                                 IDirect3DVertexShader9 **ppShader )
1613 {
1614     HRESULT r;
1615     mtx_lock(&d3dlock_global);
1616     r = NineDevice9_CreateVertexShader(This, pFunction, ppShader);
1617     mtx_unlock(&d3dlock_global);
1618     return r;
1619 }
1620 
1621 static HRESULT NINE_WINAPI
LockDevice9_SetVertexShader(struct NineDevice9 * This,IDirect3DVertexShader9 * pShader)1622 LockDevice9_SetVertexShader( struct NineDevice9 *This,
1623                              IDirect3DVertexShader9 *pShader )
1624 {
1625     HRESULT r;
1626     mtx_lock(&d3dlock_global);
1627     r = NineDevice9_SetVertexShader(This, pShader);
1628     mtx_unlock(&d3dlock_global);
1629     return r;
1630 }
1631 
1632 static HRESULT NINE_WINAPI
LockDevice9_GetVertexShader(struct NineDevice9 * This,IDirect3DVertexShader9 ** ppShader)1633 LockDevice9_GetVertexShader( struct NineDevice9 *This,
1634                              IDirect3DVertexShader9 **ppShader )
1635 {
1636     HRESULT r;
1637     mtx_lock(&d3dlock_global);
1638     r = NineDevice9_GetVertexShader(This, ppShader);
1639     mtx_unlock(&d3dlock_global);
1640     return r;
1641 }
1642 
1643 static HRESULT NINE_WINAPI
LockDevice9_SetVertexShaderConstantF(struct NineDevice9 * This,UINT StartRegister,const float * pConstantData,UINT Vector4fCount)1644 LockDevice9_SetVertexShaderConstantF( struct NineDevice9 *This,
1645                                       UINT StartRegister,
1646                                       const float *pConstantData,
1647                                       UINT Vector4fCount )
1648 {
1649     HRESULT r;
1650     mtx_lock(&d3dlock_global);
1651     r = NineDevice9_SetVertexShaderConstantF(This, StartRegister, pConstantData, Vector4fCount);
1652     mtx_unlock(&d3dlock_global);
1653     return r;
1654 }
1655 
1656 static HRESULT NINE_WINAPI
LockDevice9_GetVertexShaderConstantF(struct NineDevice9 * This,UINT StartRegister,float * pConstantData,UINT Vector4fCount)1657 LockDevice9_GetVertexShaderConstantF( struct NineDevice9 *This,
1658                                       UINT StartRegister,
1659                                       float *pConstantData,
1660                                       UINT Vector4fCount )
1661 {
1662     HRESULT r;
1663     mtx_lock(&d3dlock_global);
1664     r = NineDevice9_GetVertexShaderConstantF(This, StartRegister, pConstantData, Vector4fCount);
1665     mtx_unlock(&d3dlock_global);
1666     return r;
1667 }
1668 
1669 static HRESULT NINE_WINAPI
LockDevice9_SetVertexShaderConstantI(struct NineDevice9 * This,UINT StartRegister,const int * pConstantData,UINT Vector4iCount)1670 LockDevice9_SetVertexShaderConstantI( struct NineDevice9 *This,
1671                                       UINT StartRegister,
1672                                       const int *pConstantData,
1673                                       UINT Vector4iCount )
1674 {
1675     HRESULT r;
1676     mtx_lock(&d3dlock_global);
1677     r = NineDevice9_SetVertexShaderConstantI(This, StartRegister, pConstantData, Vector4iCount);
1678     mtx_unlock(&d3dlock_global);
1679     return r;
1680 }
1681 
1682 static HRESULT NINE_WINAPI
LockDevice9_GetVertexShaderConstantI(struct NineDevice9 * This,UINT StartRegister,int * pConstantData,UINT Vector4iCount)1683 LockDevice9_GetVertexShaderConstantI( struct NineDevice9 *This,
1684                                       UINT StartRegister,
1685                                       int *pConstantData,
1686                                       UINT Vector4iCount )
1687 {
1688     HRESULT r;
1689     mtx_lock(&d3dlock_global);
1690     r = NineDevice9_GetVertexShaderConstantI(This, StartRegister, pConstantData, Vector4iCount);
1691     mtx_unlock(&d3dlock_global);
1692     return r;
1693 }
1694 
1695 static HRESULT NINE_WINAPI
LockDevice9_SetVertexShaderConstantB(struct NineDevice9 * This,UINT StartRegister,const BOOL * pConstantData,UINT BoolCount)1696 LockDevice9_SetVertexShaderConstantB( struct NineDevice9 *This,
1697                                       UINT StartRegister,
1698                                       const BOOL *pConstantData,
1699                                       UINT BoolCount )
1700 {
1701     HRESULT r;
1702     mtx_lock(&d3dlock_global);
1703     r = NineDevice9_SetVertexShaderConstantB(This, StartRegister, pConstantData, BoolCount);
1704     mtx_unlock(&d3dlock_global);
1705     return r;
1706 }
1707 
1708 static HRESULT NINE_WINAPI
LockDevice9_GetVertexShaderConstantB(struct NineDevice9 * This,UINT StartRegister,BOOL * pConstantData,UINT BoolCount)1709 LockDevice9_GetVertexShaderConstantB( struct NineDevice9 *This,
1710                                       UINT StartRegister,
1711                                       BOOL *pConstantData,
1712                                       UINT BoolCount )
1713 {
1714     HRESULT r;
1715     mtx_lock(&d3dlock_global);
1716     r = NineDevice9_GetVertexShaderConstantB(This, StartRegister, pConstantData, BoolCount);
1717     mtx_unlock(&d3dlock_global);
1718     return r;
1719 }
1720 
1721 static HRESULT NINE_WINAPI
LockDevice9_SetStreamSource(struct NineDevice9 * This,UINT StreamNumber,IDirect3DVertexBuffer9 * pStreamData,UINT OffsetInBytes,UINT Stride)1722 LockDevice9_SetStreamSource( struct NineDevice9 *This,
1723                              UINT StreamNumber,
1724                              IDirect3DVertexBuffer9 *pStreamData,
1725                              UINT OffsetInBytes,
1726                              UINT Stride )
1727 {
1728     HRESULT r;
1729     mtx_lock(&d3dlock_global);
1730     r = NineDevice9_SetStreamSource(This, StreamNumber, pStreamData, OffsetInBytes, Stride);
1731     mtx_unlock(&d3dlock_global);
1732     return r;
1733 }
1734 
1735 static HRESULT NINE_WINAPI
LockDevice9_GetStreamSource(struct NineDevice9 * This,UINT StreamNumber,IDirect3DVertexBuffer9 ** ppStreamData,UINT * pOffsetInBytes,UINT * pStride)1736 LockDevice9_GetStreamSource( struct NineDevice9 *This,
1737                              UINT StreamNumber,
1738                              IDirect3DVertexBuffer9 **ppStreamData,
1739                              UINT *pOffsetInBytes,
1740                              UINT *pStride )
1741 {
1742     HRESULT r;
1743     mtx_lock(&d3dlock_global);
1744     r = NineDevice9_GetStreamSource(This, StreamNumber, ppStreamData, pOffsetInBytes, pStride);
1745     mtx_unlock(&d3dlock_global);
1746     return r;
1747 }
1748 
1749 static HRESULT NINE_WINAPI
LockDevice9_SetStreamSourceFreq(struct NineDevice9 * This,UINT StreamNumber,UINT Setting)1750 LockDevice9_SetStreamSourceFreq( struct NineDevice9 *This,
1751                                  UINT StreamNumber,
1752                                  UINT Setting )
1753 {
1754     HRESULT r;
1755     mtx_lock(&d3dlock_global);
1756     r = NineDevice9_SetStreamSourceFreq(This, StreamNumber, Setting);
1757     mtx_unlock(&d3dlock_global);
1758     return r;
1759 }
1760 
1761 static HRESULT NINE_WINAPI
LockDevice9_GetStreamSourceFreq(struct NineDevice9 * This,UINT StreamNumber,UINT * pSetting)1762 LockDevice9_GetStreamSourceFreq( struct NineDevice9 *This,
1763                                  UINT StreamNumber,
1764                                  UINT *pSetting )
1765 {
1766     HRESULT r;
1767     mtx_lock(&d3dlock_global);
1768     r = NineDevice9_GetStreamSourceFreq(This, StreamNumber, pSetting);
1769     mtx_unlock(&d3dlock_global);
1770     return r;
1771 }
1772 
1773 static HRESULT NINE_WINAPI
LockDevice9_SetIndices(struct NineDevice9 * This,IDirect3DIndexBuffer9 * pIndexData)1774 LockDevice9_SetIndices( struct NineDevice9 *This,
1775                         IDirect3DIndexBuffer9 *pIndexData )
1776 {
1777     HRESULT r;
1778     mtx_lock(&d3dlock_global);
1779     r = NineDevice9_SetIndices(This, pIndexData);
1780     mtx_unlock(&d3dlock_global);
1781     return r;
1782 }
1783 
1784 static HRESULT NINE_WINAPI
LockDevice9_GetIndices(struct NineDevice9 * This,IDirect3DIndexBuffer9 ** ppIndexData)1785 LockDevice9_GetIndices( struct NineDevice9 *This,
1786                         IDirect3DIndexBuffer9 **ppIndexData )
1787 {
1788     HRESULT r;
1789     mtx_lock(&d3dlock_global);
1790     r = NineDevice9_GetIndices(This, ppIndexData);
1791     mtx_unlock(&d3dlock_global);
1792     return r;
1793 }
1794 
1795 static HRESULT NINE_WINAPI
LockDevice9_CreatePixelShader(struct NineDevice9 * This,const DWORD * pFunction,IDirect3DPixelShader9 ** ppShader)1796 LockDevice9_CreatePixelShader( struct NineDevice9 *This,
1797                                const DWORD *pFunction,
1798                                IDirect3DPixelShader9 **ppShader )
1799 {
1800     HRESULT r;
1801     mtx_lock(&d3dlock_global);
1802     r = NineDevice9_CreatePixelShader(This, pFunction, ppShader);
1803     mtx_unlock(&d3dlock_global);
1804     return r;
1805 }
1806 
1807 static HRESULT NINE_WINAPI
LockDevice9_SetPixelShader(struct NineDevice9 * This,IDirect3DPixelShader9 * pShader)1808 LockDevice9_SetPixelShader( struct NineDevice9 *This,
1809                             IDirect3DPixelShader9 *pShader )
1810 {
1811     HRESULT r;
1812     mtx_lock(&d3dlock_global);
1813     r = NineDevice9_SetPixelShader(This, pShader);
1814     mtx_unlock(&d3dlock_global);
1815     return r;
1816 }
1817 
1818 static HRESULT NINE_WINAPI
LockDevice9_GetPixelShader(struct NineDevice9 * This,IDirect3DPixelShader9 ** ppShader)1819 LockDevice9_GetPixelShader( struct NineDevice9 *This,
1820                             IDirect3DPixelShader9 **ppShader )
1821 {
1822     HRESULT r;
1823     mtx_lock(&d3dlock_global);
1824     r = NineDevice9_GetPixelShader(This, ppShader);
1825     mtx_unlock(&d3dlock_global);
1826     return r;
1827 }
1828 
1829 static HRESULT NINE_WINAPI
LockDevice9_SetPixelShaderConstantF(struct NineDevice9 * This,UINT StartRegister,const float * pConstantData,UINT Vector4fCount)1830 LockDevice9_SetPixelShaderConstantF( struct NineDevice9 *This,
1831                                      UINT StartRegister,
1832                                      const float *pConstantData,
1833                                      UINT Vector4fCount )
1834 {
1835     HRESULT r;
1836     mtx_lock(&d3dlock_global);
1837     r = NineDevice9_SetPixelShaderConstantF(This, StartRegister, pConstantData, Vector4fCount);
1838     mtx_unlock(&d3dlock_global);
1839     return r;
1840 }
1841 
1842 static HRESULT NINE_WINAPI
LockDevice9_GetPixelShaderConstantF(struct NineDevice9 * This,UINT StartRegister,float * pConstantData,UINT Vector4fCount)1843 LockDevice9_GetPixelShaderConstantF( struct NineDevice9 *This,
1844                                      UINT StartRegister,
1845                                      float *pConstantData,
1846                                      UINT Vector4fCount )
1847 {
1848     HRESULT r;
1849     mtx_lock(&d3dlock_global);
1850     r = NineDevice9_GetPixelShaderConstantF(This, StartRegister, pConstantData, Vector4fCount);
1851     mtx_unlock(&d3dlock_global);
1852     return r;
1853 }
1854 
1855 static HRESULT NINE_WINAPI
LockDevice9_SetPixelShaderConstantI(struct NineDevice9 * This,UINT StartRegister,const int * pConstantData,UINT Vector4iCount)1856 LockDevice9_SetPixelShaderConstantI( struct NineDevice9 *This,
1857                                      UINT StartRegister,
1858                                      const int *pConstantData,
1859                                      UINT Vector4iCount )
1860 {
1861     HRESULT r;
1862     mtx_lock(&d3dlock_global);
1863     r = NineDevice9_SetPixelShaderConstantI(This, StartRegister, pConstantData, Vector4iCount);
1864     mtx_unlock(&d3dlock_global);
1865     return r;
1866 }
1867 
1868 static HRESULT NINE_WINAPI
LockDevice9_GetPixelShaderConstantI(struct NineDevice9 * This,UINT StartRegister,int * pConstantData,UINT Vector4iCount)1869 LockDevice9_GetPixelShaderConstantI( struct NineDevice9 *This,
1870                                      UINT StartRegister,
1871                                      int *pConstantData,
1872                                      UINT Vector4iCount )
1873 {
1874     HRESULT r;
1875     mtx_lock(&d3dlock_global);
1876     r = NineDevice9_GetPixelShaderConstantI(This, StartRegister, pConstantData, Vector4iCount);
1877     mtx_unlock(&d3dlock_global);
1878     return r;
1879 }
1880 
1881 static HRESULT NINE_WINAPI
LockDevice9_SetPixelShaderConstantB(struct NineDevice9 * This,UINT StartRegister,const BOOL * pConstantData,UINT BoolCount)1882 LockDevice9_SetPixelShaderConstantB( struct NineDevice9 *This,
1883                                      UINT StartRegister,
1884                                      const BOOL *pConstantData,
1885                                      UINT BoolCount )
1886 {
1887     HRESULT r;
1888     mtx_lock(&d3dlock_global);
1889     r = NineDevice9_SetPixelShaderConstantB(This, StartRegister, pConstantData, BoolCount);
1890     mtx_unlock(&d3dlock_global);
1891     return r;
1892 }
1893 
1894 static HRESULT NINE_WINAPI
LockDevice9_GetPixelShaderConstantB(struct NineDevice9 * This,UINT StartRegister,BOOL * pConstantData,UINT BoolCount)1895 LockDevice9_GetPixelShaderConstantB( struct NineDevice9 *This,
1896                                      UINT StartRegister,
1897                                      BOOL *pConstantData,
1898                                      UINT BoolCount )
1899 {
1900     HRESULT r;
1901     mtx_lock(&d3dlock_global);
1902     r = NineDevice9_GetPixelShaderConstantB(This, StartRegister, pConstantData, BoolCount);
1903     mtx_unlock(&d3dlock_global);
1904     return r;
1905 }
1906 
1907 static HRESULT NINE_WINAPI
LockDevice9_DrawRectPatch(struct NineDevice9 * This,UINT Handle,const float * pNumSegs,const D3DRECTPATCH_INFO * pRectPatchInfo)1908 LockDevice9_DrawRectPatch( struct NineDevice9 *This,
1909                            UINT Handle,
1910                            const float *pNumSegs,
1911                            const D3DRECTPATCH_INFO *pRectPatchInfo )
1912 {
1913     HRESULT r;
1914     mtx_lock(&d3dlock_global);
1915     r = NineDevice9_DrawRectPatch(This, Handle, pNumSegs, pRectPatchInfo);
1916     mtx_unlock(&d3dlock_global);
1917     return r;
1918 }
1919 
1920 static HRESULT NINE_WINAPI
LockDevice9_DrawTriPatch(struct NineDevice9 * This,UINT Handle,const float * pNumSegs,const D3DTRIPATCH_INFO * pTriPatchInfo)1921 LockDevice9_DrawTriPatch( struct NineDevice9 *This,
1922                           UINT Handle,
1923                           const float *pNumSegs,
1924                           const D3DTRIPATCH_INFO *pTriPatchInfo )
1925 {
1926     HRESULT r;
1927     mtx_lock(&d3dlock_global);
1928     r = NineDevice9_DrawTriPatch(This, Handle, pNumSegs, pTriPatchInfo);
1929     mtx_unlock(&d3dlock_global);
1930     return r;
1931 }
1932 
1933 static HRESULT NINE_WINAPI
LockDevice9_DeletePatch(struct NineDevice9 * This,UINT Handle)1934 LockDevice9_DeletePatch( struct NineDevice9 *This,
1935                          UINT Handle )
1936 {
1937     HRESULT r;
1938     mtx_lock(&d3dlock_global);
1939     r = NineDevice9_DeletePatch(This, Handle);
1940     mtx_unlock(&d3dlock_global);
1941     return r;
1942 }
1943 
1944 static HRESULT NINE_WINAPI
LockDevice9_CreateQuery(struct NineDevice9 * This,D3DQUERYTYPE Type,IDirect3DQuery9 ** ppQuery)1945 LockDevice9_CreateQuery( struct NineDevice9 *This,
1946                          D3DQUERYTYPE Type,
1947                          IDirect3DQuery9 **ppQuery )
1948 {
1949     HRESULT r;
1950     mtx_lock(&d3dlock_global);
1951     r = NineDevice9_CreateQuery(This, Type, ppQuery);
1952     mtx_unlock(&d3dlock_global);
1953     return r;
1954 }
1955 
1956 IDirect3DDevice9Vtbl LockDevice9_vtable = {
1957     (void *)NineUnknown_QueryInterface,
1958     (void *)NineUnknown_AddRef,
1959     (void *)NineUnknown_ReleaseWithDtorLock,
1960     (void *)LockDevice9_TestCooperativeLevel,
1961     (void *)LockDevice9_GetAvailableTextureMem,
1962     (void *)LockDevice9_EvictManagedResources,
1963     (void *)LockDevice9_GetDirect3D,
1964     (void *)NineDevice9_GetDeviceCaps, /* immutable */
1965     (void *)LockDevice9_GetDisplayMode,
1966     (void *)NineDevice9_GetCreationParameters, /* immutable */
1967     (void *)LockDevice9_SetCursorProperties,
1968     (void *)LockDevice9_SetCursorPosition,
1969     (void *)LockDevice9_ShowCursor,
1970     (void *)LockDevice9_CreateAdditionalSwapChain,
1971     (void *)LockDevice9_GetSwapChain,
1972     (void *)LockDevice9_GetNumberOfSwapChains,
1973     (void *)LockDevice9_Reset,
1974     (void *)LockDevice9_Present,
1975     (void *)LockDevice9_GetBackBuffer,
1976     (void *)LockDevice9_GetRasterStatus,
1977     (void *)LockDevice9_SetDialogBoxMode,
1978     (void *)LockDevice9_SetGammaRamp,
1979     (void *)LockDevice9_GetGammaRamp,
1980     (void *)LockDevice9_CreateTexture,
1981     (void *)LockDevice9_CreateVolumeTexture,
1982     (void *)LockDevice9_CreateCubeTexture,
1983     (void *)LockDevice9_CreateVertexBuffer,
1984     (void *)LockDevice9_CreateIndexBuffer,
1985     (void *)LockDevice9_CreateRenderTarget,
1986     (void *)LockDevice9_CreateDepthStencilSurface,
1987     (void *)LockDevice9_UpdateSurface,
1988     (void *)LockDevice9_UpdateTexture,
1989     (void *)LockDevice9_GetRenderTargetData,
1990     (void *)LockDevice9_GetFrontBufferData,
1991     (void *)LockDevice9_StretchRect,
1992     (void *)LockDevice9_ColorFill,
1993     (void *)LockDevice9_CreateOffscreenPlainSurface,
1994     (void *)LockDevice9_SetRenderTarget,
1995     (void *)LockDevice9_GetRenderTarget,
1996     (void *)LockDevice9_SetDepthStencilSurface,
1997     (void *)LockDevice9_GetDepthStencilSurface,
1998     (void *)LockDevice9_BeginScene,
1999     (void *)LockDevice9_EndScene,
2000     (void *)LockDevice9_Clear,
2001     (void *)LockDevice9_SetTransform,
2002     (void *)LockDevice9_GetTransform,
2003     (void *)LockDevice9_MultiplyTransform,
2004     (void *)LockDevice9_SetViewport,
2005     (void *)LockDevice9_GetViewport,
2006     (void *)LockDevice9_SetMaterial,
2007     (void *)LockDevice9_GetMaterial,
2008     (void *)LockDevice9_SetLight,
2009     (void *)LockDevice9_GetLight,
2010     (void *)LockDevice9_LightEnable,
2011     (void *)LockDevice9_GetLightEnable,
2012     (void *)LockDevice9_SetClipPlane,
2013     (void *)LockDevice9_GetClipPlane,
2014     (void *)LockDevice9_SetRenderState,
2015     (void *)LockDevice9_GetRenderState,
2016     (void *)LockDevice9_CreateStateBlock,
2017     (void *)LockDevice9_BeginStateBlock,
2018     (void *)LockDevice9_EndStateBlock,
2019     (void *)LockDevice9_SetClipStatus,
2020     (void *)LockDevice9_GetClipStatus,
2021     (void *)LockDevice9_GetTexture,
2022     (void *)LockDevice9_SetTexture,
2023     (void *)LockDevice9_GetTextureStageState,
2024     (void *)LockDevice9_SetTextureStageState,
2025     (void *)LockDevice9_GetSamplerState,
2026     (void *)LockDevice9_SetSamplerState,
2027     (void *)LockDevice9_ValidateDevice,
2028     (void *)LockDevice9_SetPaletteEntries,
2029     (void *)LockDevice9_GetPaletteEntries,
2030     (void *)LockDevice9_SetCurrentTexturePalette,
2031     (void *)LockDevice9_GetCurrentTexturePalette,
2032     (void *)LockDevice9_SetScissorRect,
2033     (void *)LockDevice9_GetScissorRect,
2034     (void *)LockDevice9_SetSoftwareVertexProcessing,
2035     (void *)LockDevice9_GetSoftwareVertexProcessing,
2036     (void *)LockDevice9_SetNPatchMode,
2037     (void *)LockDevice9_GetNPatchMode,
2038     (void *)LockDevice9_DrawPrimitive,
2039     (void *)LockDevice9_DrawIndexedPrimitive,
2040     (void *)LockDevice9_DrawPrimitiveUP,
2041     (void *)LockDevice9_DrawIndexedPrimitiveUP,
2042     (void *)LockDevice9_ProcessVertices,
2043     (void *)LockDevice9_CreateVertexDeclaration,
2044     (void *)LockDevice9_SetVertexDeclaration,
2045     (void *)LockDevice9_GetVertexDeclaration,
2046     (void *)LockDevice9_SetFVF,
2047     (void *)LockDevice9_GetFVF,
2048     (void *)LockDevice9_CreateVertexShader,
2049     (void *)LockDevice9_SetVertexShader,
2050     (void *)LockDevice9_GetVertexShader,
2051     (void *)LockDevice9_SetVertexShaderConstantF,
2052     (void *)LockDevice9_GetVertexShaderConstantF,
2053     (void *)LockDevice9_SetVertexShaderConstantI,
2054     (void *)LockDevice9_GetVertexShaderConstantI,
2055     (void *)LockDevice9_SetVertexShaderConstantB,
2056     (void *)LockDevice9_GetVertexShaderConstantB,
2057     (void *)LockDevice9_SetStreamSource,
2058     (void *)LockDevice9_GetStreamSource,
2059     (void *)LockDevice9_SetStreamSourceFreq,
2060     (void *)LockDevice9_GetStreamSourceFreq,
2061     (void *)LockDevice9_SetIndices,
2062     (void *)LockDevice9_GetIndices,
2063     (void *)LockDevice9_CreatePixelShader,
2064     (void *)LockDevice9_SetPixelShader,
2065     (void *)LockDevice9_GetPixelShader,
2066     (void *)LockDevice9_SetPixelShaderConstantF,
2067     (void *)LockDevice9_GetPixelShaderConstantF,
2068     (void *)LockDevice9_SetPixelShaderConstantI,
2069     (void *)LockDevice9_GetPixelShaderConstantI,
2070     (void *)LockDevice9_SetPixelShaderConstantB,
2071     (void *)LockDevice9_GetPixelShaderConstantB,
2072     (void *)LockDevice9_DrawRectPatch,
2073     (void *)LockDevice9_DrawTriPatch,
2074     (void *)LockDevice9_DeletePatch,
2075     (void *)LockDevice9_CreateQuery
2076 };
2077 
2078 static HRESULT NINE_WINAPI
LockDevice9Ex_SetConvolutionMonoKernel(struct NineDevice9Ex * This,UINT width,UINT height,float * rows,float * columns)2079 LockDevice9Ex_SetConvolutionMonoKernel( struct NineDevice9Ex *This,
2080                                         UINT width,
2081                                         UINT height,
2082                                         float *rows,
2083                                         float *columns )
2084 {
2085     HRESULT r;
2086     mtx_lock(&d3dlock_global);
2087     r = NineDevice9Ex_SetConvolutionMonoKernel(This, width, height, rows, columns);
2088     mtx_unlock(&d3dlock_global);
2089     return r;
2090 }
2091 
2092 static HRESULT NINE_WINAPI
LockDevice9Ex_ComposeRects(struct NineDevice9Ex * This,IDirect3DSurface9 * pSrc,IDirect3DSurface9 * pDst,IDirect3DVertexBuffer9 * pSrcRectDescs,UINT NumRects,IDirect3DVertexBuffer9 * pDstRectDescs,D3DCOMPOSERECTSOP Operation,int Xoffset,int Yoffset)2093 LockDevice9Ex_ComposeRects( struct NineDevice9Ex *This,
2094                             IDirect3DSurface9 *pSrc,
2095                             IDirect3DSurface9 *pDst,
2096                             IDirect3DVertexBuffer9 *pSrcRectDescs,
2097                             UINT NumRects,
2098                             IDirect3DVertexBuffer9 *pDstRectDescs,
2099                             D3DCOMPOSERECTSOP Operation,
2100                             int Xoffset,
2101                             int Yoffset )
2102 {
2103     HRESULT r;
2104     mtx_lock(&d3dlock_global);
2105     r = NineDevice9Ex_ComposeRects(This, pSrc, pDst, pSrcRectDescs, NumRects, pDstRectDescs, Operation, Xoffset, Yoffset);
2106     mtx_unlock(&d3dlock_global);
2107     return r;
2108 }
2109 
2110 static HRESULT NINE_WINAPI
LockDevice9Ex_PresentEx(struct NineDevice9Ex * This,const RECT * pSourceRect,const RECT * pDestRect,HWND hDestWindowOverride,const RGNDATA * pDirtyRegion,DWORD dwFlags)2111 LockDevice9Ex_PresentEx( struct NineDevice9Ex *This,
2112                          const RECT *pSourceRect,
2113                          const RECT *pDestRect,
2114                          HWND hDestWindowOverride,
2115                          const RGNDATA *pDirtyRegion,
2116                          DWORD dwFlags )
2117 {
2118     HRESULT r;
2119     mtx_lock(&d3dlock_global);
2120     r = NineDevice9Ex_PresentEx(This, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
2121     mtx_unlock(&d3dlock_global);
2122     return r;
2123 }
2124 
2125 static HRESULT NINE_WINAPI
LockDevice9Ex_GetGPUThreadPriority(struct NineDevice9Ex * This,INT * pPriority)2126 LockDevice9Ex_GetGPUThreadPriority( struct NineDevice9Ex *This,
2127                                     INT *pPriority )
2128 {
2129     HRESULT r;
2130     mtx_lock(&d3dlock_global);
2131     r = NineDevice9Ex_GetGPUThreadPriority(This, pPriority);
2132     mtx_unlock(&d3dlock_global);
2133     return r;
2134 }
2135 
2136 static HRESULT NINE_WINAPI
LockDevice9Ex_SetGPUThreadPriority(struct NineDevice9Ex * This,INT Priority)2137 LockDevice9Ex_SetGPUThreadPriority( struct NineDevice9Ex *This,
2138                                     INT Priority )
2139 {
2140     HRESULT r;
2141     mtx_lock(&d3dlock_global);
2142     r = NineDevice9Ex_SetGPUThreadPriority(This, Priority);
2143     mtx_unlock(&d3dlock_global);
2144     return r;
2145 }
2146 
2147 static HRESULT NINE_WINAPI
LockDevice9Ex_WaitForVBlank(struct NineDevice9Ex * This,UINT iSwapChain)2148 LockDevice9Ex_WaitForVBlank( struct NineDevice9Ex *This,
2149                              UINT iSwapChain )
2150 {
2151     HRESULT r;
2152     mtx_lock(&d3dlock_global);
2153     r = NineDevice9Ex_WaitForVBlank(This, iSwapChain);
2154     mtx_unlock(&d3dlock_global);
2155     return r;
2156 }
2157 
2158 static HRESULT NINE_WINAPI
LockDevice9Ex_CheckResourceResidency(struct NineDevice9Ex * This,IDirect3DResource9 ** pResourceArray,UINT32 NumResources)2159 LockDevice9Ex_CheckResourceResidency( struct NineDevice9Ex *This,
2160                                       IDirect3DResource9 **pResourceArray,
2161                                       UINT32 NumResources )
2162 {
2163     HRESULT r;
2164     mtx_lock(&d3dlock_global);
2165     r = NineDevice9Ex_CheckResourceResidency(This, pResourceArray, NumResources);
2166     mtx_unlock(&d3dlock_global);
2167     return r;
2168 }
2169 
2170 static HRESULT NINE_WINAPI
LockDevice9Ex_SetMaximumFrameLatency(struct NineDevice9Ex * This,UINT MaxLatency)2171 LockDevice9Ex_SetMaximumFrameLatency( struct NineDevice9Ex *This,
2172                                       UINT MaxLatency )
2173 {
2174     HRESULT r;
2175     mtx_lock(&d3dlock_global);
2176     r = NineDevice9Ex_SetMaximumFrameLatency(This, MaxLatency);
2177     mtx_unlock(&d3dlock_global);
2178     return r;
2179 }
2180 
2181 static HRESULT NINE_WINAPI
LockDevice9Ex_GetMaximumFrameLatency(struct NineDevice9Ex * This,UINT * pMaxLatency)2182 LockDevice9Ex_GetMaximumFrameLatency( struct NineDevice9Ex *This,
2183                                       UINT *pMaxLatency )
2184 {
2185     HRESULT r;
2186     mtx_lock(&d3dlock_global);
2187     r = NineDevice9Ex_GetMaximumFrameLatency(This, pMaxLatency);
2188     mtx_unlock(&d3dlock_global);
2189     return r;
2190 }
2191 
2192 static HRESULT NINE_WINAPI
LockDevice9Ex_CheckDeviceState(struct NineDevice9Ex * This,HWND hDestinationWindow)2193 LockDevice9Ex_CheckDeviceState( struct NineDevice9Ex *This,
2194                                 HWND hDestinationWindow )
2195 {
2196     HRESULT r;
2197     mtx_lock(&d3dlock_global);
2198     r = NineDevice9Ex_CheckDeviceState(This, hDestinationWindow);
2199     mtx_unlock(&d3dlock_global);
2200     return r;
2201 }
2202 
2203 static HRESULT NINE_WINAPI
LockDevice9Ex_CreateRenderTargetEx(struct NineDevice9Ex * This,UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9 ** ppSurface,HANDLE * pSharedHandle,DWORD Usage)2204 LockDevice9Ex_CreateRenderTargetEx( struct NineDevice9Ex *This,
2205                                     UINT Width,
2206                                     UINT Height,
2207                                     D3DFORMAT Format,
2208                                     D3DMULTISAMPLE_TYPE MultiSample,
2209                                     DWORD MultisampleQuality,
2210                                     BOOL Lockable,
2211                                     IDirect3DSurface9 **ppSurface,
2212                                     HANDLE *pSharedHandle,
2213                                     DWORD Usage )
2214 {
2215     HRESULT r;
2216     mtx_lock(&d3dlock_global);
2217     r = NineDevice9Ex_CreateRenderTargetEx(This, Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle, Usage);
2218     mtx_unlock(&d3dlock_global);
2219     return r;
2220 }
2221 
2222 static HRESULT NINE_WINAPI
LockDevice9Ex_CreateOffscreenPlainSurfaceEx(struct NineDevice9Ex * This,UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9 ** ppSurface,HANDLE * pSharedHandle,DWORD Usage)2223 LockDevice9Ex_CreateOffscreenPlainSurfaceEx( struct NineDevice9Ex *This,
2224                                              UINT Width,
2225                                              UINT Height,
2226                                              D3DFORMAT Format,
2227                                              D3DPOOL Pool,
2228                                              IDirect3DSurface9 **ppSurface,
2229                                              HANDLE *pSharedHandle,
2230                                              DWORD Usage )
2231 {
2232     HRESULT r;
2233     mtx_lock(&d3dlock_global);
2234     r = NineDevice9Ex_CreateOffscreenPlainSurfaceEx(This, Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage);
2235     mtx_unlock(&d3dlock_global);
2236     return r;
2237 }
2238 
2239 static HRESULT NINE_WINAPI
LockDevice9Ex_CreateDepthStencilSurfaceEx(struct NineDevice9Ex * This,UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9 ** ppSurface,HANDLE * pSharedHandle,DWORD Usage)2240 LockDevice9Ex_CreateDepthStencilSurfaceEx( struct NineDevice9Ex *This,
2241                                            UINT Width,
2242                                            UINT Height,
2243                                            D3DFORMAT Format,
2244                                            D3DMULTISAMPLE_TYPE MultiSample,
2245                                            DWORD MultisampleQuality,
2246                                            BOOL Discard,
2247                                            IDirect3DSurface9 **ppSurface,
2248                                            HANDLE *pSharedHandle,
2249                                            DWORD Usage )
2250 {
2251     HRESULT r;
2252     mtx_lock(&d3dlock_global);
2253     r = NineDevice9Ex_CreateDepthStencilSurfaceEx(This, Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle, Usage);
2254     mtx_unlock(&d3dlock_global);
2255     return r;
2256 }
2257 
2258 static HRESULT NINE_WINAPI
LockDevice9Ex_ResetEx(struct NineDevice9Ex * This,D3DPRESENT_PARAMETERS * pPresentationParameters,D3DDISPLAYMODEEX * pFullscreenDisplayMode)2259 LockDevice9Ex_ResetEx( struct NineDevice9Ex *This,
2260                        D3DPRESENT_PARAMETERS *pPresentationParameters,
2261                        D3DDISPLAYMODEEX *pFullscreenDisplayMode )
2262 {
2263     HRESULT r;
2264     mtx_lock(&d3dlock_global);
2265     r = NineDevice9Ex_ResetEx(This, pPresentationParameters, pFullscreenDisplayMode);
2266     mtx_unlock(&d3dlock_global);
2267     return r;
2268 }
2269 
2270 static HRESULT NINE_WINAPI
LockDevice9Ex_GetDisplayModeEx(struct NineDevice9Ex * This,UINT iSwapChain,D3DDISPLAYMODEEX * pMode,D3DDISPLAYROTATION * pRotation)2271 LockDevice9Ex_GetDisplayModeEx( struct NineDevice9Ex *This,
2272                                 UINT iSwapChain,
2273                                 D3DDISPLAYMODEEX *pMode,
2274                                 D3DDISPLAYROTATION *pRotation )
2275 {
2276     HRESULT r;
2277     mtx_lock(&d3dlock_global);
2278     r = NineDevice9Ex_GetDisplayModeEx(This, iSwapChain, pMode, pRotation);
2279     mtx_unlock(&d3dlock_global);
2280     return r;
2281 }
2282 
2283 IDirect3DDevice9ExVtbl LockDevice9Ex_vtable = {
2284     (void *)NineUnknown_QueryInterface,
2285     (void *)NineUnknown_AddRef,
2286     (void *)NineUnknown_ReleaseWithDtorLock,
2287     (void *)LockDevice9_TestCooperativeLevel,
2288     (void *)LockDevice9_GetAvailableTextureMem,
2289     (void *)LockDevice9_EvictManagedResources,
2290     (void *)LockDevice9_GetDirect3D,
2291     (void *)NineDevice9_GetDeviceCaps,
2292     (void *)LockDevice9_GetDisplayMode,
2293     (void *)NineDevice9_GetCreationParameters,
2294     (void *)LockDevice9_SetCursorProperties,
2295     (void *)LockDevice9_SetCursorPosition,
2296     (void *)LockDevice9_ShowCursor,
2297     (void *)LockDevice9_CreateAdditionalSwapChain,
2298     (void *)LockDevice9_GetSwapChain,
2299     (void *)LockDevice9_GetNumberOfSwapChains,
2300     (void *)LockDevice9_Reset,
2301     (void *)LockDevice9_Present,
2302     (void *)LockDevice9_GetBackBuffer,
2303     (void *)LockDevice9_GetRasterStatus,
2304     (void *)LockDevice9_SetDialogBoxMode,
2305     (void *)LockDevice9_SetGammaRamp,
2306     (void *)LockDevice9_GetGammaRamp,
2307     (void *)LockDevice9_CreateTexture,
2308     (void *)LockDevice9_CreateVolumeTexture,
2309     (void *)LockDevice9_CreateCubeTexture,
2310     (void *)LockDevice9_CreateVertexBuffer,
2311     (void *)LockDevice9_CreateIndexBuffer,
2312     (void *)LockDevice9_CreateRenderTarget,
2313     (void *)LockDevice9_CreateDepthStencilSurface,
2314     (void *)LockDevice9_UpdateSurface,
2315     (void *)LockDevice9_UpdateTexture,
2316     (void *)LockDevice9_GetRenderTargetData,
2317     (void *)LockDevice9_GetFrontBufferData,
2318     (void *)LockDevice9_StretchRect,
2319     (void *)LockDevice9_ColorFill,
2320     (void *)LockDevice9_CreateOffscreenPlainSurface,
2321     (void *)LockDevice9_SetRenderTarget,
2322     (void *)LockDevice9_GetRenderTarget,
2323     (void *)LockDevice9_SetDepthStencilSurface,
2324     (void *)LockDevice9_GetDepthStencilSurface,
2325     (void *)LockDevice9_BeginScene,
2326     (void *)LockDevice9_EndScene,
2327     (void *)LockDevice9_Clear,
2328     (void *)LockDevice9_SetTransform,
2329     (void *)LockDevice9_GetTransform,
2330     (void *)LockDevice9_MultiplyTransform,
2331     (void *)LockDevice9_SetViewport,
2332     (void *)LockDevice9_GetViewport,
2333     (void *)LockDevice9_SetMaterial,
2334     (void *)LockDevice9_GetMaterial,
2335     (void *)LockDevice9_SetLight,
2336     (void *)LockDevice9_GetLight,
2337     (void *)LockDevice9_LightEnable,
2338     (void *)LockDevice9_GetLightEnable,
2339     (void *)LockDevice9_SetClipPlane,
2340     (void *)LockDevice9_GetClipPlane,
2341     (void *)LockDevice9_SetRenderState,
2342     (void *)LockDevice9_GetRenderState,
2343     (void *)LockDevice9_CreateStateBlock,
2344     (void *)LockDevice9_BeginStateBlock,
2345     (void *)LockDevice9_EndStateBlock,
2346     (void *)LockDevice9_SetClipStatus,
2347     (void *)LockDevice9_GetClipStatus,
2348     (void *)LockDevice9_GetTexture,
2349     (void *)LockDevice9_SetTexture,
2350     (void *)LockDevice9_GetTextureStageState,
2351     (void *)LockDevice9_SetTextureStageState,
2352     (void *)LockDevice9_GetSamplerState,
2353     (void *)LockDevice9_SetSamplerState,
2354     (void *)LockDevice9_ValidateDevice,
2355     (void *)LockDevice9_SetPaletteEntries,
2356     (void *)LockDevice9_GetPaletteEntries,
2357     (void *)LockDevice9_SetCurrentTexturePalette,
2358     (void *)LockDevice9_GetCurrentTexturePalette,
2359     (void *)LockDevice9_SetScissorRect,
2360     (void *)LockDevice9_GetScissorRect,
2361     (void *)LockDevice9_SetSoftwareVertexProcessing,
2362     (void *)LockDevice9_GetSoftwareVertexProcessing,
2363     (void *)LockDevice9_SetNPatchMode,
2364     (void *)LockDevice9_GetNPatchMode,
2365     (void *)LockDevice9_DrawPrimitive,
2366     (void *)LockDevice9_DrawIndexedPrimitive,
2367     (void *)LockDevice9_DrawPrimitiveUP,
2368     (void *)LockDevice9_DrawIndexedPrimitiveUP,
2369     (void *)LockDevice9_ProcessVertices,
2370     (void *)LockDevice9_CreateVertexDeclaration,
2371     (void *)LockDevice9_SetVertexDeclaration,
2372     (void *)LockDevice9_GetVertexDeclaration,
2373     (void *)LockDevice9_SetFVF,
2374     (void *)LockDevice9_GetFVF,
2375     (void *)LockDevice9_CreateVertexShader,
2376     (void *)LockDevice9_SetVertexShader,
2377     (void *)LockDevice9_GetVertexShader,
2378     (void *)LockDevice9_SetVertexShaderConstantF,
2379     (void *)LockDevice9_GetVertexShaderConstantF,
2380     (void *)LockDevice9_SetVertexShaderConstantI,
2381     (void *)LockDevice9_GetVertexShaderConstantI,
2382     (void *)LockDevice9_SetVertexShaderConstantB,
2383     (void *)LockDevice9_GetVertexShaderConstantB,
2384     (void *)LockDevice9_SetStreamSource,
2385     (void *)LockDevice9_GetStreamSource,
2386     (void *)LockDevice9_SetStreamSourceFreq,
2387     (void *)LockDevice9_GetStreamSourceFreq,
2388     (void *)LockDevice9_SetIndices,
2389     (void *)LockDevice9_GetIndices,
2390     (void *)LockDevice9_CreatePixelShader,
2391     (void *)LockDevice9_SetPixelShader,
2392     (void *)LockDevice9_GetPixelShader,
2393     (void *)LockDevice9_SetPixelShaderConstantF,
2394     (void *)LockDevice9_GetPixelShaderConstantF,
2395     (void *)LockDevice9_SetPixelShaderConstantI,
2396     (void *)LockDevice9_GetPixelShaderConstantI,
2397     (void *)LockDevice9_SetPixelShaderConstantB,
2398     (void *)LockDevice9_GetPixelShaderConstantB,
2399     (void *)LockDevice9_DrawRectPatch,
2400     (void *)LockDevice9_DrawTriPatch,
2401     (void *)LockDevice9_DeletePatch,
2402     (void *)LockDevice9_CreateQuery,
2403     (void *)LockDevice9Ex_SetConvolutionMonoKernel,
2404     (void *)LockDevice9Ex_ComposeRects,
2405     (void *)LockDevice9Ex_PresentEx,
2406     (void *)LockDevice9Ex_GetGPUThreadPriority,
2407     (void *)LockDevice9Ex_SetGPUThreadPriority,
2408     (void *)LockDevice9Ex_WaitForVBlank,
2409     (void *)LockDevice9Ex_CheckResourceResidency,
2410     (void *)LockDevice9Ex_SetMaximumFrameLatency,
2411     (void *)LockDevice9Ex_GetMaximumFrameLatency,
2412     (void *)LockDevice9Ex_CheckDeviceState,
2413     (void *)LockDevice9Ex_CreateRenderTargetEx,
2414     (void *)LockDevice9Ex_CreateOffscreenPlainSurfaceEx,
2415     (void *)LockDevice9Ex_CreateDepthStencilSurfaceEx,
2416     (void *)LockDevice9Ex_ResetEx,
2417     (void *)LockDevice9Ex_GetDisplayModeEx
2418 };
2419 
2420 static HRESULT NINE_WINAPI
LockDevice9Video_GetContentProtectionCaps(struct NineDevice9Video * This,const GUID * pCryptoType,const GUID * pDecodeProfile,D3DCONTENTPROTECTIONCAPS * pCaps)2421 LockDevice9Video_GetContentProtectionCaps( struct NineDevice9Video *This,
2422                                            const GUID *pCryptoType,
2423                                            const GUID *pDecodeProfile,
2424                                            D3DCONTENTPROTECTIONCAPS *pCaps )
2425 {
2426     HRESULT r;
2427     mtx_lock(&d3dlock_global);
2428     r = NineDevice9Video_GetContentProtectionCaps(This, pCryptoType, pDecodeProfile, pCaps);
2429     mtx_unlock(&d3dlock_global);
2430     return r;
2431 }
2432 
2433 static HRESULT NINE_WINAPI
LockDevice9Video_CreateAuthenticatedChannel(struct NineDevice9Video * This,D3DAUTHENTICATEDCHANNELTYPE ChannelType,IDirect3DAuthenticatedChannel9 ** ppAuthenticatedChannel,HANDLE * pChannelHandle)2434 LockDevice9Video_CreateAuthenticatedChannel( struct NineDevice9Video *This,
2435                                              D3DAUTHENTICATEDCHANNELTYPE ChannelType,
2436                                              IDirect3DAuthenticatedChannel9 **ppAuthenticatedChannel,
2437                                              HANDLE *pChannelHandle )
2438 {
2439     HRESULT r;
2440     mtx_lock(&d3dlock_global);
2441     r = NineDevice9Video_CreateAuthenticatedChannel(This, ChannelType, ppAuthenticatedChannel, pChannelHandle);
2442     mtx_unlock(&d3dlock_global);
2443     return r;
2444 }
2445 
2446 static HRESULT NINE_WINAPI
LockDevice9Video_CreateCryptoSession(struct NineDevice9Video * This,const GUID * pCryptoType,const GUID * pDecodeProfile,IDirect3DCryptoSession9 ** ppCryptoSession,HANDLE * pCryptoHandle)2447 LockDevice9Video_CreateCryptoSession( struct NineDevice9Video *This,
2448                                       const GUID *pCryptoType,
2449                                       const GUID *pDecodeProfile,
2450                                       IDirect3DCryptoSession9 **ppCryptoSession,
2451                                       HANDLE *pCryptoHandle )
2452 {
2453     HRESULT r;
2454     mtx_lock(&d3dlock_global);
2455     r = NineDevice9Video_CreateCryptoSession(This, pCryptoType, pDecodeProfile, ppCryptoSession, pCryptoHandle);
2456     mtx_unlock(&d3dlock_global);
2457     return r;
2458 }
2459 
2460 IDirect3DDevice9VideoVtbl LockDevice9Video_vtable = {
2461     (void *)NineUnknown_QueryInterface,
2462     (void *)NineUnknown_AddRef,
2463     (void *)NineUnknown_ReleaseWithDtorLock,
2464     (void *)LockDevice9Video_GetContentProtectionCaps,
2465     (void *)LockDevice9Video_CreateAuthenticatedChannel,
2466     (void *)LockDevice9Video_CreateCryptoSession
2467 };
2468 
2469 static HRESULT NINE_WINAPI
LockIndexBuffer9_Lock(struct NineIndexBuffer9 * This,UINT OffsetToLock,UINT SizeToLock,void ** ppbData,DWORD Flags)2470 LockIndexBuffer9_Lock( struct NineIndexBuffer9 *This,
2471                        UINT OffsetToLock,
2472                        UINT SizeToLock,
2473                        void **ppbData,
2474                        DWORD Flags )
2475 {
2476     HRESULT r;
2477     mtx_lock(&d3dlock_global);
2478     r = NineIndexBuffer9_Lock(This, OffsetToLock, SizeToLock, ppbData, Flags);
2479     mtx_unlock(&d3dlock_global);
2480     return r;
2481 }
2482 
2483 static HRESULT NINE_WINAPI
LockIndexBuffer9_Unlock(struct NineIndexBuffer9 * This)2484 LockIndexBuffer9_Unlock( struct NineIndexBuffer9 *This )
2485 {
2486     HRESULT r;
2487     mtx_lock(&d3dlock_global);
2488     r = NineIndexBuffer9_Unlock(This);
2489     mtx_unlock(&d3dlock_global);
2490     return r;
2491 }
2492 
2493 #if 0
2494 static HRESULT NINE_WINAPI
2495 LockIndexBuffer9_GetDesc( struct NineIndexBuffer9 *This,
2496                           D3DINDEXBUFFER_DESC *pDesc )
2497 {
2498     HRESULT r;
2499     mtx_lock(&d3dlock_global);
2500     r = NineIndexBuffer9_GetDesc(This, pDesc);
2501     mtx_unlock(&d3dlock_global);
2502     return r;
2503 }
2504 #endif
2505 
2506 IDirect3DIndexBuffer9Vtbl LockIndexBuffer9_vtable = {
2507     (void *)NineUnknown_QueryInterface,
2508     (void *)NineUnknown_AddRef,
2509     (void *)NineUnknown_ReleaseWithDtorLock,
2510     (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
2511     (void *)LockUnknown_SetPrivateData,
2512     (void *)LockUnknown_GetPrivateData,
2513     (void *)LockUnknown_FreePrivateData,
2514     (void *)LockResource9_SetPriority,
2515     (void *)LockResource9_GetPriority,
2516     (void *)NineResource9_PreLoad, /* nop */
2517     (void *)NineResource9_GetType, /* immutable */
2518     (void *)LockIndexBuffer9_Lock,
2519     (void *)LockIndexBuffer9_Unlock,
2520     (void *)NineIndexBuffer9_GetDesc /* immutable */
2521 };
2522 
2523 #if 0
2524 static HRESULT NINE_WINAPI
2525 LockPixelShader9_GetDevice( struct NinePixelShader9 *This,
2526                             IDirect3DDevice9 **ppDevice )
2527 {
2528     HRESULT r;
2529     mtx_lock(&d3dlock_global);
2530     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
2531     mtx_unlock(&d3dlock_global);
2532     return r;
2533 }
2534 #endif
2535 
2536 static HRESULT NINE_WINAPI
LockPixelShader9_GetFunction(struct NinePixelShader9 * This,void * pData,UINT * pSizeOfData)2537 LockPixelShader9_GetFunction( struct NinePixelShader9 *This,
2538                               void *pData,
2539                               UINT *pSizeOfData )
2540 {
2541     HRESULT r;
2542     mtx_lock(&d3dlock_global);
2543     r = NinePixelShader9_GetFunction(This, pData, pSizeOfData);
2544     mtx_unlock(&d3dlock_global);
2545     return r;
2546 }
2547 
2548 IDirect3DPixelShader9Vtbl LockPixelShader9_vtable = {
2549     (void *)NineUnknown_QueryInterface,
2550     (void *)NineUnknown_AddRef,
2551     (void *)NineUnknown_ReleaseWithDtorLock,
2552     (void *)NineUnknown_GetDevice,
2553     (void *)LockPixelShader9_GetFunction
2554 };
2555 
2556 #if 0
2557 static HRESULT NINE_WINAPI
2558 LockQuery9_GetDevice( struct NineQuery9 *This,
2559                       IDirect3DDevice9 **ppDevice )
2560 {
2561     HRESULT r;
2562     mtx_lock(&d3dlock_global);
2563     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
2564     mtx_unlock(&d3dlock_global);
2565     return r;
2566 }
2567 #endif
2568 
2569 #if 0
2570 static D3DQUERYTYPE NINE_WINAPI
2571 LockQuery9_GetType( struct NineQuery9 *This )
2572 {
2573     D3DQUERYTYPE r;
2574     mtx_lock(&d3dlock_global);
2575     r = NineQuery9_GetType(This);
2576     mtx_unlock(&d3dlock_global);
2577     return r;
2578 }
2579 #endif
2580 
2581 #if 0
2582 static DWORD NINE_WINAPI
2583 LockQuery9_GetDataSize( struct NineQuery9 *This )
2584 {
2585     DWORD r;
2586     mtx_lock(&d3dlock_global);
2587     r = NineQuery9_GetDataSize(This);
2588     mtx_unlock(&d3dlock_global);
2589     return r;
2590 }
2591 #endif
2592 
2593 static HRESULT NINE_WINAPI
LockQuery9_Issue(struct NineQuery9 * This,DWORD dwIssueFlags)2594 LockQuery9_Issue( struct NineQuery9 *This,
2595                   DWORD dwIssueFlags )
2596 {
2597     HRESULT r;
2598     mtx_lock(&d3dlock_global);
2599     r = NineQuery9_Issue(This, dwIssueFlags);
2600     mtx_unlock(&d3dlock_global);
2601     return r;
2602 }
2603 
2604 static HRESULT NINE_WINAPI
LockQuery9_GetData(struct NineQuery9 * This,void * pData,DWORD dwSize,DWORD dwGetDataFlags)2605 LockQuery9_GetData( struct NineQuery9 *This,
2606                     void *pData,
2607                     DWORD dwSize,
2608                     DWORD dwGetDataFlags )
2609 {
2610     HRESULT r;
2611     mtx_lock(&d3dlock_global);
2612     r = NineQuery9_GetData(This, pData, dwSize, dwGetDataFlags);
2613     mtx_unlock(&d3dlock_global);
2614     return r;
2615 }
2616 
2617 IDirect3DQuery9Vtbl LockQuery9_vtable = {
2618     (void *)NineUnknown_QueryInterface,
2619     (void *)NineUnknown_AddRef,
2620     (void *)NineUnknown_ReleaseWithDtorLock,
2621     (void *)NineUnknown_GetDevice, /* actually part of Query9 iface */
2622     (void *)NineQuery9_GetType, /* immutable */
2623     (void *)NineQuery9_GetDataSize, /* immutable */
2624     (void *)LockQuery9_Issue,
2625     (void *)LockQuery9_GetData
2626 };
2627 
2628 #if 0
2629 static HRESULT NINE_WINAPI
2630 LockStateBlock9_GetDevice( struct NineStateBlock9 *This,
2631                            IDirect3DDevice9 **ppDevice )
2632 {
2633     HRESULT r;
2634     mtx_lock(&d3dlock_global);
2635     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
2636     mtx_unlock(&d3dlock_global);
2637     return r;
2638 }
2639 #endif
2640 
2641 static HRESULT NINE_WINAPI
LockStateBlock9_Capture(struct NineStateBlock9 * This)2642 LockStateBlock9_Capture( struct NineStateBlock9 *This )
2643 {
2644     HRESULT r;
2645     mtx_lock(&d3dlock_global);
2646     r = NineStateBlock9_Capture(This);
2647     mtx_unlock(&d3dlock_global);
2648     return r;
2649 }
2650 
2651 static HRESULT NINE_WINAPI
LockStateBlock9_Apply(struct NineStateBlock9 * This)2652 LockStateBlock9_Apply( struct NineStateBlock9 *This )
2653 {
2654     HRESULT r;
2655     mtx_lock(&d3dlock_global);
2656     r = NineStateBlock9_Apply(This);
2657     mtx_unlock(&d3dlock_global);
2658     return r;
2659 }
2660 
2661 IDirect3DStateBlock9Vtbl LockStateBlock9_vtable = {
2662     (void *)NineUnknown_QueryInterface,
2663     (void *)NineUnknown_AddRef,
2664     (void *)NineUnknown_ReleaseWithDtorLock,
2665     (void *)NineUnknown_GetDevice, /* actually part of StateBlock9 iface */
2666     (void *)LockStateBlock9_Capture,
2667     (void *)LockStateBlock9_Apply
2668 };
2669 
2670 static HRESULT NINE_WINAPI
LockSurface9_GetContainer(struct NineSurface9 * This,REFIID riid,void ** ppContainer)2671 LockSurface9_GetContainer( struct NineSurface9 *This,
2672                            REFIID riid,
2673                            void **ppContainer )
2674 {
2675     HRESULT r;
2676     mtx_lock(&d3dlock_global);
2677     r = NineSurface9_GetContainer(This, riid, ppContainer);
2678     mtx_unlock(&d3dlock_global);
2679     return r;
2680 }
2681 
2682 #if 0
2683 static HRESULT NINE_WINAPI
2684 LockSurface9_GetDesc( struct NineSurface9 *This,
2685                       D3DSURFACE_DESC *pDesc )
2686 {
2687     HRESULT r;
2688     mtx_lock(&d3dlock_global);
2689     r = NineSurface9_GetDesc(This, pDesc);
2690     mtx_unlock(&d3dlock_global);
2691     return r;
2692 }
2693 #endif
2694 
2695 static HRESULT NINE_WINAPI
LockSurface9_LockRect(struct NineSurface9 * This,D3DLOCKED_RECT * pLockedRect,const RECT * pRect,DWORD Flags)2696 LockSurface9_LockRect( struct NineSurface9 *This,
2697                        D3DLOCKED_RECT *pLockedRect,
2698                        const RECT *pRect,
2699                        DWORD Flags )
2700 {
2701     HRESULT r;
2702     mtx_lock(&d3dlock_global);
2703     r = NineSurface9_LockRect(This, pLockedRect, pRect, Flags);
2704     mtx_unlock(&d3dlock_global);
2705     return r;
2706 }
2707 
2708 static HRESULT NINE_WINAPI
LockSurface9_UnlockRect(struct NineSurface9 * This)2709 LockSurface9_UnlockRect( struct NineSurface9 *This )
2710 {
2711     HRESULT r;
2712     mtx_lock(&d3dlock_global);
2713     r = NineSurface9_UnlockRect(This);
2714     mtx_unlock(&d3dlock_global);
2715     return r;
2716 }
2717 
2718 static HRESULT NINE_WINAPI
LockSurface9_GetDC(struct NineSurface9 * This,HDC * phdc)2719 LockSurface9_GetDC( struct NineSurface9 *This,
2720                     HDC *phdc )
2721 {
2722     HRESULT r;
2723     mtx_lock(&d3dlock_global);
2724     r = NineSurface9_GetDC(This, phdc);
2725     mtx_unlock(&d3dlock_global);
2726     return r;
2727 }
2728 
2729 static HRESULT NINE_WINAPI
LockSurface9_ReleaseDC(struct NineSurface9 * This,HDC hdc)2730 LockSurface9_ReleaseDC( struct NineSurface9 *This,
2731                         HDC hdc )
2732 {
2733     HRESULT r;
2734     mtx_lock(&d3dlock_global);
2735     r = NineSurface9_ReleaseDC(This, hdc);
2736     mtx_unlock(&d3dlock_global);
2737     return r;
2738 }
2739 
2740 IDirect3DSurface9Vtbl LockSurface9_vtable = {
2741     (void *)NineUnknown_QueryInterface,
2742     (void *)NineUnknown_AddRef,
2743     (void *)NineUnknown_ReleaseWithDtorLock,
2744     (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
2745     (void *)LockUnknown_SetPrivateData,
2746     (void *)LockUnknown_GetPrivateData,
2747     (void *)LockUnknown_FreePrivateData,
2748     (void *)LockResource9_SetPriority,
2749     (void *)LockResource9_GetPriority,
2750     (void *)NineResource9_PreLoad, /* nop */
2751     (void *)NineResource9_GetType, /* immutable */
2752     (void *)LockSurface9_GetContainer,
2753     (void *)NineSurface9_GetDesc, /* immutable */
2754     (void *)LockSurface9_LockRect,
2755     (void *)LockSurface9_UnlockRect,
2756     (void *)LockSurface9_GetDC,
2757     (void *)LockSurface9_ReleaseDC
2758 };
2759 
2760 static HRESULT NINE_WINAPI
LockSwapChain9_Present(struct NineSwapChain9 * This,const RECT * pSourceRect,const RECT * pDestRect,HWND hDestWindowOverride,const RGNDATA * pDirtyRegion,DWORD dwFlags)2761 LockSwapChain9_Present( struct NineSwapChain9 *This,
2762                         const RECT *pSourceRect,
2763                         const RECT *pDestRect,
2764                         HWND hDestWindowOverride,
2765                         const RGNDATA *pDirtyRegion,
2766                         DWORD dwFlags )
2767 {
2768     HRESULT r;
2769     mtx_lock(&d3dlock_global);
2770     r = NineSwapChain9_Present(This, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
2771     mtx_unlock(&d3dlock_global);
2772     return r;
2773 }
2774 
2775 static HRESULT NINE_WINAPI
LockSwapChain9_GetFrontBufferData(struct NineSwapChain9 * This,IDirect3DSurface9 * pDestSurface)2776 LockSwapChain9_GetFrontBufferData( struct NineSwapChain9 *This,
2777                                    IDirect3DSurface9 *pDestSurface )
2778 {
2779     HRESULT r;
2780     mtx_lock(&d3dlock_global);
2781     r = NineSwapChain9_GetFrontBufferData(This, pDestSurface);
2782     mtx_unlock(&d3dlock_global);
2783     return r;
2784 }
2785 
2786 static HRESULT NINE_WINAPI
LockSwapChain9_GetBackBuffer(struct NineSwapChain9 * This,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9 ** ppBackBuffer)2787 LockSwapChain9_GetBackBuffer( struct NineSwapChain9 *This,
2788                               UINT iBackBuffer,
2789                               D3DBACKBUFFER_TYPE Type,
2790                               IDirect3DSurface9 **ppBackBuffer )
2791 {
2792     HRESULT r;
2793     mtx_lock(&d3dlock_global);
2794     r = NineSwapChain9_GetBackBuffer(This, iBackBuffer, Type, ppBackBuffer);
2795     mtx_unlock(&d3dlock_global);
2796     return r;
2797 }
2798 
2799 static HRESULT NINE_WINAPI
LockSwapChain9_GetRasterStatus(struct NineSwapChain9 * This,D3DRASTER_STATUS * pRasterStatus)2800 LockSwapChain9_GetRasterStatus( struct NineSwapChain9 *This,
2801                                 D3DRASTER_STATUS *pRasterStatus )
2802 {
2803     HRESULT r;
2804     mtx_lock(&d3dlock_global);
2805     r = NineSwapChain9_GetRasterStatus(This, pRasterStatus);
2806     mtx_unlock(&d3dlock_global);
2807     return r;
2808 }
2809 
2810 static HRESULT NINE_WINAPI
LockSwapChain9_GetDisplayMode(struct NineSwapChain9 * This,D3DDISPLAYMODE * pMode)2811 LockSwapChain9_GetDisplayMode( struct NineSwapChain9 *This,
2812                                D3DDISPLAYMODE *pMode )
2813 {
2814     HRESULT r;
2815     mtx_lock(&d3dlock_global);
2816     r = NineSwapChain9_GetDisplayMode(This, pMode);
2817     mtx_unlock(&d3dlock_global);
2818     return r;
2819 }
2820 
2821 #if 0
2822 static HRESULT NINE_WINAPI
2823 LockSwapChain9_GetDevice( struct NineSwapChain9 *This,
2824                           IDirect3DDevice9 **ppDevice )
2825 {
2826     HRESULT r;
2827     mtx_lock(&d3dlock_global);
2828     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
2829     mtx_unlock(&d3dlock_global);
2830     return r;
2831 }
2832 #endif
2833 
2834 static HRESULT NINE_WINAPI
LockSwapChain9_GetPresentParameters(struct NineSwapChain9 * This,D3DPRESENT_PARAMETERS * pPresentationParameters)2835 LockSwapChain9_GetPresentParameters( struct NineSwapChain9 *This,
2836                                      D3DPRESENT_PARAMETERS *pPresentationParameters )
2837 {
2838     HRESULT r;
2839     mtx_lock(&d3dlock_global);
2840     r = NineSwapChain9_GetPresentParameters(This, pPresentationParameters);
2841     mtx_unlock(&d3dlock_global);
2842     return r;
2843 }
2844 
2845 IDirect3DSwapChain9Vtbl LockSwapChain9_vtable = {
2846     (void *)NineUnknown_QueryInterface,
2847     (void *)NineUnknown_AddRef,
2848     (void *)NineUnknown_ReleaseWithDtorLock,
2849     (void *)LockSwapChain9_Present,
2850     (void *)LockSwapChain9_GetFrontBufferData,
2851     (void *)LockSwapChain9_GetBackBuffer,
2852     (void *)LockSwapChain9_GetRasterStatus,
2853     (void *)LockSwapChain9_GetDisplayMode,
2854     (void *)NineUnknown_GetDevice, /* actually part of SwapChain9 iface */
2855     (void *)LockSwapChain9_GetPresentParameters
2856 };
2857 
2858 static HRESULT NINE_WINAPI
LockSwapChain9Ex_GetLastPresentCount(struct NineSwapChain9Ex * This,UINT * pLastPresentCount)2859 LockSwapChain9Ex_GetLastPresentCount( struct NineSwapChain9Ex *This,
2860                                       UINT *pLastPresentCount )
2861 {
2862     HRESULT r;
2863     mtx_lock(&d3dlock_global);
2864     r = NineSwapChain9Ex_GetLastPresentCount(This, pLastPresentCount);
2865     mtx_unlock(&d3dlock_global);
2866     return r;
2867 }
2868 
2869 static HRESULT NINE_WINAPI
LockSwapChain9Ex_GetPresentStats(struct NineSwapChain9Ex * This,D3DPRESENTSTATS * pPresentationStatistics)2870 LockSwapChain9Ex_GetPresentStats( struct NineSwapChain9Ex *This,
2871                                   D3DPRESENTSTATS *pPresentationStatistics )
2872 {
2873     HRESULT r;
2874     mtx_lock(&d3dlock_global);
2875     r = NineSwapChain9Ex_GetPresentStats(This, pPresentationStatistics);
2876     mtx_unlock(&d3dlock_global);
2877     return r;
2878 }
2879 
2880 static HRESULT NINE_WINAPI
LockSwapChain9Ex_GetDisplayModeEx(struct NineSwapChain9Ex * This,D3DDISPLAYMODEEX * pMode,D3DDISPLAYROTATION * pRotation)2881 LockSwapChain9Ex_GetDisplayModeEx( struct NineSwapChain9Ex *This,
2882                                    D3DDISPLAYMODEEX *pMode,
2883                                    D3DDISPLAYROTATION *pRotation )
2884 {
2885     HRESULT r;
2886     mtx_lock(&d3dlock_global);
2887     r = NineSwapChain9Ex_GetDisplayModeEx(This, pMode, pRotation);
2888     mtx_unlock(&d3dlock_global);
2889     return r;
2890 }
2891 
2892 IDirect3DSwapChain9ExVtbl LockSwapChain9Ex_vtable = {
2893     (void *)NineUnknown_QueryInterface,
2894     (void *)NineUnknown_AddRef,
2895     (void *)NineUnknown_ReleaseWithDtorLock,
2896     (void *)LockSwapChain9_Present,
2897     (void *)LockSwapChain9_GetFrontBufferData,
2898     (void *)LockSwapChain9_GetBackBuffer,
2899     (void *)LockSwapChain9_GetRasterStatus,
2900     (void *)LockSwapChain9_GetDisplayMode,
2901     (void *)NineUnknown_GetDevice, /* actually part of NineSwapChain9 iface */
2902     (void *)LockSwapChain9_GetPresentParameters,
2903     (void *)LockSwapChain9Ex_GetLastPresentCount,
2904     (void *)LockSwapChain9Ex_GetPresentStats,
2905     (void *)LockSwapChain9Ex_GetDisplayModeEx
2906 };
2907 
2908 #if 0
2909 static HRESULT NINE_WINAPI
2910 LockTexture9_GetLevelDesc( struct NineTexture9 *This,
2911                            UINT Level,
2912                            D3DSURFACE_DESC *pDesc )
2913 {
2914     HRESULT r;
2915     mtx_lock(&d3dlock_global);
2916     r = NineTexture9_GetLevelDesc(This, Level, pDesc);
2917     mtx_unlock(&d3dlock_global);
2918     return r;
2919 }
2920 #endif
2921 
2922 #if 0
2923 static HRESULT NINE_WINAPI
2924 LockTexture9_GetSurfaceLevel( struct NineTexture9 *This,
2925                               UINT Level,
2926                               IDirect3DSurface9 **ppSurfaceLevel )
2927 {
2928     HRESULT r;
2929     mtx_lock(&d3dlock_global);
2930     r = NineTexture9_GetSurfaceLevel(This, Level, ppSurfaceLevel);
2931     mtx_unlock(&d3dlock_global);
2932     return r;
2933 }
2934 #endif
2935 
2936 static HRESULT NINE_WINAPI
LockTexture9_LockRect(struct NineTexture9 * This,UINT Level,D3DLOCKED_RECT * pLockedRect,const RECT * pRect,DWORD Flags)2937 LockTexture9_LockRect( struct NineTexture9 *This,
2938                        UINT Level,
2939                        D3DLOCKED_RECT *pLockedRect,
2940                        const RECT *pRect,
2941                        DWORD Flags )
2942 {
2943     HRESULT r;
2944     mtx_lock(&d3dlock_global);
2945     r = NineTexture9_LockRect(This, Level, pLockedRect, pRect, Flags);
2946     mtx_unlock(&d3dlock_global);
2947     return r;
2948 }
2949 
2950 static HRESULT NINE_WINAPI
LockTexture9_UnlockRect(struct NineTexture9 * This,UINT Level)2951 LockTexture9_UnlockRect( struct NineTexture9 *This,
2952                          UINT Level )
2953 {
2954     HRESULT r;
2955     mtx_lock(&d3dlock_global);
2956     r = NineTexture9_UnlockRect(This, Level);
2957     mtx_unlock(&d3dlock_global);
2958     return r;
2959 }
2960 
2961 static HRESULT NINE_WINAPI
LockTexture9_AddDirtyRect(struct NineTexture9 * This,const RECT * pDirtyRect)2962 LockTexture9_AddDirtyRect( struct NineTexture9 *This,
2963                            const RECT *pDirtyRect )
2964 {
2965     HRESULT r;
2966     mtx_lock(&d3dlock_global);
2967     r = NineTexture9_AddDirtyRect(This, pDirtyRect);
2968     mtx_unlock(&d3dlock_global);
2969     return r;
2970 }
2971 
2972 IDirect3DTexture9Vtbl LockTexture9_vtable = {
2973     (void *)NineUnknown_QueryInterface,
2974     (void *)NineUnknown_AddRef,
2975     (void *)NineUnknown_ReleaseWithDtorLock,
2976     (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
2977     (void *)LockUnknown_SetPrivateData,
2978     (void *)LockUnknown_GetPrivateData,
2979     (void *)LockUnknown_FreePrivateData,
2980     (void *)LockResource9_SetPriority,
2981     (void *)LockResource9_GetPriority,
2982     (void *)LockBaseTexture9_PreLoad,
2983     (void *)NineResource9_GetType, /* immutable */
2984     (void *)LockBaseTexture9_SetLOD,
2985     (void *)LockBaseTexture9_GetLOD,
2986     (void *)LockBaseTexture9_GetLevelCount,
2987     (void *)LockBaseTexture9_SetAutoGenFilterType,
2988     (void *)LockBaseTexture9_GetAutoGenFilterType,
2989     (void *)LockBaseTexture9_GenerateMipSubLevels,
2990     (void *)NineTexture9_GetLevelDesc, /* immutable */
2991     (void *)NineTexture9_GetSurfaceLevel, /* AddRef */
2992     (void *)LockTexture9_LockRect,
2993     (void *)LockTexture9_UnlockRect,
2994     (void *)LockTexture9_AddDirtyRect
2995 };
2996 
2997 static HRESULT NINE_WINAPI
LockVertexBuffer9_Lock(struct NineVertexBuffer9 * This,UINT OffsetToLock,UINT SizeToLock,void ** ppbData,DWORD Flags)2998 LockVertexBuffer9_Lock( struct NineVertexBuffer9 *This,
2999                         UINT OffsetToLock,
3000                         UINT SizeToLock,
3001                         void **ppbData,
3002                         DWORD Flags )
3003 {
3004     HRESULT r;
3005     mtx_lock(&d3dlock_global);
3006     r = NineVertexBuffer9_Lock(This, OffsetToLock, SizeToLock, ppbData, Flags);
3007     mtx_unlock(&d3dlock_global);
3008     return r;
3009 }
3010 
3011 static HRESULT NINE_WINAPI
LockVertexBuffer9_Unlock(struct NineVertexBuffer9 * This)3012 LockVertexBuffer9_Unlock( struct NineVertexBuffer9 *This )
3013 {
3014     HRESULT r;
3015     mtx_lock(&d3dlock_global);
3016     r = NineVertexBuffer9_Unlock(This);
3017     mtx_unlock(&d3dlock_global);
3018     return r;
3019 }
3020 
3021 #if 0
3022 static HRESULT NINE_WINAPI
3023 LockVertexBuffer9_GetDesc( struct NineVertexBuffer9 *This,
3024                            D3DVERTEXBUFFER_DESC *pDesc )
3025 {
3026     HRESULT r;
3027     mtx_lock(&d3dlock_global);
3028     r = NineVertexBuffer9_GetDesc(This, pDesc);
3029     mtx_unlock(&d3dlock_global);
3030     return r;
3031 }
3032 #endif
3033 
3034 IDirect3DVertexBuffer9Vtbl LockVertexBuffer9_vtable = {
3035     (void *)NineUnknown_QueryInterface,
3036     (void *)NineUnknown_AddRef,
3037     (void *)NineUnknown_ReleaseWithDtorLock,
3038     (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
3039     (void *)LockUnknown_SetPrivateData,
3040     (void *)LockUnknown_GetPrivateData,
3041     (void *)LockUnknown_FreePrivateData,
3042     (void *)LockResource9_SetPriority,
3043     (void *)LockResource9_GetPriority,
3044     (void *)NineResource9_PreLoad, /* nop */
3045     (void *)NineResource9_GetType, /* immutable */
3046     (void *)LockVertexBuffer9_Lock,
3047     (void *)LockVertexBuffer9_Unlock,
3048     (void *)NineVertexBuffer9_GetDesc /* immutable */
3049 };
3050 
3051 #if 0
3052 static HRESULT NINE_WINAPI
3053 LockVertexDeclaration9_GetDevice( struct NineVertexDeclaration9 *This,
3054                                   IDirect3DDevice9 **ppDevice )
3055 {
3056     HRESULT r;
3057     mtx_lock(&d3dlock_global);
3058     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
3059     mtx_unlock(&d3dlock_global);
3060     return r;
3061 }
3062 #endif
3063 
3064 static HRESULT NINE_WINAPI
LockVertexDeclaration9_GetDeclaration(struct NineVertexDeclaration9 * This,D3DVERTEXELEMENT9 * pElement,UINT * pNumElements)3065 LockVertexDeclaration9_GetDeclaration( struct NineVertexDeclaration9 *This,
3066                                        D3DVERTEXELEMENT9 *pElement,
3067                                        UINT *pNumElements )
3068 {
3069     HRESULT r;
3070     mtx_lock(&d3dlock_global);
3071     r = NineVertexDeclaration9_GetDeclaration(This, pElement, pNumElements);
3072     mtx_unlock(&d3dlock_global);
3073     return r;
3074 }
3075 
3076 IDirect3DVertexDeclaration9Vtbl LockVertexDeclaration9_vtable = {
3077     (void *)NineUnknown_QueryInterface,
3078     (void *)NineUnknown_AddRef,
3079     (void *)NineUnknown_ReleaseWithDtorLock,
3080     (void *)NineUnknown_GetDevice, /* actually part of VertexDecl9 iface */
3081     (void *)LockVertexDeclaration9_GetDeclaration
3082 };
3083 
3084 #if 0
3085 static HRESULT NINE_WINAPI
3086 LockVertexShader9_GetDevice( struct NineVertexShader9 *This,
3087                              IDirect3DDevice9 **ppDevice )
3088 {
3089     HRESULT r;
3090     mtx_lock(&d3dlock_global);
3091     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
3092     mtx_unlock(&d3dlock_global);
3093     return r;
3094 }
3095 #endif
3096 
3097 static HRESULT NINE_WINAPI
LockVertexShader9_GetFunction(struct NineVertexShader9 * This,void * pData,UINT * pSizeOfData)3098 LockVertexShader9_GetFunction( struct NineVertexShader9 *This,
3099                                void *pData,
3100                                UINT *pSizeOfData )
3101 {
3102     HRESULT r;
3103     mtx_lock(&d3dlock_global);
3104     r = NineVertexShader9_GetFunction(This, pData, pSizeOfData);
3105     mtx_unlock(&d3dlock_global);
3106     return r;
3107 }
3108 
3109 IDirect3DVertexShader9Vtbl LockVertexShader9_vtable = {
3110     (void *)NineUnknown_QueryInterface,
3111     (void *)NineUnknown_AddRef,
3112     (void *)NineUnknown_ReleaseWithDtorLock,
3113     (void *)NineUnknown_GetDevice,
3114     (void *)LockVertexShader9_GetFunction
3115 };
3116 
3117 #if 0
3118 static HRESULT NINE_WINAPI
3119 LockVolume9_GetDevice( struct NineVolume9 *This,
3120                        IDirect3DDevice9 **ppDevice )
3121 {
3122     HRESULT r;
3123     mtx_lock(&d3dlock_global);
3124     r = NineUnknown_GetDevice(NineUnknown(This), ppDevice);
3125     mtx_unlock(&d3dlock_global);
3126     return r;
3127 }
3128 #endif
3129 
3130 static HRESULT NINE_WINAPI
LockVolume9_GetContainer(struct NineVolume9 * This,REFIID riid,void ** ppContainer)3131 LockVolume9_GetContainer( struct NineVolume9 *This,
3132                           REFIID riid,
3133                           void **ppContainer )
3134 {
3135     HRESULT r;
3136     mtx_lock(&d3dlock_global);
3137     r = NineVolume9_GetContainer(This, riid, ppContainer);
3138     mtx_unlock(&d3dlock_global);
3139     return r;
3140 }
3141 
3142 #if 0
3143 static HRESULT NINE_WINAPI
3144 LockVolume9_GetDesc( struct NineVolume9 *This,
3145                      D3DVOLUME_DESC *pDesc )
3146 {
3147     HRESULT r;
3148     mtx_lock(&d3dlock_global);
3149     r = NineVolume9_GetDesc(This, pDesc);
3150     mtx_unlock(&d3dlock_global);
3151     return r;
3152 }
3153 #endif
3154 
3155 static HRESULT NINE_WINAPI
LockVolume9_LockBox(struct NineVolume9 * This,D3DLOCKED_BOX * pLockedVolume,const D3DBOX * pBox,DWORD Flags)3156 LockVolume9_LockBox( struct NineVolume9 *This,
3157                      D3DLOCKED_BOX *pLockedVolume,
3158                      const D3DBOX *pBox,
3159                      DWORD Flags )
3160 {
3161     HRESULT r;
3162     mtx_lock(&d3dlock_global);
3163     r = NineVolume9_LockBox(This, pLockedVolume, pBox, Flags);
3164     mtx_unlock(&d3dlock_global);
3165     return r;
3166 }
3167 
3168 static HRESULT NINE_WINAPI
LockVolume9_UnlockBox(struct NineVolume9 * This)3169 LockVolume9_UnlockBox( struct NineVolume9 *This )
3170 {
3171     HRESULT r;
3172     mtx_lock(&d3dlock_global);
3173     r = NineVolume9_UnlockBox(This);
3174     mtx_unlock(&d3dlock_global);
3175     return r;
3176 }
3177 
3178 IDirect3DVolume9Vtbl LockVolume9_vtable = {
3179     (void *)NineUnknown_QueryInterface,
3180     (void *)NineUnknown_AddRef,
3181     (void *)NineUnknown_ReleaseWithDtorLock,
3182     (void *)NineUnknown_GetDevice, /* actually part of Volume9 iface */
3183     (void *)NineUnknown_SetPrivateData,
3184     (void *)NineUnknown_GetPrivateData,
3185     (void *)NineUnknown_FreePrivateData,
3186     (void *)LockVolume9_GetContainer,
3187     (void *)NineVolume9_GetDesc, /* immutable */
3188     (void *)LockVolume9_LockBox,
3189     (void *)LockVolume9_UnlockBox
3190 };
3191 
3192 #if 0
3193 static HRESULT NINE_WINAPI
3194 LockVolumeTexture9_GetLevelDesc( struct NineVolumeTexture9 *This,
3195                                  UINT Level,
3196                                  D3DVOLUME_DESC *pDesc )
3197 {
3198     HRESULT r;
3199     mtx_lock(&d3dlock_global);
3200     r = NineVolumeTexture9_GetLevelDesc(This, Level, pDesc);
3201     mtx_unlock(&d3dlock_global);
3202     return r;
3203 }
3204 #endif
3205 
3206 #if 0
3207 static HRESULT NINE_WINAPI
3208 LockVolumeTexture9_GetVolumeLevel( struct NineVolumeTexture9 *This,
3209                                    UINT Level,
3210                                    IDirect3DVolume9 **ppVolumeLevel )
3211 {
3212     HRESULT r;
3213     mtx_lock(&d3dlock_global);
3214     r = NineVolumeTexture9_GetVolumeLevel(This, Level, ppVolumeLevel);
3215     mtx_unlock(&d3dlock_global);
3216     return r;
3217 }
3218 #endif
3219 
3220 static HRESULT NINE_WINAPI
LockVolumeTexture9_LockBox(struct NineVolumeTexture9 * This,UINT Level,D3DLOCKED_BOX * pLockedVolume,const D3DBOX * pBox,DWORD Flags)3221 LockVolumeTexture9_LockBox( struct NineVolumeTexture9 *This,
3222                             UINT Level,
3223                             D3DLOCKED_BOX *pLockedVolume,
3224                             const D3DBOX *pBox,
3225                             DWORD Flags )
3226 {
3227     HRESULT r;
3228     mtx_lock(&d3dlock_global);
3229     r = NineVolumeTexture9_LockBox(This, Level, pLockedVolume, pBox, Flags);
3230     mtx_unlock(&d3dlock_global);
3231     return r;
3232 }
3233 
3234 static HRESULT NINE_WINAPI
LockVolumeTexture9_UnlockBox(struct NineVolumeTexture9 * This,UINT Level)3235 LockVolumeTexture9_UnlockBox( struct NineVolumeTexture9 *This,
3236                               UINT Level )
3237 {
3238     HRESULT r;
3239     mtx_lock(&d3dlock_global);
3240     r = NineVolumeTexture9_UnlockBox(This, Level);
3241     mtx_unlock(&d3dlock_global);
3242     return r;
3243 }
3244 
3245 static HRESULT NINE_WINAPI
LockVolumeTexture9_AddDirtyBox(struct NineVolumeTexture9 * This,const D3DBOX * pDirtyBox)3246 LockVolumeTexture9_AddDirtyBox( struct NineVolumeTexture9 *This,
3247                                 const D3DBOX *pDirtyBox )
3248 {
3249     HRESULT r;
3250     mtx_lock(&d3dlock_global);
3251     r = NineVolumeTexture9_AddDirtyBox(This, pDirtyBox);
3252     mtx_unlock(&d3dlock_global);
3253     return r;
3254 }
3255 
3256 IDirect3DVolumeTexture9Vtbl LockVolumeTexture9_vtable = {
3257     (void *)NineUnknown_QueryInterface,
3258     (void *)NineUnknown_AddRef,
3259     (void *)NineUnknown_ReleaseWithDtorLock,
3260     (void *)NineUnknown_GetDevice, /* actually part of Resource9 iface */
3261     (void *)LockUnknown_SetPrivateData,
3262     (void *)LockUnknown_GetPrivateData,
3263     (void *)LockUnknown_FreePrivateData,
3264     (void *)LockResource9_SetPriority,
3265     (void *)LockResource9_GetPriority,
3266     (void *)LockBaseTexture9_PreLoad,
3267     (void *)NineResource9_GetType, /* immutable */
3268     (void *)LockBaseTexture9_SetLOD,
3269     (void *)LockBaseTexture9_GetLOD,
3270     (void *)LockBaseTexture9_GetLevelCount,
3271     (void *)LockBaseTexture9_SetAutoGenFilterType,
3272     (void *)LockBaseTexture9_GetAutoGenFilterType,
3273     (void *)LockBaseTexture9_GenerateMipSubLevels,
3274     (void *)NineVolumeTexture9_GetLevelDesc, /* immutable */
3275     (void *)NineVolumeTexture9_GetVolumeLevel, /* AddRef */
3276     (void *)LockVolumeTexture9_LockBox,
3277     (void *)LockVolumeTexture9_UnlockBox,
3278     (void *)LockVolumeTexture9_AddDirtyBox
3279 };
3280 
3281 ID3DAdapter9Vtbl LockAdapter9_vtable = { /* not used */
3282     (void *)NULL,
3283     (void *)NULL,
3284     (void *)NULL,
3285     (void *)NULL,
3286     (void *)NULL,
3287     (void *)NULL,
3288     (void *)NULL,
3289     (void *)NULL,
3290     (void *)NULL,
3291     (void *)NULL,
3292     (void *)NULL,
3293     (void *)NULL
3294 };
3295