/***************************************************************************** * IDirect3DVertexBuffer7::Lock * * Locks the vertex buffer and returns a pointer to the vertex data * Locking vertex buffers is similar to locking surfaces, because Windows * uses surfaces to store vertex data internally (According to the DX sdk) * * Params: * Flags: Locking flags. Relevant here are DDLOCK_READONLY, DDLOCK_WRITEONLY, * DDLOCK_DISCARDCONTENTS and DDLOCK_NOOVERWRITE. * Data: Returns a pointer to the vertex data * Size: Returns the size of the buffer if not NULL * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS if Data is NULL * D3DERR_VERTEXBUFFEROPTIMIZED if called on an optimized buffer(WineD3D) * *****************************************************************************/ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, DWORD Flags, void **Data, DWORD *Size) { IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; WINED3DBUFFER_DESC Desc; HRESULT hr; DWORD wined3d_flags = 0; TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface, Flags, Data, Size); /* Writeonly: Pointless. Event: Unsupported by native according to the sdk * nosyslock: Not applicable */ if(!(Flags & DDLOCK_WAIT)) wined3d_flags |= WINED3DLOCK_DONOTWAIT; if(Flags & DDLOCK_READONLY) wined3d_flags |= WINED3DLOCK_READONLY; if(Flags & DDLOCK_NOOVERWRITE) wined3d_flags |= WINED3DLOCK_NOOVERWRITE; if(Flags & DDLOCK_DISCARDCONTENTS) wined3d_flags |= WINED3DLOCK_DISCARD; EnterCriticalSection(&ddraw_cs); if(Size) { /* Get the size, for returning it, and for locking */ IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &Desc); *Size = Desc.Size; } hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, 0 /* OffsetToLock */, 0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, wined3d_flags); LeaveCriticalSection(&ddraw_cs); return hr; }
/* IDirect3DVertexBuffer8 Interface follow: */ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) { IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface; HRESULT hr; TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n", iface, OffsetToLock, SizeToLock, ppbData, Flags); wined3d_mutex_lock(); hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags); wined3d_mutex_unlock(); return hr; }
static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface, UINT offset, UINT size, void **data, DWORD flags) { HRESULT hr; TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n", iface, offset, size, data, flags); wined3d_mutex_lock(); hr = IWineD3DBuffer_Map(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, offset, size, (BYTE **)data, flags); wined3d_mutex_unlock(); return hr; }