/***************************************************************************** * IDirect3DVertexBuffer7::Release * * Release for Vertex Buffers * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface) { struct d3d_vertex_buffer *buffer = impl_from_IDirect3DVertexBuffer7(iface); ULONG ref = InterlockedDecrement(&buffer->ref); TRACE("%p decreasing refcount to %u.\n", buffer, ref); if (ref == 0) { struct wined3d_buffer *curVB = NULL; UINT offset, stride; /* D3D7 Vertex buffers don't stay bound in the device, they are passed * as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the * stream source in wined3d, and they should get unset there before * they are destroyed. */ wined3d_mutex_lock(); wined3d_device_get_stream_source(buffer->ddraw->wined3d_device, 0, &curVB, &offset, &stride); if (curVB == buffer->wineD3DVertexBuffer) wined3d_device_set_stream_source(buffer->ddraw->wined3d_device, 0, NULL, 0, 0); wined3d_vertex_declaration_decref(buffer->wineD3DVertexDeclaration); wined3d_buffer_decref(buffer->wineD3DVertexBuffer); wined3d_mutex_unlock(); HeapFree(GetProcessHeap(), 0, buffer); } return ref; }
/***************************************************************************** * IDirect3DVertexBuffer7::Release * * Release for Vertex Buffers * * Returns: * The new refcount * *****************************************************************************/ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface) { IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; ULONG ref = InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u.\n", This, ref); if (ref == 0) { struct wined3d_buffer *curVB = NULL; UINT offset, stride; EnterCriticalSection(&ddraw_cs); /* D3D7 Vertex buffers don't stay bound in the device, they are passed * as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the * stream source in wined3d, and they should get unset there before * they are destroyed. */ wined3d_device_get_stream_source(This->ddraw->wined3d_device, 0, &curVB, &offset, &stride); if (curVB == This->wineD3DVertexBuffer) wined3d_device_set_stream_source(This->ddraw->wined3d_device, 0, NULL, 0, 0); if (curVB) wined3d_buffer_decref(curVB); /* For the GetStreamSource */ wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration); wined3d_buffer_decref(This->wineD3DVertexBuffer); LeaveCriticalSection(&ddraw_cs); HeapFree(GetProcessHeap(), 0, This); return 0; } return ref; }