Changeset 23571 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8
- Timestamp:
- Oct 6, 2009 6:07:06 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 53228
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/cubetexture.c
r21731 r23571 56 56 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 57 57 58 if (ref == 1) 59 { 60 IUnknown_AddRef(This->parentDevice); 61 wined3d_mutex_lock(); 62 IWineD3DCubeTexture_AddRef(This->wineD3DCubeTexture); 63 wined3d_mutex_unlock(); 64 } 65 58 66 return ref; 59 67 } … … 67 75 if (ref == 0) { 68 76 TRACE("Releasing child %p\n", This->wineD3DCubeTexture); 69 EnterCriticalSection(&d3d8_cs); 70 IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D8CB_DestroySurface); 71 LeaveCriticalSection(&d3d8_cs); 77 72 78 IUnknown_Release(This->parentDevice); 73 HeapFree(GetProcessHeap(), 0, This); 79 wined3d_mutex_lock(); 80 IWineD3DCubeTexture_Release(This->wineD3DCubeTexture); 81 wined3d_mutex_unlock(); 74 82 } 75 83 return ref; … … 83 91 TRACE("(%p) Relay\n" , This); 84 92 85 EnterCriticalSection(&d3d8_cs);93 wined3d_mutex_lock(); 86 94 hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device); 87 95 if (SUCCEEDED(hr)) … … 90 98 IWineD3DDevice_Release(wined3d_device); 91 99 } 92 LeaveCriticalSection(&d3d8_cs); 100 wined3d_mutex_unlock(); 101 93 102 return hr; 94 103 } … … 99 108 TRACE("(%p) Relay\n", This); 100 109 101 EnterCriticalSection(&d3d8_cs);110 wined3d_mutex_lock(); 102 111 hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags); 103 LeaveCriticalSection(&d3d8_cs); 112 wined3d_mutex_unlock(); 113 104 114 return hr; 105 115 } … … 110 120 TRACE("(%p) Relay\n", This); 111 121 112 EnterCriticalSection(&d3d8_cs);122 wined3d_mutex_lock(); 113 123 hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData); 114 LeaveCriticalSection(&d3d8_cs); 124 wined3d_mutex_unlock(); 125 115 126 return hr; 116 127 } … … 121 132 TRACE("(%p) Relay\n", This); 122 133 123 EnterCriticalSection(&d3d8_cs);134 wined3d_mutex_lock(); 124 135 hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid); 125 LeaveCriticalSection(&d3d8_cs); 136 wined3d_mutex_unlock(); 137 126 138 return hr; 127 139 } … … 132 144 TRACE("(%p) Relay\n", This); 133 145 134 EnterCriticalSection(&d3d8_cs);146 wined3d_mutex_lock(); 135 147 ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew); 136 LeaveCriticalSection(&d3d8_cs); 148 wined3d_mutex_unlock(); 149 137 150 return ret; 138 151 } … … 143 156 TRACE("(%p) Relay\n", This); 144 157 145 EnterCriticalSection(&d3d8_cs);158 wined3d_mutex_lock(); 146 159 ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture); 147 LeaveCriticalSection(&d3d8_cs); 160 wined3d_mutex_unlock(); 161 148 162 return ret; 149 163 } … … 153 167 TRACE("(%p) Relay\n", This); 154 168 155 EnterCriticalSection(&d3d8_cs);169 wined3d_mutex_lock(); 156 170 IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture); 157 LeaveCriticalSection(&d3d8_cs);171 wined3d_mutex_unlock(); 158 172 } 159 173 … … 163 177 TRACE("(%p) Relay\n", This); 164 178 165 EnterCriticalSection(&d3d8_cs);179 wined3d_mutex_lock(); 166 180 type = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture); 167 LeaveCriticalSection(&d3d8_cs); 181 wined3d_mutex_unlock(); 182 168 183 return type; 169 184 } … … 175 190 TRACE("(%p) Relay\n", This); 176 191 177 EnterCriticalSection(&d3d8_cs);192 wined3d_mutex_lock(); 178 193 lod = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew); 179 LeaveCriticalSection(&d3d8_cs); 194 wined3d_mutex_unlock(); 195 180 196 return lod; 181 197 } … … 186 202 TRACE("(%p) Relay\n", This); 187 203 188 EnterCriticalSection(&d3d8_cs);204 wined3d_mutex_lock(); 189 205 lod = IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This); 190 LeaveCriticalSection(&d3d8_cs); 206 wined3d_mutex_unlock(); 207 191 208 return lod; 192 209 } … … 197 214 TRACE("(%p) Relay\n", This); 198 215 199 EnterCriticalSection(&d3d8_cs);216 wined3d_mutex_lock(); 200 217 cnt = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture); 201 LeaveCriticalSection(&d3d8_cs); 218 wined3d_mutex_unlock(); 219 202 220 return cnt; 203 221 } … … 211 229 TRACE("(%p) Relay\n", This); 212 230 213 EnterCriticalSection(&d3d8_cs);231 wined3d_mutex_lock(); 214 232 hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc); 215 LeaveCriticalSection(&d3d8_cs);233 wined3d_mutex_unlock(); 216 234 217 235 if (SUCCEEDED(hr)) … … 237 255 TRACE("(%p) Relay\n", This); 238 256 239 EnterCriticalSection(&d3d8_cs);257 wined3d_mutex_lock(); 240 258 hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface); 241 259 if (hrc == D3D_OK && NULL != ppCubeMapSurface) { … … 243 261 IWineD3DCubeTexture_Release(mySurface); 244 262 } 245 LeaveCriticalSection(&d3d8_cs); 263 wined3d_mutex_unlock(); 264 246 265 return hrc; 247 266 } … … 252 271 TRACE("(%p) Relay\n", This); 253 272 254 EnterCriticalSection(&d3d8_cs);273 wined3d_mutex_lock(); 255 274 hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags); 256 LeaveCriticalSection(&d3d8_cs); 275 wined3d_mutex_unlock(); 276 257 277 return hr; 258 278 } … … 263 283 TRACE("(%p) Relay\n", This); 264 284 265 EnterCriticalSection(&d3d8_cs);285 wined3d_mutex_lock(); 266 286 hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level); 267 LeaveCriticalSection(&d3d8_cs); 287 wined3d_mutex_unlock(); 288 268 289 return hr; 269 290 } … … 274 295 TRACE("(%p) Relay\n", This); 275 296 276 EnterCriticalSection(&d3d8_cs);297 wined3d_mutex_lock(); 277 298 hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect); 278 LeaveCriticalSection(&d3d8_cs);279 return hr; 280 } 281 282 283 const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =299 wined3d_mutex_unlock(); 300 301 return hr; 302 } 303 304 static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl = 284 305 { 285 306 /* IUnknown */ … … 307 328 IDirect3DCubeTexture8Impl_AddDirtyRect 308 329 }; 330 331 static void STDMETHODCALLTYPE d3d8_cubetexture_wined3d_object_destroyed(void *parent) 332 { 333 HeapFree(GetProcessHeap(), 0, parent); 334 } 335 336 static const struct wined3d_parent_ops d3d8_cubetexture_wined3d_parent_ops = 337 { 338 d3d8_cubetexture_wined3d_object_destroyed, 339 }; 340 341 HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device, 342 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) 343 { 344 HRESULT hr; 345 346 texture->lpVtbl = &Direct3DCubeTexture8_Vtbl; 347 texture->ref = 1; 348 349 wined3d_mutex_lock(); 350 hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage & WINED3DUSAGE_MASK, 351 wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, 352 (IUnknown *)texture, &d3d8_cubetexture_wined3d_parent_ops); 353 wined3d_mutex_unlock(); 354 if (FAILED(hr)) 355 { 356 WARN("Failed to create wined3d cube texture, hr %#x.\n", hr); 357 return hr; 358 } 359 360 texture->parentDevice = (IDirect3DDevice8 *)device; 361 IDirect3DDevice8_AddRef(texture->parentDevice); 362 363 return D3D_OK; 364 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_main.c
r16477 r23571 34 34 #include "wine/debug.h" 35 35 36 static CRITICAL_SECTION_DEBUG d3d8_cs_debug =37 {38 0, 0, &d3d8_cs,39 { &d3d8_cs_debug.ProcessLocksList,40 &d3d8_cs_debug.ProcessLocksList },41 0, 0, { (DWORD_PTR)(__FILE__ ": d3d8_cs") }42 };43 CRITICAL_SECTION d3d8_cs = { &d3d8_cs_debug, -1, 0, 0, 0, 0 };44 45 36 WINE_DEFAULT_DEBUG_CHANNEL(d3d8); 46 37 … … 58 49 TRACE("SDKVersion = %x\n", SDKVersion); 59 50 60 EnterCriticalSection(&d3d8_cs); 51 wined3d_mutex_lock(); 52 61 53 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl)); 62 54 … … 66 58 67 59 TRACE("Created Direct3D object @ %p, WineObj @ %p\n", object, object->WineD3D); 68 LeaveCriticalSection(&d3d8_cs); 60 61 wined3d_mutex_unlock(); 69 62 70 63 if (!object->WineD3D) … … 87 80 88 81 /*********************************************************************** 89 * 82 * ValidateVertexShader (D3D8.@) 90 83 * 91 84 * I've seen reserved1 and reserved2 always passed as 0's 92 * bool seems always passed as 0 or 1, but other values work as well... .85 * bool seems always passed as 0 or 1, but other values work as well... 93 86 * toto result? 94 87 */ 95 88 HRESULT WINAPI ValidateVertexShader(DWORD* vertexshader, DWORD* reserved1, DWORD* reserved2, BOOL bool, DWORD* toto) 96 { 89 { 97 90 HRESULT ret; 98 91 FIXME("(%p %p %p %d %p): stub\n", vertexshader, reserved1, reserved2, bool, toto); … … 106 99 switch(*vertexshader) { 107 100 case 0xFFFE0101: 108 case 0xFFFE0100: 101 case 0xFFFE0100: 109 102 ret=S_OK; 110 103 break; … … 118 111 119 112 /*********************************************************************** 120 * 113 * ValidatePixelShader (D3D8.@) 121 114 * 122 115 * PARAMS … … 127 120 HRESULT ret; 128 121 FIXME("(%p %p %d %p): stub\n", pixelshader, reserved1, bool, toto); 129 122 130 123 if (!pixelshader) 131 124 return E_FAIL; 132 125 133 126 if (reserved1) 134 return E_FAIL; 127 return E_FAIL; 135 128 136 129 switch(*pixelshader) { -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/d3d8_private.h
r22496 r23571 107 107 _pD3D8Caps->MaxPixelShaderValue = _pWineCaps->PixelShader1xMaxValue; 108 108 109 void fixup_caps(WINED3DCAPS *pWineCaps) ;109 void fixup_caps(WINED3DCAPS *pWineCaps) DECLSPEC_HIDDEN; 110 110 111 111 /* Direct3D8 Interfaces: */ … … 132 132 typedef struct IDirect3DVertexShader8Impl IDirect3DVertexShader8Impl; 133 133 134 /* Global critical section */135 extern CRITICAL_SECTION d3d8_cs;136 137 134 /* =========================================================================== 138 135 The interfaces themselves … … 146 143 * Predeclare the interface implementation structures 147 144 */ 148 extern const IDirect3D8Vtbl Direct3D8_Vtbl ;145 extern const IDirect3D8Vtbl Direct3D8_Vtbl DECLSPEC_HIDDEN; 149 146 150 147 /***************************************************************************** … … 168 165 * Predeclare the interface implementation structures 169 166 */ 170 extern const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl ;171 extern const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl ;167 extern const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl DECLSPEC_HIDDEN; 168 extern const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl DECLSPEC_HIDDEN; 172 169 173 170 /***************************************************************************** … … 231 228 * IDirect3DVolume8 implementation structure 232 229 */ 233 extern const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl;234 230 struct IDirect3DVolume8Impl 235 231 { … … 247 243 IUnknown *forwardReference; 248 244 }; 245 246 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height, 247 UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool) DECLSPEC_HIDDEN; 249 248 250 249 /* ------------------- */ … … 255 254 * Predeclare the interface implementation structures 256 255 */ 257 extern const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl ;256 extern const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl DECLSPEC_HIDDEN; 258 257 259 258 /***************************************************************************** … … 278 277 279 278 /***************************************************************************** 280 * Predeclare the interface implementation structures281 */282 extern const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl;283 284 /*****************************************************************************285 279 * IDirect3DSurface8 implementation structure 286 280 */ … … 302 296 /* If set forward refcounting to this object */ 303 297 IUnknown *forwardReference; 304 305 /* Flags an implicit surface */ 306 BOOL isImplicit; 307 }; 298 }; 299 300 HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *device, 301 UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, 302 DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN; 308 303 309 304 /* ------------------ */ … … 314 309 * Predeclare the interface implementation structures 315 310 */ 316 extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl ;311 extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl DECLSPEC_HIDDEN; 317 312 318 313 /***************************************************************************** … … 334 329 335 330 /***************************************************************************** 336 * Predeclare the interface implementation structures337 */338 extern const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl;339 340 /*****************************************************************************341 331 * IDirect3DVertexBuffer8 implementation structure 342 332 */ … … 355 345 DWORD fvf; 356 346 }; 347 348 HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Impl *device, 349 UINT size, DWORD usage, DWORD fvf, D3DPOOL pool) DECLSPEC_HIDDEN; 357 350 358 351 /* --------------------- */ … … 361 354 362 355 /***************************************************************************** 363 * Predeclare the interface implementation structures364 */365 extern const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl;366 367 /*****************************************************************************368 356 * IDirect3DIndexBuffer8 implementation structure 369 357 */ … … 382 370 WINED3DFORMAT format; 383 371 }; 372 373 HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl *device, 374 UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; 384 375 385 376 /* --------------------- */ … … 405 396 406 397 /***************************************************************************** 407 * Predeclare the interface implementation structures408 */409 extern const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl;410 411 /*****************************************************************************412 398 * IDirect3DCubeTexture8 implementation structure 413 399 */ … … 424 410 LPDIRECT3DDEVICE8 parentDevice; 425 411 }; 412 413 HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device, 414 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; 426 415 427 416 /* ----------------- */ … … 430 419 431 420 /***************************************************************************** 432 * Predeclare the interface implementation structures433 */434 extern const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl;435 436 /*****************************************************************************437 421 * IDirect3DTexture8 implementation structure 438 422 */ … … 449 433 LPDIRECT3DDEVICE8 parentDevice; 450 434 }; 435 436 HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *device, 437 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; 451 438 452 439 /* ----------------------- */ … … 455 442 456 443 /***************************************************************************** 457 * Predeclare the interface implementation structures458 */459 extern const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl;460 461 /*****************************************************************************462 444 * IDirect3DVolumeTexture8 implementation structure 463 445 */ … … 474 456 LPDIRECT3DDEVICE8 parentDevice; 475 457 }; 458 459 HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device, 460 UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; 476 461 477 462 /* ----------------------- */ … … 481 466 /* TODO: Generate a valid GUIDs */ 482 467 /* {83B073CE-6F30-11d9-C687-00046142C14F} */ 483 DEFINE_GUID(IID_IDirect3DStateBlock8, 468 DEFINE_GUID(IID_IDirect3DStateBlock8, 484 469 0x83b073ce, 0x6f30, 0x11d9, 0xc6, 0x87, 0x0, 0x4, 0x61, 0x42, 0xc1, 0x4f); 485 470 … … 523 508 * Predeclare the interface implementation structures 524 509 */ 525 extern const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl ;510 extern const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl DECLSPEC_HIDDEN; 526 511 527 512 /***************************************************************************** … … 555 540 #define IDirect3DVertexDeclaration8_Release(p) (p)->lpVtbl->Release(p) 556 541 557 /*** Implementation ***/558 extern const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl;559 560 542 typedef struct { 561 543 const IDirect3DVertexDeclaration8Vtbl *lpVtbl; … … 569 551 } IDirect3DVertexDeclaration8Impl; 570 552 553 HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration8Impl *declaration, 554 IDirect3DDevice8Impl *device, const DWORD *elements, DWORD shader_handle) DECLSPEC_HIDDEN; 555 HRESULT vertexdeclaration_init_fvf(IDirect3DVertexDeclaration8Impl *declaration, 556 IDirect3DDevice8Impl *device, DWORD fvf) DECLSPEC_HIDDEN; 571 557 572 558 /***************************************************************************** … … 611 597 612 598 /***************************************************************************** 613 * Predeclare the interface implementation structures614 */615 extern const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl;616 617 /*****************************************************************************618 599 * IDirect3DVertexShader implementation structure 619 600 */ … … 627 608 }; 628 609 610 HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device, 611 const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage) DECLSPEC_HIDDEN; 612 629 613 #define D3D8_MAX_VERTEX_SHADER_CONSTANTF 256 630 631 632 /* ------------------------ */633 /* IDirect3DPixelShaderImpl */634 /* ------------------------ */635 636 637 /*****************************************************************************638 * Predeclare the interface implementation structures639 */640 extern const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl;641 614 642 615 /***************************************************************************** … … 650 623 IWineD3DPixelShader *wineD3DPixelShader; 651 624 } IDirect3DPixelShader8Impl; 625 626 HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device, 627 const DWORD *byte_code, DWORD shader_handle) DECLSPEC_HIDDEN; 652 628 653 629 /** … … 656 632 * to see how not defined it here 657 633 */ 658 D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format); 659 WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format); 660 void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader); 661 UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, WINED3DVERTEXELEMENT **wined3d_elements); 662 size_t parse_token(const DWORD* pToken); 634 D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format) DECLSPEC_HIDDEN; 635 WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; 636 void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader) DECLSPEC_HIDDEN; 637 UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, 638 WINED3DVERTEXELEMENT **wined3d_elements) DECLSPEC_HIDDEN; 639 size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN; 663 640 664 641 /* Callbacks */ 665 extern ULONG WINAPI D3D8CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain); 666 extern ULONG WINAPI D3D8CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface); 667 extern ULONG WINAPI D3D8CB_DestroyRenderTarget (IWineD3DSurface *pSurface); 668 extern ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface); 669 extern ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume); 642 extern ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) DECLSPEC_HIDDEN; 670 643 671 644 #endif /* __WINE_D3DX8_PRIVATE_H */ -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/device.c
r22496 r23571 56 56 { 57 57 case WINED3DFMT_UNKNOWN: return D3DFMT_UNKNOWN; 58 case WINED3DFMT_ R8G8B8: return D3DFMT_R8G8B8;59 case WINED3DFMT_ A8R8G8B8: return D3DFMT_A8R8G8B8;60 case WINED3DFMT_ X8R8G8B8: return D3DFMT_X8R8G8B8;61 case WINED3DFMT_ R5G6B5: return D3DFMT_R5G6B5;62 case WINED3DFMT_ X1R5G5B5: return D3DFMT_X1R5G5B5;63 case WINED3DFMT_ A1R5G5B5: return D3DFMT_A1R5G5B5;64 case WINED3DFMT_ A4R4G4B4: return D3DFMT_A4R4G4B4;65 case WINED3DFMT_ R3G3B2: return D3DFMT_R3G3B2;58 case WINED3DFMT_B8G8R8_UNORM: return D3DFMT_R8G8B8; 59 case WINED3DFMT_B8G8R8A8_UNORM: return D3DFMT_A8R8G8B8; 60 case WINED3DFMT_B8G8R8X8_UNORM: return D3DFMT_X8R8G8B8; 61 case WINED3DFMT_B5G6R5_UNORM: return D3DFMT_R5G6B5; 62 case WINED3DFMT_B5G5R5X1_UNORM: return D3DFMT_X1R5G5B5; 63 case WINED3DFMT_B5G5R5A1_UNORM: return D3DFMT_A1R5G5B5; 64 case WINED3DFMT_B4G4R4A4_UNORM: return D3DFMT_A4R4G4B4; 65 case WINED3DFMT_B2G3R3_UNORM: return D3DFMT_R3G3B2; 66 66 case WINED3DFMT_A8_UNORM: return D3DFMT_A8; 67 case WINED3DFMT_ A8R3G3B2: return D3DFMT_A8R3G3B2;68 case WINED3DFMT_ X4R4G4B4: return D3DFMT_X4R4G4B4;67 case WINED3DFMT_B2G3R3A8_UNORM: return D3DFMT_A8R3G3B2; 68 case WINED3DFMT_B4G4R4X4_UNORM: return D3DFMT_X4R4G4B4; 69 69 case WINED3DFMT_R10G10B10A2_UNORM: return D3DFMT_A2B10G10R10; 70 70 case WINED3DFMT_R16G16_UNORM: return D3DFMT_G16R16; 71 case WINED3DFMT_ A8P8: return D3DFMT_A8P8;72 case WINED3DFMT_P8 : return D3DFMT_P8;73 case WINED3DFMT_L8 : return D3DFMT_L8;74 case WINED3DFMT_ A8L8: return D3DFMT_A8L8;75 case WINED3DFMT_ A4L4: return D3DFMT_A4L4;71 case WINED3DFMT_P8_UINT_A8_UNORM: return D3DFMT_A8P8; 72 case WINED3DFMT_P8_UINT: return D3DFMT_P8; 73 case WINED3DFMT_L8_UNORM: return D3DFMT_L8; 74 case WINED3DFMT_L8A8_UNORM: return D3DFMT_A8L8; 75 case WINED3DFMT_L4A4_UNORM: return D3DFMT_A4L4; 76 76 case WINED3DFMT_R8G8_SNORM: return D3DFMT_V8U8; 77 case WINED3DFMT_ L6V5U5: return D3DFMT_L6V5U5;78 case WINED3DFMT_ X8L8V8U8: return D3DFMT_X8L8V8U8;77 case WINED3DFMT_R5G5_SNORM_L6_UNORM: return D3DFMT_L6V5U5; 78 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM: return D3DFMT_X8L8V8U8; 79 79 case WINED3DFMT_R8G8B8A8_SNORM: return D3DFMT_Q8W8V8U8; 80 80 case WINED3DFMT_R16G16_SNORM: return D3DFMT_V16U16; 81 case WINED3DFMT_ W11V11U10: return D3DFMT_W11V11U10;82 case WINED3DFMT_ A2W10V10U10: return D3DFMT_A2W10V10U10;81 case WINED3DFMT_R10G11B11_SNORM: return D3DFMT_W11V11U10; 82 case WINED3DFMT_R10G10B10_SNORM_A2_UNORM: return D3DFMT_A2W10V10U10; 83 83 case WINED3DFMT_D16_LOCKABLE: return D3DFMT_D16_LOCKABLE; 84 case WINED3DFMT_D32 : return D3DFMT_D32;85 case WINED3DFMT_ D15S1: return D3DFMT_D15S1;86 case WINED3DFMT_ D24S8: return D3DFMT_D24S8;87 case WINED3DFMT_ D24X8: return D3DFMT_D24X8;88 case WINED3DFMT_ D24X4S4: return D3DFMT_D24X4S4;84 case WINED3DFMT_D32_UNORM: return D3DFMT_D32; 85 case WINED3DFMT_S1_UINT_D15_UNORM: return D3DFMT_D15S1; 86 case WINED3DFMT_S8_UINT_D24_UNORM: return D3DFMT_D24S8; 87 case WINED3DFMT_X8D24_UNORM: return D3DFMT_D24X8; 88 case WINED3DFMT_S4X4_UINT_D24_UNORM: return D3DFMT_D24X4S4; 89 89 case WINED3DFMT_D16_UNORM: return D3DFMT_D16; 90 90 case WINED3DFMT_VERTEXDATA: return D3DFMT_VERTEXDATA; … … 107 107 { 108 108 case D3DFMT_UNKNOWN: return WINED3DFMT_UNKNOWN; 109 case D3DFMT_R8G8B8: return WINED3DFMT_ R8G8B8;110 case D3DFMT_A8R8G8B8: return WINED3DFMT_ A8R8G8B8;111 case D3DFMT_X8R8G8B8: return WINED3DFMT_ X8R8G8B8;112 case D3DFMT_R5G6B5: return WINED3DFMT_ R5G6B5;113 case D3DFMT_X1R5G5B5: return WINED3DFMT_ X1R5G5B5;114 case D3DFMT_A1R5G5B5: return WINED3DFMT_ A1R5G5B5;115 case D3DFMT_A4R4G4B4: return WINED3DFMT_ A4R4G4B4;116 case D3DFMT_R3G3B2: return WINED3DFMT_ R3G3B2;109 case D3DFMT_R8G8B8: return WINED3DFMT_B8G8R8_UNORM; 110 case D3DFMT_A8R8G8B8: return WINED3DFMT_B8G8R8A8_UNORM; 111 case D3DFMT_X8R8G8B8: return WINED3DFMT_B8G8R8X8_UNORM; 112 case D3DFMT_R5G6B5: return WINED3DFMT_B5G6R5_UNORM; 113 case D3DFMT_X1R5G5B5: return WINED3DFMT_B5G5R5X1_UNORM; 114 case D3DFMT_A1R5G5B5: return WINED3DFMT_B5G5R5A1_UNORM; 115 case D3DFMT_A4R4G4B4: return WINED3DFMT_B4G4R4A4_UNORM; 116 case D3DFMT_R3G3B2: return WINED3DFMT_B2G3R3_UNORM; 117 117 case D3DFMT_A8: return WINED3DFMT_A8_UNORM; 118 case D3DFMT_A8R3G3B2: return WINED3DFMT_ A8R3G3B2;119 case D3DFMT_X4R4G4B4: return WINED3DFMT_ X4R4G4B4;118 case D3DFMT_A8R3G3B2: return WINED3DFMT_B2G3R3A8_UNORM; 119 case D3DFMT_X4R4G4B4: return WINED3DFMT_B4G4R4X4_UNORM; 120 120 case D3DFMT_A2B10G10R10: return WINED3DFMT_R10G10B10A2_UNORM; 121 121 case D3DFMT_G16R16: return WINED3DFMT_R16G16_UNORM; 122 case D3DFMT_A8P8: return WINED3DFMT_ A8P8;123 case D3DFMT_P8: return WINED3DFMT_P8 ;124 case D3DFMT_L8: return WINED3DFMT_L8 ;125 case D3DFMT_A8L8: return WINED3DFMT_ A8L8;126 case D3DFMT_A4L4: return WINED3DFMT_ A4L4;122 case D3DFMT_A8P8: return WINED3DFMT_P8_UINT_A8_UNORM; 123 case D3DFMT_P8: return WINED3DFMT_P8_UINT; 124 case D3DFMT_L8: return WINED3DFMT_L8_UNORM; 125 case D3DFMT_A8L8: return WINED3DFMT_L8A8_UNORM; 126 case D3DFMT_A4L4: return WINED3DFMT_L4A4_UNORM; 127 127 case D3DFMT_V8U8: return WINED3DFMT_R8G8_SNORM; 128 case D3DFMT_L6V5U5: return WINED3DFMT_ L6V5U5;129 case D3DFMT_X8L8V8U8: return WINED3DFMT_ X8L8V8U8;128 case D3DFMT_L6V5U5: return WINED3DFMT_R5G5_SNORM_L6_UNORM; 129 case D3DFMT_X8L8V8U8: return WINED3DFMT_R8G8_SNORM_L8X8_UNORM; 130 130 case D3DFMT_Q8W8V8U8: return WINED3DFMT_R8G8B8A8_SNORM; 131 131 case D3DFMT_V16U16: return WINED3DFMT_R16G16_SNORM; 132 case D3DFMT_W11V11U10: return WINED3DFMT_ W11V11U10;133 case D3DFMT_A2W10V10U10: return WINED3DFMT_ A2W10V10U10;132 case D3DFMT_W11V11U10: return WINED3DFMT_R10G11B11_SNORM; 133 case D3DFMT_A2W10V10U10: return WINED3DFMT_R10G10B10_SNORM_A2_UNORM; 134 134 case D3DFMT_D16_LOCKABLE: return WINED3DFMT_D16_LOCKABLE; 135 case D3DFMT_D32: return WINED3DFMT_D32 ;136 case D3DFMT_D15S1: return WINED3DFMT_ D15S1;137 case D3DFMT_D24S8: return WINED3DFMT_ D24S8;138 case D3DFMT_D24X8: return WINED3DFMT_ D24X8;139 case D3DFMT_D24X4S4: return WINED3DFMT_ D24X4S4;135 case D3DFMT_D32: return WINED3DFMT_D32_UNORM; 136 case D3DFMT_D15S1: return WINED3DFMT_S1_UINT_D15_UNORM; 137 case D3DFMT_D24S8: return WINED3DFMT_S8_UINT_D24_UNORM; 138 case D3DFMT_D24X8: return WINED3DFMT_X8D24_UNORM; 139 case D3DFMT_D24X4S4: return WINED3DFMT_S4X4_UINT_D24_UNORM; 140 140 case D3DFMT_D16: return WINED3DFMT_D16_UNORM; 141 141 case D3DFMT_VERTEXDATA: return WINED3DFMT_VERTEXDATA; … … 309 309 310 310 TRACE("Releasing wined3d device %p\n", This->WineD3DDevice); 311 EnterCriticalSection(&d3d8_cs); 311 312 wined3d_mutex_lock(); 313 312 314 This->inDestruction = TRUE; 313 315 … … 317 319 HeapFree(GetProcessHeap(), 0, This->decls); 318 320 319 IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_Destroy DepthStencilSurface, D3D8CB_DestroySwapChain);321 IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroySwapChain); 320 322 IWineD3DDevice_Release(This->WineD3DDevice); 321 323 HeapFree(GetProcessHeap(), 0, This->handle_table.entries); 322 324 HeapFree(GetProcessHeap(), 0, This); 323 LeaveCriticalSection(&d3d8_cs); 325 326 wined3d_mutex_unlock(); 324 327 } 325 328 return ref; … … 332 335 333 336 TRACE("(%p) : Relay\n", This); 334 EnterCriticalSection(&d3d8_cs); 337 338 wined3d_mutex_lock(); 335 339 hr = IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice); 336 LeaveCriticalSection(&d3d8_cs); 340 wined3d_mutex_unlock(); 341 337 342 return hr; 338 343 } … … 343 348 344 349 TRACE("(%p) Relay\n", This); 345 EnterCriticalSection(&d3d8_cs); 350 351 wined3d_mutex_lock(); 346 352 hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice); 347 LeaveCriticalSection(&d3d8_cs); 353 wined3d_mutex_unlock(); 354 348 355 return hr; 349 356 } … … 354 361 355 362 TRACE("(%p) : Relay bytes(%d)\n", This, Bytes); 356 EnterCriticalSection(&d3d8_cs); 363 364 wined3d_mutex_lock(); 357 365 hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice); 358 LeaveCriticalSection(&d3d8_cs); 366 wined3d_mutex_unlock(); 367 359 368 return hr; 360 369 } … … 371 380 } 372 381 373 EnterCriticalSection(&d3d8_cs);382 wined3d_mutex_lock(); 374 383 hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D); 375 384 if (hr == D3D_OK && pWineD3D != NULL) … … 381 390 *ppD3D8 = NULL; 382 391 } 392 wined3d_mutex_unlock(); 393 383 394 TRACE("(%p) returning %p\n",This , *ppD3D8); 384 LeaveCriticalSection(&d3d8_cs);385 395 386 396 return hr; … … 401 411 } 402 412 403 EnterCriticalSection(&d3d8_cs);413 wined3d_mutex_lock(); 404 414 hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps); 405 LeaveCriticalSection(&d3d8_cs); 415 wined3d_mutex_unlock(); 416 406 417 fixup_caps(pWineCaps); 407 418 WINECAPSTOD3D8CAPS(pCaps, pWineCaps) … … 417 428 TRACE("(%p) Relay\n", This); 418 429 419 EnterCriticalSection(&d3d8_cs);430 wined3d_mutex_lock(); 420 431 hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode); 421 LeaveCriticalSection(&d3d8_cs);432 wined3d_mutex_unlock(); 422 433 423 434 if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format); … … 431 442 TRACE("(%p) Relay\n", This); 432 443 433 EnterCriticalSection(&d3d8_cs);444 wined3d_mutex_lock(); 434 445 hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters); 435 LeaveCriticalSection(&d3d8_cs); 446 wined3d_mutex_unlock(); 447 436 448 return hr; 437 449 } … … 447 459 } 448 460 449 EnterCriticalSection(&d3d8_cs);461 wined3d_mutex_lock(); 450 462 hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,pSurface->wineD3DSurface); 451 LeaveCriticalSection(&d3d8_cs); 463 wined3d_mutex_unlock(); 464 452 465 return hr; 453 466 } … … 457 470 TRACE("(%p) Relay\n", This); 458 471 459 EnterCriticalSection(&d3d8_cs);472 wined3d_mutex_lock(); 460 473 IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags); 461 LeaveCriticalSection(&d3d8_cs);474 wined3d_mutex_unlock(); 462 475 } 463 476 … … 467 480 TRACE("(%p) Relay\n", This); 468 481 469 EnterCriticalSection(&d3d8_cs);482 wined3d_mutex_lock(); 470 483 ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow); 471 LeaveCriticalSection(&d3d8_cs); 484 wined3d_mutex_unlock(); 485 472 486 return ret; 473 487 } … … 512 526 localParameters.AutoRestoreDisplayMode = TRUE; 513 527 514 EnterCriticalSection(&d3d8_cs);528 wined3d_mutex_lock(); 515 529 hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters, 516 530 &object->wineD3DSwapChain, (IUnknown *)object, SURFACE_OPENGL); 517 LeaveCriticalSection(&d3d8_cs);531 wined3d_mutex_unlock(); 518 532 519 533 pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; … … 567 581 localParameters.AutoRestoreDisplayMode = TRUE; 568 582 569 EnterCriticalSection(&d3d8_cs);583 wined3d_mutex_lock(); 570 584 hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters); 571 LeaveCriticalSection(&d3d8_cs);585 wined3d_mutex_unlock(); 572 586 573 587 pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; … … 593 607 TRACE("(%p) Relay\n", This); 594 608 595 EnterCriticalSection(&d3d8_cs);609 wined3d_mutex_lock(); 596 610 hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); 597 LeaveCriticalSection(&d3d8_cs); 611 wined3d_mutex_unlock(); 612 598 613 return hr; 599 614 } … … 606 621 TRACE("(%p) Relay\n", This); 607 622 608 EnterCriticalSection(&d3d8_cs);623 wined3d_mutex_lock(); 609 624 rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface); 610 625 if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) { … … 612 627 IWineD3DSurface_Release(retSurface); 613 628 } 614 LeaveCriticalSection(&d3d8_cs); 629 wined3d_mutex_unlock(); 630 615 631 return rc; 616 632 } … … 621 637 TRACE("(%p) Relay\n", This); 622 638 623 EnterCriticalSection(&d3d8_cs);639 wined3d_mutex_lock(); 624 640 hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus); 625 LeaveCriticalSection(&d3d8_cs); 641 wined3d_mutex_unlock(); 642 626 643 return hr; 627 644 } … … 632 649 633 650 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */ 634 EnterCriticalSection(&d3d8_cs);651 wined3d_mutex_lock(); 635 652 IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, 0, Flags, (CONST WINED3DGAMMARAMP *) pRamp); 636 LeaveCriticalSection(&d3d8_cs);653 wined3d_mutex_unlock(); 637 654 } 638 655 … … 642 659 643 660 /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */ 644 EnterCriticalSection(&d3d8_cs);661 wined3d_mutex_lock(); 645 662 IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *) pRamp); 646 LeaveCriticalSection(&d3d8_cs); 647 } 648 649 static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, 650 D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8 **ppTexture) { 663 wined3d_mutex_unlock(); 664 } 665 666 static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(IDirect3DDevice8 *iface, 667 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, 668 D3DPOOL pool, IDirect3DTexture8 **texture) 669 { 670 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 651 671 IDirect3DTexture8Impl *object; 652 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 653 HRESULT hrc = D3D_OK; 654 655 TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%d), Fmt(%u), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool); 656 657 /* Allocate the storage for the device */ 658 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl)); 659 660 if (NULL == object) { 661 FIXME("Allocation of memory failed\n"); 662 /* *ppTexture = NULL; */ 672 HRESULT hr; 673 674 TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n", 675 iface, width, height, levels, usage, format, pool, texture); 676 677 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 678 if (!object) 679 { 680 ERR("Failed to allocate texture memory.\n"); 663 681 return D3DERR_OUTOFVIDEOMEMORY; 664 682 } 665 683 666 object->lpVtbl = &Direct3DTexture8_Vtbl; 667 object->ref = 1; 668 EnterCriticalSection(&d3d8_cs); 669 hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK, 670 wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DTexture, (IUnknown *)object); 671 LeaveCriticalSection(&d3d8_cs); 672 673 if (FAILED(hrc)) { 674 /* free up object */ 675 FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This); 684 hr = texture_init(object, This, width, height, levels, usage, format, pool); 685 if (FAILED(hr)) 686 { 687 WARN("Failed to initialize texture, hr %#x.\n", hr); 676 688 HeapFree(GetProcessHeap(), 0, object); 677 /* *ppTexture = NULL; */ 678 } else { 679 IUnknown_AddRef(iface); 680 object->parentDevice = iface; 681 *ppTexture = (LPDIRECT3DTEXTURE8) object; 682 TRACE("(%p) Created Texture %p, %p\n",This,object,object->wineD3DTexture); 683 } 684 685 return hrc; 686 } 687 688 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface, 689 UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, 690 D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) { 691 689 return hr; 690 } 691 692 TRACE("Created texture %p.\n", object); 693 *texture = (IDirect3DTexture8 *)object; 694 695 return D3D_OK; 696 } 697 698 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8 *iface, 699 UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, 700 D3DPOOL pool, IDirect3DVolumeTexture8 **texture) 701 { 702 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 692 703 IDirect3DVolumeTexture8Impl *object; 693 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 694 HRESULT hrc = D3D_OK; 695 696 TRACE("(%p) Relay\n", This); 697 698 /* Allocate the storage for the device */ 699 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl)); 700 if (NULL == object) { 701 FIXME("(%p) allocation of memory failed\n", This); 702 *ppVolumeTexture = NULL; 704 HRESULT hr; 705 706 TRACE("iface %p, width %u, height %u, depth %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n", 707 iface, width, height, depth, levels, usage, format, pool, texture); 708 709 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 710 if (!object) 711 { 712 ERR("Failed to allocate volume texture memory.\n"); 703 713 return D3DERR_OUTOFVIDEOMEMORY; 704 714 } 705 715 706 object->lpVtbl = &Direct3DVolumeTexture8_Vtbl; 707 object->ref = 1; 708 EnterCriticalSection(&d3d8_cs); 709 hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, 710 Usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(Format), 711 Pool, &object->wineD3DVolumeTexture, (IUnknown *)object); 712 LeaveCriticalSection(&d3d8_cs); 713 714 if (hrc != D3D_OK) { 715 716 /* free up object */ 717 FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This); 716 hr = volumetexture_init(object, This, width, height, depth, levels, usage, format, pool); 717 if (FAILED(hr)) 718 { 719 WARN("Failed to initialize volume texture, hr %#x.\n", hr); 718 720 HeapFree(GetProcessHeap(), 0, object); 719 *ppVolumeTexture = NULL;720 } else {721 IUnknown_AddRef(iface); 722 object->parentDevice = iface;723 *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE8)object;724 } 725 TRACE("(%p) returning %p\n", This , *ppVolumeTexture);726 return hrc; 727 } 728 729 static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage, 730 D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture){731 721 return hr; 722 } 723 724 TRACE("Created volume texture %p.\n", object); 725 *texture = (IDirect3DVolumeTexture8 *)object; 726 727 return D3D_OK; 728 } 729 730 static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length, 731 UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture) 732 { 733 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 732 734 IDirect3DCubeTexture8Impl *object; 733 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 734 HRESULT hr = D3D_OK; 735 736 TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d)\n" , This, EdgeLength, Levels, Usage, Format, Pool); 737 738 /* Allocate the storage for the device */ 735 HRESULT hr; 736 737 TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n", 738 iface, edge_length, levels, usage, format, pool, texture); 739 739 740 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 740 741 if (NULL == object) { 742 FIXME("(%p) allocation of CubeTexture failed\n", This); 743 *ppCubeTexture = NULL; 741 if (!object) 742 { 743 ERR("Failed to allocate cube texture memory.\n"); 744 744 return D3DERR_OUTOFVIDEOMEMORY; 745 745 } 746 746 747 object->lpVtbl = &Direct3DCubeTexture8_Vtbl; 748 object->ref = 1; 749 EnterCriticalSection(&d3d8_cs); 750 hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage & WINED3DUSAGE_MASK, 751 wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object); 752 LeaveCriticalSection(&d3d8_cs); 753 754 if (hr != D3D_OK){ 755 756 /* free up object */ 757 FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This); 747 hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool); 748 if (FAILED(hr)) 749 { 750 WARN("Failed to initialize cube texture, hr %#x.\n", hr); 758 751 HeapFree(GetProcessHeap(), 0, object); 759 *ppCubeTexture = NULL; 760 } else { 761 IUnknown_AddRef(iface); 762 object->parentDevice = iface; 763 *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object; 764 } 765 766 TRACE("(%p) returning %p\n",This, *ppCubeTexture); 767 return hr; 768 } 769 770 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) { 752 return hr; 753 } 754 755 TRACE("Created cube texture %p.\n", object); 756 *texture = (IDirect3DCubeTexture8 *)object; 757 758 return hr; 759 } 760 761 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage, 762 DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer8 **buffer) 763 { 764 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 771 765 IDirect3DVertexBuffer8Impl *object; 772 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;773 HRESULT hrc = D3D_OK; 774 775 TRACE("(%p) Relay\n", This);776 /* Allocate the storage for the device */ 777 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( IDirect3DVertexBuffer8Impl));778 if ( NULL == object) {779 FIXME("Allocation of memory failed\n");780 *ppVertexBuffer = NULL;766 HRESULT hr; 767 768 TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p.\n", 769 iface, size, usage, fvf, pool, buffer); 770 771 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 772 if (!object) 773 { 774 ERR("Failed to allocate buffer memory.\n"); 781 775 return D3DERR_OUTOFVIDEOMEMORY; 782 776 } 783 777 784 object->lpVtbl = &Direct3DVertexBuffer8_Vtbl; 785 object->ref = 1; 786 EnterCriticalSection(&d3d8_cs); 787 hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK, 788 0 /* fvf for ddraw only */, (WINED3DPOOL)Pool, &object->wineD3DVertexBuffer, (IUnknown *)object); 789 LeaveCriticalSection(&d3d8_cs); 790 object->fvf = FVF; 791 792 if (D3D_OK != hrc) { 793 794 /* free up object */ 795 FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This); 778 hr = vertexbuffer_init(object, This, size, usage, fvf, pool); 779 if (FAILED(hr)) 780 { 781 WARN("Failed to initialize vertex buffer, hr %#x.\n", hr); 796 782 HeapFree(GetProcessHeap(), 0, object); 797 *ppVertexBuffer = NULL; 798 } else { 799 IUnknown_AddRef(iface); 800 object->parentDevice = iface; 801 *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8) object; 802 } 803 return hrc; 804 } 805 806 static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer) { 783 return hr; 784 } 785 786 TRACE("Created vertex buffer %p.\n", object); 787 *buffer = (IDirect3DVertexBuffer8 *)object; 788 789 return D3D_OK; 790 } 791 792 static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage, 793 D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer8 **buffer) 794 { 795 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 807 796 IDirect3DIndexBuffer8Impl *object; 808 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;809 HRESULT hrc = D3D_OK; 810 811 TRACE("(%p) Relay\n", This);812 /* Allocate the storage for the device */ 797 HRESULT hr; 798 799 TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p.\n", 800 iface, size, usage, format, pool, buffer); 801 813 802 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 814 if ( NULL == object) {815 FIXME("Allocation of memory failed\n");816 *ppIndexBuffer = NULL;803 if (!object) 804 { 805 ERR("Failed to allocate buffer memory.\n"); 817 806 return D3DERR_OUTOFVIDEOMEMORY; 818 807 } 819 808 820 object->lpVtbl = &Direct3DIndexBuffer8_Vtbl; 821 object->ref = 1; 822 object->format = wined3dformat_from_d3dformat(Format); 823 TRACE("Calling wined3d create index buffer\n"); 824 EnterCriticalSection(&d3d8_cs); 825 hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, 826 (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer, (IUnknown *)object); 827 LeaveCriticalSection(&d3d8_cs); 828 829 if (D3D_OK != hrc) { 830 831 /* free up object */ 832 FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This); 809 hr = indexbuffer_init(object, This, size, usage, format, pool); 810 if (FAILED(hr)) 811 { 812 WARN("Failed to initialize index buffer, hr %#x.\n", hr); 833 813 HeapFree(GetProcessHeap(), 0, object); 834 *ppIndexBuffer = NULL;835 } else {836 IUnknown_AddRef(iface); 837 object->parentDevice = iface;838 *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8)object;839 } 840 return hrc;814 return hr; 815 } 816 817 TRACE("Created index buffer %p.\n", object); 818 *buffer = (IDirect3DIndexBuffer8 *)object; 819 820 return D3D_OK; 841 821 } 842 822 … … 845 825 UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality) 846 826 { 847 HRESULT hrc;827 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 848 828 IDirect3DSurface8Impl *object; 849 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 850 TRACE("(%p) Relay\n", This); 851 852 if(MultisampleQuality > 0){ 853 FIXME("MultisampleQuality set to %d, substituting 0\n" , MultisampleQuality); 854 /* 855 MultisampleQuality 856 [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D8::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match. 857 */ 858 MultisampleQuality=0; 859 } 860 /*FIXME: Check MAX bounds of MultisampleQuality*/ 861 862 /* Allocate the storage for the device */ 829 HRESULT hr; 830 831 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface); 832 863 833 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl)); 864 if ( NULL == object) {865 FIXME("Allocation of memory failed\n");866 *ppSurface = NULL;834 if (!object) 835 { 836 FIXME("Failed to allocate surface memory.\n"); 867 837 return D3DERR_OUTOFVIDEOMEMORY; 868 838 } 869 839 870 object->lpVtbl = &Direct3DSurface8_Vtbl; 871 object->ref = 1; 872 873 TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface); 874 875 EnterCriticalSection(&d3d8_cs); 876 hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format), 877 Lockable, Discard, Level, &object->wineD3DSurface, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL)Pool, 878 MultiSample, MultisampleQuality, SURFACE_OPENGL, (IUnknown *)object); 879 LeaveCriticalSection(&d3d8_cs); 880 if (hrc != D3D_OK || NULL == object->wineD3DSurface) { 881 /* free up object */ 882 FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This); 840 hr = surface_init(object, This, Width, Height, Format, Lockable, Discard, 841 Level, Usage, Pool, MultiSample, MultisampleQuality); 842 if (FAILED(hr)) 843 { 844 WARN("Failed to initialize surface, hr %#x.\n", hr); 883 845 HeapFree(GetProcessHeap(), 0, object); 884 *ppSurface = NULL;885 } else {886 IUnknown_AddRef(iface); 887 object->parentDevice = iface;888 *ppSurface = (LPDIRECT3DSURFACE8)object;889 } 890 return hrc;846 return hr; 847 } 848 849 TRACE("Created surface %p.\n", object); 850 *ppSurface = (IDirect3DSurface8 *)object; 851 852 return D3D_OK; 891 853 } 892 854 … … 941 903 /* Check that the source texture is in WINED3DPOOL_SYSTEMMEM and the destination texture is in WINED3DPOOL_DEFAULT */ 942 904 943 EnterCriticalSection(&d3d8_cs);905 wined3d_mutex_lock(); 944 906 IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc); 945 907 srcFormat = winedesc.format; … … 956 918 if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) { 957 919 WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", iface, pSourceSurface, pDestinationSurface); 958 LeaveCriticalSection(&d3d8_cs);920 wined3d_mutex_unlock(); 959 921 return WINED3DERR_INVALIDCALL; 960 922 } else if (WINED3DFMT_UNKNOWN == destFormat) { … … 980 942 } 981 943 } 982 LeaveCriticalSection(&d3d8_cs);944 wined3d_mutex_unlock(); 983 945 984 946 return hr; … … 990 952 TRACE("(%p) Relay\n" , This); 991 953 992 EnterCriticalSection(&d3d8_cs);954 wined3d_mutex_lock(); 993 955 hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture); 994 LeaveCriticalSection(&d3d8_cs); 956 wined3d_mutex_unlock(); 957 995 958 return hr; 996 959 } … … 1008 971 } 1009 972 1010 EnterCriticalSection(&d3d8_cs);973 wined3d_mutex_lock(); 1011 974 hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wineD3DSurface); 1012 LeaveCriticalSection(&d3d8_cs); 975 wined3d_mutex_unlock(); 976 1013 977 return hr; 1014 978 } … … 1022 986 TRACE("(%p) Relay\n" , This); 1023 987 1024 EnterCriticalSection(&d3d8_cs);988 wined3d_mutex_lock(); 1025 989 1026 990 hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &original_ds); … … 1034 998 if (original_ds) IWineD3DSurface_Release(original_ds); 1035 999 1036 LeaveCriticalSection(&d3d8_cs); 1000 wined3d_mutex_unlock(); 1001 1037 1002 return hr; 1038 1003 } … … 1048 1013 return D3DERR_INVALIDCALL; 1049 1014 } 1050 EnterCriticalSection(&d3d8_cs); 1015 1016 wined3d_mutex_lock(); 1051 1017 hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget); 1052 1018 … … 1058 1024 *ppRenderTarget = NULL; 1059 1025 } 1060 LeaveCriticalSection(&d3d8_cs);1026 wined3d_mutex_unlock(); 1061 1027 1062 1028 return hr; … … 1073 1039 } 1074 1040 1075 EnterCriticalSection(&d3d8_cs);1041 wined3d_mutex_lock(); 1076 1042 hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface); 1077 1043 if (hr == WINED3D_OK) { … … 1083 1049 *ppZStencilSurface = NULL; 1084 1050 } 1085 LeaveCriticalSection(&d3d8_cs);1051 wined3d_mutex_unlock(); 1086 1052 1087 1053 return hr; … … 1093 1059 TRACE("(%p) Relay\n" , This); 1094 1060 1095 EnterCriticalSection(&d3d8_cs);1061 wined3d_mutex_lock(); 1096 1062 hr = IWineD3DDevice_BeginScene(This->WineD3DDevice); 1097 LeaveCriticalSection(&d3d8_cs); 1063 wined3d_mutex_unlock(); 1064 1098 1065 return hr; 1099 1066 } … … 1104 1071 TRACE("(%p) Relay\n" , This); 1105 1072 1106 EnterCriticalSection(&d3d8_cs);1073 wined3d_mutex_lock(); 1107 1074 hr = IWineD3DDevice_EndScene(This->WineD3DDevice); 1108 LeaveCriticalSection(&d3d8_cs); 1075 wined3d_mutex_unlock(); 1076 1109 1077 return hr; 1110 1078 } … … 1116 1084 1117 1085 /* Note: D3DRECT is compatible with WINED3DRECT */ 1118 EnterCriticalSection(&d3d8_cs);1086 wined3d_mutex_lock(); 1119 1087 hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil); 1120 LeaveCriticalSection(&d3d8_cs); 1088 wined3d_mutex_unlock(); 1089 1121 1090 return hr; 1122 1091 } … … 1128 1097 1129 1098 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */ 1130 EnterCriticalSection(&d3d8_cs);1099 wined3d_mutex_lock(); 1131 1100 hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix); 1132 LeaveCriticalSection(&d3d8_cs); 1101 wined3d_mutex_unlock(); 1102 1133 1103 return hr; 1134 1104 } … … 1140 1110 1141 1111 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */ 1142 EnterCriticalSection(&d3d8_cs);1112 wined3d_mutex_lock(); 1143 1113 hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix); 1144 LeaveCriticalSection(&d3d8_cs); 1114 wined3d_mutex_unlock(); 1115 1145 1116 return hr; 1146 1117 } … … 1152 1123 1153 1124 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */ 1154 EnterCriticalSection(&d3d8_cs);1125 wined3d_mutex_lock(); 1155 1126 hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix); 1156 LeaveCriticalSection(&d3d8_cs); 1127 wined3d_mutex_unlock(); 1128 1157 1129 return hr; 1158 1130 } … … 1164 1136 1165 1137 /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */ 1166 EnterCriticalSection(&d3d8_cs);1138 wined3d_mutex_lock(); 1167 1139 hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport); 1168 LeaveCriticalSection(&d3d8_cs); 1140 wined3d_mutex_unlock(); 1141 1169 1142 return hr; 1170 1143 } … … 1176 1149 1177 1150 /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */ 1178 EnterCriticalSection(&d3d8_cs);1151 wined3d_mutex_lock(); 1179 1152 hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport); 1180 LeaveCriticalSection(&d3d8_cs); 1153 wined3d_mutex_unlock(); 1154 1181 1155 return hr; 1182 1156 } … … 1188 1162 1189 1163 /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */ 1190 EnterCriticalSection(&d3d8_cs);1164 wined3d_mutex_lock(); 1191 1165 hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial); 1192 LeaveCriticalSection(&d3d8_cs); 1166 wined3d_mutex_unlock(); 1167 1193 1168 return hr; 1194 1169 } … … 1200 1175 1201 1176 /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */ 1202 EnterCriticalSection(&d3d8_cs);1177 wined3d_mutex_lock(); 1203 1178 hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial); 1204 LeaveCriticalSection(&d3d8_cs); 1179 wined3d_mutex_unlock(); 1180 1205 1181 return hr; 1206 1182 } … … 1210 1186 HRESULT hr; 1211 1187 TRACE("(%p) Relay\n" , This); 1212 1188 1213 1189 /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */ 1214 EnterCriticalSection(&d3d8_cs);1190 wined3d_mutex_lock(); 1215 1191 hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight); 1216 LeaveCriticalSection(&d3d8_cs); 1192 wined3d_mutex_unlock(); 1193 1217 1194 return hr; 1218 1195 } … … 1224 1201 1225 1202 /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */ 1226 EnterCriticalSection(&d3d8_cs);1203 wined3d_mutex_lock(); 1227 1204 hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight); 1228 LeaveCriticalSection(&d3d8_cs); 1205 wined3d_mutex_unlock(); 1206 1229 1207 return hr; 1230 1208 } … … 1235 1213 TRACE("(%p) Relay\n" , This); 1236 1214 1237 EnterCriticalSection(&d3d8_cs);1215 wined3d_mutex_lock(); 1238 1216 hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable); 1239 LeaveCriticalSection(&d3d8_cs); 1217 wined3d_mutex_unlock(); 1218 1240 1219 return hr; 1241 1220 } … … 1246 1225 TRACE("(%p) Relay\n" , This); 1247 1226 1248 EnterCriticalSection(&d3d8_cs);1227 wined3d_mutex_lock(); 1249 1228 hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable); 1250 LeaveCriticalSection(&d3d8_cs); 1229 wined3d_mutex_unlock(); 1230 1251 1231 return hr; 1252 1232 } … … 1257 1237 TRACE("(%p) Relay\n" , This); 1258 1238 1259 EnterCriticalSection(&d3d8_cs);1239 wined3d_mutex_lock(); 1260 1240 hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane); 1261 LeaveCriticalSection(&d3d8_cs); 1241 wined3d_mutex_unlock(); 1242 1262 1243 return hr; 1263 1244 } … … 1268 1249 TRACE("(%p) Relay\n" , This); 1269 1250 1270 EnterCriticalSection(&d3d8_cs);1251 wined3d_mutex_lock(); 1271 1252 hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane); 1272 LeaveCriticalSection(&d3d8_cs); 1253 wined3d_mutex_unlock(); 1254 1273 1255 return hr; 1274 1256 } … … 1279 1261 TRACE("(%p) Relay\n" , This); 1280 1262 1281 EnterCriticalSection(&d3d8_cs);1263 wined3d_mutex_lock(); 1282 1264 hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value); 1283 LeaveCriticalSection(&d3d8_cs); 1265 wined3d_mutex_unlock(); 1266 1284 1267 return hr; 1285 1268 } … … 1290 1273 TRACE("(%p) Relay\n" , This); 1291 1274 1292 EnterCriticalSection(&d3d8_cs);1275 wined3d_mutex_lock(); 1293 1276 hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue); 1294 LeaveCriticalSection(&d3d8_cs); 1277 wined3d_mutex_unlock(); 1278 1295 1279 return hr; 1296 1280 } … … 1301 1285 TRACE("(%p)\n", This); 1302 1286 1303 EnterCriticalSection(&d3d8_cs);1287 wined3d_mutex_lock(); 1304 1288 hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice); 1305 LeaveCriticalSection(&d3d8_cs); 1289 wined3d_mutex_unlock(); 1290 1306 1291 return hr; 1307 1292 } … … 1318 1303 * of memory later and cause locking problems) 1319 1304 */ 1320 EnterCriticalSection(&d3d8_cs);1305 wined3d_mutex_lock(); 1321 1306 hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &wineD3DStateBlock); 1322 1307 if (hr != D3D_OK) { 1323 1308 WARN("IWineD3DDevice_EndStateBlock returned an error\n"); 1324 LeaveCriticalSection(&d3d8_cs);1309 wined3d_mutex_unlock(); 1325 1310 return hr; 1326 1311 } … … 1334 1319 1335 1320 *pToken = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_SB); 1336 LeaveCriticalSection(&d3d8_cs);1321 wined3d_mutex_unlock(); 1337 1322 1338 1323 if (*pToken == D3D8_INVALID_HANDLE) … … 1356 1341 TRACE("(%p) %#x Relay\n", This, Token); 1357 1342 1358 EnterCriticalSection(&d3d8_cs);1343 wined3d_mutex_lock(); 1359 1344 pSB = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB); 1360 1345 if (!pSB) 1361 1346 { 1362 1347 WARN("Invalid handle (%#x) passed.\n", Token); 1363 LeaveCriticalSection(&d3d8_cs);1348 wined3d_mutex_unlock(); 1364 1349 return D3DERR_INVALIDCALL; 1365 1350 } 1366 1351 hr = IWineD3DStateBlock_Apply(pSB->wineD3DStateBlock); 1367 LeaveCriticalSection(&d3d8_cs); 1352 wined3d_mutex_unlock(); 1353 1368 1354 return hr; 1369 1355 } … … 1376 1362 TRACE("(%p) %#x Relay\n", This, Token); 1377 1363 1378 EnterCriticalSection(&d3d8_cs);1364 wined3d_mutex_lock(); 1379 1365 pSB = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB); 1380 1366 if (!pSB) 1381 1367 { 1382 1368 WARN("Invalid handle (%#x) passed.\n", Token); 1383 LeaveCriticalSection(&d3d8_cs);1369 wined3d_mutex_unlock(); 1384 1370 return D3DERR_INVALIDCALL; 1385 1371 } 1386 1372 hr = IWineD3DStateBlock_Capture(pSB->wineD3DStateBlock); 1387 LeaveCriticalSection(&d3d8_cs); 1373 wined3d_mutex_unlock(); 1374 1388 1375 return hr; 1389 1376 } … … 1395 1382 TRACE("(%p) Relay\n", This); 1396 1383 1397 EnterCriticalSection(&d3d8_cs);1384 wined3d_mutex_lock(); 1398 1385 pSB = d3d8_free_handle(&This->handle_table, Token - 1, D3D8_HANDLE_SB); 1399 LeaveCriticalSection(&d3d8_cs);1386 wined3d_mutex_unlock(); 1400 1387 1401 1388 if (!pSB) … … 1440 1427 object->ref = 1; 1441 1428 1442 EnterCriticalSection(&d3d8_cs);1429 wined3d_mutex_lock(); 1443 1430 hr = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, 1444 1431 &object->wineD3DStateBlock, (IUnknown *)object); 1445 1432 if (FAILED(hr)) 1446 1433 { 1447 LeaveCriticalSection(&d3d8_cs);1434 wined3d_mutex_unlock(); 1448 1435 ERR("IWineD3DDevice_CreateStateBlock failed, hr %#x\n", hr); 1449 1436 HeapFree(GetProcessHeap(), 0, object); … … 1452 1439 1453 1440 *handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_SB); 1454 LeaveCriticalSection(&d3d8_cs);1441 wined3d_mutex_unlock(); 1455 1442 1456 1443 if (*handle == D3D8_INVALID_HANDLE) … … 1472 1459 TRACE("(%p) Relay\n" , This); 1473 1460 /* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */ 1474 EnterCriticalSection(&d3d8_cs); 1461 1462 wined3d_mutex_lock(); 1475 1463 hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus); 1476 LeaveCriticalSection(&d3d8_cs); 1464 wined3d_mutex_unlock(); 1465 1477 1466 return hr; 1478 1467 } … … 1483 1472 TRACE("(%p) Relay\n" , This); 1484 1473 1485 EnterCriticalSection(&d3d8_cs);1474 wined3d_mutex_lock(); 1486 1475 hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus); 1487 LeaveCriticalSection(&d3d8_cs); 1476 wined3d_mutex_unlock(); 1477 1488 1478 return hr; 1489 1479 } … … 1491 1481 static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture) { 1492 1482 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 1493 IWineD3DBaseTexture *retTexture = NULL;1494 HRESULT rc = D3D_OK;1483 IWineD3DBaseTexture *retTexture; 1484 HRESULT hr; 1495 1485 1496 1486 TRACE("(%p) Relay\n" , This); … … 1500 1490 } 1501 1491 1502 EnterCriticalSection(&d3d8_cs); 1503 rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture); 1504 if (rc == D3D_OK && NULL != retTexture) { 1492 wined3d_mutex_lock(); 1493 hr = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture); 1494 if (FAILED(hr)) 1495 { 1496 WARN("Failed to get texture for stage %u, hr %#x.\n", Stage, hr); 1497 wined3d_mutex_unlock(); 1498 *ppTexture = NULL; 1499 return hr; 1500 } 1501 1502 if (retTexture) 1503 { 1505 1504 IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture); 1506 1505 IWineD3DBaseTexture_Release(retTexture); 1507 } else { 1508 FIXME("Call to get texture (%d) failed (%p)\n", Stage, retTexture); 1506 } 1507 else 1508 { 1509 1509 *ppTexture = NULL; 1510 1510 } 1511 LeaveCriticalSection(&d3d8_cs);1512 1513 return rc;1511 wined3d_mutex_unlock(); 1512 1513 return D3D_OK; 1514 1514 } 1515 1515 … … 1519 1519 TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture); 1520 1520 1521 EnterCriticalSection(&d3d8_cs);1521 wined3d_mutex_lock(); 1522 1522 hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage, 1523 1523 pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture); 1524 LeaveCriticalSection(&d3d8_cs); 1524 wined3d_mutex_unlock(); 1525 1525 1526 return hr; 1526 1527 } … … 1570 1571 TRACE("(%p) Relay\n" , This); 1571 1572 1572 EnterCriticalSection(&d3d8_cs); 1573 1573 wined3d_mutex_lock(); 1574 1574 if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue); 1575 1575 else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue); 1576 1577 LeaveCriticalSection(&d3d8_cs); 1576 wined3d_mutex_unlock(); 1577 1578 1578 return hr; 1579 1579 } … … 1585 1585 TRACE("(%p) Relay\n" , This); 1586 1586 1587 EnterCriticalSection(&d3d8_cs); 1588 1587 wined3d_mutex_lock(); 1589 1588 if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value); 1590 1589 else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value); 1591 1592 LeaveCriticalSection(&d3d8_cs); 1590 wined3d_mutex_unlock(); 1591 1593 1592 return hr; 1594 1593 } … … 1599 1598 TRACE("(%p) Relay\n" , This); 1600 1599 1601 EnterCriticalSection(&d3d8_cs);1600 wined3d_mutex_lock(); 1602 1601 hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses); 1603 LeaveCriticalSection(&d3d8_cs); 1602 wined3d_mutex_unlock(); 1603 1604 1604 return hr; 1605 1605 } … … 1616 1616 TRACE("(%p) Relay\n" , This); 1617 1617 1618 EnterCriticalSection(&d3d8_cs);1618 wined3d_mutex_lock(); 1619 1619 hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries); 1620 LeaveCriticalSection(&d3d8_cs); 1620 wined3d_mutex_unlock(); 1621 1621 1622 return hr; 1622 1623 } … … 1627 1628 TRACE("(%p) Relay\n" , This); 1628 1629 1629 EnterCriticalSection(&d3d8_cs);1630 wined3d_mutex_lock(); 1630 1631 hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries); 1631 LeaveCriticalSection(&d3d8_cs); 1632 wined3d_mutex_unlock(); 1633 1632 1634 return hr; 1633 1635 } … … 1638 1640 TRACE("(%p) Relay\n" , This); 1639 1641 1640 EnterCriticalSection(&d3d8_cs);1642 wined3d_mutex_lock(); 1641 1643 hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber); 1642 LeaveCriticalSection(&d3d8_cs); 1644 wined3d_mutex_unlock(); 1645 1643 1646 return hr; 1644 1647 } … … 1649 1652 TRACE("(%p) Relay\n" , This); 1650 1653 1651 EnterCriticalSection(&d3d8_cs);1654 wined3d_mutex_lock(); 1652 1655 hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber); 1653 LeaveCriticalSection(&d3d8_cs); 1654 return hr; 1655 } 1656 1657 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount) { 1658 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 1659 HRESULT hr; 1660 TRACE("(%p) Relay\n" , This); 1661 1662 EnterCriticalSection(&d3d8_cs); 1656 wined3d_mutex_unlock(); 1657 1658 return hr; 1659 } 1660 1661 static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(IDirect3DDevice8 *iface, D3DPRIMITIVETYPE PrimitiveType, 1662 UINT StartVertex, UINT PrimitiveCount) 1663 { 1664 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 1665 HRESULT hr; 1666 TRACE("(%p) Relay\n" , This); 1667 1668 wined3d_mutex_lock(); 1663 1669 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType); 1664 1670 hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex, 1665 1671 vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount)); 1666 LeaveCriticalSection(&d3d8_cs); 1672 wined3d_mutex_unlock(); 1673 1667 1674 return hr; 1668 1675 } … … 1674 1681 TRACE("(%p) Relay\n" , This); 1675 1682 1676 EnterCriticalSection(&d3d8_cs);1683 wined3d_mutex_lock(); 1677 1684 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType); 1678 hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, MinVertexIndex, NumVertices, 1679 startIndex, vertex_count_from_primitive_count(PrimitiveType, primCount)); 1680 LeaveCriticalSection(&d3d8_cs); 1685 hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex, 1686 vertex_count_from_primitive_count(PrimitiveType, primCount)); 1687 wined3d_mutex_unlock(); 1688 1681 1689 return hr; 1682 1690 } … … 1687 1695 TRACE("(%p) Relay\n" , This); 1688 1696 1689 EnterCriticalSection(&d3d8_cs);1697 wined3d_mutex_lock(); 1690 1698 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType); 1691 1699 hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, 1692 1700 vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), 1693 1701 pVertexStreamZeroData, VertexStreamZeroStride); 1694 LeaveCriticalSection(&d3d8_cs); 1702 wined3d_mutex_unlock(); 1703 1695 1704 return hr; 1696 1705 } … … 1704 1713 TRACE("(%p) Relay\n" , This); 1705 1714 1706 EnterCriticalSection(&d3d8_cs);1715 wined3d_mutex_lock(); 1707 1716 IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType); 1708 hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, MinVertexIndex, NumVertexIndices,1717 hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, 1709 1718 vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData, 1710 1719 wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride); 1711 LeaveCriticalSection(&d3d8_cs); 1720 wined3d_mutex_unlock(); 1721 1712 1722 return hr; 1713 1723 } … … 1719 1729 TRACE("(%p) Relay\n" , This); 1720 1730 1721 EnterCriticalSection(&d3d8_cs);1731 wined3d_mutex_lock(); 1722 1732 hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf); 1723 LeaveCriticalSection(&d3d8_cs); 1724 return hr; 1725 } 1726 1727 static HRESULT IDirect3DDevice8Impl_CreateVertexDeclaration(IDirect3DDevice8 *iface, CONST DWORD *declaration, IDirect3DVertexDeclaration8 **decl_ptr) { 1728 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 1729 IDirect3DVertexDeclaration8Impl *object; 1730 WINED3DVERTEXELEMENT *wined3d_elements; 1731 UINT wined3d_element_count; 1732 HRESULT hr = D3D_OK; 1733 1734 TRACE("(%p) : declaration %p\n", This, declaration); 1733 wined3d_mutex_unlock(); 1734 1735 return hr; 1736 } 1737 1738 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(IDirect3DDevice8 *iface, 1739 const DWORD *declaration, const DWORD *byte_code, DWORD *shader, DWORD usage) 1740 { 1741 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 1742 IDirect3DVertexShader8Impl *object; 1743 DWORD shader_handle; 1744 DWORD handle; 1745 HRESULT hr; 1746 1747 TRACE("iface %p, declaration %p, byte_code %p, shader %p, usage %#x.\n", 1748 iface, declaration, byte_code, shader, usage); 1735 1749 1736 1750 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 1737 if (!object) { 1738 ERR("Memory allocation failed\n"); 1739 *decl_ptr = NULL; 1740 return D3DERR_OUTOFVIDEOMEMORY; 1741 } 1742 1743 object->ref_count = 1; 1744 object->lpVtbl = &Direct3DVertexDeclaration8_Vtbl; 1745 1746 wined3d_element_count = convert_to_wined3d_declaration(declaration, &object->elements_size, &wined3d_elements); 1747 object->elements = HeapAlloc(GetProcessHeap(), 0, object->elements_size); 1748 if (!object->elements) { 1749 ERR("Memory allocation failed\n"); 1750 HeapFree(GetProcessHeap(), 0, wined3d_elements); 1751 if (!object) 1752 { 1753 ERR("Failed to allocate vertex shader memory.\n"); 1754 *shader = 0; 1755 return E_OUTOFMEMORY; 1756 } 1757 1758 wined3d_mutex_lock(); 1759 handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_VS); 1760 wined3d_mutex_unlock(); 1761 if (handle == D3D8_INVALID_HANDLE) 1762 { 1763 ERR("Failed to allocate vertex shader handle.\n"); 1751 1764 HeapFree(GetProcessHeap(), 0, object); 1752 *decl_ptr = NULL; 1753 return D3DERR_OUTOFVIDEOMEMORY; 1754 } 1755 1756 CopyMemory(object->elements, declaration, object->elements_size); 1757 1758 EnterCriticalSection(&d3d8_cs); 1759 hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wined3d_vertex_declaration, 1760 (IUnknown *)object, wined3d_elements, wined3d_element_count); 1761 LeaveCriticalSection(&d3d8_cs); 1762 HeapFree(GetProcessHeap(), 0, wined3d_elements); 1763 1764 if (FAILED(hr)) { 1765 ERR("(%p) : IWineD3DDevice_CreateVertexDeclaration call failed\n", This); 1766 HeapFree(GetProcessHeap(), 0, object->elements); 1765 *shader = 0; 1766 return E_OUTOFMEMORY; 1767 } 1768 1769 shader_handle = handle + VS_HIGHESTFIXEDFXF + 1; 1770 1771 hr = vertexshader_init(object, This, declaration, byte_code, shader_handle, usage); 1772 if (FAILED(hr)) 1773 { 1774 WARN("Failed to initialize vertex shader, hr %#x.\n", hr); 1775 wined3d_mutex_lock(); 1776 d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_VS); 1777 wined3d_mutex_unlock(); 1767 1778 HeapFree(GetProcessHeap(), 0, object); 1768 } else { 1769 *decl_ptr = (IDirect3DVertexDeclaration8 *)object; 1770 TRACE("(%p) : Created vertex declaration %p\n", This, object); 1771 } 1772 1773 return hr; 1774 } 1775 1776 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* ppShader, DWORD Usage) { 1777 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 1778 HRESULT hrc = D3D_OK; 1779 IDirect3DVertexShader8Impl *object; 1780 const DWORD *token = pDeclaration; 1781 DWORD handle; 1782 1783 /* Test if the vertex declaration is valid */ 1784 while (D3DVSD_END() != *token) { 1785 D3DVSD_TOKENTYPE token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); 1786 1787 if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000)) { 1788 DWORD type = ((*token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT); 1789 DWORD reg = ((*token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT); 1790 1791 if(reg == D3DVSDE_NORMAL && type != D3DVSDT_FLOAT3 && !pFunction) { 1792 WARN("Attempt to use a non-FLOAT3 normal with the fixed function function\n"); 1793 return D3DERR_INVALIDCALL; 1794 } 1795 } 1796 token += parse_token(token); 1797 } 1798 1799 /* Setup a stub object for now */ 1800 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 1801 TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader); 1802 if (NULL == object) { 1803 FIXME("Allocation of memory failed\n"); 1804 *ppShader = 0; 1805 return D3DERR_OUTOFVIDEOMEMORY; 1806 } 1807 1808 object->ref = 1; 1809 object->lpVtbl = &Direct3DVertexShader8_Vtbl; 1810 1811 hrc = IDirect3DDevice8Impl_CreateVertexDeclaration(iface, pDeclaration, &object->vertex_declaration); 1812 if (FAILED(hrc)) { 1813 ERR("(%p) : IDirect3DDeviceImpl_CreateVertexDeclaration call failed\n", This); 1814 HeapFree(GetProcessHeap(), 0, object); 1815 *ppShader = 0; 1816 return D3DERR_INVALIDCALL; 1817 } 1818 1819 EnterCriticalSection(&d3d8_cs); 1820 handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_VS); 1821 if (handle == D3D8_INVALID_HANDLE) 1822 { 1823 ERR("Failed to allocate shader handle\n"); 1824 LeaveCriticalSection(&d3d8_cs); 1825 IDirect3DVertexDeclaration8_Release(object->vertex_declaration); 1826 HeapFree(GetProcessHeap(), 0, object); 1827 *ppShader = 0; 1828 return E_OUTOFMEMORY; 1829 } 1830 else 1831 { 1832 DWORD shader_handle = handle + VS_HIGHESTFIXEDFXF + 1; 1833 *ppShader = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->shader_handle = shader_handle; 1834 } 1835 1836 if (pFunction) 1837 { 1838 /* Usage is missing ... Use SetRenderState to set the sw vp render state in SetVertexShader */ 1839 hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction, 1840 NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object); 1841 1842 if (FAILED(hrc)) 1843 { 1844 /* free up object */ 1845 FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n"); 1846 d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_VS); 1847 IDirect3DVertexDeclaration8_Release(object->vertex_declaration); 1848 HeapFree(GetProcessHeap(), 0, object); 1849 *ppShader = 0; 1850 } 1851 else 1852 { 1853 load_local_constants(pDeclaration, object->wineD3DVertexShader); 1854 TRACE("(%p) : returning %p (handle %#x)\n", This, object, *ppShader); 1855 } 1856 } 1857 1858 LeaveCriticalSection(&d3d8_cs); 1859 1860 return hrc; 1779 *shader = 0; 1780 return hr; 1781 } 1782 1783 TRACE("Created vertex shader %p (handle %#x).\n", object, shader_handle); 1784 *shader = shader_handle; 1785 1786 return D3D_OK; 1861 1787 } 1862 1788 … … 1893 1819 } 1894 1820 1895 d3d8_declaration->ref_count = 1; 1896 d3d8_declaration->lpVtbl = &Direct3DVertexDeclaration8_Vtbl; 1897 d3d8_declaration->elements = NULL; 1898 d3d8_declaration->elements_size = 0; 1899 d3d8_declaration->shader_handle = fvf; 1900 1901 hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(This->WineD3DDevice, 1902 &d3d8_declaration->wined3d_vertex_declaration, (IUnknown *)d3d8_declaration, fvf); 1821 hr = vertexdeclaration_init_fvf(d3d8_declaration, This, fvf); 1903 1822 if (FAILED(hr)) 1904 1823 { 1905 ERR("Failed to create wined3d vertex declaration.\n");1824 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr); 1906 1825 HeapFree(GetProcessHeap(), 0, d3d8_declaration); 1907 1826 return NULL; … … 1940 1859 TRACE("Setting FVF, %#x\n", pShader); 1941 1860 1942 EnterCriticalSection(&d3d8_cs);1861 wined3d_mutex_lock(); 1943 1862 IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, 1944 1863 IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration); 1945 1864 IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL); 1946 LeaveCriticalSection(&d3d8_cs); 1865 wined3d_mutex_unlock(); 1866 1947 1867 return D3D_OK; 1948 1868 } … … 1950 1870 TRACE("Setting shader\n"); 1951 1871 1952 EnterCriticalSection(&d3d8_cs);1872 wined3d_mutex_lock(); 1953 1873 shader = d3d8_get_object(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS); 1954 1874 if (!shader) 1955 1875 { 1956 1876 WARN("Invalid handle (%#x) passed.\n", pShader); 1957 LeaveCriticalSection(&d3d8_cs); 1877 wined3d_mutex_unlock(); 1878 1958 1879 return D3DERR_INVALIDCALL; 1959 1880 } … … 1962 1883 ((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration); 1963 1884 if (SUCCEEDED(hr)) hr = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader); 1964 LeaveCriticalSection(&d3d8_cs);1885 wined3d_mutex_unlock(); 1965 1886 1966 1887 TRACE("Returning hr %#x\n", hr); … … 1976 1897 1977 1898 TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice); 1978 EnterCriticalSection(&d3d8_cs); 1979 1899 1900 wined3d_mutex_lock(); 1980 1901 hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration); 1981 1902 if (FAILED(hrc)) 1982 1903 { 1983 LeaveCriticalSection(&d3d8_cs);1904 wined3d_mutex_unlock(); 1984 1905 WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n", 1985 1906 This, hrc, This->WineD3DDevice); … … 1989 1910 if (!wined3d_declaration) 1990 1911 { 1991 LeaveCriticalSection(&d3d8_cs);1912 wined3d_mutex_unlock(); 1992 1913 *ppShader = 0; 1993 1914 return D3D_OK; … … 1996 1917 hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration); 1997 1918 IWineD3DVertexDeclaration_Release(wined3d_declaration); 1998 LeaveCriticalSection(&d3d8_cs);1919 wined3d_mutex_unlock(); 1999 1920 if (SUCCEEDED(hrc)) 2000 1921 { … … 2015 1936 TRACE("(%p) : pShader %#x\n", This, pShader); 2016 1937 2017 EnterCriticalSection(&d3d8_cs); 2018 1938 wined3d_mutex_lock(); 2019 1939 shader = d3d8_free_handle(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS); 2020 1940 if (!shader) 2021 1941 { 2022 1942 WARN("Invalid handle (%#x) passed.\n", pShader); 2023 LeaveCriticalSection(&d3d8_cs); 1943 wined3d_mutex_unlock(); 1944 2024 1945 return D3DERR_INVALIDCALL; 2025 1946 } … … 2033 1954 } 2034 1955 2035 LeaveCriticalSection(&d3d8_cs);1956 wined3d_mutex_unlock(); 2036 1957 2037 1958 if (IUnknown_Release((IUnknown *)shader)) … … 2054 1975 } 2055 1976 2056 EnterCriticalSection(&d3d8_cs);1977 wined3d_mutex_lock(); 2057 1978 hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount); 2058 LeaveCriticalSection(&d3d8_cs); 1979 wined3d_mutex_unlock(); 1980 2059 1981 return hr; 2060 1982 } … … 2071 1993 } 2072 1994 2073 EnterCriticalSection(&d3d8_cs);1995 wined3d_mutex_lock(); 2074 1996 hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount); 2075 LeaveCriticalSection(&d3d8_cs); 1997 wined3d_mutex_unlock(); 1998 2076 1999 return hr; 2077 2000 } … … 2084 2007 TRACE("(%p) : pVertexShader 0x%08x, pData %p, *pSizeOfData %u\n", This, pVertexShader, pData, *pSizeOfData); 2085 2008 2086 EnterCriticalSection(&d3d8_cs); 2087 2009 wined3d_mutex_lock(); 2088 2010 shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS); 2089 LeaveCriticalSection(&d3d8_cs); 2011 wined3d_mutex_unlock(); 2012 2090 2013 if (!shader) 2091 2014 { … … 2120 2043 TRACE("(%p) : pVertexShader %#x, pData %p, pSizeOfData %p\n", This, pVertexShader, pData, pSizeOfData); 2121 2044 2122 EnterCriticalSection(&d3d8_cs); 2123 2045 wined3d_mutex_lock(); 2124 2046 shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_VS); 2125 2047 if (!shader) 2126 2048 { 2127 2049 WARN("Invalid handle (%#x) passed.\n", pVertexShader); 2128 LeaveCriticalSection(&d3d8_cs); 2050 wined3d_mutex_unlock(); 2051 2129 2052 return D3DERR_INVALIDCALL; 2130 2053 } … … 2132 2055 if (!shader->wineD3DVertexShader) 2133 2056 { 2134 LeaveCriticalSection(&d3d8_cs);2057 wined3d_mutex_unlock(); 2135 2058 *pSizeOfData = 0; 2136 2059 return D3D_OK; … … 2138 2061 2139 2062 hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData); 2140 2141 LeaveCriticalSection(&d3d8_cs); 2063 wined3d_mutex_unlock(); 2064 2142 2065 return hr; 2143 2066 } … … 2149 2072 TRACE("(%p) Relay\n", This); 2150 2073 2151 EnterCriticalSection(&d3d8_cs);2152 2074 /* WineD3D takes an INT(due to d3d9), but d3d8 uses UINTs. Do I have to add a check here that 2153 2075 * the UINT doesn't cause an overflow in the INT? It seems rather unlikely because such large … … 2156 2078 * problem) 2157 2079 */ 2080 wined3d_mutex_lock(); 2158 2081 IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex); 2159 hr = IWineD3DDevice_SetInd ices(This->WineD3DDevice,2082 hr = IWineD3DDevice_SetIndexBuffer(This->WineD3DDevice, 2160 2083 ib ? ib->wineD3DIndexBuffer : NULL, 2161 2084 ib ? ib->format : WINED3DFMT_UNKNOWN); 2162 LeaveCriticalSection(&d3d8_cs); 2085 wined3d_mutex_unlock(); 2086 2163 2087 return hr; 2164 2088 } … … 2175 2099 } 2176 2100 2177 EnterCriticalSection(&d3d8_cs);2178 2101 /* The case from UINT to INT is safe because d3d8 will never set negative values */ 2102 wined3d_mutex_lock(); 2179 2103 IWineD3DDevice_GetBaseVertexIndex(This->WineD3DDevice, (INT *) pBaseVertexIndex); 2180 rc = IWineD3DDevice_GetInd ices(This->WineD3DDevice, &retIndexData);2104 rc = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData); 2181 2105 if (SUCCEEDED(rc) && retIndexData) { 2182 2106 IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData); … … 2186 2110 *ppIndexData = NULL; 2187 2111 } 2188 LeaveCriticalSection(&d3d8_cs);2112 wined3d_mutex_unlock(); 2189 2113 2190 2114 return rc; 2191 2115 } 2192 static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(LPDIRECT3DDEVICE8 iface, CONST DWORD* pFunction, DWORD* ppShader) { 2116 2117 static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *iface, 2118 const DWORD *byte_code, DWORD *shader) 2119 { 2193 2120 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; 2194 2121 IDirect3DPixelShader8Impl *object; 2122 DWORD shader_handle; 2195 2123 DWORD handle; 2196 2124 HRESULT hr; 2197 2125 2198 TRACE("(%p) : pFunction(%p), ppShader(%p)\n", This, pFunction, ppShader); 2199 2200 if (NULL == ppShader) { 2126 TRACE("iface %p, byte_code %p, shader %p.\n", iface, byte_code, shader); 2127 2128 if (!shader) 2129 { 2201 2130 TRACE("(%p) Invalid call\n", This); 2202 2131 return D3DERR_INVALIDCALL; … … 2206 2135 if (!object) 2207 2136 { 2208 ERR("Failed to allocate memmory.\n");2137 ERR("Failed to allocate pixel shader memmory.\n"); 2209 2138 return E_OUTOFMEMORY; 2210 2139 } 2211 2140 2212 object->ref = 1; 2213 object->lpVtbl = &Direct3DPixelShader8_Vtbl; 2214 2215 EnterCriticalSection(&d3d8_cs); 2216 hr = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, 2217 NULL, &object->wineD3DPixelShader, (IUnknown *)object); 2141 wined3d_mutex_lock(); 2142 handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_PS); 2143 wined3d_mutex_unlock(); 2144 if (handle == D3D8_INVALID_HANDLE) 2145 { 2146 ERR("Failed to allocate pixel shader handle.\n"); 2147 HeapFree(GetProcessHeap(), 0, object); 2148 return E_OUTOFMEMORY; 2149 } 2150 2151 shader_handle = handle + VS_HIGHESTFIXEDFXF + 1; 2152 2153 hr = pixelshader_init(object, This, byte_code, shader_handle); 2218 2154 if (FAILED(hr)) 2219 2155 { 2220 LeaveCriticalSection(&d3d8_cs); 2221 FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This); 2222 HeapFree(GetProcessHeap(), 0 , object); 2223 *ppShader = 0; 2156 WARN("Failed to initialize pixel shader, hr %#x.\n", hr); 2157 wined3d_mutex_lock(); 2158 d3d8_free_handle(&This->handle_table, handle, D3D8_HANDLE_PS); 2159 wined3d_mutex_unlock(); 2160 HeapFree(GetProcessHeap(), 0, object); 2161 *shader = 0; 2224 2162 return hr; 2225 2163 } 2226 2164 2227 handle = d3d8_allocate_handle(&This->handle_table, object, D3D8_HANDLE_PS); 2228 LeaveCriticalSection(&d3d8_cs); 2229 if (handle == D3D8_INVALID_HANDLE) 2230 { 2231 ERR("Failed to allocate shader handle\n"); 2232 IDirect3DVertexShader8_Release((IUnknown *)object); 2233 return E_OUTOFMEMORY; 2234 } 2235 2236 *ppShader = object->handle = handle + VS_HIGHESTFIXEDFXF + 1; 2237 TRACE("(%p) : returning %p (handle %#x)\n", This, object, *ppShader); 2238 2239 return hr; 2165 TRACE("Created pixel shader %p (handle %#x).\n", object, shader_handle); 2166 *shader = shader_handle; 2167 2168 return D3D_OK; 2240 2169 } 2241 2170 … … 2247 2176 TRACE("(%p) : pShader %#x\n", This, pShader); 2248 2177 2249 EnterCriticalSection(&d3d8_cs);2178 wined3d_mutex_lock(); 2250 2179 2251 2180 if (!pShader) 2252 2181 { 2253 2182 hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, NULL); 2254 LeaveCriticalSection(&d3d8_cs);2183 wined3d_mutex_unlock(); 2255 2184 return hr; 2256 2185 } … … 2260 2189 { 2261 2190 WARN("Invalid handle (%#x) passed.\n", pShader); 2262 LeaveCriticalSection(&d3d8_cs);2191 wined3d_mutex_unlock(); 2263 2192 return D3DERR_INVALIDCALL; 2264 2193 } … … 2266 2195 TRACE("(%p) : Setting shader %p\n", This, shader); 2267 2196 hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader->wineD3DPixelShader); 2268 LeaveCriticalSection(&d3d8_cs); 2197 wined3d_mutex_unlock(); 2198 2269 2199 return hr; 2270 2200 } … … 2281 2211 } 2282 2212 2283 EnterCriticalSection(&d3d8_cs);2213 wined3d_mutex_lock(); 2284 2214 hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object); 2285 2215 if (D3D_OK == hrc && NULL != object) { … … 2292 2222 *ppShader = 0; 2293 2223 } 2224 wined3d_mutex_unlock(); 2294 2225 2295 2226 TRACE("(%p) : returning %#x\n", This, *ppShader); 2296 LeaveCriticalSection(&d3d8_cs); 2227 2297 2228 return hrc; 2298 2229 } … … 2305 2236 TRACE("(%p) : pShader %#x\n", This, pShader); 2306 2237 2307 EnterCriticalSection(&d3d8_cs);2238 wined3d_mutex_lock(); 2308 2239 2309 2240 shader = d3d8_free_handle(&This->handle_table, pShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS); … … 2311 2242 { 2312 2243 WARN("Invalid handle (%#x) passed.\n", pShader); 2313 LeaveCriticalSection(&d3d8_cs);2244 wined3d_mutex_unlock(); 2314 2245 return D3D_OK; 2315 2246 } … … 2323 2254 } 2324 2255 2325 LeaveCriticalSection(&d3d8_cs);2256 wined3d_mutex_unlock(); 2326 2257 2327 2258 if (IUnknown_Release((IUnknown *)shader)) … … 2338 2269 TRACE("(%p) Relay\n", This); 2339 2270 2340 EnterCriticalSection(&d3d8_cs);2271 wined3d_mutex_lock(); 2341 2272 hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount); 2342 LeaveCriticalSection(&d3d8_cs); 2273 wined3d_mutex_unlock(); 2274 2343 2275 return hr; 2344 2276 } … … 2349 2281 TRACE("(%p) Relay\n", This); 2350 2282 2351 EnterCriticalSection(&d3d8_cs);2283 wined3d_mutex_lock(); 2352 2284 hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount); 2353 LeaveCriticalSection(&d3d8_cs); 2285 wined3d_mutex_unlock(); 2286 2354 2287 return hr; 2355 2288 } … … 2362 2295 TRACE("(%p) : pPixelShader %#x, pData %p, pSizeOfData %p\n", This, pPixelShader, pData, pSizeOfData); 2363 2296 2364 EnterCriticalSection(&d3d8_cs);2297 wined3d_mutex_lock(); 2365 2298 shader = d3d8_get_object(&This->handle_table, pPixelShader - (VS_HIGHESTFIXEDFXF + 1), D3D8_HANDLE_PS); 2366 2299 if (!shader) 2367 2300 { 2368 2301 WARN("Invalid handle (%#x) passed.\n", pPixelShader); 2369 LeaveCriticalSection(&d3d8_cs); 2302 wined3d_mutex_unlock(); 2303 2370 2304 return D3DERR_INVALIDCALL; 2371 2305 } 2372 2306 2373 2307 hr = IWineD3DPixelShader_GetFunction(shader->wineD3DPixelShader, pData, pSizeOfData); 2374 LeaveCriticalSection(&d3d8_cs); 2308 wined3d_mutex_unlock(); 2309 2375 2310 return hr; 2376 2311 } … … 2381 2316 TRACE("(%p) Relay\n", This); 2382 2317 2383 EnterCriticalSection(&d3d8_cs);2318 wined3d_mutex_lock(); 2384 2319 hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo); 2385 LeaveCriticalSection(&d3d8_cs); 2320 wined3d_mutex_unlock(); 2321 2386 2322 return hr; 2387 2323 } … … 2392 2328 TRACE("(%p) Relay\n", This); 2393 2329 2394 EnterCriticalSection(&d3d8_cs);2330 wined3d_mutex_lock(); 2395 2331 hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo); 2396 LeaveCriticalSection(&d3d8_cs); 2332 wined3d_mutex_unlock(); 2333 2397 2334 return hr; 2398 2335 } … … 2403 2340 TRACE("(%p) Relay\n", This); 2404 2341 2405 EnterCriticalSection(&d3d8_cs);2342 wined3d_mutex_lock(); 2406 2343 hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle); 2407 LeaveCriticalSection(&d3d8_cs); 2344 wined3d_mutex_unlock(); 2345 2408 2346 return hr; 2409 2347 } … … 2414 2352 TRACE("(%p) Relay\n" , This); 2415 2353 2416 EnterCriticalSection(&d3d8_cs);2354 wined3d_mutex_lock(); 2417 2355 hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber, 2418 2356 NULL == pStreamData ? NULL : ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer, 2419 2357 0/* Offset in bytes */, Stride); 2420 LeaveCriticalSection(&d3d8_cs); 2358 wined3d_mutex_unlock(); 2359 2421 2360 return hr; 2422 2361 } … … 2433 2372 } 2434 2373 2435 EnterCriticalSection(&d3d8_cs);2374 wined3d_mutex_lock(); 2436 2375 rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, 0 /* Offset in bytes */, pStride); 2437 2376 if (rc == D3D_OK && NULL != retStream) { … … 2444 2383 *pStream = NULL; 2445 2384 } 2446 LeaveCriticalSection(&d3d8_cs);2385 wined3d_mutex_unlock(); 2447 2386 2448 2387 return rc; … … 2551 2490 }; 2552 2491 2553 ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface) {2554 IDirect3DSurface8Impl* surfaceParent;2555 TRACE("(%p) call back\n", pSurface);2556 2557 IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);2558 /* GetParent's AddRef was forwarded to an object in destruction.2559 * Releasing it here again would cause an endless recursion. */2560 surfaceParent->forwardReference = NULL;2561 return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);2562 }2563 2564 2492 /* IWineD3DDeviceParent IUnknown methods */ 2565 2493 … … 2621 2549 2622 2550 *surface = d3d_surface->wineD3DSurface; 2551 IWineD3DSurface_AddRef(*surface); 2552 2623 2553 d3d_surface->container = superior; 2624 2554 IUnknown_Release(d3d_surface->parentDevice); 2625 2555 d3d_surface->parentDevice = NULL; 2556 2557 IDirect3DSurface8_Release((IDirect3DSurface8 *)d3d_surface); 2626 2558 d3d_surface->forwardReference = superior; 2627 2559 … … 2650 2582 2651 2583 *surface = d3d_surface->wineD3DSurface; 2584 IWineD3DSurface_AddRef(*surface); 2585 2652 2586 d3d_surface->container = (IUnknown *)This; 2653 d3d_surface->isImplicit = TRUE;2654 2587 /* Implicit surfaces are created with an refcount of 0 */ 2655 2588 IUnknown_Release((IUnknown *)d3d_surface); … … 2679 2612 2680 2613 *surface = d3d_surface->wineD3DSurface; 2614 IWineD3DSurface_AddRef(*surface); 2615 2681 2616 d3d_surface->container = (IUnknown *)This; 2682 d3d_surface->isImplicit = TRUE;2683 2617 /* Implicit surfaces are created with an refcount of 0 */ 2684 2618 IUnknown_Release((IUnknown *)d3d_surface); … … 2707 2641 } 2708 2642 2709 object->lpVtbl = &Direct3DVolume8_Vtbl; 2710 object->ref = 1; 2711 hr = IWineD3DDevice_CreateVolume(This->WineD3DDevice, width, height, depth, usage, 2712 format, pool, &object->wineD3DVolume, (IUnknown *)object); 2643 hr = volume_init(object, This, width, height, depth, usage, format, pool); 2713 2644 if (FAILED(hr)) 2714 2645 { 2715 ERR("(%p) CreateVolume failed, returning %#x\n", iface, hr);2646 WARN("Failed to initialize volume, hr %#x.\n", hr); 2716 2647 HeapFree(GetProcessHeap(), 0, object); 2717 *volume = NULL;2718 2648 return hr; 2719 2649 } 2720 2650 2721 2651 *volume = object->wineD3DVolume; 2652 IWineD3DVolume_AddRef(*volume); 2653 IDirect3DVolume8_Release((IDirect3DVolume8 *)object); 2654 2722 2655 object->container = superior; 2723 2656 object->forwardReference = superior; 2724 2657 2725 TRACE("(%p) Created volume %p\n", iface, *volume);2658 TRACE("(%p) Created volume %p\n", iface, object); 2726 2659 2727 2660 return hr; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/directx.c
r22496 r23571 81 81 if (ref == 0) { 82 82 TRACE("Releasing wined3d %p\n", This->WineD3D); 83 EnterCriticalSection(&d3d8_cs); 83 84 wined3d_mutex_lock(); 84 85 IWineD3D_Release(This->WineD3D); 85 LeaveCriticalSection(&d3d8_cs); 86 wined3d_mutex_unlock(); 87 86 88 HeapFree(GetProcessHeap(), 0, This); 87 89 } … … 96 98 TRACE("(%p)->(%p)\n", This, pInitializeFunction); 97 99 98 EnterCriticalSection(&d3d8_cs);100 wined3d_mutex_lock(); 99 101 hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction); 100 LeaveCriticalSection(&d3d8_cs); 102 wined3d_mutex_unlock(); 103 101 104 return hr; 102 105 } … … 107 110 TRACE("(%p)\n", This); 108 111 109 EnterCriticalSection(&d3d8_cs);112 wined3d_mutex_lock(); 110 113 hr = IWineD3D_GetAdapterCount(This->WineD3D); 111 LeaveCriticalSection(&d3d8_cs); 114 wined3d_mutex_unlock(); 115 112 116 return hr; 113 117 } … … 129 133 adapter_id.device_name_size = 0; /* d3d9 only */ 130 134 131 EnterCriticalSection(&d3d8_cs);135 wined3d_mutex_lock(); 132 136 hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id); 133 LeaveCriticalSection(&d3d8_cs);137 wined3d_mutex_unlock(); 134 138 135 139 pIdentifier->DriverVersion = adapter_id.driver_version; … … 149 153 TRACE("(%p)->(%d)\n", This, Adapter); 150 154 151 EnterCriticalSection(&d3d8_cs);155 wined3d_mutex_lock(); 152 156 hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */); 153 LeaveCriticalSection(&d3d8_cs); 157 wined3d_mutex_unlock(); 158 154 159 return hr; 155 160 } … … 160 165 TRACE("(%p)->(%d, %d, %p)\n", This, Adapter, Mode, pMode); 161 166 162 EnterCriticalSection(&d3d8_cs);167 wined3d_mutex_lock(); 163 168 hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode); 164 LeaveCriticalSection(&d3d8_cs);169 wined3d_mutex_unlock(); 165 170 166 171 if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format); … … 174 179 TRACE("(%p)->(%d,%p)\n", This, Adapter, pMode); 175 180 176 EnterCriticalSection(&d3d8_cs);181 wined3d_mutex_lock(); 177 182 hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode); 178 LeaveCriticalSection(&d3d8_cs);183 wined3d_mutex_unlock(); 179 184 180 185 if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format); … … 190 195 TRACE("(%p)->(%d, %d, %d, %d, %s)\n", This, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed ? "true" : "false"); 191 196 192 EnterCriticalSection(&d3d8_cs);197 wined3d_mutex_lock(); 193 198 hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat), 194 199 wined3dformat_from_d3dformat(BackBufferFormat), Windowed); 195 LeaveCriticalSection(&d3d8_cs); 200 wined3d_mutex_unlock(); 201 196 202 return hr; 197 203 } … … 224 230 } 225 231 226 EnterCriticalSection(&d3d8_cs);232 wined3d_mutex_lock(); 227 233 hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat), 228 234 Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL); 229 LeaveCriticalSection(&d3d8_cs); 230 return hr; 231 } 232 233 static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface, 234 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, 235 BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) { 235 wined3d_mutex_unlock(); 236 237 return hr; 238 } 239 240 static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter, 241 D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) 242 { 236 243 IDirect3D8Impl *This = (IDirect3D8Impl *)iface; 237 244 HRESULT hr; 238 245 TRACE("(%p)-<(%d, %d, %d, %s, %d)\n", This, Adapter, DeviceType, SurfaceFormat, Windowed ? "true" : "false", MultiSampleType); 239 246 240 EnterCriticalSection(&d3d8_cs);247 wined3d_mutex_lock(); 241 248 hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, 242 249 wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL); 243 LeaveCriticalSection(&d3d8_cs); 244 return hr; 245 } 246 247 static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface, 248 UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, 249 D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) { 250 wined3d_mutex_unlock(); 251 252 return hr; 253 } 254 255 static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter, D3DDEVTYPE DeviceType, 256 D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) 257 { 250 258 IDirect3D8Impl *This = (IDirect3D8Impl *)iface; 251 259 HRESULT hr; 252 260 TRACE("(%p)-<(%d, %d, %d, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); 253 261 254 EnterCriticalSection(&d3d8_cs);262 wined3d_mutex_lock(); 255 263 hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, 256 264 wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat), 257 265 wined3dformat_from_d3dformat(DepthStencilFormat)); 258 LeaveCriticalSection(&d3d8_cs); 266 wined3d_mutex_unlock(); 267 259 268 return hr; 260 269 } … … 288 297 return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/ 289 298 } 290 EnterCriticalSection(&d3d8_cs); 299 300 wined3d_mutex_lock(); 291 301 hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps); 292 LeaveCriticalSection(&d3d8_cs); 302 wined3d_mutex_unlock(); 303 293 304 fixup_caps(pWineCaps); 294 305 WINECAPSTOD3D8CAPS(pCaps, pWineCaps) … … 304 315 TRACE("(%p)->(%d)\n", This, Adapter); 305 316 306 EnterCriticalSection(&d3d8_cs);317 wined3d_mutex_lock(); 307 318 ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter); 308 LeaveCriticalSection(&d3d8_cs); 319 wined3d_mutex_unlock(); 320 309 321 return ret; 310 }311 312 ULONG WINAPI D3D8CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {313 IDirect3DSurface8Impl* surfaceParent;314 TRACE("(%p) call back\n", pSurface);315 316 IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);317 surfaceParent->isImplicit = FALSE;318 /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */319 return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);320 322 } 321 323 … … 327 329 IUnknown_Release(swapChainParent); 328 330 return IUnknown_Release(swapChainParent); 329 }330 331 ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {332 IDirect3DSurface8Impl* surfaceParent;333 TRACE("(%p) call back\n", pSurface);334 335 IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);336 surfaceParent->isImplicit = FALSE;337 /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */338 return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);339 331 } 340 332 … … 372 364 373 365 /* Allocate an associated WineD3DDevice object */ 374 EnterCriticalSection(&d3d8_cs);366 wined3d_mutex_lock(); 375 367 hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, 376 368 (IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice); … … 379 371 HeapFree(GetProcessHeap(), 0, object); 380 372 *ppReturnedDeviceInterface = NULL; 381 LeaveCriticalSection(&d3d8_cs); 373 wined3d_mutex_unlock(); 374 382 375 return hr; 383 376 } … … 406 399 407 400 hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters); 408 LeaveCriticalSection(&d3d8_cs);401 wined3d_mutex_unlock(); 409 402 410 403 pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; … … 432 425 if(!object->decls) { 433 426 ERR("Out of memory\n"); 434 EnterCriticalSection(&d3d8_cs); 427 428 wined3d_mutex_lock(); 435 429 IWineD3DDevice_Release(object->WineD3DDevice); 436 LeaveCriticalSection(&d3d8_cs); 430 wined3d_mutex_unlock(); 431 437 432 HeapFree(GetProcessHeap(), 0, object); 438 433 *ppReturnedDeviceInterface = NULL; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/indexbuffer.c
r19678 r23571 56 56 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 57 57 58 if (ref == 1) 59 { 60 IDirect3DDevice8_AddRef(This->parentDevice); 61 wined3d_mutex_lock(); 62 IWineD3DBuffer_AddRef(This->wineD3DIndexBuffer); 63 wined3d_mutex_unlock(); 64 } 65 58 66 return ref; 59 67 } … … 66 74 67 75 if (ref == 0) { 68 EnterCriticalSection(&d3d8_cs); 76 IDirect3DDevice8_Release(This->parentDevice); 77 wined3d_mutex_lock(); 69 78 IWineD3DBuffer_Release(This->wineD3DIndexBuffer); 70 LeaveCriticalSection(&d3d8_cs); 71 IUnknown_Release(This->parentDevice); 72 HeapFree(GetProcessHeap(), 0, This); 79 wined3d_mutex_unlock(); 73 80 } 74 81 return ref; … … 82 89 TRACE("(%p) Relay\n", This); 83 90 84 EnterCriticalSection(&d3d8_cs);91 wined3d_mutex_lock(); 85 92 hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device); 86 93 if (SUCCEEDED(hr)) … … 89 96 IWineD3DDevice_Release(wined3d_device); 90 97 } 91 LeaveCriticalSection(&d3d8_cs); 98 wined3d_mutex_unlock(); 99 92 100 return hr; 93 101 } … … 98 106 TRACE("(%p) Relay\n", This); 99 107 100 EnterCriticalSection(&d3d8_cs);108 wined3d_mutex_lock(); 101 109 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags); 102 LeaveCriticalSection(&d3d8_cs); 110 wined3d_mutex_unlock(); 111 103 112 return hr; 104 113 } … … 109 118 TRACE("(%p) Relay\n", This); 110 119 111 EnterCriticalSection(&d3d8_cs);120 wined3d_mutex_lock(); 112 121 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData); 113 LeaveCriticalSection(&d3d8_cs); 122 wined3d_mutex_unlock(); 123 114 124 return hr; 115 125 } … … 120 130 TRACE("(%p) Relay\n", This); 121 131 122 EnterCriticalSection(&d3d8_cs);132 wined3d_mutex_lock(); 123 133 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid); 124 LeaveCriticalSection(&d3d8_cs); 134 wined3d_mutex_unlock(); 135 125 136 return hr; 126 137 } … … 131 142 TRACE("(%p) Relay\n", This); 132 143 133 EnterCriticalSection(&d3d8_cs);144 wined3d_mutex_lock(); 134 145 ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew); 135 LeaveCriticalSection(&d3d8_cs); 146 wined3d_mutex_unlock(); 147 136 148 return ret; 137 149 } … … 142 154 TRACE("(%p) Relay\n", This); 143 155 144 EnterCriticalSection(&d3d8_cs);156 wined3d_mutex_lock(); 145 157 ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer); 146 LeaveCriticalSection(&d3d8_cs); 158 wined3d_mutex_unlock(); 159 147 160 return ret; 148 161 } … … 152 165 TRACE("(%p) Relay\n", This); 153 166 154 EnterCriticalSection(&d3d8_cs);167 wined3d_mutex_lock(); 155 168 IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer); 156 LeaveCriticalSection(&d3d8_cs);169 wined3d_mutex_unlock(); 157 170 } 158 171 … … 170 183 TRACE("(%p) Relay\n", This); 171 184 172 EnterCriticalSection(&d3d8_cs);185 wined3d_mutex_lock(); 173 186 hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags); 174 LeaveCriticalSection(&d3d8_cs); 187 wined3d_mutex_unlock(); 188 175 189 return hr; 176 190 } … … 181 195 TRACE("(%p) Relay\n", This); 182 196 183 EnterCriticalSection(&d3d8_cs);197 wined3d_mutex_lock(); 184 198 hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer); 185 LeaveCriticalSection(&d3d8_cs); 199 wined3d_mutex_unlock(); 200 186 201 return hr; 187 202 } … … 193 208 TRACE("(%p) Relay\n", This); 194 209 195 EnterCriticalSection(&d3d8_cs);210 wined3d_mutex_lock(); 196 211 hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc); 197 LeaveCriticalSection(&d3d8_cs);212 wined3d_mutex_unlock(); 198 213 199 214 if (SUCCEEDED(hr)) { … … 208 223 } 209 224 210 211 const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl = 225 static const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl = 212 226 { 213 227 /* IUnknown */ … … 229 243 IDirect3DIndexBuffer8Impl_GetDesc 230 244 }; 245 246 static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *parent) 247 { 248 HeapFree(GetProcessHeap(), 0, parent); 249 } 250 251 static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops = 252 { 253 d3d8_indexbuffer_wined3d_object_destroyed, 254 }; 255 256 HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl *device, 257 UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) 258 { 259 HRESULT hr; 260 261 buffer->lpVtbl = &Direct3DIndexBuffer8_Vtbl; 262 buffer->ref = 1; 263 buffer->format = wined3dformat_from_d3dformat(format); 264 265 wined3d_mutex_lock(); 266 hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size, 267 usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, &buffer->wineD3DIndexBuffer, 268 (IUnknown *)buffer, &d3d8_indexbuffer_wined3d_parent_ops); 269 wined3d_mutex_unlock(); 270 if (FAILED(hr)) 271 { 272 WARN("Failed to create wined3d buffer, hr %#x.\n", hr); 273 return hr; 274 } 275 276 buffer->parentDevice = (IDirect3DDevice8 *)device; 277 IUnknown_AddRef(buffer->parentDevice); 278 279 return D3D_OK; 280 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/pixelshader.c
r19678 r23571 56 56 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 57 57 58 if (ref == 1) 59 { 60 wined3d_mutex_lock(); 61 IWineD3DPixelShader_AddRef(This->wineD3DPixelShader); 62 wined3d_mutex_unlock(); 63 } 64 58 65 return ref; 59 66 } … … 66 73 67 74 if (ref == 0) { 68 EnterCriticalSection(&d3d8_cs);75 wined3d_mutex_lock(); 69 76 IWineD3DPixelShader_Release(This->wineD3DPixelShader); 70 LeaveCriticalSection(&d3d8_cs); 71 HeapFree(GetProcessHeap(), 0, This); 77 wined3d_mutex_unlock(); 72 78 } 73 79 return ref; 74 80 } 75 81 76 const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl =82 static const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl = 77 83 { 78 84 /* IUnknown */ … … 81 87 IDirect3DPixelShader8Impl_Release, 82 88 }; 89 90 static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent) 91 { 92 HeapFree(GetProcessHeap(), 0, parent); 93 } 94 95 static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops = 96 { 97 d3d8_pixelshader_wined3d_object_destroyed, 98 }; 99 100 HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device, 101 const DWORD *byte_code, DWORD shader_handle) 102 { 103 HRESULT hr; 104 105 shader->ref = 1; 106 shader->lpVtbl = &Direct3DPixelShader8_Vtbl; 107 shader->handle = shader_handle; 108 109 wined3d_mutex_lock(); 110 hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code, 111 NULL, &shader->wineD3DPixelShader, (IUnknown *)shader, 112 &d3d8_pixelshader_wined3d_parent_ops); 113 wined3d_mutex_unlock(); 114 if (FAILED(hr)) 115 { 116 WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr); 117 return hr; 118 } 119 120 return D3D_OK; 121 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/stateblock.c
r19678 r23571 68 68 69 69 if (ref == 0) { 70 EnterCriticalSection(&d3d8_cs);70 wined3d_mutex_lock(); 71 71 IWineD3DStateBlock_Release(This->wineD3DStateBlock); 72 LeaveCriticalSection(&d3d8_cs); 72 wined3d_mutex_unlock(); 73 73 74 HeapFree(GetProcessHeap(), 0, This); 74 75 } … … 84 85 TRACE("(%p) Relay\n", This); 85 86 86 EnterCriticalSection(&d3d8_cs); 87 87 wined3d_mutex_lock(); 88 88 hr = IWineD3DStateBlock_GetDevice(This->wineD3DStateBlock, &wined3d_device); 89 89 if (SUCCEEDED(hr)) … … 92 92 IWineD3DDevice_Release(wined3d_device); 93 93 } 94 95 LeaveCriticalSection(&d3d8_cs); 94 wined3d_mutex_unlock(); 96 95 97 96 return hr; … … 104 103 TRACE("(%p) Relay\n", This); 105 104 106 EnterCriticalSection(&d3d8_cs); 107 105 wined3d_mutex_lock(); 108 106 hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock); 109 110 LeaveCriticalSection(&d3d8_cs); 107 wined3d_mutex_unlock(); 111 108 112 109 return hr; … … 119 116 TRACE("(%p) Relay\n", This); 120 117 121 EnterCriticalSection(&d3d8_cs); 122 118 wined3d_mutex_lock(); 123 119 hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock); 124 125 LeaveCriticalSection(&d3d8_cs); 120 wined3d_mutex_unlock(); 126 121 127 122 return hr; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/surface.c
r21731 r23571 62 62 /* No container, handle our own refcounting */ 63 63 ULONG ref = InterlockedIncrement(&This->ref); 64 if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice); 64 if (ref == 1) 65 { 66 if (This->parentDevice) IUnknown_AddRef(This->parentDevice); 67 wined3d_mutex_lock(); 68 IUnknown_AddRef(This->wineD3DSurface); 69 wined3d_mutex_unlock(); 70 } 65 71 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 66 72 return ref; … … 85 91 if (This->parentDevice) IUnknown_Release(This->parentDevice); 86 92 /* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */ 87 if (!This->isImplicit) { 88 EnterCriticalSection(&d3d8_cs); 89 IWineD3DSurface_Release(This->wineD3DSurface); 90 LeaveCriticalSection(&d3d8_cs); 91 HeapFree(GetProcessHeap(), 0, This); 92 } 93 wined3d_mutex_lock(); 94 IWineD3DSurface_Release(This->wineD3DSurface); 95 wined3d_mutex_unlock(); 93 96 } 94 97 … … 104 107 TRACE("(%p)->(%p)\n", This, ppDevice); 105 108 106 EnterCriticalSection(&d3d8_cs);109 wined3d_mutex_lock(); 107 110 hr = IWineD3DSurface_GetDevice(This->wineD3DSurface, &wined3d_device); 108 111 if (SUCCEEDED(hr)) … … 111 114 IWineD3DDevice_Release(wined3d_device); 112 115 } 113 LeaveCriticalSection(&d3d8_cs); 116 wined3d_mutex_unlock(); 117 114 118 return hr; 115 119 } … … 120 124 TRACE("(%p) Relay\n", This); 121 125 122 EnterCriticalSection(&d3d8_cs);126 wined3d_mutex_lock(); 123 127 hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags); 124 LeaveCriticalSection(&d3d8_cs); 128 wined3d_mutex_unlock(); 129 125 130 return hr; 126 131 } … … 131 136 TRACE("(%p) Relay\n", This); 132 137 133 EnterCriticalSection(&d3d8_cs);138 wined3d_mutex_lock(); 134 139 hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData); 135 LeaveCriticalSection(&d3d8_cs); 140 wined3d_mutex_unlock(); 141 136 142 return hr; 137 143 } … … 142 148 TRACE("(%p) Relay\n", This); 143 149 144 EnterCriticalSection(&d3d8_cs);150 wined3d_mutex_lock(); 145 151 hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid); 146 LeaveCriticalSection(&d3d8_cs); 152 wined3d_mutex_unlock(); 153 147 154 return hr; 148 155 } … … 169 176 TRACE("(%p) Relay\n", This); 170 177 171 EnterCriticalSection(&d3d8_cs);178 wined3d_mutex_lock(); 172 179 hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc); 173 LeaveCriticalSection(&d3d8_cs);180 wined3d_mutex_unlock(); 174 181 175 182 if (SUCCEEDED(hr)) … … 194 201 TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags); 195 202 196 EnterCriticalSection(&d3d8_cs);203 wined3d_mutex_lock(); 197 204 if (pRect) { 198 205 D3DSURFACE_DESC desc; … … 206 213 || (pRect->bottom > desc.Height)) { 207 214 WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n"); 208 LeaveCriticalSection(&d3d8_cs); 215 wined3d_mutex_unlock(); 216 209 217 return D3DERR_INVALIDCALL; 210 218 } … … 212 220 213 221 hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags); 214 LeaveCriticalSection(&d3d8_cs); 222 wined3d_mutex_unlock(); 223 215 224 return hr; 216 225 } … … 221 230 TRACE("(%p) Relay\n", This); 222 231 223 EnterCriticalSection(&d3d8_cs);232 wined3d_mutex_lock(); 224 233 hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface); 225 LeaveCriticalSection(&d3d8_cs); 234 wined3d_mutex_unlock(); 235 226 236 switch(hr) 227 237 { … … 231 241 } 232 242 233 const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =243 static const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl = 234 244 { 235 245 /* IUnknown */ … … 248 258 IDirect3DSurface8Impl_UnlockRect 249 259 }; 260 261 static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent) 262 { 263 HeapFree(GetProcessHeap(), 0, parent); 264 } 265 266 static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = 267 { 268 surface_wined3d_object_destroyed, 269 }; 270 271 HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *device, 272 UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, 273 DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) 274 { 275 HRESULT hr; 276 277 surface->lpVtbl = &Direct3DSurface8_Vtbl; 278 surface->ref = 1; 279 280 /* FIXME: Check MAX bounds of MultisampleQuality. */ 281 if (multisample_quality > 0) 282 { 283 FIXME("Multisample quality set to %u, substituting 0.\n", multisample_quality); 284 multisample_quality = 0; 285 } 286 287 wined3d_mutex_lock(); 288 hr = IWineD3DDevice_CreateSurface(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format), 289 lockable, discard, level, &surface->wineD3DSurface, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, 290 multisample_type, multisample_quality, SURFACE_OPENGL, (IUnknown *)surface, 291 &d3d8_surface_wined3d_parent_ops); 292 wined3d_mutex_unlock(); 293 if (FAILED(hr)) 294 { 295 WARN("Failed to create wined3d surface, hr %#x.\n", hr); 296 return hr; 297 } 298 299 surface->parentDevice = (IDirect3DDevice8 *)device; 300 IUnknown_AddRef(surface->parentDevice); 301 302 return D3D_OK; 303 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/swapchain.c
r16477 r23571 66 66 67 67 if (ref == 0) { 68 EnterCriticalSection(&d3d8_cs); 69 IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D8CB_DestroyRenderTarget); 70 LeaveCriticalSection(&d3d8_cs); 68 wined3d_mutex_lock(); 69 IWineD3DSwapChain_Destroy(This->wineD3DSwapChain); 70 wined3d_mutex_unlock(); 71 71 72 if (This->parentDevice) IUnknown_Release(This->parentDevice); 72 73 HeapFree(GetProcessHeap(), 0, This); … … 81 82 TRACE("(%p) Relay\n", This); 82 83 83 EnterCriticalSection(&d3d8_cs);84 wined3d_mutex_lock(); 84 85 hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0); 85 LeaveCriticalSection(&d3d8_cs); 86 wined3d_mutex_unlock(); 87 86 88 return hr; 87 89 } … … 94 96 TRACE("(%p) Relay\n", This); 95 97 96 EnterCriticalSection(&d3d8_cs);98 wined3d_mutex_lock(); 97 99 hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE )Type, &mySurface); 98 100 if (hrc == D3D_OK && NULL != mySurface) { … … 100 102 IWineD3DSurface_Release(mySurface); 101 103 } 102 LeaveCriticalSection(&d3d8_cs); 104 wined3d_mutex_unlock(); 105 103 106 return hrc; 104 107 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/texture.c
r21731 r23571 57 57 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 58 58 59 if (ref == 1) 60 { 61 IDirect3DDevice8_AddRef(This->parentDevice); 62 wined3d_mutex_lock(); 63 IWineD3DTexture_AddRef(This->wineD3DTexture); 64 wined3d_mutex_unlock(); 65 } 66 59 67 return ref; 60 68 } … … 67 75 68 76 if (ref == 0) { 69 EnterCriticalSection(&d3d8_cs); 70 IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface); 71 LeaveCriticalSection(&d3d8_cs); 72 IUnknown_Release(This->parentDevice); 73 HeapFree(GetProcessHeap(), 0, This); 77 IDirect3DDevice8_Release(This->parentDevice); 78 wined3d_mutex_lock(); 79 IWineD3DTexture_Release(This->wineD3DTexture); 80 wined3d_mutex_unlock(); 74 81 } 75 82 return ref; … … 82 89 HRESULT hr; 83 90 TRACE("(%p) Relay\n", This); 84 EnterCriticalSection(&d3d8_cs); 91 92 wined3d_mutex_lock(); 85 93 hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device); 86 94 if (SUCCEEDED(hr)) … … 89 97 IWineD3DDevice_Release(wined3d_device); 90 98 } 91 LeaveCriticalSection(&d3d8_cs); 99 wined3d_mutex_unlock(); 100 92 101 return hr; 93 102 } … … 98 107 TRACE("(%p) Relay\n", This); 99 108 100 EnterCriticalSection(&d3d8_cs);109 wined3d_mutex_lock(); 101 110 hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags); 102 LeaveCriticalSection(&d3d8_cs); 111 wined3d_mutex_unlock(); 112 103 113 return hr; 104 114 } … … 109 119 TRACE("(%p) Relay\n", This); 110 120 111 EnterCriticalSection(&d3d8_cs);121 wined3d_mutex_lock(); 112 122 hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData); 113 LeaveCriticalSection(&d3d8_cs); 123 wined3d_mutex_unlock(); 124 114 125 return hr; 115 126 } … … 120 131 TRACE("(%p) Relay\n", This); 121 132 122 EnterCriticalSection(&d3d8_cs);133 wined3d_mutex_lock(); 123 134 hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid); 124 LeaveCriticalSection(&d3d8_cs); 135 wined3d_mutex_unlock(); 136 125 137 return hr; 126 138 } … … 131 143 TRACE("(%p) Relay\n", This); 132 144 133 EnterCriticalSection(&d3d8_cs);145 wined3d_mutex_lock(); 134 146 ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew); 135 LeaveCriticalSection(&d3d8_cs); 147 wined3d_mutex_unlock(); 148 136 149 return ret; 137 150 } … … 142 155 TRACE("(%p) Relay\n", This); 143 156 144 EnterCriticalSection(&d3d8_cs);157 wined3d_mutex_lock(); 145 158 ret = IWineD3DTexture_GetPriority(This->wineD3DTexture); 146 LeaveCriticalSection(&d3d8_cs); 159 wined3d_mutex_unlock(); 160 147 161 return ret; 148 162 } … … 152 166 TRACE("(%p) Relay\n", This); 153 167 154 EnterCriticalSection(&d3d8_cs);168 wined3d_mutex_lock(); 155 169 IWineD3DTexture_PreLoad(This->wineD3DTexture); 156 LeaveCriticalSection(&d3d8_cs);170 wined3d_mutex_unlock(); 157 171 } 158 172 … … 162 176 TRACE("(%p) Relay\n", This); 163 177 164 EnterCriticalSection(&d3d8_cs);178 wined3d_mutex_lock(); 165 179 type = IWineD3DTexture_GetType(This->wineD3DTexture); 166 LeaveCriticalSection(&d3d8_cs); 180 wined3d_mutex_unlock(); 181 167 182 return type; 168 183 } … … 174 189 TRACE("(%p) Relay\n", This); 175 190 176 EnterCriticalSection(&d3d8_cs);191 wined3d_mutex_lock(); 177 192 ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew); 178 LeaveCriticalSection(&d3d8_cs); 193 wined3d_mutex_unlock(); 194 179 195 return ret; 180 196 } … … 185 201 TRACE("(%p) Relay\n", This); 186 202 187 EnterCriticalSection(&d3d8_cs);203 wined3d_mutex_lock(); 188 204 ret = IWineD3DTexture_GetLOD(This->wineD3DTexture); 189 LeaveCriticalSection(&d3d8_cs); 205 wined3d_mutex_unlock(); 206 190 207 return ret; 191 208 } … … 196 213 TRACE("(%p) Relay\n", This); 197 214 198 EnterCriticalSection(&d3d8_cs);215 wined3d_mutex_lock(); 199 216 ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture); 200 LeaveCriticalSection(&d3d8_cs); 217 wined3d_mutex_unlock(); 218 201 219 return ret; 202 220 } … … 210 228 TRACE("(%p) Relay\n", This); 211 229 212 EnterCriticalSection(&d3d8_cs);230 wined3d_mutex_lock(); 213 231 hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc); 214 LeaveCriticalSection(&d3d8_cs);232 wined3d_mutex_unlock(); 215 233 216 234 if (SUCCEEDED(hr)) … … 235 253 236 254 TRACE("(%p) Relay\n", This); 237 EnterCriticalSection(&d3d8_cs); 255 256 wined3d_mutex_lock(); 238 257 hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface); 239 258 if (hrc == D3D_OK && NULL != ppSurfaceLevel) { … … 241 260 IWineD3DSurface_Release(mySurface); 242 261 } 243 LeaveCriticalSection(&d3d8_cs); 262 wined3d_mutex_unlock(); 263 244 264 return hrc; 245 265 } … … 250 270 TRACE("(%p) Relay\n", This); 251 271 252 EnterCriticalSection(&d3d8_cs);272 wined3d_mutex_lock(); 253 273 hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags); 254 LeaveCriticalSection(&d3d8_cs); 274 wined3d_mutex_unlock(); 275 255 276 return hr; 256 277 } … … 261 282 TRACE("(%p) Relay\n", This); 262 283 263 EnterCriticalSection(&d3d8_cs);284 wined3d_mutex_lock(); 264 285 hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level); 265 LeaveCriticalSection(&d3d8_cs); 286 wined3d_mutex_unlock(); 287 266 288 return hr; 267 289 } … … 272 294 TRACE("(%p) Relay\n", This); 273 295 274 EnterCriticalSection(&d3d8_cs);296 wined3d_mutex_lock(); 275 297 hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect); 276 LeaveCriticalSection(&d3d8_cs); 277 return hr; 278 } 279 280 const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl = 298 wined3d_mutex_unlock(); 299 300 return hr; 301 } 302 303 static const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl = 281 304 { 282 305 /* IUnknown */ … … 304 327 IDirect3DTexture8Impl_AddDirtyRect 305 328 }; 329 330 static void STDMETHODCALLTYPE d3d8_texture_wined3d_object_destroyed(void *parent) 331 { 332 HeapFree(GetProcessHeap(), 0, parent); 333 } 334 335 static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops = 336 { 337 d3d8_texture_wined3d_object_destroyed, 338 }; 339 340 HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *device, 341 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) 342 { 343 HRESULT hr; 344 345 texture->lpVtbl = &Direct3DTexture8_Vtbl; 346 texture->ref = 1; 347 348 wined3d_mutex_lock(); 349 hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels, 350 usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, 351 &texture->wineD3DTexture, (IUnknown *)texture, &d3d8_texture_wined3d_parent_ops); 352 wined3d_mutex_unlock(); 353 if (FAILED(hr)) 354 { 355 WARN("Failed to create wined3d texture, hr %#x.\n", hr); 356 return hr; 357 } 358 359 texture->parentDevice = (IDirect3DDevice8 *)device; 360 IDirect3DDevice8_AddRef(texture->parentDevice); 361 362 return D3D_OK; 363 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexbuffer.c
r19678 r23571 57 57 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 58 58 59 if (ref == 1) 60 { 61 IDirect3DDevice8_AddRef(This->parentDevice); 62 wined3d_mutex_lock(); 63 IWineD3DBuffer_AddRef(This->wineD3DVertexBuffer); 64 wined3d_mutex_unlock(); 65 } 66 59 67 return ref; 60 68 } … … 67 75 68 76 if (ref == 0) { 69 EnterCriticalSection(&d3d8_cs); 77 IDirect3DDevice8_Release(This->parentDevice); 78 wined3d_mutex_lock(); 70 79 IWineD3DBuffer_Release(This->wineD3DVertexBuffer); 71 LeaveCriticalSection(&d3d8_cs); 72 IUnknown_Release(This->parentDevice); 73 HeapFree(GetProcessHeap(), 0, This); 80 wined3d_mutex_unlock(); 74 81 } 75 82 … … 84 91 TRACE("(%p) Relay\n", This); 85 92 86 EnterCriticalSection(&d3d8_cs);93 wined3d_mutex_lock(); 87 94 hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device); 88 95 if (SUCCEEDED(hr)) … … 91 98 IWineD3DDevice_Release(wined3d_device); 92 99 } 93 LeaveCriticalSection(&d3d8_cs); 100 wined3d_mutex_unlock(); 101 94 102 return hr; 95 103 } … … 100 108 TRACE("(%p) Relay\n", This); 101 109 102 EnterCriticalSection(&d3d8_cs);110 wined3d_mutex_lock(); 103 111 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags); 104 LeaveCriticalSection(&d3d8_cs); 112 wined3d_mutex_unlock(); 113 105 114 return hr; 106 115 } … … 111 120 TRACE("(%p) Relay\n", This); 112 121 113 EnterCriticalSection(&d3d8_cs);122 wined3d_mutex_lock(); 114 123 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData); 115 LeaveCriticalSection(&d3d8_cs); 124 wined3d_mutex_unlock(); 125 116 126 return hr; 117 127 } … … 122 132 TRACE("(%p) Relay\n", This); 123 133 124 EnterCriticalSection(&d3d8_cs);134 wined3d_mutex_lock(); 125 135 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid); 126 LeaveCriticalSection(&d3d8_cs); 136 wined3d_mutex_unlock(); 137 127 138 return hr; 128 139 } … … 133 144 TRACE("(%p) Relay\n", This); 134 145 135 EnterCriticalSection(&d3d8_cs);146 wined3d_mutex_lock(); 136 147 ret = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew); 137 LeaveCriticalSection(&d3d8_cs); 148 wined3d_mutex_unlock(); 149 138 150 return ret; 139 151 } … … 144 156 TRACE("(%p) Relay\n", This); 145 157 146 EnterCriticalSection(&d3d8_cs);158 wined3d_mutex_lock(); 147 159 ret = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer); 148 LeaveCriticalSection(&d3d8_cs); 160 wined3d_mutex_unlock(); 161 149 162 return ret; 150 163 } … … 154 167 TRACE("(%p) Relay\n", This); 155 168 156 EnterCriticalSection(&d3d8_cs);169 wined3d_mutex_lock(); 157 170 IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer); 158 LeaveCriticalSection(&d3d8_cs);171 wined3d_mutex_unlock(); 159 172 } 160 173 … … 172 185 TRACE("(%p) Relay\n", This); 173 186 174 EnterCriticalSection(&d3d8_cs);187 wined3d_mutex_lock(); 175 188 hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags); 176 LeaveCriticalSection(&d3d8_cs); 189 wined3d_mutex_unlock(); 190 177 191 return hr; 178 192 } … … 183 197 TRACE("(%p) Relay\n", This); 184 198 185 EnterCriticalSection(&d3d8_cs);199 wined3d_mutex_lock(); 186 200 hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer); 187 LeaveCriticalSection(&d3d8_cs); 201 wined3d_mutex_unlock(); 202 188 203 return hr; 189 204 } … … 195 210 TRACE("(%p) Relay\n", This); 196 211 197 EnterCriticalSection(&d3d8_cs);212 wined3d_mutex_lock(); 198 213 hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc); 199 LeaveCriticalSection(&d3d8_cs);214 wined3d_mutex_unlock(); 200 215 201 216 if (SUCCEEDED(hr)) { … … 211 226 } 212 227 213 const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =228 static const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl = 214 229 { 215 230 /* IUnknown */ … … 231 246 IDirect3DVertexBuffer8Impl_GetDesc 232 247 }; 248 249 static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *parent) 250 { 251 HeapFree(GetProcessHeap(), 0, parent); 252 } 253 254 static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops = 255 { 256 d3d8_vertexbuffer_wined3d_object_destroyed, 257 }; 258 259 HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Impl *device, 260 UINT size, DWORD usage, DWORD fvf, D3DPOOL pool) 261 { 262 HRESULT hr; 263 264 buffer->lpVtbl = &Direct3DVertexBuffer8_Vtbl; 265 buffer->ref = 1; 266 buffer->fvf = fvf; 267 268 wined3d_mutex_lock(); 269 hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size, 270 usage & WINED3DUSAGE_MASK, 0, (WINED3DPOOL)pool, &buffer->wineD3DVertexBuffer, 271 (IUnknown *)buffer, &d3d8_vertexbuffer_wined3d_parent_ops); 272 wined3d_mutex_unlock(); 273 if (FAILED(hr)) 274 { 275 WARN("Failed to create wined3d buffer, hr %#x.\n", hr); 276 return hr; 277 } 278 279 buffer->parentDevice = (IDirect3DDevice8 *)device; 280 IUnknown_AddRef(buffer->parentDevice); 281 282 return D3D_OK; 283 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexdeclaration.c
r19678 r23571 60 60 TRACE("(%p) : AddRef increasing to %d\n", This, ref_count); 61 61 62 if (ref_count == 1) 63 { 64 wined3d_mutex_lock(); 65 IWineD3DVertexDeclaration_AddRef(This->wined3d_vertex_declaration); 66 wined3d_mutex_unlock(); 67 } 68 62 69 return ref_count; 63 70 } … … 71 78 72 79 if (!ref_count) { 73 EnterCriticalSection(&d3d8_cs);80 wined3d_mutex_lock(); 74 81 IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration); 75 LeaveCriticalSection(&d3d8_cs); 76 HeapFree(GetProcessHeap(), 0, This->elements); 77 HeapFree(GetProcessHeap(), 0, This); 82 wined3d_mutex_unlock(); 78 83 } 79 84 … … 265 270 /*WINED3DDECLTYPE_FLOAT3*/ WINED3DFMT_R32G32B32_FLOAT, 266 271 /*WINED3DDECLTYPE_FLOAT4*/ WINED3DFMT_R32G32B32A32_FLOAT, 267 /*WINED3DDECLTYPE_D3DCOLOR*/ WINED3DFMT_ A8R8G8B8,272 /*WINED3DDECLTYPE_D3DCOLOR*/ WINED3DFMT_B8G8R8A8_UNORM, 268 273 /*WINED3DDECLTYPE_UBYTE4*/ WINED3DFMT_R8G8B8A8_UINT, 269 274 /*WINED3DDECLTYPE_SHORT2*/ WINED3DFMT_R16G16_SINT, … … 361 366 } 362 367 363 const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl =368 static const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl = 364 369 { 365 370 IDirect3DVertexDeclaration8Impl_QueryInterface, … … 367 372 IDirect3DVertexDeclaration8Impl_Release 368 373 }; 374 375 static void STDMETHODCALLTYPE d3d8_vertexdeclaration_wined3d_object_destroyed(void *parent) 376 { 377 IDirect3DVertexDeclaration8Impl *declaration = parent; 378 HeapFree(GetProcessHeap(), 0, declaration->elements); 379 HeapFree(GetProcessHeap(), 0, declaration); 380 } 381 382 static const struct wined3d_parent_ops d3d8_vertexdeclaration_wined3d_parent_ops = 383 { 384 d3d8_vertexdeclaration_wined3d_object_destroyed, 385 }; 386 387 HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration8Impl *declaration, 388 IDirect3DDevice8Impl *device, const DWORD *elements, DWORD shader_handle) 389 { 390 WINED3DVERTEXELEMENT *wined3d_elements; 391 UINT wined3d_element_count; 392 HRESULT hr; 393 394 declaration->lpVtbl = &Direct3DVertexDeclaration8_Vtbl; 395 declaration->ref_count = 1; 396 declaration->shader_handle = shader_handle; 397 398 wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size, &wined3d_elements); 399 declaration->elements = HeapAlloc(GetProcessHeap(), 0, declaration->elements_size); 400 if (!declaration->elements) 401 { 402 ERR("Failed to allocate vertex declaration elements memory.\n"); 403 HeapFree(GetProcessHeap(), 0, wined3d_elements); 404 return E_OUTOFMEMORY; 405 } 406 407 memcpy(declaration->elements, elements, declaration->elements_size); 408 409 wined3d_mutex_lock(); 410 hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, &declaration->wined3d_vertex_declaration, 411 (IUnknown *)declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, 412 wined3d_elements, wined3d_element_count); 413 wined3d_mutex_unlock(); 414 HeapFree(GetProcessHeap(), 0, wined3d_elements); 415 if (FAILED(hr)) 416 { 417 WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr); 418 HeapFree(GetProcessHeap(), 0, declaration->elements); 419 return hr; 420 } 421 422 return D3D_OK; 423 } 424 425 HRESULT vertexdeclaration_init_fvf(IDirect3DVertexDeclaration8Impl *declaration, 426 IDirect3DDevice8Impl *device, DWORD fvf) 427 { 428 HRESULT hr; 429 430 declaration->ref_count = 1; 431 declaration->lpVtbl = &Direct3DVertexDeclaration8_Vtbl; 432 declaration->elements = NULL; 433 declaration->elements_size = 0; 434 declaration->shader_handle = fvf; 435 436 hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(device->WineD3DDevice, 437 &declaration->wined3d_vertex_declaration, (IUnknown *)declaration, 438 &d3d8_vertexdeclaration_wined3d_parent_ops, fvf); 439 if (FAILED(hr)) 440 { 441 WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr); 442 return hr; 443 } 444 445 return D3D_OK; 446 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexshader.c
r19678 r23571 56 56 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 57 57 58 if (ref == 1 && This->wineD3DVertexShader) 59 { 60 wined3d_mutex_lock(); 61 IWineD3DVertexShader_AddRef(This->wineD3DVertexShader); 62 wined3d_mutex_unlock(); 63 } 64 58 65 return ref; 66 } 67 68 static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent) 69 { 70 IDirect3DVertexShader8Impl *shader = parent; 71 IDirect3DVertexDeclaration8_Release(shader->vertex_declaration); 72 HeapFree(GetProcessHeap(), 0, shader); 59 73 } 60 74 … … 66 80 67 81 if (ref == 0) { 68 IDirect3DVertexDeclaration8_Release(This->vertex_declaration);69 82 if (This->wineD3DVertexShader) 70 83 { 71 EnterCriticalSection(&d3d8_cs);84 wined3d_mutex_lock(); 72 85 IWineD3DVertexShader_Release(This->wineD3DVertexShader); 73 LeaveCriticalSection(&d3d8_cs);86 wined3d_mutex_unlock(); 74 87 } 75 HeapFree(GetProcessHeap(), 0, This); 88 else 89 { 90 d3d8_vertexshader_wined3d_object_destroyed(This); 91 } 76 92 } 77 93 return ref; 78 94 } 79 95 80 const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl =96 static const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl = 81 97 { 82 98 /* IUnknown */ … … 85 101 IDirect3DVertexShader8Impl_Release, 86 102 }; 103 104 static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops = 105 { 106 d3d8_vertexshader_wined3d_object_destroyed, 107 }; 108 109 static HRESULT vertexshader_create_vertexdeclaration(IDirect3DDevice8Impl *device, 110 const DWORD *declaration, DWORD shader_handle, IDirect3DVertexDeclaration8 **decl_ptr) 111 { 112 IDirect3DVertexDeclaration8Impl *object; 113 HRESULT hr; 114 115 TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n", 116 device, declaration, shader_handle, decl_ptr); 117 118 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 119 if (!object) { 120 ERR("Memory allocation failed\n"); 121 *decl_ptr = NULL; 122 return D3DERR_OUTOFVIDEOMEMORY; 123 } 124 125 hr = vertexdeclaration_init(object, device, declaration, shader_handle); 126 if (FAILED(hr)) 127 { 128 WARN("Failed to initialize vertex declaration, hr %#x.\n", hr); 129 HeapFree(GetProcessHeap(), 0, object); 130 return hr; 131 } 132 133 TRACE("Created vertex declaration %p.\n", object); 134 *decl_ptr = (IDirect3DVertexDeclaration8 *)object; 135 136 return D3D_OK; 137 } 138 139 HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device, 140 const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage) 141 { 142 const DWORD *token = declaration; 143 HRESULT hr; 144 145 /* Test if the vertex declaration is valid */ 146 while (D3DVSD_END() != *token) 147 { 148 D3DVSD_TOKENTYPE token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); 149 150 if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000)) 151 { 152 DWORD type = ((*token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT); 153 DWORD reg = ((*token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT); 154 155 if (reg == D3DVSDE_NORMAL && type != D3DVSDT_FLOAT3 && !byte_code) 156 { 157 WARN("Attempt to use a non-FLOAT3 normal with the fixed function function\n"); 158 return D3DERR_INVALIDCALL; 159 } 160 } 161 token += parse_token(token); 162 } 163 164 shader->ref = 1; 165 shader->lpVtbl = &Direct3DVertexShader8_Vtbl; 166 167 hr = vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration); 168 if (FAILED(hr)) 169 { 170 WARN("Failed to create vertex declaration, hr %#x.\n", hr); 171 return hr; 172 } 173 174 if (byte_code) 175 { 176 if (usage) FIXME("Usage %#x not implemented.\n", usage); 177 178 wined3d_mutex_lock(); 179 hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code, 180 NULL /* output signature */, &shader->wineD3DVertexShader, 181 (IUnknown *)shader, &d3d8_vertexshader_wined3d_parent_ops); 182 wined3d_mutex_unlock(); 183 if (FAILED(hr)) 184 { 185 WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr); 186 IDirect3DVertexDeclaration8_Release(shader->vertex_declaration); 187 return hr; 188 } 189 190 load_local_constants(declaration, shader->wineD3DVertexShader); 191 } 192 193 return D3D_OK; 194 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/volume.c
r21731 r23571 62 62 ULONG ref = InterlockedIncrement(&This->ref); 63 63 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 64 65 if (ref == 1) 66 { 67 wined3d_mutex_lock(); 68 IWineD3DVolume_AddRef(This->wineD3DVolume); 69 wined3d_mutex_unlock(); 70 } 71 64 72 return ref; 65 73 } … … 82 90 83 91 if (ref == 0) { 84 EnterCriticalSection(&d3d8_cs);92 wined3d_mutex_lock(); 85 93 IWineD3DVolume_Release(This->wineD3DVolume); 86 LeaveCriticalSection(&d3d8_cs); 87 HeapFree(GetProcessHeap(), 0, This); 94 wined3d_mutex_unlock(); 88 95 } 89 96 … … 97 104 IWineD3DDevice *myDevice = NULL; 98 105 99 EnterCriticalSection(&d3d8_cs);106 wined3d_mutex_lock(); 100 107 IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice); 101 108 IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice); 102 109 IWineD3DDevice_Release(myDevice); 103 LeaveCriticalSection(&d3d8_cs); 110 wined3d_mutex_unlock(); 111 104 112 return D3D_OK; 105 113 } … … 110 118 TRACE("(%p) Relay\n", This); 111 119 112 EnterCriticalSection(&d3d8_cs);120 wined3d_mutex_lock(); 113 121 hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags); 114 LeaveCriticalSection(&d3d8_cs); 122 wined3d_mutex_unlock(); 123 115 124 return hr; 116 125 } … … 121 130 TRACE("(%p) Relay\n", This); 122 131 123 EnterCriticalSection(&d3d8_cs);132 wined3d_mutex_lock(); 124 133 hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData); 125 LeaveCriticalSection(&d3d8_cs); 134 wined3d_mutex_unlock(); 135 126 136 return hr; 127 137 } … … 132 142 TRACE("(%p) Relay\n", This); 133 143 134 EnterCriticalSection(&d3d8_cs);144 wined3d_mutex_lock(); 135 145 hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid); 136 LeaveCriticalSection(&d3d8_cs); 146 wined3d_mutex_unlock(); 147 137 148 return hr; 138 149 } … … 164 175 TRACE("(%p) Relay\n", This); 165 176 166 EnterCriticalSection(&d3d8_cs);177 wined3d_mutex_lock(); 167 178 hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc); 168 LeaveCriticalSection(&d3d8_cs);179 wined3d_mutex_unlock(); 169 180 170 181 if (SUCCEEDED(hr)) … … 188 199 TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags); 189 200 190 EnterCriticalSection(&d3d8_cs);201 wined3d_mutex_lock(); 191 202 hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags); 192 LeaveCriticalSection(&d3d8_cs); 203 wined3d_mutex_unlock(); 204 193 205 return hr; 194 206 } … … 199 211 TRACE("(%p) relay %p\n", This, This->wineD3DVolume); 200 212 201 EnterCriticalSection(&d3d8_cs);213 wined3d_mutex_lock(); 202 214 hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume); 203 LeaveCriticalSection(&d3d8_cs); 204 return hr; 205 } 206 207 const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl = 215 wined3d_mutex_unlock(); 216 217 return hr; 218 } 219 220 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl = 208 221 { 209 222 /* IUnknown */ … … 222 235 }; 223 236 224 ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) { 225 IDirect3DVolume8Impl* volumeParent; 226 227 IWineD3DVolume_GetParent(pVolume, (IUnknown **) &volumeParent); 228 /* GetParent's AddRef was forwarded to an object in destruction. 229 * Releasing it here again would cause an endless recursion. */ 230 volumeParent->forwardReference = NULL; 231 return IDirect3DVolume8_Release((IDirect3DVolume8*) volumeParent); 232 } 237 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) 238 { 239 HeapFree(GetProcessHeap(), 0, parent); 240 } 241 242 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = 243 { 244 volume_wined3d_object_destroyed, 245 }; 246 247 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height, 248 UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool) 249 { 250 HRESULT hr; 251 252 volume->lpVtbl = &Direct3DVolume8_Vtbl; 253 volume->ref = 1; 254 255 hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage, 256 format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d8_volume_wined3d_parent_ops); 257 if (FAILED(hr)) 258 { 259 WARN("Failed to create wined3d volume, hr %#x.\n", hr); 260 return hr; 261 } 262 263 return D3D_OK; 264 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/volumetexture.c
r21731 r23571 57 57 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 58 58 59 if (ref == 1) 60 { 61 IDirect3DDevice8_AddRef(This->parentDevice); 62 wined3d_mutex_lock(); 63 IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture); 64 wined3d_mutex_unlock(); 65 } 66 59 67 return ref; 60 68 } … … 67 75 68 76 if (ref == 0) { 69 EnterCriticalSection(&d3d8_cs);70 IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D8CB_DestroyVolume);71 LeaveCriticalSection(&d3d8_cs);72 77 IUnknown_Release(This->parentDevice); 73 HeapFree(GetProcessHeap(), 0, This); 78 wined3d_mutex_lock(); 79 IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture); 80 wined3d_mutex_unlock(); 74 81 } 75 82 return ref; … … 83 90 TRACE("(%p) Relay\n", This); 84 91 85 EnterCriticalSection(&d3d8_cs);92 wined3d_mutex_lock(); 86 93 hr = IWineD3DVolumeTexture_GetDevice(This->wineD3DVolumeTexture, &wined3d_device); 87 94 if (SUCCEEDED(hr)) … … 90 97 IWineD3DDevice_Release(wined3d_device); 91 98 } 92 LeaveCriticalSection(&d3d8_cs); 99 wined3d_mutex_unlock(); 100 93 101 return hr; 94 102 } … … 99 107 TRACE("(%p) Relay\n", This); 100 108 101 EnterCriticalSection(&d3d8_cs);109 wined3d_mutex_lock(); 102 110 hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags); 103 LeaveCriticalSection(&d3d8_cs); 111 wined3d_mutex_unlock(); 112 104 113 return hr; 105 114 } … … 110 119 TRACE("(%p) Relay\n", This); 111 120 112 EnterCriticalSection(&d3d8_cs);121 wined3d_mutex_lock(); 113 122 hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData); 114 LeaveCriticalSection(&d3d8_cs); 123 wined3d_mutex_unlock(); 124 115 125 return hr; 116 126 } … … 121 131 TRACE("(%p) Relay\n", This); 122 132 123 EnterCriticalSection(&d3d8_cs);133 wined3d_mutex_lock(); 124 134 hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid); 125 LeaveCriticalSection(&d3d8_cs); 135 wined3d_mutex_unlock(); 136 126 137 return hr; 127 138 } … … 132 143 TRACE("(%p) Relay\n", This); 133 144 134 EnterCriticalSection(&d3d8_cs);145 wined3d_mutex_lock(); 135 146 ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew); 136 LeaveCriticalSection(&d3d8_cs); 147 wined3d_mutex_unlock(); 148 137 149 return ret; 138 150 } … … 143 155 TRACE("(%p) Relay\n", This); 144 156 145 EnterCriticalSection(&d3d8_cs);157 wined3d_mutex_lock(); 146 158 ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture); 147 LeaveCriticalSection(&d3d8_cs); 159 wined3d_mutex_unlock(); 160 148 161 return ret; 149 162 } … … 153 166 TRACE("(%p) Relay\n", This); 154 167 155 EnterCriticalSection(&d3d8_cs);168 wined3d_mutex_lock(); 156 169 IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture); 157 LeaveCriticalSection(&d3d8_cs);170 wined3d_mutex_unlock(); 158 171 } 159 172 … … 163 176 TRACE("(%p) Relay\n", This); 164 177 165 EnterCriticalSection(&d3d8_cs);178 wined3d_mutex_lock(); 166 179 type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture); 167 LeaveCriticalSection(&d3d8_cs); 180 wined3d_mutex_unlock(); 181 168 182 return type; 169 183 } … … 175 189 TRACE("(%p) Relay\n", This); 176 190 177 EnterCriticalSection(&d3d8_cs);191 wined3d_mutex_lock(); 178 192 ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew); 179 LeaveCriticalSection(&d3d8_cs); 193 wined3d_mutex_unlock(); 194 180 195 return ret; 181 196 } … … 186 201 TRACE("(%p) Relay\n", This); 187 202 188 EnterCriticalSection(&d3d8_cs);203 wined3d_mutex_lock(); 189 204 ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture); 190 LeaveCriticalSection(&d3d8_cs); 205 wined3d_mutex_unlock(); 206 191 207 return ret; 192 208 } … … 197 213 TRACE("(%p) Relay\n", This); 198 214 199 EnterCriticalSection(&d3d8_cs);215 wined3d_mutex_lock(); 200 216 ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture); 201 LeaveCriticalSection(&d3d8_cs); 217 wined3d_mutex_unlock(); 218 202 219 return ret; 203 220 } … … 211 228 TRACE("(%p) Relay\n", This); 212 229 213 EnterCriticalSection(&d3d8_cs);230 wined3d_mutex_lock(); 214 231 hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc); 215 LeaveCriticalSection(&d3d8_cs);232 wined3d_mutex_unlock(); 216 233 217 234 if (SUCCEEDED(hr)) … … 237 254 TRACE("(%p) Relay\n", This); 238 255 239 EnterCriticalSection(&d3d8_cs);256 wined3d_mutex_lock(); 240 257 hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume); 241 258 if (hrc == D3D_OK && NULL != ppVolumeLevel) { … … 243 260 IWineD3DVolumeTexture_Release(myVolume); 244 261 } 245 LeaveCriticalSection(&d3d8_cs); 262 wined3d_mutex_unlock(); 263 246 264 return hrc; 247 265 } … … 252 270 TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags); 253 271 254 EnterCriticalSection(&d3d8_cs);272 wined3d_mutex_lock(); 255 273 hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags); 256 LeaveCriticalSection(&d3d8_cs); 274 wined3d_mutex_unlock(); 275 257 276 return hr; 258 277 } … … 263 282 TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level); 264 283 265 EnterCriticalSection(&d3d8_cs);284 wined3d_mutex_lock(); 266 285 hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level); 267 LeaveCriticalSection(&d3d8_cs); 286 wined3d_mutex_unlock(); 287 268 288 return hr; 269 289 } … … 274 294 TRACE("(%p) Relay\n", This); 275 295 276 EnterCriticalSection(&d3d8_cs);296 wined3d_mutex_lock(); 277 297 hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox); 278 LeaveCriticalSection(&d3d8_cs);279 return hr; 280 } 281 282 283 const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =298 wined3d_mutex_unlock(); 299 300 return hr; 301 } 302 303 static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl = 284 304 { 285 305 /* IUnknown */ … … 307 327 IDirect3DVolumeTexture8Impl_AddDirtyBox 308 328 }; 329 330 static void STDMETHODCALLTYPE volumetexture_wined3d_object_destroyed(void *parent) 331 { 332 HeapFree(GetProcessHeap(), 0, parent); 333 } 334 335 static const struct wined3d_parent_ops d3d8_volumetexture_wined3d_parent_ops = 336 { 337 volumetexture_wined3d_object_destroyed, 338 }; 339 340 HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device, 341 UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) 342 { 343 HRESULT hr; 344 345 texture->lpVtbl = &Direct3DVolumeTexture8_Vtbl; 346 texture->ref = 1; 347 348 wined3d_mutex_lock(); 349 hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels, 350 usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, 351 &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d8_volumetexture_wined3d_parent_ops); 352 wined3d_mutex_unlock(); 353 if (FAILED(hr)) 354 { 355 WARN("Failed to create wined3d volume texture, hr %#x.\n", hr); 356 return hr; 357 } 358 359 texture->parentDevice = (IDirect3DDevice8 *)device; 360 IDirect3DDevice8_AddRef(texture->parentDevice); 361 362 return D3D_OK; 363 }
Note:
See TracChangeset
for help on using the changeset viewer.