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