Changeset 23571 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/indexbuffer.c
- Timestamp:
- Oct 6, 2009 6:07:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/indexbuffer.c
r19678 r23571 57 57 TRACE("(%p) : AddRef from %d\n", This, ref - 1); 58 58 59 if (ref == 1) 60 { 61 IDirect3DDevice9Ex_AddRef(This->parentDevice); 62 wined3d_mutex_lock(); 63 IWineD3DBuffer_AddRef(This->wineD3DIndexBuffer); 64 wined3d_mutex_unlock(); 65 } 66 59 67 return ref; 60 68 } … … 67 75 68 76 if (ref == 0) { 69 EnterCriticalSection(&d3d9_cs); 77 IDirect3DDevice9Ex_Release(This->parentDevice); 78 wined3d_mutex_lock(); 70 79 IWineD3DBuffer_Release(This->wineD3DIndexBuffer); 71 LeaveCriticalSection(&d3d9_cs); 72 IDirect3DDevice9Ex_Release(This->parentDevice); 73 HeapFree(GetProcessHeap(), 0, This); 80 wined3d_mutex_unlock(); 74 81 } 75 82 return ref; … … 83 90 TRACE("(%p) Relay\n", This); 84 91 85 EnterCriticalSection(&d3d9_cs);92 wined3d_mutex_lock(); 86 93 hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device); 87 94 if (SUCCEEDED(hr)) … … 90 97 IWineD3DDevice_Release(wined3d_device); 91 98 } 92 LeaveCriticalSection(&d3d9_cs); 99 wined3d_mutex_unlock(); 100 93 101 return hr; 94 102 } … … 99 107 TRACE("(%p) Relay\n", This); 100 108 101 EnterCriticalSection(&d3d9_cs);109 wined3d_mutex_lock(); 102 110 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags); 103 LeaveCriticalSection(&d3d9_cs); 111 wined3d_mutex_unlock(); 112 104 113 return hr; 105 114 } … … 110 119 TRACE("(%p) Relay\n", This); 111 120 112 EnterCriticalSection(&d3d9_cs);121 wined3d_mutex_lock(); 113 122 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData); 114 LeaveCriticalSection(&d3d9_cs); 123 wined3d_mutex_unlock(); 124 115 125 return hr; 116 126 } … … 121 131 TRACE("(%p) Relay\n", This); 122 132 123 EnterCriticalSection(&d3d9_cs);133 wined3d_mutex_lock(); 124 134 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid); 125 LeaveCriticalSection(&d3d9_cs); 135 wined3d_mutex_unlock(); 136 126 137 return hr; 127 138 } … … 132 143 TRACE("(%p) Relay\n", This); 133 144 134 EnterCriticalSection(&d3d9_cs);145 wined3d_mutex_lock(); 135 146 ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew); 136 LeaveCriticalSection(&d3d9_cs); 147 wined3d_mutex_unlock(); 148 137 149 return ret; 138 150 } … … 143 155 TRACE("(%p) Relay\n", This); 144 156 145 EnterCriticalSection(&d3d9_cs);157 wined3d_mutex_lock(); 146 158 ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer); 147 LeaveCriticalSection(&d3d9_cs); 159 wined3d_mutex_unlock(); 160 148 161 return ret; 149 162 } … … 153 166 TRACE("(%p) Relay\n", This); 154 167 155 EnterCriticalSection(&d3d9_cs);168 wined3d_mutex_lock(); 156 169 IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer); 157 LeaveCriticalSection(&d3d9_cs);170 wined3d_mutex_unlock(); 158 171 } 159 172 … … 171 184 TRACE("(%p) Relay\n", This); 172 185 173 EnterCriticalSection(&d3d9_cs);186 wined3d_mutex_lock(); 174 187 hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags); 175 LeaveCriticalSection(&d3d9_cs); 188 wined3d_mutex_unlock(); 189 176 190 return hr; 177 191 } … … 182 196 TRACE("(%p) Relay\n", This); 183 197 184 EnterCriticalSection(&d3d9_cs);198 wined3d_mutex_lock(); 185 199 hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer); 186 LeaveCriticalSection(&d3d9_cs); 200 wined3d_mutex_unlock(); 201 187 202 return hr; 188 203 } … … 194 209 TRACE("(%p) Relay\n", This); 195 210 196 EnterCriticalSection(&d3d9_cs);211 wined3d_mutex_lock(); 197 212 hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc); 198 LeaveCriticalSection(&d3d9_cs);213 wined3d_mutex_unlock(); 199 214 200 215 if (SUCCEEDED(hr)) { … … 231 246 }; 232 247 233 234 /* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */ 235 HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface, 236 UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, 237 IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) { 238 239 IDirect3DIndexBuffer9Impl *object; 240 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; 241 HRESULT hrc = D3D_OK; 242 243 TRACE("(%p) Relay\n", This); 244 /* Allocate the storage for the device */ 245 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 246 if (NULL == object) { 247 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n"); 248 return D3DERR_OUTOFVIDEOMEMORY; 249 } 250 251 object->lpVtbl = &Direct3DIndexBuffer9_Vtbl; 252 object->ref = 1; 253 object->format = wined3dformat_from_d3dformat(Format); 254 TRACE("Calling wined3d create index buffer\n"); 255 EnterCriticalSection(&d3d9_cs); 256 hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, 257 (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer, (IUnknown *)object); 258 LeaveCriticalSection(&d3d9_cs); 259 if (hrc != D3D_OK) { 260 261 /* free up object */ 262 FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This); 263 HeapFree(GetProcessHeap(), 0, object); 264 } else { 265 IDirect3DDevice9Ex_AddRef(iface); 266 object->parentDevice = iface; 267 *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object; 268 TRACE("(%p) : Created index buffer %p\n", This, object); 269 } 270 return hrc; 271 } 248 static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *parent) 249 { 250 HeapFree(GetProcessHeap(), 0, parent); 251 } 252 253 static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops = 254 { 255 d3d9_indexbuffer_wined3d_object_destroyed, 256 }; 257 258 HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl *device, 259 UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) 260 { 261 HRESULT hr; 262 263 buffer->lpVtbl = &Direct3DIndexBuffer9_Vtbl; 264 buffer->ref = 1; 265 buffer->format = wined3dformat_from_d3dformat(format); 266 267 wined3d_mutex_lock(); 268 hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size, 269 usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, &buffer->wineD3DIndexBuffer, 270 (IUnknown *)buffer, &d3d9_indexbuffer_wined3d_parent_ops); 271 wined3d_mutex_unlock(); 272 if (FAILED(hr)) 273 { 274 WARN("Failed to create wined3d buffer, hr %#x.\n", hr); 275 return hr; 276 } 277 278 buffer->parentDevice = (IDirect3DDevice9Ex *)device; 279 IDirect3DDevice9Ex_AddRef(buffer->parentDevice); 280 281 return D3D_OK; 282 }
Note:
See TracChangeset
for help on using the changeset viewer.