[PATCH 2/5] wined3d: Remove COM from the device implementation.

Henri Verbeet hverbeet at codeweavers.com
Mon May 16 16:01:22 CDT 2011


---
 dlls/d3d10core/d3d10core_private.h |    2 +-
 dlls/d3d10core/device.c            |   18 +-
 dlls/d3d8/buffer.c                 |    4 +-
 dlls/d3d8/cubetexture.c            |    2 +-
 dlls/d3d8/d3d8_private.h           |    3 +-
 dlls/d3d8/device.c                 |  243 +++++++-------
 dlls/d3d8/shader.c                 |    4 +-
 dlls/d3d8/surface.c                |    2 +-
 dlls/d3d8/swapchain.c              |    2 +-
 dlls/d3d8/texture.c                |    2 +-
 dlls/d3d8/vertexdeclaration.c      |    4 +-
 dlls/d3d8/volume.c                 |    2 +-
 dlls/d3d8/volumetexture.c          |    2 +-
 dlls/d3d9/buffer.c                 |    4 +-
 dlls/d3d9/cubetexture.c            |    2 +-
 dlls/d3d9/d3d9_private.h           |    2 +-
 dlls/d3d9/device.c                 |  256 +++++++-------
 dlls/d3d9/query.c                  |    2 +-
 dlls/d3d9/shader.c                 |    4 +-
 dlls/d3d9/stateblock.c             |    2 +-
 dlls/d3d9/surface.c                |    2 +-
 dlls/d3d9/swapchain.c              |    2 +-
 dlls/d3d9/texture.c                |    2 +-
 dlls/d3d9/vertexdeclaration.c      |    2 +-
 dlls/d3d9/volume.c                 |    2 +-
 dlls/d3d9/volumetexture.c          |    2 +-
 dlls/ddraw/ddraw.c                 |   93 +++---
 dlls/ddraw/ddraw_private.h         |    4 +-
 dlls/ddraw/device.c                |  265 +++++++-------
 dlls/ddraw/executebuffer.c         |    8 +-
 dlls/ddraw/palette.c               |    2 +-
 dlls/ddraw/surface.c               |   14 +-
 dlls/ddraw/vertexbuffer.c          |   26 +-
 dlls/ddraw/viewport.c              |    6 +-
 dlls/dxgi/device.c                 |   10 +-
 dlls/dxgi/dxgi_private.h           |    2 +-
 dlls/dxgi/factory.c                |   14 +-
 dlls/dxgi/swapchain.c              |    4 +-
 dlls/wined3d/context.c             |    4 +-
 dlls/wined3d/device.c              |  674 ++++++++++++++++--------------------
 dlls/wined3d/resource.c            |    2 +-
 dlls/wined3d/stateblock.c          |    2 +-
 dlls/wined3d/swapchain.c           |    6 +-
 dlls/wined3d/wined3d.spec          |   54 +++
 dlls/wined3d/wined3d_private.h     |   21 +-
 include/wine/wined3d.idl           |  473 ++++++++++----------------
 include/wine/winedxgi.idl          |    2 +-
 47 files changed, 1052 insertions(+), 1208 deletions(-)

diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index cb63458..7d19755 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -75,7 +75,7 @@ struct d3d10_device
     IUnknown *outer_unknown;
     LONG refcount;
 
-    IWineD3DDevice *wined3d_device;
+    struct wined3d_device *wined3d_device;
 };
 
 void d3d10_device_init(struct d3d10_device *device, void *outer_unknown) DECLSPEC_HIDDEN;
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index c2df413..98d713f 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -77,7 +77,8 @@ static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
 
     if (!refcount)
     {
-        if (This->wined3d_device) IWineD3DDevice_Release(This->wined3d_device);
+        if (This->wined3d_device)
+            wined3d_device_decref(This->wined3d_device);
     }
 
     return refcount;
@@ -158,7 +159,7 @@ static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface,
             iface, index_count, start_index_location, base_vertex_location);
 
     wined3d_device_set_base_vertex_index(This->wined3d_device, base_vertex_location);
-    IWineD3DDevice_DrawIndexedPrimitive(This->wined3d_device, start_index_location, index_count);
+    wined3d_device_draw_indexed_primitive(This->wined3d_device, start_index_location, index_count);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface,
@@ -169,7 +170,7 @@ static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device *iface,
     TRACE("iface %p, vertex_count %u, start_vertex_location %u\n",
             iface, vertex_count, start_vertex_location);
 
-    IWineD3DDevice_DrawPrimitive(This->wined3d_device, start_vertex_location, vertex_count);
+    wined3d_device_draw_primitive(This->wined3d_device, start_vertex_location, vertex_count);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device *iface,
@@ -259,7 +260,7 @@ static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *
 
     TRACE("iface %p, topology %s\n", iface, debug_d3d10_primitive_topology(topology));
 
-    IWineD3DDevice_SetPrimitiveType(This->wined3d_device, (WINED3DPRIMITIVETYPE)topology);
+    wined3d_device_set_primitive_type(This->wined3d_device, (WINED3DPRIMITIVETYPE)topology);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device *iface,
@@ -380,7 +381,7 @@ static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device *i
             iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]);
 
     wined3d_view = ((struct d3d10_rendertarget_view *)render_target_view)->wined3d_view;
-    IWineD3DDevice_ClearRendertargetView(This->wined3d_device, wined3d_view, &color);
+    wined3d_device_clear_rendertarget_view(This->wined3d_device, wined3d_view, &color);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device *iface,
@@ -479,7 +480,7 @@ static void STDMETHODCALLTYPE d3d10_device_IAGetPrimitiveTopology(ID3D10Device *
 
     TRACE("iface %p, topology %p\n", iface, topology);
 
-    IWineD3DDevice_GetPrimitiveType(This->wined3d_device, (WINED3DPRIMITIVETYPE *)topology);
+    wined3d_device_get_primitive_type(This->wined3d_device, (WINED3DPRIMITIVETYPE *)topology);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_VSGetShaderResources(ID3D10Device *iface,
@@ -1311,13 +1312,14 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface,
+        struct wined3d_device *device)
 {
     struct d3d10_device *This = device_from_device_parent(iface);
 
     TRACE("iface %p, device %p\n", iface, device);
 
-    IWineD3DDevice_AddRef(device);
+    wined3d_device_incref(device);
     This->wined3d_device = device;
 }
 
diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c
index 978bdb7..8cf5531 100644
--- a/dlls/d3d8/buffer.c
+++ b/dlls/d3d8/buffer.c
@@ -270,7 +270,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im
     buffer->fvf = fvf;
 
     wined3d_mutex_lock();
-    hr = wined3d_buffer_create_vb(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+    hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
             (WINED3DPOOL)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
     wined3d_mutex_unlock();
     if (FAILED(hr))
@@ -533,7 +533,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl
     buffer->format = wined3dformat_from_d3dformat(format);
 
     wined3d_mutex_lock();
-    hr = wined3d_buffer_create_ib(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+    hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
             (WINED3DPOOL)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
     wined3d_mutex_unlock();
     if (FAILED(hr))
diff --git a/dlls/d3d8/cubetexture.c b/dlls/d3d8/cubetexture.c
index 92ea2a2..5915c54 100644
--- a/dlls/d3d8/cubetexture.c
+++ b/dlls/d3d8/cubetexture.c
@@ -425,7 +425,7 @@ HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Imp
     texture->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_cube(device->WineD3DDevice, edge_length, levels,
+    hr = wined3d_texture_create_cube(device->wined3d_device, edge_length, levels,
             usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
             &d3d8_cubetexture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 8039048..0262e6e 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -177,8 +177,7 @@ struct IDirect3DDevice8Impl
     IDirect3DDevice8        IDirect3DDevice8_iface;
     IWineD3DDeviceParent    IWineD3DDeviceParent_iface;
     LONG                    ref;
-/* But what about baseVertexIndex in state blocks? hmm... it may be a better idea to pass this to wined3d */
-    IWineD3DDevice         *WineD3DDevice;
+    struct wined3d_device *wined3d_device;
     struct                  d3d8_handle_table handle_table;
 
     /* FVF management */
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 7d5936d..11455ec 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -309,7 +309,7 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(IDirect3DDevice8 *iface)
     if (ref == 0) {
         unsigned i;
 
-        TRACE("Releasing wined3d device %p\n", This->WineD3DDevice);
+        TRACE("Releasing wined3d device %p.\n", This->wined3d_device);
 
         wined3d_mutex_lock();
 
@@ -320,9 +320,9 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(IDirect3DDevice8 *iface)
         }
         HeapFree(GetProcessHeap(), 0, This->decls);
 
-        IWineD3DDevice_Uninit3D(This->WineD3DDevice);
-        IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
-        IWineD3DDevice_Release(This->WineD3DDevice);
+        wined3d_device_uninit_3d(This->wined3d_device);
+        wined3d_device_release_focus_window(This->wined3d_device);
+        wined3d_device_decref(This->wined3d_device);
         HeapFree(GetProcessHeap(), 0, This->handle_table.entries);
         HeapFree(GetProcessHeap(), 0, This);
 
@@ -355,7 +355,7 @@ static UINT WINAPI  IDirect3DDevice8Impl_GetAvailableTextureMem(IDirect3DDevice8
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
+    hr = wined3d_device_get_available_texture_mem(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -371,7 +371,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(IDirect3D
     FIXME("Byte count ignored.\n");
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
+    hr = wined3d_device_evict_managed_resources(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -390,7 +390,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(IDirect3DDevice8 *iface,
     }
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &wined3d);
+    hr = wined3d_device_get_wined3d(This->wined3d_device, &wined3d);
     if (SUCCEEDED(hr) && wined3d)
     {
         *ppD3D8 = wined3d_get_parent(wined3d);
@@ -426,7 +426,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(IDirect3DDevice8 *iface
     }
 
     wined3d_mutex_lock();
-    hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
+    hrc = wined3d_device_get_device_caps(This->wined3d_device, pWineCaps);
     wined3d_mutex_unlock();
 
     fixup_caps(pWineCaps);
@@ -446,7 +446,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(IDirect3DDevice8 *ifac
     TRACE("iface %p, mode %p.\n", iface, pMode);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode);
+    hr = wined3d_device_get_display_mode(This->wined3d_device, 0, (WINED3DDISPLAYMODE *)pMode);
     wined3d_mutex_unlock();
 
     if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -463,7 +463,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(IDirect3DDevice
     TRACE("iface %p, parameters %p.\n", iface, pParameters);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
+    hr = wined3d_device_get_creation_parameters(This->wined3d_device,
+            (WINED3DDEVICE_CREATION_PARAMETERS *)pParameters);
     wined3d_mutex_unlock();
 
     return hr;
@@ -486,7 +487,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(IDirect3DDevice8
     }
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice, XHotSpot, YHotSpot, pSurface->wined3d_surface);
+    hr = wined3d_device_set_cursor_properties(This->wined3d_device, XHotSpot, YHotSpot, pSurface->wined3d_surface);
     wined3d_mutex_unlock();
 
     return hr;
@@ -501,7 +502,7 @@ static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(IDirect3DDevice8 *ifac
             iface, XScreenSpace, YScreenSpace, Flags);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
+    wined3d_device_set_cursor_position(This->wined3d_device, XScreenSpace, YScreenSpace, Flags);
     wined3d_mutex_unlock();
 }
 
@@ -513,7 +514,7 @@ static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(IDirect3DDevice8 *iface, BOOL
     TRACE("iface %p, show %#x.\n", iface, bShow);
 
     wined3d_mutex_lock();
-    ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
+    ret = wined3d_device_show_cursor(This->wined3d_device, bShow);
     wined3d_mutex_unlock();
 
     return ret;
@@ -595,17 +596,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
     TRACE("iface %p, present_parameters %p.\n", iface, pPresentationParameters);
 
     wined3d_mutex_lock();
-    wined3d_device_set_index_buffer(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
+    wined3d_device_set_index_buffer(This->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
     for (i = 0; i < 16; ++i)
     {
-        wined3d_device_set_stream_source(This->WineD3DDevice, i, NULL, 0, 0);
+        wined3d_device_set_stream_source(This->wined3d_device, i, NULL, 0, 0);
     }
     for (i = 0; i < 16; ++i)
     {
-        wined3d_device_set_texture(This->WineD3DDevice, i, NULL);
+        wined3d_device_set_texture(This->wined3d_device, i, NULL);
     }
 
-    IWineD3DDevice_EnumResources(This->WineD3DDevice, reset_enum_callback, &resources_ok);
+    wined3d_device_enum_resources(This->wined3d_device, reset_enum_callback, &resources_ok);
     if (!resources_ok)
     {
         WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset.\n");
@@ -631,10 +632,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
     localParameters.PresentationInterval                        = pPresentationParameters->FullScreen_PresentationInterval;
     localParameters.AutoRestoreDisplayMode                      = TRUE;
 
-    hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
+    hr = wined3d_device_reset(This->wined3d_device, &localParameters);
     if (SUCCEEDED(hr))
     {
-        hr = wined3d_device_set_render_state(This->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
+        hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_POINTSIZE_MIN, 0);
         This->lost = FALSE;
     }
     else
@@ -670,7 +671,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Present(IDirect3DDevice8 *iface, cons
             iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
+    hr = wined3d_device_present(This->wined3d_device, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
     wined3d_mutex_unlock();
 
     return hr;
@@ -687,7 +688,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(IDirect3DDevice8 *iface
             iface, BackBuffer, Type, ppBackBuffer);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0,
+    hr = wined3d_device_get_back_buffer(This->wined3d_device, 0,
             BackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &wined3d_surface);
     if (SUCCEEDED(hr) && wined3d_surface && ppBackBuffer)
     {
@@ -709,7 +710,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(IDirect3DDevice8 *ifa
     TRACE("iface %p, raster_status %p.\n", iface, pRasterStatus);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus);
+    hr = wined3d_device_get_raster_status(This->wined3d_device, 0, (WINED3DRASTER_STATUS *)pRasterStatus);
     wined3d_mutex_unlock();
 
     return hr;
@@ -724,7 +725,7 @@ static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(IDirect3DDevice8 *iface, DW
 
     /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
     wined3d_mutex_lock();
-    wined3d_device_set_gamma_ramp(This->WineD3DDevice, 0, Flags, (const WINED3DGAMMARAMP *)pRamp);
+    wined3d_device_set_gamma_ramp(This->wined3d_device, 0, Flags, (const WINED3DGAMMARAMP *)pRamp);
     wined3d_mutex_unlock();
 }
 
@@ -736,7 +737,7 @@ static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(IDirect3DDevice8 *iface, D3
 
     /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
     wined3d_mutex_lock();
-    wined3d_device_get_gamma_ramp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *)pRamp);
+    wined3d_device_get_gamma_ramp(This->wined3d_device, 0, (WINED3DGAMMARAMP *)pRamp);
     wined3d_mutex_unlock();
 }
 
@@ -1063,7 +1064,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(IDirect3DDevice8 *iface
     TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, src_texture, dst_texture);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice,
+    hr = wined3d_device_update_texture(This->wined3d_device,
             ((IDirect3DBaseTexture8Impl *)src_texture)->wined3d_texture,
             ((IDirect3DBaseTexture8Impl *)dst_texture)->wined3d_texture);
     wined3d_mutex_unlock();
@@ -1086,7 +1087,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(IDirect3DDevice8 *ifac
     }
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wined3d_surface);
+    hr = wined3d_device_get_front_buffer_data(This->wined3d_device, 0, destSurface->wined3d_surface);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1137,15 +1138,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(IDirect3DDevice8 *ifa
         }
     }
 
-    hr = wined3d_device_get_depth_stencil(This->WineD3DDevice, &original_ds);
+    hr = wined3d_device_get_depth_stencil(This->wined3d_device, &original_ds);
     if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
     {
-        hr = wined3d_device_set_depth_stencil(This->WineD3DDevice, pZSurface ? pZSurface->wined3d_surface : NULL);
+        hr = wined3d_device_set_depth_stencil(This->wined3d_device, pZSurface ? pZSurface->wined3d_surface : NULL);
         if (SUCCEEDED(hr) && pRenderTarget)
         {
-            hr = wined3d_device_set_render_target(This->WineD3DDevice, 0, pSurface->wined3d_surface, TRUE);
+            hr = wined3d_device_set_render_target(This->wined3d_device, 0, pSurface->wined3d_surface, TRUE);
             if (FAILED(hr))
-                wined3d_device_set_depth_stencil(This->WineD3DDevice, original_ds);
+                wined3d_device_set_depth_stencil(This->wined3d_device, original_ds);
         }
     }
     if (original_ds)
@@ -1170,7 +1171,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(IDirect3DDevice8 *ifa
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_render_target(This->WineD3DDevice, 0, &wined3d_surface);
+    hr = wined3d_device_get_render_target(This->wined3d_device, 0, &wined3d_surface);
     if (SUCCEEDED(hr) && wined3d_surface)
     {
         *ppRenderTarget = wined3d_surface_get_parent(wined3d_surface);
@@ -1201,7 +1202,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(IDirect3DDevic
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_depth_stencil(This->WineD3DDevice, &wined3d_surface);
+    hr = wined3d_device_get_depth_stencil(This->wined3d_device, &wined3d_surface);
     if (SUCCEEDED(hr))
     {
         *ppZStencilSurface = wined3d_surface_get_parent(wined3d_surface);
@@ -1227,7 +1228,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(IDirect3DDevice8 *iface)
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
+    hr = wined3d_device_begin_scene(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1241,7 +1242,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(IDirect3DD
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
+    hr = wined3d_device_end_scene(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1257,7 +1258,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Clear(IDirect3DDevice8 *iface, DWORD
             iface, Count, pRects, Flags, Color, Z, Stencil);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
+    hr = wined3d_device_clear(This->wined3d_device, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1273,7 +1274,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(IDirect3DDevice8 *iface,
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_transform(This->WineD3DDevice, State, (const WINED3DMATRIX *)lpMatrix);
+    hr = wined3d_device_set_transform(This->wined3d_device, State, (const WINED3DMATRIX *)lpMatrix);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1289,7 +1290,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(IDirect3DDevice8 *iface,
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_transform(This->WineD3DDevice, State, (WINED3DMATRIX *)pMatrix);
+    hr = wined3d_device_get_transform(This->wined3d_device, State, (WINED3DMATRIX *)pMatrix);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1305,7 +1306,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(IDirect3DDevice8 *i
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
+    hr = wined3d_device_multiply_transform(This->wined3d_device, State, (const WINED3DMATRIX *)pMatrix);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1321,7 +1322,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(IDirect3DDevice8 *iface,
 
     /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_viewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_set_viewport(This->wined3d_device, (const WINED3DVIEWPORT *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1337,7 +1338,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(IDirect3DDevice8 *iface,
 
     /* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_viewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1353,7 +1354,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(IDirect3DDevice8 *iface,
 
     /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_material(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
+    hr = wined3d_device_set_material(This->wined3d_device, (const WINED3DMATERIAL *)pMaterial);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1369,7 +1370,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(IDirect3DDevice8 *iface,
 
     /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_material(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
+    hr = wined3d_device_get_material(This->wined3d_device, (WINED3DMATERIAL *)pMaterial);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1385,7 +1386,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(IDirect3DDevice8 *iface, DWO
 
     /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_light(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
+    hr = wined3d_device_set_light(This->wined3d_device, Index, (const WINED3DLIGHT *)pLight);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1401,7 +1402,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(IDirect3DDevice8 *iface, DWO
 
     /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_light(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
+    hr = wined3d_device_get_light(This->wined3d_device, Index, (WINED3DLIGHT *)pLight);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1416,7 +1417,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(IDirect3DDevice8 *iface,
     TRACE("iface %p, index %u, enable %#x.\n", iface, Index, Enable);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_light_enable(This->WineD3DDevice, Index, Enable);
+    hr = wined3d_device_set_light_enable(This->wined3d_device, Index, Enable);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1431,7 +1432,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(IDirect3DDevice8 *ifac
     TRACE("iface %p, index %u, enable %p.\n", iface, Index, pEnable);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_light_enable(This->WineD3DDevice, Index, pEnable);
+    hr = wined3d_device_get_light_enable(This->wined3d_device, Index, pEnable);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1446,7 +1447,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(IDirect3DDevice8 *iface,
     TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_clip_plane(This->WineD3DDevice, Index, pPlane);
+    hr = wined3d_device_set_clip_plane(This->wined3d_device, Index, pPlane);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1461,7 +1462,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(IDirect3DDevice8 *iface,
     TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_clip_plane(This->WineD3DDevice, Index, pPlane);
+    hr = wined3d_device_get_clip_plane(This->wined3d_device, Index, pPlane);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1491,11 +1492,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *ifac
     {
         case D3DRS_ZBIAS:
             wined3d_value.f = Value * zbias_factor;
-            hr = wined3d_device_set_render_state(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, wined3d_value.d);
+            hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, wined3d_value.d);
             break;
 
         default:
-            hr = wined3d_device_set_render_state(This->WineD3DDevice, State, Value);
+            hr = wined3d_device_set_render_state(This->wined3d_device, State, Value);
     }
     wined3d_mutex_unlock();
 
@@ -1519,12 +1520,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(IDirect3DDevice8 *ifac
     switch (State)
     {
         case D3DRS_ZBIAS:
-            hr = wined3d_device_get_render_state(This->WineD3DDevice, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
+            hr = wined3d_device_get_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
             if (SUCCEEDED(hr)) *pValue = wined3d_value.f / zbias_factor;
             break;
 
         default:
-        hr = wined3d_device_get_render_state(This->WineD3DDevice, State, pValue);
+            hr = wined3d_device_get_render_state(This->wined3d_device, State, pValue);
     }
     wined3d_mutex_unlock();
 
@@ -1539,7 +1540,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(IDirect3DDevice8 *ifa
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
+    hr = wined3d_device_begin_stateblock(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1557,8 +1558,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(IDirect3DDevice8 *iface
      * of memory later and cause locking problems)
      */
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &stateblock);
-    if (hr != D3D_OK) {
+    hr = wined3d_device_end_stateblock(This->wined3d_device, &stateblock);
+    if (FAILED(hr))
+    {
         WARN("IWineD3DDevice_EndStateBlock returned an error\n");
         wined3d_mutex_unlock();
         return hr;
@@ -1672,7 +1674,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *if
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_stateblock_create(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &stateblock);
+    hr = wined3d_stateblock_create(This->wined3d_device, (WINED3DSTATEBLOCKTYPE)Type, &stateblock);
     if (FAILED(hr))
     {
         wined3d_mutex_unlock();
@@ -1708,7 +1710,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(IDirect3DDevice8 *iface
 /* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_clip_status(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
+    hr = wined3d_device_set_clip_status(This->wined3d_device, (const WINED3DCLIPSTATUS *)pClipStatus);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1723,7 +1725,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(IDirect3DDevice8 *iface
     TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_clip_status(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
+    hr = wined3d_device_get_clip_status(This->wined3d_device, (WINED3DCLIPSTATUS *)pClipStatus);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1743,7 +1745,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_texture(This->WineD3DDevice, Stage, &wined3d_texture);
+    hr = wined3d_device_get_texture(This->wined3d_device, Stage, &wined3d_texture);
     if (FAILED(hr))
     {
         WARN("Failed to get texture for stage %u, hr %#x.\n", Stage, hr);
@@ -1776,7 +1778,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(IDirect3DDevice8 *iface, D
     TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, pTexture);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture(This->WineD3DDevice, Stage,
+    hr = wined3d_device_set_texture(This->wined3d_device, Stage,
             pTexture ? ((IDirect3DBaseTexture8Impl *)pTexture)->wined3d_texture : NULL);
     wined3d_mutex_unlock();
 
@@ -1840,9 +1842,9 @@ static HRESULT  WINAPI  IDirect3DDevice8Impl_GetTextureStageState(IDirect3DDevic
 
     wined3d_mutex_lock();
     if (l->sampler_state)
-        hr = wined3d_device_get_sampler_state(This->WineD3DDevice, Stage, l->state, pValue);
+        hr = wined3d_device_get_sampler_state(This->wined3d_device, Stage, l->state, pValue);
     else
-        hr = wined3d_device_get_texture_stage_state(This->WineD3DDevice, Stage, l->state, pValue);
+        hr = wined3d_device_get_texture_stage_state(This->wined3d_device, Stage, l->state, pValue);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1867,9 +1869,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(IDirect3DDevice8
 
     wined3d_mutex_lock();
     if (l->sampler_state)
-        hr = wined3d_device_set_sampler_state(This->WineD3DDevice, Stage, l->state, Value);
+        hr = wined3d_device_set_sampler_state(This->wined3d_device, Stage, l->state, Value);
     else
-        hr = wined3d_device_set_texture_stage_state(This->WineD3DDevice, Stage, l->state, Value);
+        hr = wined3d_device_set_texture_stage_state(This->wined3d_device, Stage, l->state, Value);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1884,7 +1886,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(IDirect3DDevice8 *ifac
     TRACE("iface %p, pass_count %p.\n", iface, pNumPasses);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
+    hr = wined3d_device_validate_device(This->wined3d_device, pNumPasses);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1907,7 +1909,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(IDirect3DDevice8 *i
     TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_palette_entries(This->WineD3DDevice, PaletteNumber, pEntries);
+    hr = wined3d_device_set_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1922,7 +1924,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(IDirect3DDevice8 *i
     TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_palette_entries(This->WineD3DDevice, PaletteNumber, pEntries);
+    hr = wined3d_device_get_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1937,7 +1939,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(IDirect3DDev
     TRACE("iface %p, palette_idx %u.\n", iface, PaletteNumber);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_current_texture_palette(This->WineD3DDevice, PaletteNumber);
+    hr = wined3d_device_set_current_texture_palette(This->wined3d_device, PaletteNumber);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1952,7 +1954,7 @@ static HRESULT  WINAPI  IDirect3DDevice8Impl_GetCurrentTexturePalette(IDirect3DD
     TRACE("iface %p, palette_idx %p.\n", iface, PaletteNumber);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_current_texture_palette(This->WineD3DDevice, PaletteNumber);
+    hr = wined3d_device_get_current_texture_palette(This->wined3d_device, PaletteNumber);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1968,8 +1970,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(IDirect3DDevice8 *iface
             iface, PrimitiveType, StartVertex, PrimitiveCount);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive(This->wined3d_device, StartVertex,
             vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
     wined3d_mutex_unlock();
 
@@ -1987,8 +1989,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(IDirect3DDevice8
             iface, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, startIndex,
             vertex_count_from_primitive_count(PrimitiveType, primCount));
     wined3d_mutex_unlock();
 
@@ -2006,8 +2008,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(IDirect3DDevice8 *ifa
             iface, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive_up(This->wined3d_device,
             vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
             pVertexStreamZeroData, VertexStreamZeroStride);
     wined3d_mutex_unlock();
@@ -2029,8 +2031,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(IDirect3DDevic
             pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive_up(This->wined3d_device,
             vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
             wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
     wined3d_mutex_unlock();
@@ -2050,7 +2052,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(IDirect3DDevice8 *ifa
             iface, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, Flags);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf);
+    hr = wined3d_device_process_vertices(This->wined3d_device, SrcStartIndex, DestIndex,
+            VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2181,9 +2184,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(IDirect3DDevice8 *ifa
         TRACE("Setting FVF, %#x\n", pShader);
 
         wined3d_mutex_lock();
-        wined3d_device_set_vertex_declaration(This->WineD3DDevice,
+        wined3d_device_set_vertex_declaration(This->wined3d_device,
                 IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
-        wined3d_device_set_vertex_shader(This->WineD3DDevice, NULL);
+        wined3d_device_set_vertex_shader(This->wined3d_device, NULL);
         wined3d_mutex_unlock();
 
         return D3D_OK;
@@ -2201,10 +2204,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(IDirect3DDevice8 *ifa
         return D3DERR_INVALIDCALL;
     }
 
-    hr = wined3d_device_set_vertex_declaration(This->WineD3DDevice,
+    hr = wined3d_device_set_vertex_declaration(This->wined3d_device,
             ((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
     if (SUCCEEDED(hr))
-        hr = wined3d_device_set_vertex_shader(This->WineD3DDevice, shader->wined3d_shader);
+        hr = wined3d_device_set_vertex_shader(This->wined3d_device, shader->wined3d_shader);
     wined3d_mutex_unlock();
 
     TRACE("Returning hr %#x\n", hr);
@@ -2222,12 +2225,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *ifa
     TRACE("iface %p, shader %p.\n", iface, ppShader);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vertex_declaration(This->WineD3DDevice, &wined3d_declaration);
+    hr = wined3d_device_get_vertex_declaration(This->wined3d_device, &wined3d_declaration);
     if (FAILED(hr))
     {
         wined3d_mutex_unlock();
         WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
-                This, hr, This->WineD3DDevice);
+                This, hr, This->wined3d_device);
         return hr;
     }
 
@@ -2266,7 +2269,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8 *
         return D3DERR_INVALIDCALL;
     }
 
-    cur = wined3d_device_get_vertex_shader(This->WineD3DDevice);
+    cur = wined3d_device_get_vertex_shader(This->wined3d_device);
     if (cur)
     {
         if (cur == shader->wined3d_shader)
@@ -2300,7 +2303,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(IDirect3DDevi
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vs_consts_f(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+    hr = wined3d_device_set_vs_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2322,7 +2325,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(IDirect3DDevi
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vs_consts_f(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+    hr = wined3d_device_get_vs_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2416,8 +2419,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(IDirect3DDevice8 *iface,
      * problem)
      */
     wined3d_mutex_lock();
-    wined3d_device_set_base_vertex_index(This->WineD3DDevice, baseVertexIndex);
-    hr = wined3d_device_set_index_buffer(This->WineD3DDevice,
+    wined3d_device_set_base_vertex_index(This->wined3d_device, baseVertexIndex);
+    hr = wined3d_device_set_index_buffer(This->wined3d_device,
             ib ? ib->wineD3DIndexBuffer : NULL,
             ib ? ib->format : WINED3DFMT_UNKNOWN);
     wined3d_mutex_unlock();
@@ -2440,8 +2443,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(IDirect3DDevice8 *iface,
 
     /* The case from UINT to INT is safe because d3d8 will never set negative values */
     wined3d_mutex_lock();
-    *pBaseVertexIndex = wined3d_device_get_base_vertex_index(This->WineD3DDevice);
-    hr = wined3d_device_get_index_buffer(This->WineD3DDevice, &retIndexData);
+    *pBaseVertexIndex = wined3d_device_get_base_vertex_index(This->wined3d_device);
+    hr = wined3d_device_get_index_buffer(This->wined3d_device, &retIndexData);
     if (SUCCEEDED(hr) && retIndexData)
     {
         *ppIndexData = wined3d_buffer_get_parent(retIndexData);
@@ -2522,7 +2525,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *ifac
 
     if (!pShader)
     {
-        hr = wined3d_device_set_pixel_shader(This->WineD3DDevice, NULL);
+        hr = wined3d_device_set_pixel_shader(This->wined3d_device, NULL);
         wined3d_mutex_unlock();
         return hr;
     }
@@ -2536,7 +2539,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *ifac
     }
 
     TRACE("(%p) : Setting shader %p\n", This, shader);
-    hr = wined3d_device_set_pixel_shader(This->WineD3DDevice, shader->wined3d_shader);
+    hr = wined3d_device_set_pixel_shader(This->wined3d_device, shader->wined3d_shader);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2555,7 +2558,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
     }
 
     wined3d_mutex_lock();
-    object = wined3d_device_get_pixel_shader(This->WineD3DDevice);
+    object = wined3d_device_get_pixel_shader(This->wined3d_device);
     if (object)
     {
         IDirect3DPixelShader8Impl *d3d8_shader;
@@ -2592,7 +2595,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *i
         return D3DERR_INVALIDCALL;
     }
 
-    cur = wined3d_device_get_pixel_shader(This->WineD3DDevice);
+    cur = wined3d_device_get_pixel_shader(This->wined3d_device);
     if (cur)
     {
         if (cur == shader->wined3d_shader)
@@ -2620,7 +2623,7 @@ static HRESULT  WINAPI  IDirect3DDevice8Impl_SetPixelShaderConstant(IDirect3DDev
             iface, Register, pConstantData, ConstantCount);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_ps_consts_f(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+    hr = wined3d_device_set_ps_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2636,7 +2639,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(IDirect3DDevic
             iface, Register, pConstantData, ConstantCount);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_ps_consts_f(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+    hr = wined3d_device_get_ps_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2678,7 +2681,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(IDirect3DDevice8 *iface
             iface, Handle, pNumSegs, pRectPatchInfo);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
+    hr = wined3d_device_draw_rect_patch(This->wined3d_device, Handle,
+            pNumSegs, (const WINED3DRECTPATCH_INFO *)pRectPatchInfo);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2694,7 +2698,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(IDirect3DDevice8 *iface,
             iface, Handle, pNumSegs, pTriPatchInfo);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
+    hr = wined3d_device_draw_tri_patch(This->wined3d_device, Handle,
+            pNumSegs, (const WINED3DTRIPATCH_INFO *)pTriPatchInfo);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2708,7 +2713,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(IDirect3DDevice8 *iface,
     TRACE("iface %p, handle %#x.\n", iface, Handle);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
+    hr = wined3d_device_delete_patch(This->wined3d_device, Handle);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2724,7 +2729,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(IDirect3DDevice8 *ifa
             iface, StreamNumber, pStreamData, Stride);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_stream_source(This->WineD3DDevice, StreamNumber,
+    hr = wined3d_device_set_stream_source(This->wined3d_device, StreamNumber,
             pStreamData ? ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer : NULL,
             0/* Offset in bytes */, Stride);
     wined3d_mutex_unlock();
@@ -2747,7 +2752,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(IDirect3DDevice8 *ifa
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_stream_source(This->WineD3DDevice, StreamNumber,
+    hr = wined3d_device_get_stream_source(This->wined3d_device, StreamNumber,
             &retStream, 0 /* Offset in bytes */, pStride);
     if (SUCCEEDED(hr) && retStream)
     {
@@ -2892,7 +2897,8 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface,
+        struct wined3d_device *device)
 {
     TRACE("iface %p, device %p\n", iface, device);
 }
@@ -3141,7 +3147,7 @@ HRESULT device_init(IDirect3DDevice8Impl *device, struct wined3d *wined3d, UINT
 
     wined3d_mutex_lock();
     hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags,
-            &device->IWineD3DDeviceParent_iface, &device->WineD3DDevice);
+            &device->IWineD3DDeviceParent_iface, &device->wined3d_device);
     if (FAILED(hr))
     {
         WARN("Failed to create wined3d device, hr %#x.\n", hr);
@@ -3154,23 +3160,26 @@ HRESULT device_init(IDirect3DDevice8Impl *device, struct wined3d *wined3d, UINT
     {
         HWND device_window = parameters->hDeviceWindow;
 
-        if (!focus_window) focus_window = device_window;
-        if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
+        if (!focus_window)
+            focus_window = device_window;
+        if (FAILED(hr = wined3d_device_acquire_focus_window(device->wined3d_device, focus_window)))
         {
             ERR("Failed to acquire focus window, hr %#x.\n", hr);
-            IWineD3DDevice_Release(device->WineD3DDevice);
+            wined3d_device_decref(device->wined3d_device);
             wined3d_mutex_unlock();
             HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
             return hr;
         }
 
-        if (!device_window) device_window = focus_window;
-        IWineD3DDevice_SetupFullscreenWindow(device->WineD3DDevice, device_window,
+        if (!device_window)
+            device_window = focus_window;
+        wined3d_device_setup_fullscreen_window(device->wined3d_device, device_window,
                 parameters->BackBufferWidth,
                 parameters->BackBufferHeight);
     }
 
-    if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
+    if (flags & D3DCREATE_MULTITHREADED)
+        wined3d_device_set_multithreaded(device->wined3d_device);
 
     wined3d_parameters.BackBufferWidth = parameters->BackBufferWidth;
     wined3d_parameters.BackBufferHeight = parameters->BackBufferHeight;
@@ -3188,18 +3197,18 @@ HRESULT device_init(IDirect3DDevice8Impl *device, struct wined3d *wined3d, UINT
     wined3d_parameters.PresentationInterval = parameters->FullScreen_PresentationInterval;
     wined3d_parameters.AutoRestoreDisplayMode = TRUE;
 
-    hr = IWineD3DDevice_Init3D(device->WineD3DDevice, &wined3d_parameters);
+    hr = wined3d_device_init_3d(device->wined3d_device, &wined3d_parameters);
     if (FAILED(hr))
     {
         WARN("Failed to initialize 3D, hr %#x.\n", hr);
-        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
-        IWineD3DDevice_Release(device->WineD3DDevice);
+        wined3d_device_release_focus_window(device->wined3d_device);
+        wined3d_device_decref(device->wined3d_device);
         wined3d_mutex_unlock();
         HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
         return hr;
     }
 
-    hr = wined3d_device_set_render_state(device->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
+    hr = wined3d_device_set_render_state(device->wined3d_device, WINED3DRS_POINTSIZE_MIN, 0);
     wined3d_mutex_unlock();
     if (FAILED(hr))
     {
@@ -3234,9 +3243,9 @@ HRESULT device_init(IDirect3DDevice8Impl *device, struct wined3d *wined3d, UINT
 
 err:
     wined3d_mutex_lock();
-    IWineD3DDevice_Uninit3D(device->WineD3DDevice);
-    IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
-    IWineD3DDevice_Release(device->WineD3DDevice);
+    wined3d_device_uninit_3d(device->wined3d_device);
+    wined3d_device_release_focus_window(device->wined3d_device);
+    wined3d_device_decref(device->wined3d_device);
     wined3d_mutex_unlock();
     HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
     return hr;
diff --git a/dlls/d3d8/shader.c b/dlls/d3d8/shader.c
index 1fa4cbc..e04c2a2 100644
--- a/dlls/d3d8/shader.c
+++ b/dlls/d3d8/shader.c
@@ -176,7 +176,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
         if (usage) FIXME("Usage %#x not implemented.\n", usage);
 
         wined3d_mutex_lock();
-        hr = wined3d_shader_create_vs(device->WineD3DDevice, byte_code, NULL /* output signature */,
+        hr = wined3d_shader_create_vs(device->wined3d_device, byte_code, NULL /* output signature */,
                 shader, &d3d8_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
         wined3d_mutex_unlock();
         if (FAILED(hr))
@@ -277,7 +277,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl
     shader->handle = shader_handle;
 
     wined3d_mutex_lock();
-    hr = wined3d_shader_create_ps(device->WineD3DDevice, byte_code, NULL, shader,
+    hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
             &d3d8_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
     wined3d_mutex_unlock();
     if (FAILED(hr))
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index 96811bc..8a07244 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -304,7 +304,7 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_create(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
+    hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
             lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
             multisample_quality, SURFACE_OPENGL, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d8/swapchain.c b/dlls/d3d8/swapchain.c
index a66c1f4..866335f 100644
--- a/dlls/d3d8/swapchain.c
+++ b/dlls/d3d8/swapchain.c
@@ -174,7 +174,7 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl
     wined3d_parameters.AutoRestoreDisplayMode = TRUE;
 
     wined3d_mutex_lock();
-    hr = wined3d_swapchain_create(device->WineD3DDevice, &wined3d_parameters,
+    hr = wined3d_swapchain_create(device->wined3d_device, &wined3d_parameters,
             SURFACE_OPENGL, swapchain, &d3d8_swapchain_wined3d_parent_ops,
             &swapchain->wined3d_swapchain);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c
index f9dee5c..1b9db9d 100644
--- a/dlls/d3d8/texture.c
+++ b/dlls/d3d8/texture.c
@@ -413,7 +413,7 @@ HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *devic
     texture->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_2d(device->WineD3DDevice, width, height, levels,
+    hr = wined3d_texture_create_2d(device->wined3d_device, width, height, levels,
             usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
             texture, &d3d8_texture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d8/vertexdeclaration.c b/dlls/d3d8/vertexdeclaration.c
index a7b0867..4994125 100644
--- a/dlls/d3d8/vertexdeclaration.c
+++ b/dlls/d3d8/vertexdeclaration.c
@@ -400,7 +400,7 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration8Impl *declaration,
     memcpy(declaration->elements, elements, declaration->elements_size);
 
     wined3d_mutex_lock();
-    hr = wined3d_vertex_declaration_create(device->WineD3DDevice, wined3d_elements, wined3d_element_count,
+    hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
             declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
     wined3d_mutex_unlock();
     HeapFree(GetProcessHeap(), 0, wined3d_elements);
@@ -425,7 +425,7 @@ HRESULT vertexdeclaration_init_fvf(IDirect3DVertexDeclaration8Impl *declaration,
     declaration->elements_size = 0;
     declaration->shader_handle = fvf;
 
-    hr = wined3d_vertex_declaration_create_from_fvf(device->WineD3DDevice, fvf, declaration,
+    hr = wined3d_vertex_declaration_create_from_fvf(device->wined3d_device, fvf, declaration,
             &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
     if (FAILED(hr))
     {
diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c
index 3c0d8cc..2726880 100644
--- a/dlls/d3d8/volume.c
+++ b/dlls/d3d8/volume.c
@@ -277,7 +277,7 @@ HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device,
     volume->IDirect3DVolume8_iface.lpVtbl = &Direct3DVolume8_Vtbl;
     volume->ref = 1;
 
-    hr = wined3d_volume_create(device->WineD3DDevice, width, height, depth, usage,
+    hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage,
             format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume);
     if (FAILED(hr))
     {
diff --git a/dlls/d3d8/volumetexture.c b/dlls/d3d8/volumetexture.c
index 91fd58c..08e3680 100644
--- a/dlls/d3d8/volumetexture.c
+++ b/dlls/d3d8/volumetexture.c
@@ -401,7 +401,7 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice
     texture->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_3d(device->WineD3DDevice, width, height, depth, levels,
+    hr = wined3d_texture_create_3d(device->wined3d_device, width, height, depth, levels,
             usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
             &d3d8_volumetexture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c
index 1cb84b4..d9a5564 100644
--- a/dlls/d3d9/buffer.c
+++ b/dlls/d3d9/buffer.c
@@ -272,7 +272,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Im
     buffer->fvf = fvf;
 
     wined3d_mutex_lock();
-    hr = wined3d_buffer_create_vb(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+    hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
             (WINED3DPOOL)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
     wined3d_mutex_unlock();
     if (FAILED(hr))
@@ -535,7 +535,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl
     buffer->format = wined3dformat_from_d3dformat(format);
 
     wined3d_mutex_lock();
-    hr = wined3d_buffer_create_ib(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+    hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
             (WINED3DPOOL)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
     wined3d_mutex_unlock();
     if (FAILED(hr))
diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c
index 9a712c0..1f5e27b8 100644
--- a/dlls/d3d9/cubetexture.c
+++ b/dlls/d3d9/cubetexture.c
@@ -470,7 +470,7 @@ HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Imp
     texture->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_cube(device->WineD3DDevice, edge_length,
+    hr = wined3d_texture_create_cube(device->wined3d_device, edge_length,
             levels, usage, wined3dformat_from_d3dformat(format), pool, texture,
             &d3d9_cubetexture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index dc7dc79..f6aec21 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -165,7 +165,7 @@ typedef struct IDirect3DDevice9Impl
     IDirect3DDevice9Ex IDirect3DDevice9Ex_iface;
     const IWineD3DDeviceParentVtbl *device_parent_vtbl;
     LONG ref;
-    IWineD3DDevice *WineD3DDevice;
+    struct wined3d_device *wined3d_device;
     /* Avoids recursion with nested ReleaseRef to 0 */
     BOOL                          inDestruction;
 
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 443f229..99f4559 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -267,9 +267,9 @@ static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(IDirect3DDevi
       }
       HeapFree(GetProcessHeap(), 0, This->convertedDecls);
 
-      IWineD3DDevice_Uninit3D(This->WineD3DDevice);
-      IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
-      IWineD3DDevice_Release(This->WineD3DDevice);
+      wined3d_device_uninit_3d(This->wined3d_device);
+      wined3d_device_release_focus_window(This->wined3d_device);
+      wined3d_device_decref(This->wined3d_device);
       wined3d_mutex_unlock();
 
       HeapFree(GetProcessHeap(), 0, This);
@@ -300,7 +300,7 @@ static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(IDirect3DDevice9E
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
+    hr = wined3d_device_get_available_texture_mem(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -314,7 +314,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(IDirect3DDevice
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
+    hr = wined3d_device_evict_managed_resources(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -334,7 +334,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(IDirect3DDevice9Ex *iface
     }
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &wined3d);
+    hr = wined3d_device_get_wined3d(This->wined3d_device, &wined3d);
     if (hr == D3D_OK && wined3d)
     {
         *ppD3D9 = wined3d_get_parent(wined3d);
@@ -371,7 +371,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(IDirect3DDevice9Ex *ifa
     memset(pCaps, 0, sizeof(*pCaps));
 
     wined3d_mutex_lock();
-    hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
+    hrc = wined3d_device_get_device_caps(This->wined3d_device, pWineCaps);
     wined3d_mutex_unlock();
 
     WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
@@ -395,7 +395,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(IDirect3DDevice9Ex *if
     TRACE("iface %p, swapchain %u, mode %p.\n", iface, iSwapChain, pMode);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
+    hr = wined3d_device_get_display_mode(This->wined3d_device, iSwapChain, (WINED3DDISPLAYMODE *)pMode);
     wined3d_mutex_unlock();
 
     if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -412,7 +412,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(IDirect3DDevice
     TRACE("iface %p, parameters %p.\n", iface, pParameters);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
+    hr = wined3d_device_get_creation_parameters(This->wined3d_device,
+            (WINED3DDEVICE_CREATION_PARAMETERS *)pParameters);
     wined3d_mutex_unlock();
 
     return hr;
@@ -435,7 +436,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(IDirect3DDevice9E
     }
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice, XHotSpot, YHotSpot, pSurface->wined3d_surface);
+    hr = wined3d_device_set_cursor_properties(This->wined3d_device, XHotSpot, YHotSpot, pSurface->wined3d_surface);
     wined3d_mutex_unlock();
 
     return hr;
@@ -449,7 +450,7 @@ static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(IDirect3DDevice9Ex *if
     TRACE("iface %p, x %u, y %u, flags %#x.\n", iface, XScreenSpace, YScreenSpace, Flags);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
+    wined3d_device_set_cursor_position(This->wined3d_device, XScreenSpace, YScreenSpace, Flags);
     wined3d_mutex_unlock();
 }
 
@@ -461,7 +462,7 @@ static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(IDirect3DDevice9Ex *iface, BO
     TRACE("iface %p, show %#x.\n", iface, bShow);
 
     wined3d_mutex_lock();
-    ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
+    ret = wined3d_device_show_cursor(This->wined3d_device, bShow);
     wined3d_mutex_unlock();
 
     return ret;
@@ -508,7 +509,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(IDirec
     TRACE("iface %p, swapchain_idx %u, swapchain %p.\n", iface, swapchain_idx, swapchain);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, swapchain_idx, &wined3d_swapchain);
+    hr = wined3d_device_get_swapchain(This->wined3d_device, swapchain_idx, &wined3d_swapchain);
     if (SUCCEEDED(hr) && wined3d_swapchain)
     {
        *swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
@@ -532,7 +533,7 @@ static UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    count = IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
+    count = wined3d_device_get_swapchain_count(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return count;
@@ -591,18 +592,19 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevi
      * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
      */
     wined3d_mutex_lock();
-    wined3d_device_set_index_buffer(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
+    wined3d_device_set_index_buffer(This->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
     for (i = 0; i < 16; ++i)
     {
-        wined3d_device_set_stream_source(This->WineD3DDevice, i, NULL, 0, 0);
+        wined3d_device_set_stream_source(This->wined3d_device, i, NULL, 0, 0);
     }
     for (i = 0; i < 16; ++i)
     {
-        wined3d_device_set_texture(This->WineD3DDevice, i, NULL);
+        wined3d_device_set_texture(This->wined3d_device, i, NULL);
     }
 
-    IWineD3DDevice_EnumResources(This->WineD3DDevice, reset_enum_callback, &resources_ok);
-    if(!resources_ok) {
+    wined3d_device_enum_resources(This->wined3d_device, reset_enum_callback, &resources_ok);
+    if (!resources_ok)
+    {
         WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
         This->notreset = TRUE;
         wined3d_mutex_unlock();
@@ -626,7 +628,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevi
     localParameters.PresentationInterval                = pPresentationParameters->PresentationInterval;
     localParameters.AutoRestoreDisplayMode              = TRUE;
 
-    hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
+    hr = wined3d_device_reset(This->wined3d_device, &localParameters);
     if(FAILED(hr)) {
         This->notreset = TRUE;
 
@@ -664,7 +666,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Present(IDirect3DDe
             iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
+    hr = wined3d_device_present(This->wined3d_device, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
     wined3d_mutex_unlock();
 
     return hr;
@@ -681,7 +683,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(IDirect3DDevice9Ex *ifa
             iface, iSwapChain, BackBuffer, Type, ppBackBuffer);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain,
+    hr = wined3d_device_get_back_buffer(This->wined3d_device, iSwapChain,
             BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &wined3d_surface);
     if (SUCCEEDED(hr) && wined3d_surface && ppBackBuffer)
     {
@@ -702,7 +704,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(IDirect3DDevice9Ex *i
     TRACE("iface %p, swapchain %u, raster_status %p.\n", iface, iSwapChain, pRasterStatus);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
+    hr = wined3d_device_get_raster_status(This->wined3d_device, iSwapChain, (WINED3DRASTER_STATUS *)pRasterStatus);
     wined3d_mutex_unlock();
 
     return hr;
@@ -717,7 +719,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(IDirect3DDevice9Ex *
     TRACE("iface %p, enable %#x.\n", iface, bEnableDialogs);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
+    hr = wined3d_device_set_dialog_box_mode(This->wined3d_device, bEnableDialogs);
     wined3d_mutex_unlock();
 
     return hr;
@@ -732,7 +734,7 @@ static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(IDirect3DDevice9Ex *iface,
 
     /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
     wined3d_mutex_lock();
-    wined3d_device_set_gamma_ramp(This->WineD3DDevice, iSwapChain, Flags, (const WINED3DGAMMARAMP *)pRamp);
+    wined3d_device_set_gamma_ramp(This->wined3d_device, iSwapChain, Flags, (const WINED3DGAMMARAMP *)pRamp);
     wined3d_mutex_unlock();
 }
 
@@ -745,7 +747,7 @@ static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(IDirect3DDevice9Ex *iface,
 
     /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
     wined3d_mutex_lock();
-    wined3d_device_get_gamma_ramp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *)pRamp);
+    wined3d_device_get_gamma_ramp(This->wined3d_device, iSwapChain, (WINED3DGAMMARAMP *)pRamp);
     wined3d_mutex_unlock();
 }
 
@@ -997,7 +999,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(IDirect3DDevice9Ex *ifa
             iface, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_UpdateSurface(This->WineD3DDevice,
+    hr = wined3d_device_update_surface(This->wined3d_device,
             ((IDirect3DSurface9Impl *)pSourceSurface)->wined3d_surface, pSourceRect,
             ((IDirect3DSurface9Impl *)pDestinationSurface)->wined3d_surface, pDestPoint);
     wined3d_mutex_unlock();
@@ -1014,7 +1016,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(IDirect3DDevice9Ex *ifa
     TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, src_texture, dst_texture);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice,
+    hr = wined3d_device_update_texture(This->wined3d_device,
             ((IDirect3DBaseTexture9Impl *)src_texture)->wined3d_texture,
             ((IDirect3DBaseTexture9Impl *)dst_texture)->wined3d_texture);
     wined3d_mutex_unlock();
@@ -1049,7 +1051,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(IDirect3DDevice9Ex
     TRACE("iface %p, swapchain %u, dst_surface %p.\n", iface, iSwapChain, pDestSurface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wined3d_surface);
+    hr = wined3d_device_get_front_buffer_data(This->wined3d_device, iSwapChain, destSurface->wined3d_surface);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1105,7 +1107,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(IDirect3DDevice9Ex *iface,
     }
 
     /* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
-    hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wined3d_surface, pRect, &c);
+    hr = wined3d_device_color_fill(This->wined3d_device, surface->wined3d_surface, pRect, &c);
 
     wined3d_mutex_unlock();
 
@@ -1157,7 +1159,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(IDirect3DDevice9Ex *i
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_render_target(This->WineD3DDevice, RenderTargetIndex,
+    hr = wined3d_device_set_render_target(This->wined3d_device, RenderTargetIndex,
             pSurface ? pSurface->wined3d_surface : NULL, TRUE);
     wined3d_mutex_unlock();
 
@@ -1185,7 +1187,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(IDirect3DDevice9Ex *i
 
     wined3d_mutex_lock();
 
-    hr = wined3d_device_get_render_target(This->WineD3DDevice, RenderTargetIndex, &wined3d_surface);
+    hr = wined3d_device_get_render_target(This->wined3d_device, RenderTargetIndex, &wined3d_surface);
 
     if (FAILED(hr))
     {
@@ -1219,7 +1221,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(IDirect3DDevic
     pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_depth_stencil(This->WineD3DDevice, pSurface ? pSurface->wined3d_surface : NULL);
+    hr = wined3d_device_set_depth_stencil(This->wined3d_device, pSurface ? pSurface->wined3d_surface : NULL);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1239,7 +1241,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(IDirect3DDevic
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_depth_stencil(This->WineD3DDevice, &wined3d_surface);
+    hr = wined3d_device_get_depth_stencil(This->wined3d_device, &wined3d_surface);
     if (SUCCEEDED(hr))
     {
         *ppZStencilSurface = wined3d_surface_get_parent(wined3d_surface);
@@ -1265,7 +1267,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(IDirect3DDevice9Ex *iface)
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
+    hr = wined3d_device_begin_scene(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1279,7 +1281,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_EndScene(IDirect3DD
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
+    hr = wined3d_device_end_scene(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1296,7 +1298,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Clear(IDirect3DDevice9Ex *iface, DWOR
 
     /* Note: D3DRECT is compatible with WINED3DRECT */
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
+    hr = wined3d_device_clear(This->wined3d_device, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1312,7 +1314,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(IDirect3DDevice9Ex *ifac
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_transform(This->WineD3DDevice, State, (const WINED3DMATRIX *)lpMatrix);
+    hr = wined3d_device_set_transform(This->wined3d_device, State, (const WINED3DMATRIX *)lpMatrix);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1328,7 +1330,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(IDirect3DDevice9Ex *ifac
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_transform(This->WineD3DDevice, State, (WINED3DMATRIX *)pMatrix);
+    hr = wined3d_device_get_transform(This->wined3d_device, State, (WINED3DMATRIX *)pMatrix);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1344,7 +1346,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(IDirect3DDevice9Ex
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
+    hr = wined3d_device_multiply_transform(This->wined3d_device, State, (const WINED3DMATRIX *)pMatrix);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1360,7 +1362,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(IDirect3DDevice9Ex *iface
 
     /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_viewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_set_viewport(This->wined3d_device, (const WINED3DVIEWPORT *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1376,7 +1378,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(IDirect3DDevice9Ex *iface
 
     /* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_viewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
+    hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)pViewport);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1392,7 +1394,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(IDirect3DDevice9Ex *iface
 
     /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_material(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
+    hr = wined3d_device_set_material(This->wined3d_device, (const WINED3DMATERIAL *)pMaterial);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1408,7 +1410,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(IDirect3DDevice9Ex *iface
 
     /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_material(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
+    hr = wined3d_device_get_material(This->wined3d_device, (WINED3DMATERIAL *)pMaterial);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1424,7 +1426,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(IDirect3DDevice9Ex *iface, D
 
     /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
     wined3d_mutex_lock();
-    hr = wined3d_device_set_light(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
+    hr = wined3d_device_set_light(This->wined3d_device, Index, (const WINED3DLIGHT *)pLight);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1440,7 +1442,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(IDirect3DDevice9Ex *iface, D
 
     /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
     wined3d_mutex_lock();
-    hr = wined3d_device_get_light(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
+    hr = wined3d_device_get_light(This->wined3d_device, Index, (WINED3DLIGHT *)pLight);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1455,7 +1457,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(IDirect3DDevice9Ex *iface
     TRACE("iface %p, index %u, enable %#x.\n", iface, Index, Enable);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_light_enable(This->WineD3DDevice, Index, Enable);
+    hr = wined3d_device_set_light_enable(This->wined3d_device, Index, Enable);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1470,7 +1472,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(IDirect3DDevice9Ex *if
     TRACE("iface %p, index %u, enable %p.\n", iface, Index, pEnable);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_light_enable(This->WineD3DDevice, Index, pEnable);
+    hr = wined3d_device_get_light_enable(This->wined3d_device, Index, pEnable);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1485,7 +1487,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(IDirect3DDevice9Ex *ifac
     TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_clip_plane(This->WineD3DDevice, Index, pPlane);
+    hr = wined3d_device_set_clip_plane(This->wined3d_device, Index, pPlane);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1500,7 +1502,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(IDirect3DDevice9Ex *ifac
     TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_clip_plane(This->WineD3DDevice, Index, pPlane);
+    hr = wined3d_device_get_clip_plane(This->wined3d_device, Index, pPlane);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1515,7 +1517,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetRenderState(IDir
     TRACE("iface %p, state %#x, value %#x.\n", iface, State, Value);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_render_state(This->WineD3DDevice, State, Value);
+    hr = wined3d_device_set_render_state(This->wined3d_device, State, Value);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1530,7 +1532,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(IDirect3DDevice9Ex *if
     TRACE("iface %p, state %#x, value %p.\n", iface, State, pValue);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_render_state(This->WineD3DDevice, State, pValue);
+    hr = wined3d_device_get_render_state(This->wined3d_device, State, pValue);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1580,7 +1582,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *i
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
+    hr = wined3d_device_begin_stateblock(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1597,7 +1599,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *ifa
     TRACE("iface %p, stateblock %p.\n", iface, stateblock);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice, &wined3d_stateblock);
+    hr = wined3d_device_end_stateblock(This->wined3d_device, &wined3d_stateblock);
     wined3d_mutex_unlock();
     if (FAILED(hr))
     {
@@ -1641,7 +1643,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(IDirect3DDevice9Ex *ifa
     TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_clip_status(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
+    hr = wined3d_device_set_clip_status(This->wined3d_device, (const WINED3DCLIPSTATUS *)pClipStatus);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1656,7 +1658,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(IDirect3DDevice9Ex *ifa
     TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_clip_status(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
+    hr = wined3d_device_get_clip_status(This->wined3d_device, (WINED3DCLIPSTATUS *)pClipStatus);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1676,7 +1678,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(IDirect3DDevice9Ex *iface,
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_texture(This->WineD3DDevice, Stage, &wined3d_texture);
+    hr = wined3d_device_get_texture(This->wined3d_device, Stage, &wined3d_texture);
     if (SUCCEEDED(hr) && wined3d_texture)
     {
         *ppTexture = wined3d_texture_get_parent(wined3d_texture);
@@ -1705,7 +1707,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(IDirect3DDevice9Ex *iface,
     TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture(device->WineD3DDevice, stage,
+    hr = wined3d_device_set_texture(device->wined3d_device, stage,
             texture ? ((IDirect3DBaseTexture9Impl *)texture)->wined3d_texture : NULL);
     wined3d_mutex_unlock();
 
@@ -1764,7 +1766,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(IDirect3DDevice9
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_texture_stage_state(This->WineD3DDevice, Stage, tss_lookup[Type], pValue);
+    hr = wined3d_device_get_texture_stage_state(This->wined3d_device, Stage, tss_lookup[Type], pValue);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1785,7 +1787,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(IDirect3DDevice9
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_texture_stage_state(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
+    hr = wined3d_device_set_texture_stage_state(This->wined3d_device, Stage, tss_lookup[Type], Value);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1800,7 +1802,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(IDirect3DDevice9Ex *i
     TRACE("iface %p, sampler %u, state %#x, value %p.\n", iface, Sampler, Type, pValue);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_sampler_state(This->WineD3DDevice, Sampler, Type, pValue);
+    hr = wined3d_device_get_sampler_state(This->wined3d_device, Sampler, Type, pValue);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1815,7 +1817,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetSamplerState(IDi
     TRACE("iface %p, sampler %u, state %#x, value %#x.\n", iface, Sampler, Type, Value);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_sampler_state(This->WineD3DDevice, Sampler, Type, Value);
+    hr = wined3d_device_set_sampler_state(This->wined3d_device, Sampler, Type, Value);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1830,7 +1832,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(IDirect3DDevice9Ex *if
     TRACE("iface %p, pass_count %p.\n", iface, pNumPasses);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
+    hr = wined3d_device_validate_device(This->wined3d_device, pNumPasses);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1845,7 +1847,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(IDirect3DDevice9Ex
     TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_palette_entries(This->WineD3DDevice, PaletteNumber, pEntries);
+    hr = wined3d_device_set_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1860,7 +1862,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(IDirect3DDevice9Ex
     TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_palette_entries(This->WineD3DDevice, PaletteNumber, pEntries);
+    hr = wined3d_device_get_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1875,7 +1877,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(IDirect3DDev
     TRACE("iface %p, palette_idx %u.\n", iface, PaletteNumber);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_current_texture_palette(This->WineD3DDevice, PaletteNumber);
+    hr = wined3d_device_set_current_texture_palette(This->wined3d_device, PaletteNumber);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1890,7 +1892,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(IDirect3DDev
     TRACE("iface %p, palette_idx %p.\n", iface, PaletteNumber);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_current_texture_palette(This->WineD3DDevice, PaletteNumber);
+    hr = wined3d_device_get_current_texture_palette(This->wined3d_device, PaletteNumber);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1905,7 +1907,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(IDirect3DDevice9Ex *if
     TRACE("iface %p, rect %p.\n", iface, pRect);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_scissor_rect(This->WineD3DDevice, pRect);
+    hr = wined3d_device_set_scissor_rect(This->wined3d_device, pRect);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1919,7 +1921,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(IDirect3DDevice9Ex *if
     TRACE("iface %p, rect %p.\n", iface, pRect);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_scissor_rect(This->WineD3DDevice, pRect);
+    hr = wined3d_device_get_scissor_rect(This->wined3d_device, pRect);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1934,7 +1936,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(IDirect3D
     TRACE("iface %p, software %#x.\n", iface, bSoftware);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_software_vertex_processing(This->WineD3DDevice, bSoftware);
+    hr = wined3d_device_set_software_vertex_processing(This->wined3d_device, bSoftware);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1948,7 +1950,7 @@ static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(IDirect3DDev
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    ret = wined3d_device_get_software_vertex_processing(This->WineD3DDevice);
+    ret = wined3d_device_get_software_vertex_processing(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return ret;
@@ -1962,7 +1964,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(IDirect3DDevice9Ex *ifa
     TRACE("iface %p, segment_count %.8e.\n", iface, nSegments);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_npatch_mode(This->WineD3DDevice, nSegments);
+    hr = wined3d_device_set_npatch_mode(This->wined3d_device, nSegments);
     wined3d_mutex_unlock();
 
     return hr;
@@ -1976,7 +1978,7 @@ static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(IDirect3DDevice9Ex *iface
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    ret = wined3d_device_get_npatch_mode(This->WineD3DDevice);
+    ret = wined3d_device_get_npatch_mode(This->wined3d_device);
     wined3d_mutex_unlock();
 
     return ret;
@@ -1992,8 +1994,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(IDirect3DDevice9Ex *ifa
             iface, PrimitiveType, StartVertex, PrimitiveCount);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive(This->wined3d_device, StartVertex,
             vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
     wined3d_mutex_unlock();
 
@@ -2013,9 +2015,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(IDirect3DDevice9
             NumVertices, startIndex, primCount);
 
     wined3d_mutex_lock();
-    wined3d_device_set_base_vertex_index(This->WineD3DDevice, BaseVertexIndex);
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex,
+    wined3d_device_set_base_vertex_index(This->wined3d_device, BaseVertexIndex);
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, startIndex,
             vertex_count_from_primitive_count(PrimitiveType, primCount));
     wined3d_mutex_unlock();
 
@@ -2033,8 +2035,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(IDirect3DDevice9Ex *i
             iface, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive_up(This->wined3d_device,
             vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
             pVertexStreamZeroData, VertexStreamZeroStride);
     wined3d_mutex_unlock();
@@ -2056,8 +2058,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(IDirect3DDevic
             pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
 
     wined3d_mutex_lock();
-    IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive_up(This->wined3d_device,
             vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
             wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
     wined3d_mutex_unlock();
@@ -2078,7 +2080,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(IDirect3DDevice9Ex *i
             iface, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags, dest->fvf);
+    hr = wined3d_device_process_vertices(This->wined3d_device, SrcStartIndex, DestIndex, VertexCount,
+            dest->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags, dest->fvf);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2129,7 +2132,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9
     TRACE("iface %p, declaration %p.\n", iface, declaration);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vertex_declaration(This->WineD3DDevice,
+    hr = wined3d_device_set_vertex_declaration(This->wined3d_device,
             declaration ? ((IDirect3DVertexDeclaration9Impl *)declaration)->wineD3DVertexDeclaration : NULL);
     wined3d_mutex_unlock();
 
@@ -2148,7 +2151,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9
     if (!declaration) return D3DERR_INVALIDCALL;
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vertex_declaration(This->WineD3DDevice, &wined3d_declaration);
+    hr = wined3d_device_get_vertex_declaration(This->wined3d_device, &wined3d_declaration);
     if (SUCCEEDED(hr) && wined3d_declaration)
     {
         *declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
@@ -2323,7 +2326,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *i
     TRACE("iface %p, shader %p.\n", iface, shader);
 
     wined3d_mutex_lock();
-    hr =  wined3d_device_set_vertex_shader(This->WineD3DDevice,
+    hr =  wined3d_device_set_vertex_shader(This->wined3d_device,
             shader ? ((IDirect3DVertexShader9Impl *)shader)->wined3d_shader : NULL);
     wined3d_mutex_unlock();
 
@@ -2339,7 +2342,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *i
     TRACE("iface %p, shader %p.\n", iface, shader);
 
     wined3d_mutex_lock();
-    wined3d_shader = wined3d_device_get_vertex_shader(This->WineD3DDevice);
+    wined3d_shader = wined3d_device_get_vertex_shader(This->wined3d_device);
     if (wined3d_shader)
     {
         *shader = wined3d_shader_get_parent(wined3d_shader);
@@ -2373,7 +2376,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(IDirect3DDev
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vs_consts_f(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_set_vs_consts_f(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2395,7 +2398,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(IDirect3DDev
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vs_consts_f(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_get_vs_consts_f(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2410,7 +2413,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(IDirect3DDev
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vs_consts_i(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_set_vs_consts_i(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2425,7 +2428,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(IDirect3DDev
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vs_consts_i(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_get_vs_consts_i(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2440,7 +2443,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(IDirect3DDev
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vs_consts_b(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_set_vs_consts_b(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2455,7 +2458,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(IDirect3DDev
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vs_consts_b(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_get_vs_consts_b(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2471,7 +2474,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(IDirect3DDevice9Ex *i
             iface, StreamNumber, pStreamData, OffsetInBytes, Stride);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_stream_source(This->WineD3DDevice, StreamNumber,
+    hr = wined3d_device_set_stream_source(This->wined3d_device, StreamNumber,
             pStreamData ? ((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer : NULL,
             OffsetInBytes, Stride);
     wined3d_mutex_unlock();
@@ -2494,7 +2497,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(IDirect3DDevice9Ex *i
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_stream_source(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
+    hr = wined3d_device_get_stream_source(This->wined3d_device, StreamNumber, &retStream, OffsetInBytes, pStride);
     if (SUCCEEDED(hr) && retStream)
     {
         *pStream = wined3d_buffer_get_parent(retStream);
@@ -2523,7 +2526,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(IDirect3DDevice9E
     TRACE("iface %p, stream_idx %u, freq %u.\n", iface, StreamNumber, Divider);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_stream_source_freq(This->WineD3DDevice, StreamNumber, Divider);
+    hr = wined3d_device_set_stream_source_freq(This->wined3d_device, StreamNumber, Divider);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2538,7 +2541,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(IDirect3DDevice9E
     TRACE("iface %p, stream_idx %u, freq %p.\n", iface, StreamNumber, Divider);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_stream_source_freq(This->WineD3DDevice, StreamNumber, Divider);
+    hr = wined3d_device_get_stream_source_freq(This->wined3d_device, StreamNumber, Divider);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2554,7 +2557,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(IDirect3DDevice9Ex *iface,
     TRACE("iface %p, buffer %p.\n", iface, pIndexData);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_index_buffer(This->WineD3DDevice,
+    hr = wined3d_device_set_index_buffer(This->wined3d_device,
             ib ? ib->wineD3DIndexBuffer : NULL,
             ib ? ib->format : WINED3DFMT_UNKNOWN);
     wined3d_mutex_unlock();
@@ -2576,7 +2579,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(IDirect3DDevice9Ex *iface,
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_index_buffer(This->WineD3DDevice, &retIndexData);
+    hr = wined3d_device_get_index_buffer(This->wined3d_device, &retIndexData);
     if (SUCCEEDED(hr) && retIndexData)
     {
         *ppIndexData = wined3d_buffer_get_parent(retIndexData);
@@ -2632,7 +2635,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *if
     TRACE("iface %p, shader %p.\n", iface, shader);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_pixel_shader(This->WineD3DDevice,
+    hr = wined3d_device_set_pixel_shader(This->wined3d_device,
             shader ? ((IDirect3DPixelShader9Impl *)shader)->wined3d_shader : NULL);
     wined3d_mutex_unlock();
 
@@ -2650,7 +2653,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *if
     if (!shader) return D3DERR_INVALIDCALL;
 
     wined3d_mutex_lock();
-    wined3d_shader = wined3d_device_get_pixel_shader(This->WineD3DDevice);
+    wined3d_shader = wined3d_device_get_pixel_shader(This->wined3d_device);
     if (wined3d_shader)
     {
         *shader = wined3d_shader_get_parent(wined3d_shader);
@@ -2677,7 +2680,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(IDirect3DDevi
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_ps_consts_f(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_set_ps_consts_f(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2692,7 +2695,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(IDirect3DDevi
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_ps_consts_f(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_get_ps_consts_f(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2707,7 +2710,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(IDirect3DDevi
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_ps_consts_i(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_set_ps_consts_i(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2722,7 +2725,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(IDirect3DDevi
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_ps_consts_i(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_get_ps_consts_i(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2737,7 +2740,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevi
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_ps_consts_b(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_set_ps_consts_b(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2752,7 +2755,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevi
     TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_ps_consts_b(This->WineD3DDevice, reg_idx, data, count);
+    hr = wined3d_device_get_ps_consts_b(This->wined3d_device, reg_idx, data, count);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2768,7 +2771,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(IDirect3DDevice9Ex *ifa
             iface, Handle, pNumSegs, pRectPatchInfo);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
+    hr = wined3d_device_draw_rect_patch(This->wined3d_device, Handle,
+            pNumSegs, (const WINED3DRECTPATCH_INFO *)pRectPatchInfo);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2784,7 +2788,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(IDirect3DDevice9Ex *ifac
             iface, Handle, pNumSegs, pTriPatchInfo);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
+    hr = wined3d_device_draw_tri_patch(This->wined3d_device, Handle,
+            pNumSegs, (const WINED3DTRIPATCH_INFO *)pTriPatchInfo);
     wined3d_mutex_unlock();
 
     return hr;
@@ -2798,7 +2803,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(IDirect3DDevice9Ex *iface
     TRACE("iface %p, handle %#x.\n", iface, Handle);
 
     wined3d_mutex_lock();
-    hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
+    hr = wined3d_device_delete_patch(This->wined3d_device, Handle);
     wined3d_mutex_unlock();
 
     return hr;
@@ -3144,7 +3149,8 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface,
+        struct wined3d_device *device)
 {
     TRACE("iface %p, device %p\n", iface, device);
 }
@@ -3392,7 +3398,7 @@ HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT
 
     wined3d_mutex_lock();
     hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags,
-            (IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->WineD3DDevice);
+            (IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->wined3d_device);
     if (FAILED(hr))
     {
         WARN("Failed to create wined3d device, hr %#x.\n", hr);
@@ -3408,15 +3414,17 @@ HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT
         count = caps.NumberOfAdaptersInGroup;
     }
 
-    if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
+    if (flags & D3DCREATE_MULTITHREADED)
+        wined3d_device_set_multithreaded(device->wined3d_device);
 
     if (!parameters->Windowed)
     {
-        if (!focus_window) focus_window = parameters->hDeviceWindow;
-        if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
+        if (!focus_window)
+            focus_window = parameters->hDeviceWindow;
+        if (FAILED(hr = wined3d_device_acquire_focus_window(device->wined3d_device, focus_window)))
         {
             ERR("Failed to acquire focus window, hr %#x.\n", hr);
-            IWineD3DDevice_Release(device->WineD3DDevice);
+            wined3d_device_decref(device->wined3d_device);
             wined3d_mutex_unlock();
             return hr;
         }
@@ -3426,7 +3434,7 @@ HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT
             HWND device_window = parameters[i].hDeviceWindow;
 
             if (!device_window) device_window = focus_window;
-            IWineD3DDevice_SetupFullscreenWindow(device->WineD3DDevice, device_window,
+            wined3d_device_setup_fullscreen_window(device->wined3d_device, device_window,
                     parameters[i].BackBufferWidth,
                     parameters[i].BackBufferHeight);
         }
@@ -3436,7 +3444,7 @@ HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT
     if (!wined3d_parameters)
     {
         ERR("Failed to allocate wined3d parameters.\n");
-        IWineD3DDevice_Release(device->WineD3DDevice);
+        wined3d_device_decref(device->wined3d_device);
         wined3d_mutex_unlock();
         return E_OUTOFMEMORY;
     }
@@ -3461,13 +3469,13 @@ HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT
         wined3d_parameters[i].AutoRestoreDisplayMode = TRUE;
     }
 
-    hr = IWineD3DDevice_Init3D(device->WineD3DDevice, wined3d_parameters);
+    hr = wined3d_device_init_3d(device->wined3d_device, wined3d_parameters);
     if (FAILED(hr))
     {
         WARN("Failed to initialize 3D, hr %#x.\n", hr);
-        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
+        wined3d_device_release_focus_window(device->wined3d_device);
         HeapFree(GetProcessHeap(), 0, wined3d_parameters);
-        IWineD3DDevice_Release(device->WineD3DDevice);
+        wined3d_device_decref(device->wined3d_device);
         wined3d_mutex_unlock();
         return hr;
     }
@@ -3501,9 +3509,9 @@ HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT
     {
         ERR("Failed to allocate FVF vertex declaration map memory.\n");
         wined3d_mutex_lock();
-        IWineD3DDevice_Uninit3D(device->WineD3DDevice);
-        IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
-        IWineD3DDevice_Release(device->WineD3DDevice);
+        wined3d_device_uninit_3d(device->wined3d_device);
+        wined3d_device_release_focus_window(device->wined3d_device);
+        wined3d_device_decref(device->wined3d_device);
         wined3d_mutex_unlock();
         return E_OUTOFMEMORY;
     }
diff --git a/dlls/d3d9/query.c b/dlls/d3d9/query.c
index fc3a85a..4252332 100644
--- a/dlls/d3d9/query.c
+++ b/dlls/d3d9/query.c
@@ -171,7 +171,7 @@ HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3D
     query->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_query_create(device->WineD3DDevice, type, &query->wineD3DQuery);
+    hr = wined3d_query_create(device->wined3d_device, type, &query->wineD3DQuery);
     wined3d_mutex_unlock();
     if (FAILED(hr))
     {
diff --git a/dlls/d3d9/shader.c b/dlls/d3d9/shader.c
index 4024c5c..c36600d 100644
--- a/dlls/d3d9/shader.c
+++ b/dlls/d3d9/shader.c
@@ -135,7 +135,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Im
     shader->lpVtbl = &d3d9_vertexshader_vtbl;
 
     wined3d_mutex_lock();
-    hr = wined3d_shader_create_vs(device->WineD3DDevice, byte_code, NULL,
+    hr = wined3d_shader_create_vs(device->wined3d_device, byte_code, NULL,
             shader, &d3d9_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
     wined3d_mutex_unlock();
     if (FAILED(hr))
@@ -262,7 +262,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl
     shader->lpVtbl = &d3d9_pixelshader_vtbl;
 
     wined3d_mutex_lock();
-    hr = wined3d_shader_create_ps(device->WineD3DDevice, byte_code, NULL, shader,
+    hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
             &d3d9_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
     wined3d_mutex_unlock();
     if (FAILED(hr))
diff --git a/dlls/d3d9/stateblock.c b/dlls/d3d9/stateblock.c
index e03da84..06f8aed 100644
--- a/dlls/d3d9/stateblock.c
+++ b/dlls/d3d9/stateblock.c
@@ -149,7 +149,7 @@ HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Im
     else
     {
         wined3d_mutex_lock();
-        hr = wined3d_stateblock_create(device->WineD3DDevice,
+        hr = wined3d_stateblock_create(device->wined3d_device,
                 (WINED3DSTATEBLOCKTYPE)type, &stateblock->wined3d_stateblock);
         wined3d_mutex_unlock();
         if (FAILED(hr))
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index 6e2bf8f..1d66bde 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -392,7 +392,7 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_create(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
+    hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
             lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
             multisample_quality, SURFACE_OPENGL, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c
index 1c78f45..2643707 100644
--- a/dlls/d3d9/swapchain.c
+++ b/dlls/d3d9/swapchain.c
@@ -259,7 +259,7 @@ HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl
     wined3d_parameters.AutoRestoreDisplayMode = TRUE;
 
     wined3d_mutex_lock();
-    hr = wined3d_swapchain_create(device->WineD3DDevice, &wined3d_parameters,
+    hr = wined3d_swapchain_create(device->wined3d_device, &wined3d_parameters,
             SURFACE_OPENGL, swapchain, &d3d9_swapchain_wined3d_parent_ops,
             &swapchain->wined3d_swapchain);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index 2fc5233..d1df0f5 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -457,7 +457,7 @@ HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *devic
     texture->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_2d(device->WineD3DDevice, width, height, levels,
+    hr = wined3d_texture_create_2d(device->wined3d_device, width, height, levels,
             usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
             texture, &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c
index c43d55d..6224614 100644
--- a/dlls/d3d9/vertexdeclaration.c
+++ b/dlls/d3d9/vertexdeclaration.c
@@ -395,7 +395,7 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
     declaration->element_count = element_count;
 
     wined3d_mutex_lock();
-    hr = wined3d_vertex_declaration_create(device->WineD3DDevice, wined3d_elements, wined3d_element_count,
+    hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
             declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wineD3DVertexDeclaration);
     wined3d_mutex_unlock();
     HeapFree(GetProcessHeap(), 0, wined3d_elements);
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c
index bc6d03c..ba495b6 100644
--- a/dlls/d3d9/volume.c
+++ b/dlls/d3d9/volume.c
@@ -275,7 +275,7 @@ HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device,
     volume->IDirect3DVolume9_iface.lpVtbl = &Direct3DVolume9_Vtbl;
     volume->ref = 1;
 
-    hr = wined3d_volume_create(device->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
+    hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage & WINED3DUSAGE_MASK,
             format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wined3d_volume);
     if (FAILED(hr))
     {
diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c
index d1b5c37..9528e9b 100644
--- a/dlls/d3d9/volumetexture.c
+++ b/dlls/d3d9/volumetexture.c
@@ -443,7 +443,7 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice
     texture->ref = 1;
 
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_3d(device->WineD3DDevice, width, height, depth, levels,
+    hr = wined3d_texture_create_3d(device->wined3d_device, width, height, depth, levels,
             usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
             &d3d9_volumetexture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 7d2d718..1eb9a30 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -453,7 +453,7 @@ static void ddraw_destroy(IDirectDrawImpl *This)
     LeaveCriticalSection(&ddraw_cs);
 
     /* Release the attached WineD3D stuff */
-    IWineD3DDevice_Release(This->wineD3DDevice);
+    wined3d_device_decref(This->wined3d_device);
     wined3d_decref(This->wineD3D);
 
     /* Now free the object */
@@ -702,27 +702,27 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
 
     if ((This->cooperative_level & DDSCL_EXCLUSIVE)
             && (hwnd != window || !(cooplevel & DDSCL_EXCLUSIVE)))
-        IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice);
+        wined3d_device_release_focus_window(This->wined3d_device);
 
     if ((cooplevel & DDSCL_FULLSCREEN) != (This->cooperative_level & DDSCL_FULLSCREEN) || hwnd != window)
     {
         if (This->cooperative_level & DDSCL_FULLSCREEN)
-        {
-            IWineD3DDevice_RestoreFullscreenWindow(This->wineD3DDevice, window);
-        }
+            wined3d_device_restore_fullscreen_window(This->wined3d_device, window);
+
         if (cooplevel & DDSCL_FULLSCREEN)
         {
             WINED3DDISPLAYMODE display_mode;
 
             wined3d_get_adapter_display_mode(This->wineD3D, WINED3DADAPTER_DEFAULT, &display_mode);
-            IWineD3DDevice_SetupFullscreenWindow(This->wineD3DDevice, hwnd, display_mode.Width, display_mode.Height);
+            wined3d_device_setup_fullscreen_window(This->wined3d_device, hwnd,
+                    display_mode.Width, display_mode.Height);
         }
     }
 
     if ((cooplevel & DDSCL_EXCLUSIVE)
             && (hwnd != window || !(This->cooperative_level & DDSCL_EXCLUSIVE)))
     {
-        HRESULT hr = IWineD3DDevice_AcquireFocusWindow(This->wineD3DDevice, hwnd);
+        HRESULT hr = wined3d_device_acquire_focus_window(This->wined3d_device, hwnd);
         if (FAILED(hr))
         {
             ERR("Failed to acquire focus window, hr %#x.\n", hr);
@@ -758,11 +758,8 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
         }
     }
 
-    if(cooplevel & DDSCL_MULTITHREADED && !(This->cooperative_level & DDSCL_MULTITHREADED))
-    {
-        /* Enable thread safety in wined3d */
-        IWineD3DDevice_SetMultithreaded(This->wineD3DDevice);
-    }
+    if (cooplevel & DDSCL_MULTITHREADED && !(This->cooperative_level & DDSCL_MULTITHREADED))
+        wined3d_device_set_multithreaded(This->wined3d_device);
 
     /* Unhandled flags */
     if(cooplevel & DDSCL_ALLOWREBOOT)
@@ -856,7 +853,7 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
         default: format = WINED3DFMT_UNKNOWN;          break;
     }
 
-    if (FAILED(hr = IWineD3DDevice_GetDisplayMode(ddraw->wineD3DDevice, 0, &Mode)))
+    if (FAILED(hr = wined3d_device_get_display_mode(ddraw->wined3d_device, 0, &Mode)))
     {
         ERR("Failed to get current display mode, hr %#x.\n", hr);
     }
@@ -890,9 +887,9 @@ static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD
      */
 
     /* TODO: Lose the primary surface */
-    hr = IWineD3DDevice_SetDisplayMode(ddraw->wineD3DDevice, 0, &Mode);
-    IWineD3DDevice_RestoreFullscreenWindow(ddraw->wineD3DDevice, ddraw->dest_window);
-    IWineD3DDevice_SetupFullscreenWindow(ddraw->wineD3DDevice, ddraw->dest_window, Width, Height);
+    hr = wined3d_device_set_display_mode(ddraw->wined3d_device, 0, &Mode);
+    wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window);
+    wined3d_device_setup_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window, Width, Height);
     LeaveCriticalSection(&ddraw_cs);
     switch(hr)
     {
@@ -1085,8 +1082,9 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
     memset(&winecaps, 0, sizeof(winecaps));
     caps.dwSize = sizeof(caps);
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_GetDeviceCaps(This->wineD3DDevice, &winecaps);
-    if(FAILED(hr)) {
+    hr = wined3d_device_get_device_caps(This->wined3d_device, &winecaps);
+    if (FAILED(hr))
+    {
         WARN("IWineD3DDevice::GetDeviceCaps failed\n");
         LeaveCriticalSection(&ddraw_cs);
         return hr;
@@ -1270,12 +1268,9 @@ static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2
     }
 
     /* The necessary members of LPDDSURFACEDESC and LPDDSURFACEDESC2 are equal,
-     * so one method can be used for all versions (Hopefully)
-     */
-    hr = IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
-                                      0 /* swapchain 0 */,
-                                      &Mode);
-    if( hr != D3D_OK )
+     * so one method can be used for all versions (Hopefully) */
+    hr = wined3d_device_get_display_mode(This->wined3d_device, 0, &Mode);
+    if (FAILED(hr))
     {
         ERR(" (%p) IWineD3DDevice::GetDisplayMode returned %08x\n", This, hr);
         LeaveCriticalSection(&ddraw_cs);
@@ -1374,9 +1369,7 @@ static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes
 
     TRACE("iface %p, codes_count %p, codes %p.\n", iface, NumCodes, Codes);
 
-    IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
-                                  0 /* swapchain 0 */,
-                                  &d3ddm);
+    wined3d_device_get_display_mode(This->wined3d_device, 0, &d3ddm);
 
     outsize = NumCodes && Codes ? *NumCodes : 0;
 
@@ -1608,8 +1601,10 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C
         return DDERR_INVALIDPARAMS;
     }
 
-    if(total) *total = This->total_vidmem;
-    if(free) *free = IWineD3DDevice_GetAvailableTextureMem(This->wineD3DDevice);
+    if (total)
+        *total = This->total_vidmem;
+    if (free)
+        *free = wined3d_device_get_available_texture_mem(This->wined3d_device);
 
     LeaveCriticalSection(&ddraw_cs);
     return DD_OK;
@@ -1879,9 +1874,7 @@ static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
         hide = TRUE;
     }
 
-    IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
-                                  0,
-                                  &Mode);
+    wined3d_device_get_display_mode(This->wined3d_device, 0, &Mode);
 
     /* Fake the line sweeping of the monitor */
     /* FIXME: We should synchronize with a source to keep the refresh rate */
@@ -1983,10 +1976,9 @@ static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurfa
     TRACE("iface %p, surface %p.\n", iface, GDISurface);
 
     /* Get the back buffer from the wineD3DDevice and search its
-     * attached surfaces for the front buffer
-     */
+     * attached surfaces for the front buffer. */
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_GetBackBuffer(This->wineD3DDevice,
+    hr = wined3d_device_get_back_buffer(This->wined3d_device,
             0, 0, WINED3DBACKBUFFER_TYPE_MONO, &wined3d_surface);
     if (FAILED(hr) || !wined3d_surface)
     {
@@ -2398,7 +2390,7 @@ static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface, HDC hdc,
 
     if (!Surface) return E_INVALIDARG;
 
-    hr = IWineD3DDevice_GetSurfaceFromDC(This->wineD3DDevice, hdc, &wined3d_surface);
+    hr = wined3d_device_get_surface_from_dc(This->wined3d_device, hdc, &wined3d_surface);
     if (FAILED(hr))
     {
         TRACE("No surface found for dc %p.\n", hdc);
@@ -2552,7 +2544,7 @@ HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDE
     wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
 
     parent = wined3d_surface_get_parent(wined3d_surface);
-    hr = wined3d_surface_create(This->wineD3DDevice, wined3d_desc.width, wined3d_desc.height,
+    hr = wined3d_surface_create(This->wined3d_device, wined3d_desc.width, wined3d_desc.height,
             wined3d_desc.format, TRUE, FALSE, surfImpl->mipmap_level, wined3d_desc.usage, wined3d_desc.pool,
             wined3d_desc.multisample_type, wined3d_desc.multisample_quality, This->ImplType,
             parent, &ddraw_surface_wined3d_parent_ops, &surfImpl->wined3d_surface);
@@ -2574,7 +2566,7 @@ HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDE
         /* The backbuffers have the swapchain set as well, but the primary
          * owns it and destroys it. */
         if (surfImpl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
-            IWineD3DDevice_UninitGDI(This->wineD3DDevice);
+            wined3d_device_uninit_gdi(This->wined3d_device);
         surfImpl->isRenderTarget = FALSE;
     }
     else
@@ -2608,7 +2600,7 @@ static HRESULT ddraw_recreate_surfaces(IDirectDrawImpl *This)
         /* Should happen almost never */
         FIXME("(%p) Switching to non-opengl surfaces with d3d started. Is this a bug?\n", This);
         /* Shutdown d3d */
-        IWineD3DDevice_Uninit3D(This->wineD3DDevice);
+        wined3d_device_uninit_3d(This->wined3d_device);
     }
     /* Contrary: D3D starting is handled by the caller, because it knows the render target */
 
@@ -2882,7 +2874,7 @@ static HRESULT ddraw_attach_d3d_device(IDirectDrawImpl *ddraw, IDirectDrawSurfac
     /* Set this NOW, otherwise creating the depth stencil surface will cause a
      * recursive loop until ram or emulated video memory is full. */
     ddraw->d3d_initialized = TRUE;
-    hr = IWineD3DDevice_Init3D(ddraw->wineD3DDevice, &localParameters);
+    hr = wined3d_device_init_3d(ddraw->wined3d_device, &localParameters);
     if (FAILED(hr))
     {
         ddraw->d3d_target = NULL;
@@ -2896,7 +2888,7 @@ static HRESULT ddraw_attach_d3d_device(IDirectDrawImpl *ddraw, IDirectDrawSurfac
     {
         ERR("Error allocating an array for the converted vertex decls.\n");
         ddraw->declArraySize = 0;
-        hr = IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice);
+        hr = wined3d_device_uninit_3d(ddraw->wined3d_device);
         return E_OUTOFMEMORY;
     }
 
@@ -2935,7 +2927,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
     presentation_parameters.AutoRestoreDisplayMode = FALSE;
 
     ddraw->d3d_target = primary;
-    hr = IWineD3DDevice_InitGDI(ddraw->wineD3DDevice, &presentation_parameters);
+    hr = wined3d_device_init_gdi(ddraw->wined3d_device, &presentation_parameters);
     ddraw->d3d_target = NULL;
     if (FAILED(hr))
     {
@@ -3140,8 +3132,8 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
     desc2.u4.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT); /* Just to be sure */
 
     /* Get the video mode from WineD3D - we will need it */
-    hr = IWineD3DDevice_GetDisplayMode(ddraw->wineD3DDevice, 0, &Mode);
-    if(FAILED(hr))
+    hr = wined3d_device_get_display_mode(ddraw->wined3d_device, 0, &Mode);
+    if (FAILED(hr))
     {
         ERR("Failed to read display mode from wined3d\n");
         switch(ddraw->orig_bpp)
@@ -4955,7 +4947,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
      * not like that we'll have to find some workaround, like iterating over
      * all imaginable formats and collecting all the depth stencil formats we
      * can get. */
-    hr = IWineD3DDevice_GetDisplayMode(This->wineD3DDevice, 0, &d3ddm);
+    hr = wined3d_device_get_display_mode(This->wined3d_device, 0, &d3ddm);
 
     for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i)
     {
@@ -5606,7 +5598,7 @@ struct wined3d_vertex_declaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD
     }
     TRACE("not found. Creating and inserting at position %d.\n", low);
 
-    hr = wined3d_vertex_declaration_create_from_fvf(This->wineD3DDevice,
+    hr = wined3d_vertex_declaration_create_from_fvf(This->wined3d_device,
             fvf, This, &ddraw_null_wined3d_parent_ops, &pDecl);
     if (hr != S_OK) return NULL;
 
@@ -5659,7 +5651,8 @@ static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface
 
 /* IWineD3DDeviceParent methods */
 
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
+static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface,
+        struct wined3d_device *device)
 {
     TRACE("iface %p, device %p\n", iface, device);
 }
@@ -5864,7 +5857,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
 
     TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
 
-    hr = wined3d_swapchain_create(This->wineD3DDevice, present_parameters,
+    hr = wined3d_swapchain_create(This->wined3d_device, present_parameters,
             This->ImplType, NULL, &ddraw_null_wined3d_parent_ops, swapchain);
     if (FAILED(hr))
     {
@@ -5936,7 +5929,7 @@ HRESULT ddraw_init(IDirectDrawImpl *ddraw, WINED3DDEVTYPE device_type)
     }
 
     hr = wined3d_device_create(ddraw->wineD3D, WINED3DADAPTER_DEFAULT, device_type, NULL, 0,
-            (IWineD3DDeviceParent *)&ddraw->device_parent_vtbl, &ddraw->wineD3DDevice);
+            (IWineD3DDeviceParent *)&ddraw->device_parent_vtbl, &ddraw->wined3d_device);
     if (FAILED(hr))
     {
         WARN("Failed to create a wined3d device, hr %#x.\n", hr);
@@ -5945,7 +5938,7 @@ HRESULT ddraw_init(IDirectDrawImpl *ddraw, WINED3DDEVTYPE device_type)
     }
 
     /* Get the amount of video memory */
-    ddraw->total_vidmem = IWineD3DDevice_GetAvailableTextureMem(ddraw->wineD3DDevice);
+    ddraw->total_vidmem = wined3d_device_get_available_texture_mem(ddraw->wined3d_device);
 
     list_init(&ddraw->surface_list);
 
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 058804a..50550b6 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -85,7 +85,7 @@ struct IDirectDrawImpl
 
     /* WineD3D linkage */
     struct wined3d *wineD3D;
-    IWineD3DDevice          *wineD3DDevice;
+    struct wined3d_device *wined3d_device;
     BOOL                    d3d_initialized;
 
     /* Misc ddraw fields */
@@ -285,7 +285,7 @@ struct IDirect3DDeviceImpl
     LONG                    ref;
 
     /* Other object connections */
-    IWineD3DDevice          *wineD3DDevice;
+    struct wined3d_device *wined3d_device;
     IDirectDrawImpl         *ddraw;
     struct wined3d_buffer *indexbuffer;
     IDirectDrawSurfaceImpl  *target;
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 79768f8..728d9b1 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -297,14 +297,12 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
 
         /* Set the device up to render to the front buffer since the back
          * buffer will vanish soon. */
-        wined3d_device_set_render_target(This->wineD3DDevice, 0,
+        wined3d_device_set_render_target(This->wined3d_device, 0,
                 This->ddraw->d3d_target->wined3d_surface, TRUE);
 
-        /* Release the WineD3DDevice. This won't destroy it */
-        if(IWineD3DDevice_Release(This->wineD3DDevice) <= 0)
-        {
-            ERR(" (%p) The wineD3D device %p was destroyed unexpectedly. Prepare for trouble\n", This, This->wineD3DDevice);
-        }
+        /* Release the WineD3DDevice. This won't destroy it. */
+        if (!wined3d_device_decref(This->wined3d_device))
+            ERR("The wined3d device (%p) was destroyed unexpectedly.\n", This->wined3d_device);
 
         /* The texture handles should be unset by now, but there might be some bits
          * missing in our reference counting(needs test). Do a sanity check. */
@@ -1086,10 +1084,9 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
     EnterCriticalSection(&ddraw_cs);
 
     memset(&mode, 0, sizeof(mode));
-    hr = IWineD3DDevice_GetDisplayMode(This->ddraw->wineD3DDevice,
-                                       0,
-                                       &mode);
-    if(FAILED(hr)) {
+    hr = wined3d_device_get_display_mode(This->ddraw->wined3d_device, 0, &mode);
+    if (FAILED(hr))
+    {
         LeaveCriticalSection(&ddraw_cs);
         WARN("Cannot get the current adapter format\n");
         return hr;
@@ -1225,10 +1222,9 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
     EnterCriticalSection(&ddraw_cs);
 
     memset(&mode, 0, sizeof(mode));
-    hr = IWineD3DDevice_GetDisplayMode(This->ddraw->wineD3DDevice,
-                                       0,
-                                       &mode);
-    if(FAILED(hr)) {
+    hr = wined3d_device_get_display_mode(This->ddraw->wined3d_device, 0, &mode);
+    if (FAILED(hr))
+    {
         LeaveCriticalSection(&ddraw_cs);
         WARN("Cannot get the current adapter format\n");
         return hr;
@@ -1374,13 +1370,13 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
     *m = *D3DMatrix;
 
     if (D3DMatHandle == This->world)
-        wined3d_device_set_transform(This->wineD3DDevice, WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)D3DMatrix);
+        wined3d_device_set_transform(This->wined3d_device, WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)D3DMatrix);
 
     if (D3DMatHandle == This->view)
-        wined3d_device_set_transform(This->wineD3DDevice, WINED3DTS_VIEW, (WINED3DMATRIX *)D3DMatrix);
+        wined3d_device_set_transform(This->wined3d_device, WINED3DTS_VIEW, (WINED3DMATRIX *)D3DMatrix);
 
     if (D3DMatHandle == This->proj)
-        wined3d_device_set_transform(This->wineD3DDevice, WINED3DTS_PROJECTION, (WINED3DMATRIX *)D3DMatrix);
+        wined3d_device_set_transform(This->wined3d_device, WINED3DTS_PROJECTION, (WINED3DMATRIX *)D3DMatrix);
 
     LeaveCriticalSection(&ddraw_cs);
     return D3D_OK;
@@ -1494,7 +1490,7 @@ IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7 *iface)
     TRACE("iface %p.\n", iface);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_BeginScene(This->wineD3DDevice);
+    hr = wined3d_device_begin_scene(This->wined3d_device);
     LeaveCriticalSection(&ddraw_cs);
     if(hr == WINED3D_OK) return D3D_OK;
     else return D3DERR_SCENE_IN_SCENE; /* TODO: Other possible causes of failure */
@@ -1563,7 +1559,7 @@ IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface)
     TRACE("iface %p.\n", iface);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_EndScene(This->wineD3DDevice);
+    hr = wined3d_device_end_scene(This->wined3d_device);
     LeaveCriticalSection(&ddraw_cs);
     if(hr == WINED3D_OK) return D3D_OK;
     else return D3DERR_SCENE_NOT_IN_SCENE;
@@ -1851,7 +1847,7 @@ IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
         return D3D_OK;
     }
 
-    hr = wined3d_device_set_render_target(This->wineD3DDevice, 0,
+    hr = wined3d_device_set_render_target(This->wined3d_device, 0,
             Target ? Target->wined3d_surface : NULL, FALSE);
     if(hr != D3D_OK)
     {
@@ -2261,7 +2257,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
         {
             WINED3DTEXTUREFILTERTYPE tex_mag;
 
-            hr = wined3d_device_get_sampler_state(This->wineD3DDevice, 0, WINED3DSAMP_MAGFILTER, &tex_mag);
+            hr = wined3d_device_get_sampler_state(This->wined3d_device, 0, WINED3DSAMP_MAGFILTER, &tex_mag);
 
             switch (tex_mag)
             {
@@ -2283,14 +2279,14 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
             WINED3DTEXTUREFILTERTYPE tex_min;
             WINED3DTEXTUREFILTERTYPE tex_mip;
 
-            hr = wined3d_device_get_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_get_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_MINFILTER, &tex_min);
             if (FAILED(hr))
             {
                 LeaveCriticalSection(&ddraw_cs);
                 return hr;
             }
-            hr = wined3d_device_get_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_get_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_MIPFILTER, &tex_mip);
 
             switch (tex_min)
@@ -2341,11 +2337,11 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
 
         case D3DRENDERSTATE_TEXTUREADDRESS:
         case D3DRENDERSTATE_TEXTUREADDRESSU:
-            hr = wined3d_device_get_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_get_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_ADDRESSU, Value);
             break;
         case D3DRENDERSTATE_TEXTUREADDRESSV:
-            hr = wined3d_device_get_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_get_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_ADDRESSV, Value);
             break;
 
@@ -2368,7 +2364,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
                 float f;
             } wined3d_value;
 
-            hr = wined3d_device_get_render_state(This->wineD3DDevice, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
+            hr = wined3d_device_get_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
             if (SUCCEEDED(hr))
                 *Value = wined3d_value.f / zbias_factor;
             break;
@@ -2383,7 +2379,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
                 hr = E_NOTIMPL;
                 break;
             }
-            hr = wined3d_device_get_render_state(This->wineD3DDevice, RenderStateType, Value);
+            hr = wined3d_device_get_render_state(This->wined3d_device, RenderStateType, Value);
     }
     LeaveCriticalSection(&ddraw_cs);
     return hr;
@@ -2433,7 +2429,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
 
             EnterCriticalSection(&ddraw_cs);
 
-            hr = wined3d_device_get_texture(This->wineD3DDevice, 0, &tex);
+            hr = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
             if (SUCCEEDED(hr) && tex)
             {
                 /* The parent of the texture is the IDirectDrawSurface7
@@ -2459,12 +2455,12 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
 
             This->legacyTextureBlending = TRUE;
 
-            wined3d_device_get_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, &colorop);
-            wined3d_device_get_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, &colorarg1);
-            wined3d_device_get_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, &colorarg2);
-            wined3d_device_get_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, &alphaop);
-            wined3d_device_get_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, &alphaarg1);
-            wined3d_device_get_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, &alphaarg2);
+            wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_COLOROP, &colorop);
+            wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_COLORARG1, &colorarg1);
+            wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_COLORARG2, &colorarg2);
+            wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAOP, &alphaop);
+            wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAARG1, &alphaarg1);
+            wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAARG2, &alphaarg2);
 
             if (colorop == WINED3DTOP_SELECTARG1 && colorarg1 == WINED3DTA_TEXTURE &&
                 alphaop == WINED3DTOP_SELECTARG1 && alphaarg1 == WINED3DTA_TEXTURE)
@@ -2488,7 +2484,7 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
                 BOOL tex_alpha = FALSE;
                 DDPIXELFORMAT ddfmt;
 
-                hr = wined3d_device_get_texture(This->wineD3DDevice, 0, &tex);
+                hr = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
 
                 if(hr == WINED3D_OK && tex)
                 {
@@ -2604,7 +2600,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
                     break;
             }
 
-            hr = wined3d_device_set_sampler_state(This->wineD3DDevice, 0, WINED3DSAMP_MAGFILTER, tex_mag);
+            hr = wined3d_device_set_sampler_state(This->wined3d_device, 0, WINED3DSAMP_MAGFILTER, tex_mag);
             break;
         }
 
@@ -2647,23 +2643,23 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
                     break;
             }
 
-            wined3d_device_set_sampler_state(This->wineD3DDevice,
+            wined3d_device_set_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_MIPFILTER, tex_mip);
-            hr = wined3d_device_set_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_set_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_MINFILTER, tex_min);
             break;
         }
 
         case D3DRENDERSTATE_TEXTUREADDRESS:
-            wined3d_device_set_sampler_state(This->wineD3DDevice,
+            wined3d_device_set_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_ADDRESSV, Value);
             /* Drop through */
         case D3DRENDERSTATE_TEXTUREADDRESSU:
-            hr = wined3d_device_set_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_set_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_ADDRESSU, Value);
             break;
         case D3DRENDERSTATE_TEXTUREADDRESSV:
-            hr = wined3d_device_set_sampler_state(This->wineD3DDevice,
+            hr = wined3d_device_set_sampler_state(This->wined3d_device,
                     0, WINED3DSAMP_ADDRESSV, Value);
             break;
 
@@ -2688,7 +2684,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
                 float f;
             } wined3d_value;
             wined3d_value.f = Value * zbias_factor;
-            hr = wined3d_device_set_render_state(This->wineD3DDevice, WINED3DRS_DEPTHBIAS, wined3d_value.d);
+            hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, wined3d_value.d);
             break;
         }
 
@@ -2702,7 +2698,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
                 break;
             }
 
-            hr = wined3d_device_set_render_state(This->wineD3DDevice, RenderStateType, Value);
+            hr = wined3d_device_set_render_state(This->wined3d_device, RenderStateType, Value);
             break;
     }
     LeaveCriticalSection(&ddraw_cs);
@@ -2771,7 +2767,7 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
 
             if(Value == 0)
             {
-                hr = wined3d_device_set_texture(This->wineD3DDevice, 0, NULL);
+                hr = wined3d_device_set_texture(This->wined3d_device, 0, NULL);
                 break;
             }
 
@@ -2799,7 +2795,7 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
                     BOOL tex_alpha = FALSE;
                     DDPIXELFORMAT ddfmt;
 
-                    hr = wined3d_device_get_texture(This->wineD3DDevice, 0, &tex);
+                    hr = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
 
                     if(hr == WINED3D_OK && tex)
                     {
@@ -2819,74 +2815,74 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
                     }
 
                     if (tex_alpha)
-                        wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                        wined3d_device_set_texture_stage_state(This->wined3d_device,
                                 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
                     else
-                        wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                        wined3d_device_set_texture_stage_state(This->wined3d_device,
                                 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
                     break;
                 }
 
                 case D3DTBLEND_ADD:
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLOROP, WINED3DTOP_ADD);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
                     break;
 
                 case D3DTBLEND_MODULATEALPHA:
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAOP, WINED3DTOP_MODULATE);
                     break;
 
                 case D3DTBLEND_COPY:
                 case D3DTBLEND_DECAL:
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLOROP, WINED3DTOP_SELECTARG1);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
                     break;
 
                 case D3DTBLEND_DECALALPHA:
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLOROP, WINED3DTOP_BLENDTEXTUREALPHA);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
-                    wined3d_device_set_texture_stage_state(This->wineD3DDevice,
+                    wined3d_device_set_texture_stage_state(This->wined3d_device,
                             0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
                     break;
 
@@ -3173,7 +3169,7 @@ IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_transform(This->wineD3DDevice, type, (WINED3DMATRIX *)Matrix);
+    hr = wined3d_device_set_transform(This->wined3d_device, type, (WINED3DMATRIX *)Matrix);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -3263,7 +3259,7 @@ IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_get_transform(This->wineD3DDevice, type, (WINED3DMATRIX *)Matrix);
+    hr = wined3d_device_get_transform(This->wined3d_device, type, (WINED3DMATRIX *)Matrix);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -3351,9 +3347,8 @@ IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
 
     /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_MultiplyTransform(This->wineD3DDevice,
-                                          type,
-                                          (WINED3DMATRIX*) D3DMatrix);
+    hr = wined3d_device_multiply_transform(This->wined3d_device,
+            type, (WINED3DMATRIX *)D3DMatrix);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -3445,7 +3440,7 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
 
     /* Set the FVF */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_vertex_declaration(This->wineD3DDevice, ddraw_find_decl(This->ddraw, VertexType));
+    hr = wined3d_device_set_vertex_declaration(This->wined3d_device, ddraw_find_decl(This->ddraw, VertexType));
     if(hr != D3D_OK)
     {
         LeaveCriticalSection(&ddraw_cs);
@@ -3453,8 +3448,8 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
     }
 
     /* This method translates to the user pointer draw of WineD3D */
-    IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitiveUP(This->wineD3DDevice, VertexCount, Vertices, stride);
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive_up(This->wined3d_device, VertexCount, Vertices, stride);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -3564,7 +3559,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
 
     /* Set the D3DDevice's FVF */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_vertex_declaration(This->wineD3DDevice, ddraw_find_decl(This->ddraw, VertexType));
+    hr = wined3d_device_set_vertex_declaration(This->wined3d_device, ddraw_find_decl(This->ddraw, VertexType));
     if(FAILED(hr))
     {
         ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
@@ -3572,8 +3567,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
         return hr;
     }
 
-    IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->wineD3DDevice, IndexCount, Indices,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive_up(This->wined3d_device, IndexCount, Indices,
             WINED3DFMT_R16_UINT, Vertices, get_flexible_vertex_size(VertexType));
     LeaveCriticalSection(&ddraw_cs);
     return hr;
@@ -3825,8 +3820,8 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
 
     /* WineD3D doesn't need the FVF here */
     EnterCriticalSection(&ddraw_cs);
-    IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitiveStrided(This->wineD3DDevice, VertexCount, &WineD3DStrided);
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive_strided(This->wined3d_device, VertexCount, &WineD3DStrided);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -3964,8 +3959,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
 
     /* WineD3D doesn't need the FVF here */
     EnterCriticalSection(&ddraw_cs);
-    IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitiveStrided(This->wineD3DDevice,
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive_strided(This->wined3d_device,
             IndexCount, &WineD3DStrided, VertexCount, Indices, WINED3DFMT_R16_UINT);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
@@ -4060,7 +4055,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
     stride = get_flexible_vertex_size(vb->fvf);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_vertex_declaration(This->wineD3DDevice, vb->wineD3DVertexDeclaration);
+    hr = wined3d_device_set_vertex_declaration(This->wined3d_device, vb->wineD3DVertexDeclaration);
     if (FAILED(hr))
     {
         ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
@@ -4069,7 +4064,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
     }
 
     /* Set the vertex stream source */
-    hr = wined3d_device_set_stream_source(This->wineD3DDevice, 0, vb->wineD3DVertexBuffer, 0, stride);
+    hr = wined3d_device_set_stream_source(This->wined3d_device, 0, vb->wineD3DVertexBuffer, 0, stride);
     if(hr != D3D_OK)
     {
         ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
@@ -4078,8 +4073,8 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
     }
 
     /* Now draw the primitives */
-    IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawPrimitive(This->wineD3DDevice, StartVertex, NumVertices);
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_primitive(This->wined3d_device, StartVertex, NumVertices);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -4174,7 +4169,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
 
     EnterCriticalSection(&ddraw_cs);
 
-    hr = wined3d_device_set_vertex_declaration(This->wineD3DDevice, vb->wineD3DVertexDeclaration);
+    hr = wined3d_device_set_vertex_declaration(This->wined3d_device, vb->wineD3DVertexDeclaration);
     if (FAILED(hr))
     {
         ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
@@ -4193,7 +4188,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
 
         TRACE("Growing index buffer to %u bytes\n", size);
 
-        hr = wined3d_buffer_create_ib(This->wineD3DDevice, size, WINED3DUSAGE_DYNAMIC /* Usage */,
+        hr = wined3d_buffer_create_ib(This->wined3d_device, size, WINED3DUSAGE_DYNAMIC /* Usage */,
                 WINED3DPOOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops, &buffer);
         if (FAILED(hr))
         {
@@ -4222,11 +4217,11 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
     wined3d_buffer_unmap(This->indexbuffer);
 
     /* Set the index stream */
-    wined3d_device_set_base_vertex_index(This->wineD3DDevice, StartVertex);
-    hr = wined3d_device_set_index_buffer(This->wineD3DDevice, This->indexbuffer, WINED3DFMT_R16_UINT);
+    wined3d_device_set_base_vertex_index(This->wined3d_device, StartVertex);
+    hr = wined3d_device_set_index_buffer(This->wined3d_device, This->indexbuffer, WINED3DFMT_R16_UINT);
 
     /* Set the vertex stream source */
-    hr = wined3d_device_set_stream_source(This->wineD3DDevice, 0, vb->wineD3DVertexBuffer, 0, stride);
+    hr = wined3d_device_set_stream_source(This->wined3d_device, 0, vb->wineD3DVertexBuffer, 0, stride);
     if (FAILED(hr))
     {
         ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
@@ -4235,8 +4230,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
     }
 
 
-    IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
-    hr = IWineD3DDevice_DrawIndexedPrimitive(This->wineD3DDevice, 0 /* StartIndex */, IndexCount);
+    wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+    hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, 0, IndexCount);
 
     LeaveCriticalSection(&ddraw_cs);
     return hr;
@@ -4446,7 +4441,7 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
     }
 
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_get_texture(This->wineD3DDevice, Stage, &wined3d_texture);
+    hr = wined3d_device_get_texture(This->wined3d_device, Stage, &wined3d_texture);
     if (FAILED(hr) || !wined3d_texture)
     {
         *Texture = NULL;
@@ -4529,7 +4524,7 @@ IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
 
     /* Texture may be NULL here */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_texture(This->wineD3DDevice,
+    hr = wined3d_device_set_texture(This->wined3d_device,
             Stage, surf ? surf->wined3d_texture : NULL);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
@@ -4586,7 +4581,7 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
         DDPIXELFORMAT ddfmt;
         HRESULT result;
 
-        result = wined3d_device_get_texture(This->wineD3DDevice, 0, &tex);
+        result = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
         if (result == WINED3D_OK && tex)
         {
             struct wined3d_resource *sub_resource;
@@ -4606,9 +4601,9 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
 
         /* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
         if (tex_alpha)
-            wined3d_device_set_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
+            wined3d_device_set_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
         else
-            wined3d_device_set_texture_stage_state(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
+            wined3d_device_set_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
     }
 
     LeaveCriticalSection(&ddraw_cs);
@@ -4696,7 +4691,7 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
 
     if (l->sampler_state)
     {
-        hr = wined3d_device_get_sampler_state(This->wineD3DDevice, Stage, l->state, State);
+        hr = wined3d_device_get_sampler_state(This->wined3d_device, Stage, l->state, State);
 
         switch(TexStageStateType)
         {
@@ -4740,7 +4735,7 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
     }
     else
     {
-        hr = wined3d_device_get_texture_stage_state(This->wineD3DDevice, Stage, l->state, State);
+        hr = wined3d_device_get_texture_stage_state(This->wined3d_device, Stage, l->state, State);
     }
 
     LeaveCriticalSection(&ddraw_cs);
@@ -4863,18 +4858,18 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
             }
 
             case D3DTSS_ADDRESS:
-                wined3d_device_set_sampler_state(This->wineD3DDevice, Stage, WINED3DSAMP_ADDRESSV, State);
+                wined3d_device_set_sampler_state(This->wined3d_device, Stage, WINED3DSAMP_ADDRESSV, State);
                 break;
 
             default:
                 break;
         }
 
-        hr = wined3d_device_set_sampler_state(This->wineD3DDevice, Stage, l->state, State);
+        hr = wined3d_device_set_sampler_state(This->wined3d_device, Stage, l->state, State);
     }
     else
     {
-        hr = wined3d_device_set_texture_stage_state(This->wineD3DDevice, Stage, l->state, State);
+        hr = wined3d_device_set_texture_stage_state(This->wined3d_device, Stage, l->state, State);
     }
 
     LeaveCriticalSection(&ddraw_cs);
@@ -4944,7 +4939,7 @@ IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7 *iface,
     TRACE("iface %p, pass_count %p.\n", iface, NumPasses);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_ValidateDevice(This->wineD3DDevice, NumPasses);
+    hr = wined3d_device_validate_device(This->wined3d_device, NumPasses);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -5014,7 +5009,7 @@ IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
             iface, Count, Rects, Flags, Color, Z, Stencil);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_Clear(This->wineD3DDevice, Count, (RECT *)Rects, Flags, Color, Z, Stencil);
+    hr = wined3d_device_clear(This->wined3d_device, Count, (RECT *)Rects, Flags, Color, Z, Stencil);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -5081,7 +5076,7 @@ IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
 
     /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_viewport(This->wineD3DDevice, (WINED3DVIEWPORT *)Data);
+    hr = wined3d_device_set_viewport(This->wined3d_device, (WINED3DVIEWPORT *)Data);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -5137,7 +5132,7 @@ IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
 
     /* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_get_viewport(This->wineD3DDevice, (WINED3DVIEWPORT *)Data);
+    hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)Data);
 
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
@@ -5192,7 +5187,7 @@ IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface,
     if (!Mat) return DDERR_INVALIDPARAMS;
     /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_material(This->wineD3DDevice, (WINED3DMATERIAL *)Mat);
+    hr = wined3d_device_set_material(This->wined3d_device, (WINED3DMATERIAL *)Mat);
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
 }
@@ -5245,7 +5240,7 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
 
     EnterCriticalSection(&ddraw_cs);
     /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
-    hr = wined3d_device_get_material(This->wineD3DDevice, (WINED3DMATERIAL *)Mat);
+    hr = wined3d_device_get_material(This->wined3d_device, (WINED3DMATERIAL *)Mat);
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
 }
@@ -5299,7 +5294,7 @@ IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
 
     EnterCriticalSection(&ddraw_cs);
     /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
-    hr = wined3d_device_set_light(This->wineD3DDevice, LightIndex, (WINED3DLIGHT *)Light);
+    hr = wined3d_device_set_light(This->wined3d_device, LightIndex, (WINED3DLIGHT *)Light);
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
 }
@@ -5353,7 +5348,7 @@ IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
 
     EnterCriticalSection(&ddraw_cs);
     /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
-    rc =  wined3d_device_get_light(This->wineD3DDevice, LightIndex, (WINED3DLIGHT *)Light);
+    rc =  wined3d_device_get_light(This->wined3d_device, LightIndex, (WINED3DLIGHT *)Light);
 
     /* Translate the result. WineD3D returns other values than D3D7 */
     LeaveCriticalSection(&ddraw_cs);
@@ -5404,7 +5399,7 @@ IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7 *iface)
     TRACE("iface %p.\n", iface);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = IWineD3DDevice_BeginStateBlock(This->wineD3DDevice);
+    hr = wined3d_device_begin_stateblock(This->wined3d_device);
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
 }
@@ -5464,7 +5459,7 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
 
     EnterCriticalSection(&ddraw_cs);
 
-    hr = IWineD3DDevice_EndStateBlock(This->wineD3DDevice, &wined3d_sb);
+    hr = wined3d_device_end_stateblock(This->wined3d_device, &wined3d_sb);
     if (FAILED(hr))
     {
         WARN("Failed to end stateblock, hr %#x.\n", hr);
@@ -5794,7 +5789,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
     EnterCriticalSection(&ddraw_cs);
 
     /* The D3DSTATEBLOCKTYPE enum is fine here. */
-    hr = wined3d_stateblock_create(This->wineD3DDevice, Type, &wined3d_sb);
+    hr = wined3d_stateblock_create(This->wined3d_device, Type, &wined3d_sb);
     if (FAILED(hr))
     {
         WARN("Failed to create stateblock, hr %#x.\n", hr);
@@ -5950,11 +5945,13 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
         if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth &&
             src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight)
         {
-            /* Try UpdateSurface that may perform a more direct opengl loading. But skip this if destination is paletted texture and has no palette.
-             * Some games like Sacrifice set palette after Load, and it is a waste of effort to try to load texture without palette and generates
-             * warnings in wined3d. */
+            /* Try UpdateSurface that may perform a more direct OpenGL
+             * loading. But skip this if destination is paletted texture and
+             * has no palette. Some games like Sacrifice set palette after
+             * Load, and it is a waste of effort to try to load texture
+             * without palette and generates warnings in wined3d. */
             if (!palette_missing)
-                hr = IWineD3DDevice_UpdateSurface(device->wineD3DDevice, src_level->wined3d_surface,
+                hr = wined3d_device_update_surface(device->wined3d_device, src_level->wined3d_surface,
                         &rect, dest_level->wined3d_surface, &point);
 
             if (palette_missing || FAILED(hr))
@@ -6248,7 +6245,7 @@ IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7 *iface,
     TRACE("iface %p, light_idx %u, enabled %#x.\n", iface, LightIndex, Enable);
 
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_light_enable(This->wineD3DDevice, LightIndex, Enable);
+    hr = wined3d_device_set_light_enable(This->wined3d_device, LightIndex, Enable);
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
 }
@@ -6307,7 +6304,7 @@ IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7 *iface,
         return DDERR_INVALIDPARAMS;
 
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_get_light_enable(This->wineD3DDevice, LightIndex, Enable);
+    hr = wined3d_device_get_light_enable(This->wined3d_device, LightIndex, Enable);
     LeaveCriticalSection(&ddraw_cs);
     return hr_ddraw_from_wined3d(hr);
 }
@@ -6366,7 +6363,7 @@ IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7 *iface,
         return DDERR_INVALIDPARAMS;
 
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_set_clip_plane(This->wineD3DDevice, Index, PlaneEquation);
+    hr = wined3d_device_set_clip_plane(This->wined3d_device, Index, PlaneEquation);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -6423,7 +6420,7 @@ IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7 *iface,
         return DDERR_INVALIDPARAMS;
 
     EnterCriticalSection(&ddraw_cs);
-    hr = wined3d_device_get_clip_plane(This->wineD3DDevice, Index, PlaneEquation);
+    hr = wined3d_device_get_clip_plane(This->wined3d_device, Index, PlaneEquation);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -6747,13 +6744,13 @@ IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This)
     if(!depthStencil)
     {
         TRACE("Setting wined3d depth stencil to NULL\n");
-        wined3d_device_set_depth_stencil(This->wineD3DDevice, NULL);
+        wined3d_device_set_depth_stencil(This->wined3d_device, NULL);
         return WINED3DZB_FALSE;
     }
 
     dsi = (IDirectDrawSurfaceImpl *)depthStencil;
     TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->wined3d_surface);
-    wined3d_device_set_depth_stencil(This->wineD3DDevice, dsi->wined3d_surface);
+    wined3d_device_set_depth_stencil(This->wined3d_device, dsi->wined3d_surface);
 
     IDirectDrawSurface7_Release(depthStencil);
     return WINED3DZB_TRUE;
@@ -6785,7 +6782,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
     device->legacyTextureBlending = FALSE;
 
     /* Create an index buffer, it's needed for indexed drawing */
-    hr = wined3d_buffer_create_ib(ddraw->wineD3DDevice, 0x40000 /* Length. Don't know how long it should be */,
+    hr = wined3d_buffer_create_ib(ddraw->wined3d_device, 0x40000 /* Length. Don't know how long it should be */,
             WINED3DUSAGE_DYNAMIC /* Usage */, WINED3DPOOL_DEFAULT, NULL,
             &ddraw_null_wined3d_parent_ops, &device->indexbuffer);
     if (FAILED(hr))
@@ -6796,11 +6793,11 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
     }
 
     /* This is for convenience. */
-    device->wineD3DDevice = ddraw->wineD3DDevice;
-    IWineD3DDevice_AddRef(ddraw->wineD3DDevice);
+    device->wined3d_device = ddraw->wined3d_device;
+    wined3d_device_incref(ddraw->wined3d_device);
 
     /* Render to the back buffer */
-    hr = wined3d_device_set_render_target(ddraw->wineD3DDevice, 0, target->wined3d_surface, TRUE);
+    hr = wined3d_device_set_render_target(ddraw->wined3d_device, 0, target->wined3d_surface, TRUE);
     if (FAILED(hr))
     {
         ERR("Failed to set render target, hr %#x.\n", hr);
@@ -6823,7 +6820,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
 
     ddraw->d3ddevice = device;
 
-    wined3d_device_set_render_state(ddraw->wineD3DDevice, WINED3DRS_ZENABLE,
+    wined3d_device_set_render_state(ddraw->wined3d_device, WINED3DRS_ZENABLE,
             IDirect3DDeviceImpl_UpdateDepthStencil(device));
 
     return D3D_OK;
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c
index 581e218..86a3aa9 100644
--- a/dlls/ddraw/executebuffer.c
+++ b/dlls/ddraw/executebuffer.c
@@ -156,7 +156,7 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
                 /* IDirect3DDevices have color keying always enabled -
                  * enable it before drawing. This overwrites any ALPHA*
                  * render state. */
-                wined3d_device_set_render_state(lpDevice->wineD3DDevice, WINED3DRS_COLORKEYENABLE, 1);
+                wined3d_device_set_render_state(lpDevice->wined3d_device, WINED3DRS_COLORKEYENABLE, 1);
                 IDirect3DDevice7_DrawIndexedPrimitive((IDirect3DDevice7 *)lpDevice,
                         D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, tl_vx, 0, This->indices, count * 3, 0);
 	    } break;
@@ -315,11 +315,11 @@ HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
 
                 /* Get the transform and world matrix */
                 /* Note: D3DMATRIX is compatible with WINED3DMATRIX */
-                wined3d_device_get_transform(lpDevice->wineD3DDevice,
+                wined3d_device_get_transform(lpDevice->wined3d_device,
                         D3DTRANSFORMSTATE_VIEW, (WINED3DMATRIX *)&view_mat);
-                wined3d_device_get_transform(lpDevice->wineD3DDevice,
+                wined3d_device_get_transform(lpDevice->wined3d_device,
                         D3DTRANSFORMSTATE_PROJECTION, (WINED3DMATRIX *)&proj_mat);
-                wined3d_device_get_transform(lpDevice->wineD3DDevice,
+                wined3d_device_get_transform(lpDevice->wined3d_device,
                         WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)&world_mat);
 
 		for (i = 0; i < count; i++) {
diff --git a/dlls/ddraw/palette.c b/dlls/ddraw/palette.c
index 73967f2..b68cf82 100644
--- a/dlls/ddraw/palette.c
+++ b/dlls/ddraw/palette.c
@@ -266,7 +266,7 @@ HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
     palette->lpVtbl = &ddraw_palette_vtbl;
     palette->ref = 1;
 
-    hr = wined3d_palette_create(ddraw->wineD3DDevice, flags,
+    hr = wined3d_palette_create(ddraw->wined3d_device, flags,
             entries, palette, &palette->wineD3DPalette);
     if (FAILED(hr))
     {
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 56774b3..f46c200 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -275,7 +275,7 @@ static void ddraw_surface_cleanup(IDirectDrawSurfaceImpl *surface)
             HeapFree(GetProcessHeap(), 0, ddraw->decls);
             ddraw->numConvertedDecls = 0;
 
-            if (FAILED(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice)))
+            if (FAILED(wined3d_device_uninit_3d(ddraw->wined3d_device)))
             {
                 ERR("Failed to uninit 3D.\n");
             }
@@ -295,7 +295,7 @@ static void ddraw_surface_cleanup(IDirectDrawSurfaceImpl *surface)
         }
         else
         {
-            IWineD3DDevice_UninitGDI(ddraw->wineD3DDevice);
+            wined3d_device_uninit_gdi(ddraw->wined3d_device);
         }
 
         surface->wined3d_swapchain = NULL;
@@ -2923,7 +2923,7 @@ static HRESULT WINAPI ddraw_gamma_control_GetGammaRamp(IDirectDrawGammaControl *
     if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     {
         /* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP. */
-        wined3d_device_get_gamma_ramp(surface->ddraw->wineD3DDevice, 0, (WINED3DGAMMARAMP *)gamma_ramp);
+        wined3d_device_get_gamma_ramp(surface->ddraw->wined3d_device, 0, (WINED3DGAMMARAMP *)gamma_ramp);
     }
     else
     {
@@ -2965,7 +2965,7 @@ static HRESULT WINAPI ddraw_gamma_control_SetGammaRamp(IDirectDrawGammaControl *
     if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     {
         /* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP */
-        wined3d_device_set_gamma_ramp(surface->ddraw->wineD3DDevice, 0, flags, (WINED3DGAMMARAMP *)gamma_ramp);
+        wined3d_device_set_gamma_ramp(surface->ddraw->wined3d_device, 0, flags, (WINED3DGAMMARAMP *)gamma_ramp);
     }
     else
     {
@@ -3483,10 +3483,10 @@ HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface)
 
     format = PixelFormat_DD2WineD3D(&surface->surface_desc.u4.ddpfPixelFormat);
     if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
-        return wined3d_texture_create_cube(surface->ddraw->wineD3DDevice, desc->dwWidth,
+        return wined3d_texture_create_cube(surface->ddraw->wined3d_device, desc->dwWidth,
                 levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
     else
-        return wined3d_texture_create_2d(surface->ddraw->wineD3DDevice, desc->dwWidth, desc->dwHeight,
+        return wined3d_texture_create_2d(surface->ddraw->wined3d_device, desc->dwWidth, desc->dwHeight,
                 levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
 }
 
@@ -3572,7 +3572,7 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
     surface->first_attached = surface;
     surface->ImplType = surface_type;
 
-    hr = wined3d_surface_create(ddraw->wineD3DDevice, desc->dwWidth, desc->dwHeight, format,
+    hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format,
             TRUE /* Lockable */, FALSE /* Discard */, mip_level, usage, pool,
             WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, surface_type, surface,
             &ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface);
diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c
index 7d622a6..af4e8bc 100644
--- a/dlls/ddraw/vertexbuffer.c
+++ b/dlls/ddraw/vertexbuffer.c
@@ -145,10 +145,10 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
          * 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->wineD3DDevice,
+        wined3d_device_get_stream_source(This->ddraw->wined3d_device,
                 0, &curVB, &offset, &stride);
         if (curVB == This->wineD3DVertexBuffer)
-            wined3d_device_set_stream_source(This->ddraw->wineD3DDevice, 0, NULL, 0, 0);
+            wined3d_device_set_stream_source(This->ddraw->wined3d_device, 0, NULL, 0, 0);
         if (curVB)
             wined3d_buffer_decref(curVB); /* For the GetStreamSource */
 
@@ -326,25 +326,19 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
      * the vertex ops
      */
     doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE;
-    wined3d_device_get_render_state(D3D->wineD3DDevice, WINED3DRS_CLIPPING, (DWORD *)&oldClip);
+    wined3d_device_get_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, (DWORD *)&oldClip);
     if (doClip != oldClip)
-        wined3d_device_set_render_state(D3D->wineD3DDevice, WINED3DRS_CLIPPING, doClip);
+        wined3d_device_set_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, doClip);
 
-    wined3d_device_set_stream_source(D3D->wineD3DDevice,
+    wined3d_device_set_stream_source(D3D->wined3d_device,
             0, Src->wineD3DVertexBuffer, 0, get_flexible_vertex_size(Src->fvf));
-    wined3d_device_set_vertex_declaration(D3D->wineD3DDevice, Src->wineD3DVertexDeclaration);
-    hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice,
-                                        SrcIndex,
-                                        DestIndex,
-                                        Count,
-                                        This->wineD3DVertexBuffer,
-                                        NULL /* Output vdecl */,
-                                        Flags,
-                                        This->fvf);
+    wined3d_device_set_vertex_declaration(D3D->wined3d_device, Src->wineD3DVertexDeclaration);
+    hr = wined3d_device_process_vertices(D3D->wined3d_device, SrcIndex, DestIndex,
+            Count, This->wineD3DVertexBuffer, NULL, Flags, This->fvf);
 
     /* Restore the states if needed */
     if (doClip != oldClip)
-        wined3d_device_set_render_state(D3D->wineD3DDevice, WINED3DRS_CLIPPING, oldClip);
+        wined3d_device_set_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, oldClip);
     LeaveCriticalSection(&ddraw_cs);
     return hr;
 }
@@ -551,7 +545,7 @@ HRESULT d3d_vertex_buffer_init(IDirect3DVertexBufferImpl *buffer,
 
     EnterCriticalSection(&ddraw_cs);
 
-    hr = wined3d_buffer_create_vb(ddraw->wineD3DDevice,
+    hr = wined3d_buffer_create_vb(ddraw->wined3d_device,
             get_flexible_vertex_size(desc->dwFVF) * desc->dwNumVertices,
             usage, desc->dwCaps & D3DVBCAPS_SYSTEMMEMORY ? WINED3DPOOL_SYSTEMMEM : WINED3DPOOL_DEFAULT,
             buffer, &ddraw_null_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c
index 7aeda68..08af7e2 100644
--- a/dlls/ddraw/viewport.c
+++ b/dlls/ddraw/viewport.c
@@ -387,11 +387,11 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
 
 
     EnterCriticalSection(&ddraw_cs);
-    wined3d_device_get_transform(This->active_device->wineD3DDevice,
+    wined3d_device_get_transform(This->active_device->wined3d_device,
             D3DTRANSFORMSTATE_VIEW, (WINED3DMATRIX *)&view_mat);
-    wined3d_device_get_transform(This->active_device->wineD3DDevice,
+    wined3d_device_get_transform(This->active_device->wined3d_device,
             D3DTRANSFORMSTATE_PROJECTION, (WINED3DMATRIX *)&proj_mat);
-    wined3d_device_get_transform(This->active_device->wineD3DDevice,
+    wined3d_device_get_transform(This->active_device->wined3d_device,
             WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)&world_mat);
     multiply_matrix(&mat,&view_mat,&world_mat);
     multiply_matrix(&mat,&proj_mat,&mat);
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index f84952f..964273b 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -75,7 +75,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
     {
         if (This->child_layer) IUnknown_Release(This->child_layer);
         EnterCriticalSection(&dxgi_cs);
-        IWineD3DDevice_Release(This->wined3d_device);
+        wined3d_device_decref(This->wined3d_device);
         LeaveCriticalSection(&dxgi_cs);
         IWineDXGIFactory_Release(This->factory);
         HeapFree(GetProcessHeap(), 0, This);
@@ -142,7 +142,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface,
 
     EnterCriticalSection(&dxgi_cs);
 
-    hr = IWineD3DDevice_GetCreationParameters(This->wined3d_device, &create_parameters);
+    hr = wined3d_device_get_creation_parameters(This->wined3d_device, &create_parameters);
     if (FAILED(hr))
     {
         LeaveCriticalSection(&dxgi_cs);
@@ -239,14 +239,14 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IWineDXGIDevic
 
 /* IWineDXGIDevice methods */
 
-static IWineD3DDevice * STDMETHODCALLTYPE dxgi_device_get_wined3d_device(IWineDXGIDevice *iface)
+static struct wined3d_device * STDMETHODCALLTYPE dxgi_device_get_wined3d_device(IWineDXGIDevice *iface)
 {
     struct dxgi_device *This = (struct dxgi_device *)iface;
 
     TRACE("iface %p\n", iface);
 
     EnterCriticalSection(&dxgi_cs);
-    IWineD3DDevice_AddRef(This->wined3d_device);
+    wined3d_device_incref(This->wined3d_device);
     LeaveCriticalSection(&dxgi_cs);
     return This->wined3d_device;
 }
@@ -403,7 +403,7 @@ fail:
     if (device->wined3d_device)
     {
         EnterCriticalSection(&dxgi_cs);
-        IWineD3DDevice_Release(device->wined3d_device);
+        wined3d_device_decref(device->wined3d_device);
         LeaveCriticalSection(&dxgi_cs);
     }
     if (device->factory) IWineDXGIFactory_Release(device->factory);
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 38d173c..cb472f3 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -92,7 +92,7 @@ struct dxgi_device
     const struct IWineDXGIDeviceVtbl *vtbl;
     IUnknown *child_layer;
     LONG refcount;
-    IWineD3DDevice *wined3d_device;
+    struct wined3d_device *wined3d_device;
     IWineDXGIFactory *factory;
 };
 
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index 6127181..71e9fe1 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -163,7 +163,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
 {
     WINED3DPRESENT_PARAMETERS present_parameters;
     struct wined3d_swapchain *wined3d_swapchain;
-    IWineD3DDevice *wined3d_device;
+    struct wined3d_device *wined3d_device;
     IWineDXGIDevice *dxgi_device;
     UINT count;
     HRESULT hr;
@@ -180,11 +180,11 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
     wined3d_device = IWineDXGIDevice_get_wined3d_device(dxgi_device);
     IWineDXGIDevice_Release(dxgi_device);
 
-    count = IWineD3DDevice_GetNumberOfSwapChains(wined3d_device);
+    count = wined3d_device_get_swapchain_count(wined3d_device);
     if (count)
     {
         FIXME("Only a single swapchain supported.\n");
-        IWineD3DDevice_Release(wined3d_device);
+        wined3d_device_decref(wined3d_device);
         return E_FAIL;
     }
 
@@ -219,16 +219,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
             desc->BufferDesc.RefreshRate.Numerator / desc->BufferDesc.RefreshRate.Denominator;
     present_parameters.PresentationInterval = WINED3DPRESENT_INTERVAL_DEFAULT;
 
-    hr = IWineD3DDevice_Init3D(wined3d_device, &present_parameters);
+    hr = wined3d_device_init_3d(wined3d_device, &present_parameters);
     if (FAILED(hr))
     {
         WARN("Failed to initialize 3D, returning %#x\n", hr);
-        IWineD3DDevice_Release(wined3d_device);
+        wined3d_device_decref(wined3d_device);
         return hr;
     }
 
-    hr = IWineD3DDevice_GetSwapChain(wined3d_device, 0, &wined3d_swapchain);
-    IWineD3DDevice_Release(wined3d_device);
+    hr = wined3d_device_get_swapchain(wined3d_device, 0, &wined3d_swapchain);
+    wined3d_device_decref(wined3d_device);
     if (FAILED(hr))
     {
         WARN("Failed to get swapchain, returning %#x\n", hr);
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index 7982937..e4f7433 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -68,13 +68,13 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
 
     if (!refcount)
     {
-        IWineD3DDevice *wined3d_device;
+        struct wined3d_device *wined3d_device;
         HRESULT hr;
 
         FIXME("Only a single swapchain is supported\n");
 
         wined3d_device = wined3d_swapchain_get_device(This->wined3d_swapchain);
-        hr = IWineD3DDevice_Uninit3D(wined3d_device);
+        hr = wined3d_device_uninit_3d(wined3d_device);
         if (FAILED(hr))
         {
             ERR("Uninit3D failed, hr %#x\n", hr);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 5d417b1..abcc931 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -693,7 +693,7 @@ static void context_queue_fbo_entry_destruction(struct wined3d_context *context,
     list_add_head(&context->fbo_destroy_list, &entry->entry);
 }
 
-void context_resource_released(struct IWineD3DDeviceImpl *device,
+void context_resource_released(struct wined3d_device *device,
         struct wined3d_resource *resource, WINED3DRESOURCETYPE type)
 {
     if (!device->d3d_initialized) return;
@@ -715,7 +715,7 @@ static void context_detach_fbo_entry(struct wined3d_context *context, struct fbo
     entry->attached = FALSE;
 }
 
-void context_resource_unloaded(struct IWineD3DDeviceImpl *device,
+void context_resource_unloaded(struct wined3d_device *device,
         struct wined3d_resource *resource, WINED3DRESOURCETYPE type)
 {
     switch (type)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 885a14e..2ff2d01 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -828,90 +828,67 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, s
     return WINED3D_OK;
 }
 
-
-/**********************************************************
- * IUnknown parts follows
- **********************************************************/
-
-static HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface, REFIID riid, void **object)
+ULONG CDECL wined3d_device_incref(struct wined3d_device *device)
 {
-    TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
-    if (IsEqualGUID(riid, &IID_IWineD3DDevice)
-            || IsEqualGUID(riid, &IID_IUnknown))
-    {
-        IUnknown_AddRef(iface);
-        *object = iface;
-        return S_OK;
-    }
-
-    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
-
-    *object = NULL;
-    return E_NOINTERFACE;
-}
+    ULONG refcount = InterlockedIncrement(&device->ref);
 
-static ULONG WINAPI IWineD3DDeviceImpl_AddRef(IWineD3DDevice *iface) {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    ULONG refCount = InterlockedIncrement(&This->ref);
+    TRACE("%p increasing refcount to %u.\n", device, refcount);
 
-    TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
-    return refCount;
+    return refcount;
 }
 
-static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    ULONG refCount = InterlockedDecrement(&This->ref);
+ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
+{
+    ULONG refcount = InterlockedDecrement(&device->ref);
 
-    TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
+    TRACE("%p decreasing refcount to %u.\n", device, refcount);
 
-    if (!refCount) {
+    if (!refcount)
+    {
         UINT i;
 
-        for (i = 0; i < sizeof(This->multistate_funcs)/sizeof(This->multistate_funcs[0]); ++i) {
-            HeapFree(GetProcessHeap(), 0, This->multistate_funcs[i]);
-            This->multistate_funcs[i] = NULL;
+        for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i)
+        {
+            HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]);
+            device->multistate_funcs[i] = NULL;
         }
 
-        /* TODO: Clean up all the surfaces and textures! */
-        /* NOTE: You must release the parent if the object was created via a callback
-        ** ***************************/
-
-        if (!list_empty(&This->resources))
+        if (!list_empty(&device->resources))
         {
             struct wined3d_resource *resource;
-            FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This);
 
-            LIST_FOR_EACH_ENTRY(resource, &This->resources, struct wined3d_resource, resource_list_entry)
+            FIXME("Device released with resources still bound, acceptable but unexpected.\n");
+
+            LIST_FOR_EACH_ENTRY(resource, &device->resources, struct wined3d_resource, resource_list_entry)
             {
                 FIXME("Leftover resource %p with type %s (%#x).\n",
                         resource, debug_d3dresourcetype(resource->resourceType), resource->resourceType);
             }
         }
 
-        if(This->contexts) ERR("Context array not freed!\n");
-        if (This->hardwareCursor) DestroyCursor(This->hardwareCursor);
-        This->haveHardwareCursor = FALSE;
+        if (device->contexts)
+            ERR("Context array not freed!\n");
+        if (device->hardwareCursor)
+            DestroyCursor(device->hardwareCursor);
+        device->haveHardwareCursor = FALSE;
 
-        wined3d_decref(This->wined3d);
-        This->wined3d = NULL;
-        HeapFree(GetProcessHeap(), 0, This);
-        TRACE("Freed device  %p\n", This);
-        This = NULL;
+        wined3d_decref(device->wined3d);
+        device->wined3d = NULL;
+        HeapFree(GetProcessHeap(), 0, device);
+        TRACE("Freed device %p.\n", device);
     }
-    return refCount;
+
+    return refcount;
 }
 
-static UINT WINAPI IWineD3DDeviceImpl_GetNumberOfSwapChains(IWineD3DDevice *iface)
+UINT CDECL wined3d_device_get_swapchain_count(struct wined3d_device *device)
 {
-    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
-
-    TRACE("iface %p.\n", iface);
+    TRACE("device %p.\n", device);
 
     return device->swapchain_count;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_swapchain(IWineD3DDevice *iface,
         UINT swapchain_idx, struct wined3d_swapchain **swapchain)
 {
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
@@ -984,7 +961,7 @@ static void IWineD3DDeviceImpl_LoadLogo(IWineD3DDeviceImpl *This, const char *fi
     {
         const WINED3DCOLORVALUE c = {1.0f, 1.0f, 1.0f, 1.0f};
         /* Fill the surface with a white color to show that wined3d is there */
-        IWineD3DDevice_ColorFill((IWineD3DDevice *)This, This->logo_surface, NULL, &c);
+        wined3d_device_color_fill(This, This->logo_surface, NULL, &c);
     }
 
 out:
@@ -1071,9 +1048,8 @@ static LONG fullscreen_exstyle(LONG exstyle)
     return exstyle;
 }
 
-static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h)
+void CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h)
 {
-    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
     BOOL filter_messages;
     LONG style, exstyle;
 
@@ -1104,9 +1080,8 @@ static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *ifac
     device->filter_messages = filter_messages;
 }
 
-static void WINAPI IWineD3DDeviceImpl_RestoreFullscreenWindow(IWineD3DDevice *iface, HWND window)
+void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window)
 {
-    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
     BOOL filter_messages;
     LONG style, exstyle;
 
@@ -1139,11 +1114,9 @@ static void WINAPI IWineD3DDeviceImpl_RestoreFullscreenWindow(IWineD3DDevice *if
     device->exStyle = 0;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window)
+HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window)
 {
-    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
-
-    TRACE("iface %p, window %p.\n", iface, window);
+    TRACE("device %p, window %p.\n", device, window);
 
     if (!wined3d_register_window(window, device))
     {
@@ -1157,129 +1130,138 @@ static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *ifac
     return WINED3D_OK;
 }
 
-static void WINAPI IWineD3DDeviceImpl_ReleaseFocusWindow(IWineD3DDevice *iface)
+void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
 {
-    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
-
-    TRACE("iface %p.\n", iface);
+    TRACE("device %p.\n", device);
 
     if (device->focus_window) wined3d_unregister_window(device->focus_window);
     device->focus_window = NULL;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
-        WINED3DPRESENT_PARAMETERS *pPresentationParameters)
+HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
+        WINED3DPRESENT_PARAMETERS *present_parameters)
 {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
-    const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
+    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     struct wined3d_swapchain *swapchain = NULL;
     struct wined3d_context *context;
     HRESULT hr;
     DWORD state;
     unsigned int i;
 
-    TRACE("(%p)->(%p)\n", This, pPresentationParameters);
+    TRACE("device %p, present_parameters %p.\n", device, present_parameters);
 
-    if(This->d3d_initialized) return WINED3DERR_INVALIDCALL;
-    if(!This->adapter->opengl) return WINED3DERR_INVALIDCALL;
+    if (device->d3d_initialized)
+        return WINED3DERR_INVALIDCALL;
+    if (!device->adapter->opengl)
+        return WINED3DERR_INVALIDCALL;
 
-    TRACE("(%p) : Creating stateblock\n", This);
-    hr = wined3d_stateblock_create(iface, WINED3DSBT_INIT, &This->stateBlock);
+    TRACE("Creating stateblock.\n");
+    hr = wined3d_stateblock_create(device, WINED3DSBT_INIT, &device->stateBlock);
     if (FAILED(hr))
     {
         WARN("Failed to create stateblock\n");
         goto err_out;
     }
-    TRACE("(%p) : Created stateblock (%p)\n", This, This->stateBlock);
-    This->updateStateBlock = This->stateBlock;
-    wined3d_stateblock_incref(This->updateStateBlock);
 
-    This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-            sizeof(*This->render_targets) * gl_info->limits.buffers);
+    TRACE("Created stateblock %p.\n", device->stateBlock);
+    device->updateStateBlock = device->stateBlock;
+    wined3d_stateblock_incref(device->updateStateBlock);
+
+    device->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+            sizeof(*device->render_targets) * gl_info->limits.buffers);
 
-    This->palette_count = 1;
-    This->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
-    if (!This->palettes || !This->render_targets)
+    device->palette_count = 1;
+    device->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
+    if (!device->palettes || !device->render_targets)
     {
         ERR("Out of memory!\n");
         hr = E_OUTOFMEMORY;
         goto err_out;
     }
-    This->palettes[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
-    if(!This->palettes[0]) {
+
+    device->palettes[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
+    if (!device->palettes[0])
+    {
         ERR("Out of memory!\n");
         hr = E_OUTOFMEMORY;
         goto err_out;
     }
-    for (i = 0; i < 256; ++i) {
-        This->palettes[0][i].peRed   = 0xFF;
-        This->palettes[0][i].peGreen = 0xFF;
-        This->palettes[0][i].peBlue  = 0xFF;
-        This->palettes[0][i].peFlags = 0xFF;
+
+    for (i = 0; i < 256; ++i)
+    {
+        device->palettes[0][i].peRed = 0xff;
+        device->palettes[0][i].peGreen = 0xff;
+        device->palettes[0][i].peBlue = 0xff;
+        device->palettes[0][i].peFlags = 0xff;
     }
-    This->currentPalette = 0;
+    device->currentPalette = 0;
 
     /* Initialize the texture unit mapping to a 1:1 mapping */
     for (state = 0; state < MAX_COMBINED_SAMPLERS; ++state)
     {
         if (state < gl_info->limits.fragment_samplers)
         {
-            This->texUnitMap[state] = state;
-            This->rev_tex_unit_map[state] = state;
-        } else {
-            This->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
-            This->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
+            device->texUnitMap[state] = state;
+            device->rev_tex_unit_map[state] = state;
+        }
+        else
+        {
+            device->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
+            device->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
         }
     }
 
     /* Setup the implicit swapchain. This also initializes a context. */
     TRACE("Creating implicit swapchain\n");
-    hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
-            pPresentationParameters, &swapchain);
+    hr = IWineD3DDeviceParent_CreateSwapChain(device->device_parent,
+            present_parameters, &swapchain);
     if (FAILED(hr))
     {
         WARN("Failed to create implicit swapchain\n");
         goto err_out;
     }
 
-    This->swapchain_count = 1;
-    This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->swapchain_count * sizeof(*This->swapchains));
-    if (!This->swapchains)
+    device->swapchain_count = 1;
+    device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains));
+    if (!device->swapchains)
     {
         ERR("Out of memory!\n");
         goto err_out;
     }
-    This->swapchains[0] = swapchain;
+    device->swapchains[0] = swapchain;
 
     if (swapchain->back_buffers && swapchain->back_buffers[0])
     {
         TRACE("Setting rendertarget to %p.\n", swapchain->back_buffers);
-        This->render_targets[0] = swapchain->back_buffers[0];
+        device->render_targets[0] = swapchain->back_buffers[0];
     }
     else
     {
         TRACE("Setting rendertarget to %p.\n", swapchain->front_buffer);
-        This->render_targets[0] = swapchain->front_buffer;
+        device->render_targets[0] = swapchain->front_buffer;
     }
-    wined3d_surface_incref(This->render_targets[0]);
+    wined3d_surface_incref(device->render_targets[0]);
 
     /* Depth Stencil support */
-    This->depth_stencil = This->auto_depth_stencil;
-    if (This->depth_stencil)
-        wined3d_surface_incref(This->depth_stencil);
+    device->depth_stencil = device->auto_depth_stencil;
+    if (device->depth_stencil)
+        wined3d_surface_incref(device->depth_stencil);
 
-    hr = This->shader_backend->shader_alloc_private(This);
-    if(FAILED(hr)) {
+    hr = device->shader_backend->shader_alloc_private(device);
+    if (FAILED(hr))
+    {
         TRACE("Shader private data couldn't be allocated\n");
         goto err_out;
     }
-    hr = This->frag_pipe->alloc_private(This);
-    if(FAILED(hr)) {
+    hr = device->frag_pipe->alloc_private(device);
+    if (FAILED(hr))
+    {
         TRACE("Fragment pipeline private data couldn't be allocated\n");
         goto err_out;
     }
-    hr = This->blitter->alloc_private(This);
-    if(FAILED(hr)) {
+    hr = device->blitter->alloc_private(device);
+    if (FAILED(hr))
+    {
         TRACE("Blitter private data couldn't be allocated\n");
         goto err_out;
     }
@@ -1287,23 +1269,24 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
     /* Set up some starting GL setup */
 
     /* Setup all the devices defaults */
-    stateblock_init_default_state(This->stateBlock);
+    stateblock_init_default_state(device->stateBlock);
 
-    context = context_acquire(This, swapchain->front_buffer);
+    context = context_acquire(device, swapchain->front_buffer);
 
-    create_dummy_textures(This);
+    create_dummy_textures(device);
 
     ENTER_GL();
 
     /* Initialize the current view state */
-    This->view_ident = 1;
-    This->contexts[0]->last_was_rhw = 0;
-    glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights);
-    checkGLcall("glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights)");
+    device->view_ident = 1;
+    device->contexts[0]->last_was_rhw = 0;
+    glGetIntegerv(GL_MAX_LIGHTS, &device->maxConcurrentLights);
+    checkGLcall("glGetIntegerv(GL_MAX_LIGHTS, &device->maxConcurrentLights)");
 
-    switch(wined3d_settings.offscreen_rendering_mode) {
+    switch (wined3d_settings.offscreen_rendering_mode)
+    {
         case ORM_FBO:
-            This->offscreenBuffer = GL_COLOR_ATTACHMENT0;
+            device->offscreenBuffer = GL_COLOR_ATTACHMENT0;
             break;
 
         case ORM_BACKBUFFER:
@@ -1311,87 +1294,87 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
             if (context_get_current()->aux_buffers > 0)
             {
                 TRACE("Using auxilliary buffer for offscreen rendering\n");
-                This->offscreenBuffer = GL_AUX0;
-            } else {
+                device->offscreenBuffer = GL_AUX0;
+            }
+            else
+            {
                 TRACE("Using back buffer for offscreen rendering\n");
-                This->offscreenBuffer = GL_BACK;
+                device->offscreenBuffer = GL_BACK;
             }
         }
     }
 
-    TRACE("(%p) All defaults now set up, leaving Init3D with %p\n", This, This);
+    TRACE("All defaults now set up, leaving 3D init.\n");
     LEAVE_GL();
 
     context_release(context);
 
     /* Clear the screen */
-    IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL,
-                          WINED3DCLEAR_TARGET | (pPresentationParameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0),
-                          0x00, 1.0f, 0);
+    wined3d_device_clear(device, 0, NULL, WINED3DCLEAR_TARGET
+            | (present_parameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0),
+            0x00, 1.0f, 0);
 
-    This->d3d_initialized = TRUE;
+    device->d3d_initialized = TRUE;
 
-    if(wined3d_settings.logo) {
-        IWineD3DDeviceImpl_LoadLogo(This, wined3d_settings.logo);
-    }
-    This->highest_dirty_ps_const = 0;
-    This->highest_dirty_vs_const = 0;
+    if (wined3d_settings.logo)
+        IWineD3DDeviceImpl_LoadLogo(device, wined3d_settings.logo);
+    device->highest_dirty_ps_const = 0;
+    device->highest_dirty_vs_const = 0;
     return WINED3D_OK;
 
 err_out:
-    HeapFree(GetProcessHeap(), 0, This->render_targets);
-    HeapFree(GetProcessHeap(), 0, This->swapchains);
-    This->swapchain_count = 0;
-    if (This->palettes)
+    HeapFree(GetProcessHeap(), 0, device->render_targets);
+    HeapFree(GetProcessHeap(), 0, device->swapchains);
+    device->swapchain_count = 0;
+    if (device->palettes)
     {
-        HeapFree(GetProcessHeap(), 0, This->palettes[0]);
-        HeapFree(GetProcessHeap(), 0, This->palettes);
+        HeapFree(GetProcessHeap(), 0, device->palettes[0]);
+        HeapFree(GetProcessHeap(), 0, device->palettes);
     }
-    This->palette_count = 0;
+    device->palette_count = 0;
     if (swapchain)
         wined3d_swapchain_decref(swapchain);
-    if (This->stateBlock)
+    if (device->stateBlock)
     {
-        wined3d_stateblock_decref(This->stateBlock);
-        This->stateBlock = NULL;
-    }
-    if (This->blit_priv) {
-        This->blitter->free_private(This);
-    }
-    if (This->fragment_priv) {
-        This->frag_pipe->free_private(This);
-    }
-    if (This->shader_priv) {
-        This->shader_backend->shader_free_private(This);
+        wined3d_stateblock_decref(device->stateBlock);
+        device->stateBlock = NULL;
     }
+    if (device->blit_priv)
+        device->blitter->free_private(device);
+    if (device->fragment_priv)
+        device->frag_pipe->free_private(device);
+    if (device->shader_priv)
+        device->shader_backend->shader_free_private(device);
+
     return hr;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_InitGDI(IWineD3DDevice *iface,
-        WINED3DPRESENT_PARAMETERS *pPresentationParameters)
+HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
+        WINED3DPRESENT_PARAMETERS *present_parameters)
 {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     struct wined3d_swapchain *swapchain = NULL;
     HRESULT hr;
 
+    TRACE("device %p, present_parameters %p.\n", device, present_parameters);
+
     /* Setup the implicit swapchain */
     TRACE("Creating implicit swapchain\n");
-    hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
-            pPresentationParameters, &swapchain);
+    hr = IWineD3DDeviceParent_CreateSwapChain(device->device_parent,
+            present_parameters, &swapchain);
     if (FAILED(hr))
     {
         WARN("Failed to create implicit swapchain\n");
         goto err_out;
     }
 
-    This->swapchain_count = 1;
-    This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->swapchain_count * sizeof(*This->swapchains));
-    if (!This->swapchains)
+    device->swapchain_count = 1;
+    device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains));
+    if (!device->swapchains)
     {
         ERR("Out of memory!\n");
         goto err_out;
     }
-    This->swapchains[0] = swapchain;
+    device->swapchains[0] = swapchain;
     return WINED3D_OK;
 
 err_out:
@@ -1408,16 +1391,17 @@ static HRESULT WINAPI device_unload_resource(struct wined3d_resource *resource,
     return S_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
 {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
     struct wined3d_surface *surface;
     UINT i;
-    TRACE("(%p)\n", This);
 
-    if(!This->d3d_initialized) return WINED3DERR_INVALIDCALL;
+    TRACE("device %p.\n", device);
+
+    if (!device->d3d_initialized)
+        return WINED3DERR_INVALIDCALL;
 
     /* Force making the context current again, to verify it is still valid
      * (workaround for broken drivers) */
@@ -1425,62 +1409,66 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface)
     /* I don't think that the interface guarantees that the device is destroyed from the same thread
      * it was created. Thus make sure a context is active for the glDelete* calls
      */
-    context = context_acquire(This, NULL);
+    context = context_acquire(device, NULL);
     gl_info = context->gl_info;
 
-    if (This->logo_surface)
-        wined3d_surface_decref(This->logo_surface);
+    if (device->logo_surface)
+        wined3d_surface_decref(device->logo_surface);
 
     /* Unload resources */
-    IWineD3DDevice_EnumResources(iface, device_unload_resource, NULL);
+    wined3d_device_enum_resources(device, device_unload_resource, NULL);
 
     TRACE("Deleting high order patches\n");
     for(i = 0; i < PATCHMAP_SIZE; i++) {
         struct list *e1, *e2;
         struct WineD3DRectPatch *patch;
-        LIST_FOR_EACH_SAFE(e1, e2, &This->patches[i]) {
+        LIST_FOR_EACH_SAFE(e1, e2, &device->patches[i])
+        {
             patch = LIST_ENTRY(e1, struct WineD3DRectPatch, entry);
-            IWineD3DDevice_DeletePatch(iface, patch->Handle);
+            wined3d_device_delete_patch(device, patch->Handle);
         }
     }
 
     /* Delete the mouse cursor texture */
-    if(This->cursorTexture) {
+    if (device->cursorTexture)
+    {
         ENTER_GL();
-        glDeleteTextures(1, &This->cursorTexture);
+        glDeleteTextures(1, &device->cursorTexture);
         LEAVE_GL();
-        This->cursorTexture = 0;
+        device->cursorTexture = 0;
     }
 
     /* Destroy the depth blt resources, they will be invalid after the reset. Also free shader
      * private data, it might contain opengl pointers
      */
-    if(This->depth_blt_texture) {
+    if (device->depth_blt_texture)
+    {
         ENTER_GL();
-        glDeleteTextures(1, &This->depth_blt_texture);
+        glDeleteTextures(1, &device->depth_blt_texture);
         LEAVE_GL();
-        This->depth_blt_texture = 0;
+        device->depth_blt_texture = 0;
     }
-    if (This->depth_blt_rb) {
+    if (device->depth_blt_rb)
+    {
         ENTER_GL();
-        gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
+        gl_info->fbo_ops.glDeleteRenderbuffers(1, &device->depth_blt_rb);
         LEAVE_GL();
-        This->depth_blt_rb = 0;
-        This->depth_blt_rb_w = 0;
-        This->depth_blt_rb_h = 0;
+        device->depth_blt_rb = 0;
+        device->depth_blt_rb_w = 0;
+        device->depth_blt_rb_h = 0;
     }
 
     /* Release the update stateblock */
-    if (wined3d_stateblock_decref(This->updateStateBlock))
+    if (wined3d_stateblock_decref(device->updateStateBlock))
     {
-        if (This->updateStateBlock != This->stateBlock)
+        if (device->updateStateBlock != device->stateBlock)
             FIXME("Something's still holding the update stateblock.\n");
     }
-    This->updateStateBlock = NULL;
+    device->updateStateBlock = NULL;
 
     {
-        struct wined3d_stateblock *stateblock = This->stateBlock;
-        This->stateBlock = NULL;
+        struct wined3d_stateblock *stateblock = device->stateBlock;
+        device->stateBlock = NULL;
 
         /* Release the stateblock */
         if (wined3d_stateblock_decref(stateblock))
@@ -1488,81 +1476,77 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface)
     }
 
     /* Destroy the shader backend. Note that this has to happen after all shaders are destroyed. */
-    This->blitter->free_private(This);
-    This->frag_pipe->free_private(This);
-    This->shader_backend->shader_free_private(This);
+    device->blitter->free_private(device);
+    device->frag_pipe->free_private(device);
+    device->shader_backend->shader_free_private(device);
 
     /* Release the buffers (with sanity checks)*/
-    if (This->onscreen_depth_stencil)
+    if (device->onscreen_depth_stencil)
     {
-        surface = This->onscreen_depth_stencil;
-        This->onscreen_depth_stencil = NULL;
+        surface = device->onscreen_depth_stencil;
+        device->onscreen_depth_stencil = NULL;
         wined3d_surface_decref(surface);
     }
 
-    if (This->depth_stencil)
+    if (device->depth_stencil)
     {
-        surface = This->depth_stencil;
+        surface = device->depth_stencil;
 
         TRACE("Releasing depth/stencil buffer %p.\n", surface);
 
-        This->depth_stencil = NULL;
+        device->depth_stencil = NULL;
         if (wined3d_surface_decref(surface)
-                && surface != This->auto_depth_stencil)
-        {
+                && surface != device->auto_depth_stencil)
             ERR("Something is still holding a reference to depth/stencil buffer %p.\n", surface);
-        }
     }
 
-    if (This->auto_depth_stencil)
+    if (device->auto_depth_stencil)
     {
-        surface = This->auto_depth_stencil;
-        This->auto_depth_stencil = NULL;
+        surface = device->auto_depth_stencil;
+        device->auto_depth_stencil = NULL;
         if (wined3d_surface_decref(surface))
-        {
-            FIXME("(%p) Something's still holding the auto depth stencil buffer\n", This);
-        }
+            FIXME("Something's still holding the auto depth stencil buffer (%p).\n", surface);
     }
 
     for (i = 1; i < gl_info->limits.buffers; ++i)
     {
-        wined3d_device_set_render_target(iface, i, NULL, FALSE);
+        wined3d_device_set_render_target(device, i, NULL, FALSE);
     }
 
-    surface = This->render_targets[0];
+    surface = device->render_targets[0];
     TRACE("Setting rendertarget 0 to NULL\n");
-    This->render_targets[0] = NULL;
+    device->render_targets[0] = NULL;
     TRACE("Releasing the render target at %p\n", surface);
     wined3d_surface_decref(surface);
 
     context_release(context);
 
-    for (i = 0; i < This->swapchain_count; ++i)
+    for (i = 0; i < device->swapchain_count; ++i)
     {
         TRACE("Releasing the implicit swapchain %u.\n", i);
-        if (wined3d_swapchain_decref(This->swapchains[i]))
+        if (wined3d_swapchain_decref(device->swapchains[i]))
             FIXME("Something's still holding the implicit swapchain.\n");
     }
 
-    HeapFree(GetProcessHeap(), 0, This->swapchains);
-    This->swapchains = NULL;
-    This->swapchain_count = 0;
+    HeapFree(GetProcessHeap(), 0, device->swapchains);
+    device->swapchains = NULL;
+    device->swapchain_count = 0;
 
-    for (i = 0; i < This->palette_count; ++i)
-        HeapFree(GetProcessHeap(), 0, This->palettes[i]);
-    HeapFree(GetProcessHeap(), 0, This->palettes);
-    This->palettes = NULL;
-    This->palette_count = 0;
+    for (i = 0; i < device->palette_count; ++i)
+        HeapFree(GetProcessHeap(), 0, device->palettes[i]);
+    HeapFree(GetProcessHeap(), 0, device->palettes);
+    device->palettes = NULL;
+    device->palette_count = 0;
 
-    HeapFree(GetProcessHeap(), 0, This->render_targets);
-    This->render_targets = NULL;
+    HeapFree(GetProcessHeap(), 0, device->render_targets);
+    device->render_targets = NULL;
 
-    This->d3d_initialized = FALSE;
+    device->d3d_initialized = FALSE;
 
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_uninit_gdi(IWineD3DDevice *iface)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     unsigned int i;
@@ -1586,15 +1570,17 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface)
  *
  * There is no way to deactivate thread safety once it is enabled.
  */
-static void WINAPI IWineD3DDeviceImpl_SetMultithreaded(IWineD3DDevice *iface) {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
+void CDECL wined3d_device_set_multithreaded(struct wined3d_device *device)
+{
+    TRACE("device %p.\n", device);
 
-    /*For now just store the flag(needed in case of ddraw) */
-    This->createParms.BehaviorFlags |= WINED3DCREATE_MULTITHREADED;
+    /* For now just store the flag (needed in case of ddraw). */
+    device->createParms.BehaviorFlags |= WINED3DCREATE_MULTITHREADED;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain,
-        const WINED3DDISPLAYMODE* pMode) {
+HRESULT CDECL wined3d_device_set_display_mode(IWineD3DDevice *iface, UINT iSwapChain,
+        const WINED3DDISPLAYMODE* pMode)
+{
     DEVMODEW devmode;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     const struct wined3d_format *format = wined3d_get_format(&This->adapter->gl_info, pMode->Format);
@@ -1652,7 +1638,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, U
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice *iface, struct wined3d **wined3d)
+HRESULT CDECL wined3d_device_get_wined3d(IWineD3DDevice *iface, struct wined3d **wined3d)
 {
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
 
@@ -1666,7 +1652,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice *iface, stru
     return WINED3D_OK;
 }
 
-static UINT WINAPI IWineD3DDeviceImpl_GetAvailableTextureMem(IWineD3DDevice *iface) {
+UINT CDECL wined3d_device_get_available_texture_mem(IWineD3DDevice *iface)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
     TRACE("(%p) : simulating %dMB, returning %dMB left\n",  This,
@@ -1884,7 +1871,9 @@ HRESULT CDECL wined3d_device_get_transform(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, CONST WINED3DMATRIX* pMatrix) {
+HRESULT CDECL wined3d_device_multiply_transform(IWineD3DDevice *iface,
+        WINED3DTRANSFORMSTATETYPE State, const WINED3DMATRIX *pMatrix)
+{
     const WINED3DMATRIX *mat = NULL;
     WINED3DMATRIX temp;
 
@@ -3606,7 +3595,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn
 #undef copy_and_next
 
 /* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_process_vertices(IWineD3DDevice *iface,
         UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, struct wined3d_buffer *dst_buffer,
         struct wined3d_vertex_declaration *pVertexDecl, DWORD flags, DWORD DestFVF)
 {
@@ -3918,10 +3907,7 @@ HRESULT CDECL wined3d_device_get_texture(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-/*****
- * Get Back Buffer
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UINT swapchain_idx,
+HRESULT CDECL wined3d_device_get_back_buffer(IWineD3DDevice *iface, UINT swapchain_idx,
         UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, struct wined3d_surface **backbuffer)
 {
     struct wined3d_swapchain *swapchain;
@@ -3930,7 +3916,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UI
     TRACE("iface %p, swapchain_idx %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
             iface, swapchain_idx, backbuffer_idx, backbuffer_type, backbuffer);
 
-    hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+    hr = wined3d_device_get_swapchain(iface, swapchain_idx, &swapchain);
     if (FAILED(hr))
     {
         WARN("Failed to get swapchain %u, hr %#x.\n", swapchain_idx, hr);
@@ -3948,7 +3934,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UI
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDeviceCaps(IWineD3DDevice *iface, WINED3DCAPS *caps)
+HRESULT CDECL wined3d_device_get_device_caps(IWineD3DDevice *iface, WINED3DCAPS *caps)
 {
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
 
@@ -3957,7 +3943,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDeviceCaps(IWineD3DDevice *iface, WI
     return wined3d_get_device_caps(device->wined3d, device->adapter->ordinal, device->devType, caps);
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_display_mode(IWineD3DDevice *iface,
         UINT swapchain_idx, WINED3DDISPLAYMODE *mode)
 {
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
@@ -3968,7 +3954,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface,
 
     if (swapchain_idx)
     {
-        hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+        hr = wined3d_device_get_swapchain(iface, swapchain_idx, &swapchain);
         if (SUCCEEDED(hr))
         {
             hr = wined3d_swapchain_get_display_mode(swapchain, mode);
@@ -3994,11 +3980,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface,
     return hr;
 }
 
-/*****
- * Stateblock related functions
- *****/
-
-static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_begin_stateblock(IWineD3DDevice *iface)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct wined3d_stateblock *stateblock;
@@ -4020,7 +4002,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface)
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_end_stateblock(IWineD3DDevice *iface,
         struct wined3d_stateblock **stateblock)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -4046,10 +4028,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-/*****
- * Scene related functions
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_BeginScene(IWineD3DDevice *iface) {
+HRESULT CDECL wined3d_device_begin_scene(IWineD3DDevice *iface)
+{
     /* At the moment we have no need for any functionality at the beginning
        of a scene                                                          */
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -4063,7 +4043,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_BeginScene(IWineD3DDevice *iface) {
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_EndScene(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_end_scene(IWineD3DDevice *iface)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct wined3d_context *context;
@@ -4086,7 +4066,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndScene(IWineD3DDevice *iface)
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface, const RECT *src_rect,
+HRESULT CDECL wined3d_device_present(IWineD3DDevice *iface, const RECT *src_rect,
         const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
 {
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
@@ -4106,7 +4086,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface, const RE
 }
 
 /* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD rect_count,
+HRESULT CDECL wined3d_device_clear(IWineD3DDevice *iface, DWORD rect_count,
         const RECT *rects, DWORD flags, WINED3DCOLOR color, float depth, DWORD stencil)
 {
     const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
@@ -4143,11 +4123,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD rect
             &draw_rect, flags, &c, depth, stencil);
 }
 
-/*****
- * Drawing functions
- *****/
-
-static void WINAPI IWineD3DDeviceImpl_SetPrimitiveType(IWineD3DDevice *iface,
+void CDECL wined3d_device_set_primitive_type(IWineD3DDevice *iface,
         WINED3DPRIMITIVETYPE primitive_type)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -4158,7 +4134,7 @@ static void WINAPI IWineD3DDeviceImpl_SetPrimitiveType(IWineD3DDevice *iface,
     This->updateStateBlock->state.gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
 }
 
-static void WINAPI IWineD3DDeviceImpl_GetPrimitiveType(IWineD3DDevice *iface,
+void CDECL wined3d_device_get_primitive_type(IWineD3DDevice *iface,
         WINED3DPRIMITIVETYPE *primitive_type)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -4170,7 +4146,7 @@ static void WINAPI IWineD3DDeviceImpl_GetPrimitiveType(IWineD3DDevice *iface,
     TRACE("Returning %s\n", debug_d3dprimitivetype(*primitive_type));
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UINT StartVertex, UINT vertex_count)
+HRESULT CDECL wined3d_device_draw_primitive(IWineD3DDevice *iface, UINT StartVertex, UINT vertex_count)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
@@ -4199,7 +4175,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UI
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface, UINT startIndex, UINT index_count)
+HRESULT CDECL wined3d_device_draw_indexed_primitive(IWineD3DDevice *iface, UINT startIndex, UINT index_count)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct wined3d_buffer *index_buffer;
@@ -4249,7 +4225,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, UINT vertex_count,
+HRESULT CDECL wined3d_device_draw_primitive_up(IWineD3DDevice *iface, UINT vertex_count,
         const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -4291,7 +4267,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_draw_indexed_primitive_up(IWineD3DDevice *iface,
         UINT index_count, const void *pIndexData, enum wined3d_format_id IndexDataFormat,
         const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
 {
@@ -4349,7 +4325,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_draw_primitive_strided(IWineD3DDevice *iface,
         UINT vertex_count, const WineDirect3DVertexStridedData *DrawPrimStrideData)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
@@ -4367,7 +4343,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *if
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_draw_indexed_primitive_strided(IWineD3DDevice *iface,
         UINT vertex_count, const WineDirect3DVertexStridedData *DrawPrimStrideData,
         UINT NumVertices, const void *pIndexData, enum wined3d_format_id IndexDataFormat)
 {
@@ -4421,7 +4397,7 @@ static HRESULT IWineD3DDeviceImpl_UpdateVolume(IWineD3DDevice *iface,
     return hr;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_update_texture(IWineD3DDevice *iface,
         struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture)
 {
     unsigned int level_count, i;
@@ -4474,7 +4450,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
             {
                 src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, i));
                 dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
-                hr = IWineD3DDevice_UpdateSurface(iface, src_surface, NULL, dst_surface, NULL);
+                hr = wined3d_device_update_surface(iface, src_surface, NULL, dst_surface, NULL);
                 if (FAILED(hr))
                 {
                     WARN("IWineD3DDevice_UpdateSurface failed, hr %#x.\n", hr);
@@ -4493,7 +4469,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
             {
                 src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, i));
                 dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
-                hr = IWineD3DDevice_UpdateSurface(iface, src_surface, NULL, dst_surface, NULL);
+                hr = wined3d_device_update_surface(iface, src_surface, NULL, dst_surface, NULL);
                 if (FAILED(hr))
                 {
                     WARN("IWineD3DDevice_UpdateSurface failed, hr %#x.\n", hr);
@@ -4527,7 +4503,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_front_buffer_data(IWineD3DDevice *iface,
         UINT swapchain_idx, struct wined3d_surface *dst_surface)
 {
     struct wined3d_swapchain *swapchain;
@@ -4535,7 +4511,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *ifac
 
     TRACE("iface %p, swapchain_idx %u, dst_surface %p.\n", iface, swapchain_idx, dst_surface);
 
-    hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+    hr = wined3d_device_get_swapchain(iface, swapchain_idx, &swapchain);
     if (FAILED(hr)) return hr;
 
     hr = wined3d_swapchain_get_front_buffer_data(swapchain, dst_surface);
@@ -4544,7 +4520,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *ifac
     return hr;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD *pNumPasses)
+HRESULT CDECL wined3d_device_validate_device(IWineD3DDevice *iface, DWORD *pNumPasses)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     const struct wined3d_state *state = &This->stateBlock->state;
@@ -4779,7 +4755,7 @@ BOOL CDECL wined3d_device_get_software_vertex_processing(IWineD3DDevice *iface)
     return device->softwareVertexProcessing;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_raster_status(IWineD3DDevice *iface,
         UINT swapchain_idx, WINED3DRASTER_STATUS *raster_status)
 {
     struct wined3d_swapchain *swapchain;
@@ -4788,7 +4764,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface,
     TRACE("iface %p, swapchain_idx %u, raster_status %p.\n",
             iface, swapchain_idx, raster_status);
 
-    hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+    hr = wined3d_device_get_swapchain(iface, swapchain_idx, &swapchain);
     if (FAILED(hr))
     {
         WARN("Failed to get swapchain %u, hr %#x.\n", swapchain_idx, hr);
@@ -4839,7 +4815,7 @@ float CDECL wined3d_device_get_npatch_mode(IWineD3DDevice *iface)
     return 0.0f;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_update_surface(IWineD3DDevice *iface,
         struct wined3d_surface *src_surface, const RECT *src_rect,
         struct wined3d_surface *dst_surface, const POINT *dst_point)
 {
@@ -4978,7 +4954,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UINT Handle, CONST float* pNumSegs, CONST WINED3DRECTPATCH_INFO* pRectPatchInfo) {
+HRESULT CDECL wined3d_device_draw_rect_patch(IWineD3DDevice *iface, UINT Handle,
+        const float *pNumSegs, const WINED3DRECTPATCH_INFO *pRectPatchInfo)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct WineD3DRectPatch *patch;
     GLenum old_primitive_type;
@@ -5054,7 +5032,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UI
     This->currentPatch = patch;
     old_primitive_type = This->stateBlock->state.gl_primitive_type;
     This->stateBlock->state.gl_primitive_type = GL_TRIANGLES;
-    IWineD3DDevice_DrawPrimitiveStrided(iface, patch->numSegs[0] * patch->numSegs[1] * 2 * 3, &patch->strided);
+    wined3d_device_draw_primitive_strided(iface, patch->numSegs[0] * patch->numSegs[1] * 2 * 3, &patch->strided);
     This->stateBlock->state.gl_primitive_type = old_primitive_type;
     This->currentPatch = NULL;
 
@@ -5066,8 +5044,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UI
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawTriPatch(IWineD3DDevice *iface,
-        UINT handle, const float *segment_count, const WINED3DTRIPATCH_INFO *patch_info)
+HRESULT CDECL wined3d_device_draw_tri_patch(IWineD3DDevice *iface, UINT handle,
+        const float *segment_count, const WINED3DTRIPATCH_INFO *patch_info)
 {
     FIXME("iface %p, handle %#x, segment_count %p, patch_info %p stub!\n",
             iface, handle, segment_count, patch_info);
@@ -5075,7 +5053,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawTriPatch(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DeletePatch(IWineD3DDevice *iface, UINT Handle) {
+HRESULT CDECL wined3d_device_delete_patch(IWineD3DDevice *iface, UINT Handle)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     int i;
     struct WineD3DRectPatch *patch;
@@ -5100,7 +5079,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DeletePatch(IWineD3DDevice *iface, UINT
 }
 
 /* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_color_fill(IWineD3DDevice *iface,
         struct wined3d_surface *surface, const RECT *rect, const WINED3DCOLORVALUE *color)
 {
     TRACE("iface %p, surface %p, rect %s, color {%.8e, %.8e, %.8e, %.8e}.\n",
@@ -5117,7 +5096,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface,
 }
 
 /* Do not call while under the GL lock. */
-static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *iface,
+void CDECL wined3d_device_clear_rendertarget_view(IWineD3DDevice *iface,
         struct wined3d_rendertarget_view *rendertarget_view, const WINED3DCOLORVALUE *color)
 {
     struct wined3d_resource *resource;
@@ -5294,7 +5273,7 @@ HRESULT CDECL wined3d_device_set_depth_stencil(IWineD3DDevice *iface, struct win
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_set_cursor_properties(IWineD3DDevice *iface,
         UINT XHotSpot, UINT YHotSpot, struct wined3d_surface *cursor_image)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -5454,7 +5433,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice *ifa
     return WINED3D_OK;
 }
 
-static void WINAPI IWineD3DDeviceImpl_SetCursorPosition(IWineD3DDevice *iface,
+void CDECL wined3d_device_set_cursor_position(IWineD3DDevice *iface,
         int XScreenSpace, int YScreenSpace, DWORD flags)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
@@ -5466,7 +5445,8 @@ static void WINAPI IWineD3DDeviceImpl_SetCursorPosition(IWineD3DDevice *iface,
     This->yScreenSpace = YScreenSpace;
 }
 
-static BOOL     WINAPI  IWineD3DDeviceImpl_ShowCursor(IWineD3DDevice* iface, BOOL bShow) {
+BOOL CDECL wined3d_device_show_cursor(IWineD3DDevice* iface, BOOL bShow)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     BOOL oldVisible = This->bCursorVisible;
     POINT pt;
@@ -5511,11 +5491,11 @@ static HRESULT WINAPI evict_managed_resource(struct wined3d_resource *resource,
     return S_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_evict_managed_resources(IWineD3DDevice *iface)
 {
     TRACE("iface %p.\n", iface);
 
-    IWineD3DDevice_EnumResources(iface, evict_managed_resource, NULL);
+    wined3d_device_enum_resources(iface, evict_managed_resource, NULL);
     /* Invalidate stream sources, the buffer(s) may have been evicted. */
     IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)iface, STATE_STREAMSRC);
 
@@ -5622,7 +5602,7 @@ static void delete_opengl_contexts(IWineD3DDeviceImpl *device, struct wined3d_sw
     context = context_acquire(device, NULL);
     gl_info = context->gl_info;
 
-    IWineD3DDevice_EnumResources((IWineD3DDevice *)device, device_unload_resource, NULL);
+    wined3d_device_enum_resources(device, device_unload_resource, NULL);
     LIST_FOR_EACH_ENTRY(shader, &device->shaders, struct wined3d_shader, shader_list_entry)
     {
         device->shader_backend->shader_destroy(shader);
@@ -5724,7 +5704,7 @@ err:
 }
 
 /* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_reset(IWineD3DDevice *iface,
         WINED3DPRESENT_PARAMETERS *pPresentationParameters)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
@@ -5734,7 +5714,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
     WINED3DDISPLAYMODE mode;
     TRACE("(%p)\n", This);
 
-    hr = IWineD3DDevice_GetSwapChain(iface, 0, &swapchain);
+    hr = wined3d_device_get_swapchain(iface, 0, &swapchain);
     if (FAILED(hr))
     {
         ERR("Failed to get the first implicit swapchain\n");
@@ -5886,15 +5866,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
     if (!pPresentationParameters->Windowed != !swapchain->presentParms.Windowed
             || DisplayModeChanged)
     {
-        IWineD3DDevice_SetDisplayMode(iface, 0, &mode);
+        wined3d_device_set_display_mode(iface, 0, &mode);
 
         if (!pPresentationParameters->Windowed)
         {
             if (swapchain->presentParms.Windowed)
             {
                 HWND focus_window = This->createParms.hFocusWindow;
-                if (!focus_window) focus_window = pPresentationParameters->hDeviceWindow;
-                if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(iface, focus_window)))
+                if (!focus_window)
+                    focus_window = pPresentationParameters->hDeviceWindow;
+                if (FAILED(hr = wined3d_device_acquire_focus_window(iface, focus_window)))
                 {
                     ERR("Failed to acquire focus window, hr %#x.\n", hr);
                     wined3d_swapchain_decref(swapchain);
@@ -5902,7 +5883,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
                 }
 
                 /* switch from windowed to fs */
-                IWineD3DDevice_SetupFullscreenWindow(iface, swapchain->device_window,
+                wined3d_device_setup_fullscreen_window(iface, swapchain->device_window,
                         pPresentationParameters->BackBufferWidth,
                         pPresentationParameters->BackBufferHeight);
             }
@@ -5917,8 +5898,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
         else if (!swapchain->presentParms.Windowed)
         {
             /* Fullscreen -> windowed switch */
-            IWineD3DDevice_RestoreFullscreenWindow(iface, swapchain->device_window);
-            IWineD3DDevice_ReleaseFocusWindow(iface);
+            wined3d_device_restore_fullscreen_window(iface, swapchain->device_window);
+            wined3d_device_release_focus_window(iface);
         }
         swapchain->presentParms.Windowed = pPresentationParameters->Windowed;
     }
@@ -5931,7 +5912,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
          */
         This->style = 0;
         This->exStyle = 0;
-        IWineD3DDevice_SetupFullscreenWindow(iface, swapchain->device_window,
+        wined3d_device_setup_fullscreen_window(iface, swapchain->device_window,
                 pPresentationParameters->BackBufferWidth,
                 pPresentationParameters->BackBufferHeight);
         This->style = style;
@@ -5982,7 +5963,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
     return hr;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_SetDialogBoxMode(IWineD3DDevice *iface, BOOL enable_dialogs)
+HRESULT CDECL wined3d_device_set_dialog_box_mode(IWineD3DDevice *iface, BOOL enable_dialogs)
 {
     TRACE("iface %p, enable_dialogs %#x.\n", iface, enable_dialogs);
 
@@ -5992,7 +5973,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDialogBoxMode(IWineD3DDevice *iface,
 }
 
 
-static HRESULT  WINAPI  IWineD3DDeviceImpl_GetCreationParameters(IWineD3DDevice *iface, WINED3DDEVICE_CREATION_PARAMETERS *pParameters) {
+HRESULT CDECL wined3d_device_get_creation_parameters(IWineD3DDevice *iface,
+        WINED3DDEVICE_CREATION_PARAMETERS *pParameters)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     TRACE("(%p) : pParameters %p\n", This, pParameters);
 
@@ -6008,7 +5991,7 @@ void CDECL wined3d_device_set_gamma_ramp(IWineD3DDevice *iface,
     TRACE("iface %p, swapchain_idx %u, flags %#x, ramp %p.\n",
             iface, swapchain_idx, flags, ramp);
 
-    if (SUCCEEDED(IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain)))
+    if (SUCCEEDED(wined3d_device_get_swapchain(iface, swapchain_idx, &swapchain)))
     {
         wined3d_swapchain_set_gamma_ramp(swapchain, flags, ramp);
         wined3d_swapchain_decref(swapchain);
@@ -6022,28 +6005,28 @@ void CDECL wined3d_device_get_gamma_ramp(IWineD3DDevice *iface, UINT swapchain_i
     TRACE("iface %p, swapchain_idx %u, ramp %p.\n",
             iface, swapchain_idx, ramp);
 
-    if (SUCCEEDED(IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain)))
+    if (SUCCEEDED(wined3d_device_get_swapchain(iface, swapchain_idx, &swapchain)))
     {
         wined3d_swapchain_get_gamma_ramp(swapchain, ramp);
         wined3d_swapchain_decref(swapchain);
     }
 }
 
-void device_resource_add(struct IWineD3DDeviceImpl *device, struct wined3d_resource *resource)
+void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource)
 {
     TRACE("device %p, resource %p.\n", device, resource);
 
     list_add_head(&device->resources, &resource->resource_list_entry);
 }
 
-static void device_resource_remove(struct IWineD3DDeviceImpl *device, struct wined3d_resource *resource)
+static void device_resource_remove(struct wined3d_device *device, struct wined3d_resource *resource)
 {
     TRACE("device %p, resource %p.\n", device, resource);
 
     list_remove(&resource->resource_list_entry);
 }
 
-void device_resource_released(struct IWineD3DDeviceImpl *device, struct wined3d_resource *resource)
+void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource)
 {
     WINED3DRESOURCETYPE type = resource->resourceType;
     unsigned int i;
@@ -6151,7 +6134,7 @@ void device_resource_released(struct IWineD3DDeviceImpl *device, struct wined3d_
     TRACE("Resource released.\n");
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_EnumResources(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_enum_resources(IWineD3DDevice *iface,
         D3DCB_ENUMRESOURCES callback, void *data)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
@@ -6172,7 +6155,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EnumResources(IWineD3DDevice *iface,
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_GetSurfaceFromDC(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_surface_from_dc(IWineD3DDevice *iface,
         HDC dc, struct wined3d_surface **surface)
 {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -6196,76 +6179,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetSurfaceFromDC(IWineD3DDevice *iface,
     return WINED3DERR_INVALIDCALL;
 }
 
-/**********************************************************
- * IWineD3DDevice VTbl follows
- **********************************************************/
-
-static const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
-{
-    /*** IUnknown methods ***/
-    IWineD3DDeviceImpl_QueryInterface,
-    IWineD3DDeviceImpl_AddRef,
-    IWineD3DDeviceImpl_Release,
-    /*** IWineD3DDevice methods ***/
-    /*** Odd functions **/
-    IWineD3DDeviceImpl_Init3D,
-    IWineD3DDeviceImpl_InitGDI,
-    IWineD3DDeviceImpl_Uninit3D,
-    IWineD3DDeviceImpl_UninitGDI,
-    IWineD3DDeviceImpl_SetMultithreaded,
-    IWineD3DDeviceImpl_EvictManagedResources,
-    IWineD3DDeviceImpl_GetAvailableTextureMem,
-    IWineD3DDeviceImpl_GetBackBuffer,
-    IWineD3DDeviceImpl_GetCreationParameters,
-    IWineD3DDeviceImpl_GetDeviceCaps,
-    IWineD3DDeviceImpl_GetDirect3D,
-    IWineD3DDeviceImpl_GetDisplayMode,
-    IWineD3DDeviceImpl_SetDisplayMode,
-    IWineD3DDeviceImpl_GetNumberOfSwapChains,
-    IWineD3DDeviceImpl_GetRasterStatus,
-    IWineD3DDeviceImpl_GetSwapChain,
-    IWineD3DDeviceImpl_Reset,
-    IWineD3DDeviceImpl_SetDialogBoxMode,
-    IWineD3DDeviceImpl_SetCursorProperties,
-    IWineD3DDeviceImpl_SetCursorPosition,
-    IWineD3DDeviceImpl_ShowCursor,
-    IWineD3DDeviceImpl_MultiplyTransform,
-    IWineD3DDeviceImpl_ValidateDevice,
-    IWineD3DDeviceImpl_ProcessVertices,
-    /*** State block ***/
-    IWineD3DDeviceImpl_BeginStateBlock,
-    IWineD3DDeviceImpl_EndStateBlock,
-    /*** Scene management ***/
-    IWineD3DDeviceImpl_BeginScene,
-    IWineD3DDeviceImpl_EndScene,
-    IWineD3DDeviceImpl_Present,
-    IWineD3DDeviceImpl_Clear,
-    IWineD3DDeviceImpl_ClearRendertargetView,
-    /*** Drawing ***/
-    IWineD3DDeviceImpl_SetPrimitiveType,
-    IWineD3DDeviceImpl_GetPrimitiveType,
-    IWineD3DDeviceImpl_DrawPrimitive,
-    IWineD3DDeviceImpl_DrawIndexedPrimitive,
-    IWineD3DDeviceImpl_DrawPrimitiveUP,
-    IWineD3DDeviceImpl_DrawIndexedPrimitiveUP,
-    IWineD3DDeviceImpl_DrawPrimitiveStrided,
-    IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided,
-    IWineD3DDeviceImpl_DrawRectPatch,
-    IWineD3DDeviceImpl_DrawTriPatch,
-    IWineD3DDeviceImpl_DeletePatch,
-    IWineD3DDeviceImpl_ColorFill,
-    IWineD3DDeviceImpl_UpdateTexture,
-    IWineD3DDeviceImpl_UpdateSurface,
-    IWineD3DDeviceImpl_GetFrontBufferData,
-    /*** object tracking ***/
-    IWineD3DDeviceImpl_EnumResources,
-    IWineD3DDeviceImpl_GetSurfaceFromDC,
-    IWineD3DDeviceImpl_AcquireFocusWindow,
-    IWineD3DDeviceImpl_ReleaseFocusWindow,
-    IWineD3DDeviceImpl_SetupFullscreenWindow,
-    IWineD3DDeviceImpl_RestoreFullscreenWindow,
-};
-
 HRESULT device_init(IWineD3DDeviceImpl *device, struct wined3d *wined3d,
         UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
         IWineD3DDeviceParent *device_parent)
@@ -6278,7 +6191,6 @@ HRESULT device_init(IWineD3DDeviceImpl *device, struct wined3d *wined3d,
     unsigned int i;
     HRESULT hr;
 
-    device->lpVtbl = &IWineD3DDevice_Vtbl;
     device->ref = 1;
     device->wined3d = wined3d;
     wined3d_incref(device->wined3d);
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 583e56f..a1b7f5a 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -112,7 +112,7 @@ HRESULT resource_init(struct wined3d_resource *resource, IWineD3DDeviceImpl *dev
     /* Check that we have enough video ram left */
     if (pool == WINED3DPOOL_DEFAULT)
     {
-        if (size > IWineD3DDevice_GetAvailableTextureMem((IWineD3DDevice *)device))
+        if (size > wined3d_device_get_available_texture_mem(device))
         {
             ERR("Out of adapter memory\n");
             HeapFree(GetProcessHeap(), 0, resource->heapMemory);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index d979ed9..36958e3 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1287,7 +1287,7 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
     }
 
     /* check the return values, because the GetBackBuffer call isn't valid for ddraw */
-    hr = IWineD3DDevice_GetSwapChain((IWineD3DDevice *)device, 0, &swapchain);
+    hr = wined3d_device_get_swapchain(device, 0, &swapchain);
     if (SUCCEEDED(hr) && swapchain)
     {
         hr = wined3d_swapchain_get_back_buffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index ba12379..051754b 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -78,7 +78,7 @@ static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
         mode.Height = swapchain->orig_height;
         mode.RefreshRate = 0;
         mode.Format = swapchain->orig_fmt;
-        IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)swapchain->device, 0, &mode);
+        wined3d_device_set_display_mode(swapchain->device, 0, &mode);
     }
 
     if (swapchain->backup_dc)
@@ -571,7 +571,7 @@ static HRESULT swapchain_gl_present(struct wined3d_swapchain *swapchain, const R
     {
         TRACE("Clearing the color buffer with cyan color\n");
 
-        IWineD3DDevice_Clear((IWineD3DDevice *)swapchain->device, 0, NULL,
+        wined3d_device_clear(swapchain->device, 0, NULL,
                 WINED3DCLEAR_TARGET, 0xff00ffff, 1.0f, 0);
     }
 
@@ -927,7 +927,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTY
         mode.Format = present_parameters->BackBufferFormat;
         mode.RefreshRate = present_parameters->FullScreen_RefreshRateInHz;
 
-        hr = IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)device, 0, &mode);
+        hr = wined3d_device_set_display_mode(device, 0, &mode);
         if (FAILED(hr))
         {
             WARN("Failed to set display mode, hr %#x.\n", hr);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 4185894..45c9aaf 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -44,12 +44,38 @@
 @ cdecl wined3d_clipper_set_clip_list(ptr ptr long)
 @ cdecl wined3d_clipper_set_window(ptr long ptr)
 
+@ cdecl wined3d_device_acquire_focus_window(ptr ptr)
+@ cdecl wined3d_device_begin_scene(ptr)
+@ cdecl wined3d_device_begin_stateblock(ptr)
+@ cdecl wined3d_device_clear(ptr long ptr long long float long)
+@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr)
+@ cdecl wined3d_device_color_fill(ptr ptr ptr ptr)
 @ cdecl wined3d_device_create(ptr long long ptr long ptr ptr)
+@ cdecl wined3d_device_decref(ptr)
+@ cdecl wined3d_device_delete_patch(ptr long)
+@ cdecl wined3d_device_draw_indexed_primitive(ptr long long)
+@ cdecl wined3d_device_draw_indexed_primitive_strided(ptr long ptr long ptr long)
+@ cdecl wined3d_device_draw_indexed_primitive_up(ptr long ptr long ptr long)
+@ cdecl wined3d_device_draw_primitive(ptr long long)
+@ cdecl wined3d_device_draw_primitive_strided(ptr long ptr)
+@ cdecl wined3d_device_draw_primitive_up(ptr long ptr long)
+@ cdecl wined3d_device_draw_rect_patch(ptr long ptr ptr)
+@ cdecl wined3d_device_draw_tri_patch(ptr long ptr ptr)
+@ cdecl wined3d_device_end_scene(ptr)
+@ cdecl wined3d_device_end_stateblock(ptr ptr)
+@ cdecl wined3d_device_enum_resources(ptr ptr ptr)
+@ cdecl wined3d_device_evict_managed_resources(ptr)
+@ cdecl wined3d_device_get_available_texture_mem(ptr)
+@ cdecl wined3d_device_get_back_buffer(ptr long long long ptr)
 @ cdecl wined3d_device_get_base_vertex_index(ptr)
 @ cdecl wined3d_device_get_clip_plane(ptr long ptr)
 @ cdecl wined3d_device_get_clip_status(ptr ptr)
+@ cdecl wined3d_device_get_creation_parameters(ptr ptr)
 @ cdecl wined3d_device_get_current_texture_palette(ptr ptr)
 @ cdecl wined3d_device_get_depth_stencil(ptr ptr)
+@ cdecl wined3d_device_get_device_caps(ptr ptr)
+@ cdecl wined3d_device_get_display_mode(ptr long ptr)
+@ cdecl wined3d_device_get_front_buffer_data(ptr long ptr)
 @ cdecl wined3d_device_get_gamma_ramp(ptr long ptr)
 @ cdecl wined3d_device_get_index_buffer(ptr ptr)
 @ cdecl wined3d_device_get_light(ptr long ptr)
@@ -58,9 +84,11 @@
 @ cdecl wined3d_device_get_npatch_mode(ptr)
 @ cdecl wined3d_device_get_palette_entries(ptr long ptr)
 @ cdecl wined3d_device_get_pixel_shader(ptr)
+@ cdecl wined3d_device_get_primitive_type(ptr ptr)
 @ cdecl wined3d_device_get_ps_consts_b(ptr long ptr long)
 @ cdecl wined3d_device_get_ps_consts_f(ptr long ptr long)
 @ cdecl wined3d_device_get_ps_consts_i(ptr long ptr long)
+@ cdecl wined3d_device_get_raster_status(ptr long ptr)
 @ cdecl wined3d_device_get_render_state(ptr long ptr)
 @ cdecl wined3d_device_get_render_target(ptr long ptr)
 @ cdecl wined3d_device_get_sampler_state(ptr long long ptr)
@@ -68,6 +96,9 @@
 @ cdecl wined3d_device_get_software_vertex_processing(ptr)
 @ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
 @ cdecl wined3d_device_get_stream_source_freq(ptr long ptr)
+@ cdecl wined3d_device_get_surface_from_dc(ptr ptr ptr)
+@ cdecl wined3d_device_get_swapchain(ptr long ptr)
+@ cdecl wined3d_device_get_swapchain_count(ptr)
 @ cdecl wined3d_device_get_texture(ptr long ptr)
 @ cdecl wined3d_device_get_texture_stage_state(ptr long long ptr)
 @ cdecl wined3d_device_get_transform(ptr long ptr)
@@ -77,19 +108,35 @@
 @ cdecl wined3d_device_get_vs_consts_b(ptr long ptr long)
 @ cdecl wined3d_device_get_vs_consts_f(ptr long ptr long)
 @ cdecl wined3d_device_get_vs_consts_i(ptr long ptr long)
+@ cdecl wined3d_device_get_wined3d(ptr ptr)
+@ cdecl wined3d_device_incref(ptr)
+@ cdecl wined3d_device_init_3d(ptr ptr)
+@ cdecl wined3d_device_init_gdi(ptr ptr)
+@ cdecl wined3d_device_multiply_transform(ptr long ptr)
+@ cdecl wined3d_device_present(ptr ptr ptr ptr ptr)
+@ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
+@ cdecl wined3d_device_release_focus_window(ptr)
+@ cdecl wined3d_device_reset(ptr ptr)
+@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr)
 @ cdecl wined3d_device_set_base_vertex_index(ptr long)
 @ cdecl wined3d_device_set_clip_plane(ptr long ptr)
 @ cdecl wined3d_device_set_clip_status(ptr ptr)
 @ cdecl wined3d_device_set_current_texture_palette(ptr long)
+@ cdecl wined3d_device_set_cursor_position(ptr long long long)
+@ cdecl wined3d_device_set_cursor_properties(ptr long long ptr)
 @ cdecl wined3d_device_set_depth_stencil(ptr ptr)
+@ cdecl wined3d_device_set_dialog_box_mode(ptr long)
+@ cdecl wined3d_device_set_display_mode(ptr long ptr)
 @ cdecl wined3d_device_set_gamma_ramp(ptr long long ptr)
 @ cdecl wined3d_device_set_index_buffer(ptr ptr long)
 @ cdecl wined3d_device_set_light(ptr long ptr)
 @ cdecl wined3d_device_set_light_enable(ptr long long)
 @ cdecl wined3d_device_set_material(ptr ptr)
+@ cdecl wined3d_device_set_multithreaded(ptr)
 @ cdecl wined3d_device_set_npatch_mode(ptr float)
 @ cdecl wined3d_device_set_palette_entries(ptr long ptr)
 @ cdecl wined3d_device_set_pixel_shader(ptr ptr)
+@ cdecl wined3d_device_set_primitive_type(ptr long)
 @ cdecl wined3d_device_set_ps_consts_b(ptr long ptr long)
 @ cdecl wined3d_device_set_ps_consts_f(ptr long ptr long)
 @ cdecl wined3d_device_set_ps_consts_i(ptr long ptr long)
@@ -109,6 +156,13 @@
 @ cdecl wined3d_device_set_vs_consts_b(ptr long ptr long)
 @ cdecl wined3d_device_set_vs_consts_f(ptr long ptr long)
 @ cdecl wined3d_device_set_vs_consts_i(ptr long ptr long)
+@ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long)
+@ cdecl wined3d_device_show_cursor(ptr long)
+@ cdecl wined3d_device_uninit_3d(ptr)
+@ cdecl wined3d_device_uninit_gdi(ptr)
+@ cdecl wined3d_device_update_surface(ptr ptr ptr ptr ptr)
+@ cdecl wined3d_device_update_texture(ptr ptr ptr)
+@ cdecl wined3d_device_validate_device(ptr ptr)
 
 @ cdecl wined3d_palette_create(ptr long ptr ptr ptr)
 @ cdecl wined3d_palette_decref(ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c599af0..c6cb161 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -52,7 +52,8 @@
 #define WINED3D_QUIRK_NV_CLIP_BROKEN            0x00000010
 #define WINED3D_QUIRK_FBO_TEX_UPDATE            0x00000020
 
-typedef struct IWineD3DDeviceImpl     IWineD3DDeviceImpl;
+typedef struct wined3d_device IWineD3DDeviceImpl;
+typedef struct wined3d_device IWineD3DDevice;
 
 /* Texture format fixups */
 
@@ -1225,9 +1226,9 @@ void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPE
 struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
 DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
 void context_release(struct wined3d_context *context) DECLSPEC_HIDDEN;
-void context_resource_released(struct IWineD3DDeviceImpl *device,
+void context_resource_released(struct wined3d_device *device,
         struct wined3d_resource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
-void context_resource_unloaded(struct IWineD3DDeviceImpl *device,
+void context_resource_unloaded(struct wined3d_device *device,
         struct wined3d_resource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
 BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN;
 void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer) DECLSPEC_HIDDEN;
@@ -1629,7 +1630,7 @@ struct wined3d
 };
 
 HRESULT wined3d_init(struct wined3d *wined3d, UINT version, void *parent) DECLSPEC_HIDDEN;
-BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+BOOL wined3d_register_window(HWND window, struct wined3d_device *device) DECLSPEC_HIDDEN;
 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
 
 /*****************************************************************************
@@ -1640,11 +1641,9 @@ void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
 /* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
 #define WINED3DCREATE_MULTITHREADED 0x00000004
 
-struct IWineD3DDeviceImpl
+struct wined3d_device
 {
-    /* IUnknown fields      */
-    const IWineD3DDeviceVtbl *lpVtbl;
-    LONG                    ref;     /* Note: Ref counting not required */
+    LONG ref;
 
     /* WineD3D Information  */
     IWineD3DDeviceParent   *device_parent;
@@ -1782,8 +1781,8 @@ HRESULT device_init(IWineD3DDeviceImpl *device, struct wined3d *wined3d,
 void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
 LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, BOOL unicode,
         UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
-void device_resource_add(struct IWineD3DDeviceImpl *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
-void device_resource_released(struct IWineD3DDeviceImpl *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
 void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
         BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
 void device_switch_onscreen_ds(IWineD3DDeviceImpl *device, struct wined3d_context *context,
@@ -2631,7 +2630,7 @@ struct wined3d_shader
     struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
 
     /* Pointer to the parent device */
-    struct IWineD3DDeviceImpl *device;
+    struct wined3d_device *device;
     struct list shader_list_entry;
 
     union
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 79d4b3a..ddc9a59 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -2085,14 +2085,14 @@ struct wined3d_parent_ops
     void (__stdcall *wined3d_object_destroyed)(void *parent);
 };
 
-interface IWineD3DDevice;
 struct wined3d;
 struct wined3d_buffer;
 struct wined3d_clipper;
+struct wined3d_device;
 struct wined3d_palette;
 struct wined3d_query;
-struct wined3d_resource;
 struct wined3d_rendertarget_view;
+struct wined3d_resource;
 struct wined3d_shader;
 struct wined3d_stateblock;
 struct wined3d_surface;
@@ -2109,7 +2109,7 @@ struct wined3d_volume;
 interface IWineD3DDeviceParent : IUnknown
 {
     void WineD3DDeviceCreated(
-        [in] IWineD3DDevice *device
+        [in] struct wined3d_device *device
     );
 
     HRESULT CreateSurface(
@@ -2163,216 +2163,6 @@ interface IWineD3DDeviceParent : IUnknown
 }
 typedef HRESULT (__stdcall *D3DCB_ENUMRESOURCES)(struct wined3d_resource *resource, void *pData);
 
-[
-    object,
-    local,
-    uuid(6d10a2ce-09d0-4a53-a427-11388f9f8ca5)
-]
-interface IWineD3DDevice : IUnknown
-{
-    HRESULT Init3D(
-        [in] WINED3DPRESENT_PARAMETERS *present_parameters
-    );
-    HRESULT InitGDI(
-        [in] WINED3DPRESENT_PARAMETERS *present_parameters
-    );
-    HRESULT Uninit3D(
-    );
-    HRESULT UninitGDI(
-    );
-    void SetMultithreaded(
-    );
-    HRESULT EvictManagedResources(
-    );
-    UINT GetAvailableTextureMem(
-    );
-    HRESULT GetBackBuffer(
-        [in] UINT swapchain_idx,
-        [in] UINT backbuffer_idx,
-        [in] WINED3DBACKBUFFER_TYPE backbuffer_type,
-        [out] struct wined3d_surface **backbuffer
-    );
-    HRESULT GetCreationParameters(
-        [out] WINED3DDEVICE_CREATION_PARAMETERS *creation_parameters
-    );
-    HRESULT GetDeviceCaps(
-        [out] WINED3DCAPS *caps
-    );
-    HRESULT GetDirect3D(
-        [out] struct wined3d **d3d
-    );
-    HRESULT GetDisplayMode(
-        [in] UINT swapchain_idx,
-        [out] WINED3DDISPLAYMODE *mode
-    );
-    HRESULT SetDisplayMode(
-        [in] UINT swapchain_idx,
-        [in] const WINED3DDISPLAYMODE *mode
-    );
-    UINT GetNumberOfSwapChains(
-    );
-    HRESULT GetRasterStatus(
-        [in] UINT swapchain_idx,
-        [out] WINED3DRASTER_STATUS *raster_status
-    );
-    HRESULT GetSwapChain(
-        [in] UINT swapchain_idx,
-        [out] struct wined3d_swapchain **swapchain
-    );
-    HRESULT Reset(
-        [in] WINED3DPRESENT_PARAMETERS *present_parameters
-    );
-    HRESULT SetDialogBoxMode(
-        [in] BOOL enable_dialogs
-    );
-    HRESULT SetCursorProperties(
-        [in] UINT x_hotspot,
-        [in] UINT y_hotspot,
-        [in] struct wined3d_surface *cursor_surface
-    );
-    void SetCursorPosition(
-        [in] int x_screen_space,
-        [in] int y_screen_space,
-        [in] DWORD flags
-    );
-    BOOL ShowCursor(
-        [in] BOOL show
-    );
-    HRESULT MultiplyTransform(
-        [in] WINED3DTRANSFORMSTATETYPE state,
-        [in] const WINED3DMATRIX *matrix
-    );
-    HRESULT ValidateDevice(
-        [out] DWORD *num_passes
-    );
-    HRESULT ProcessVertices(
-        [in] UINT src_start_idx,
-        [in] UINT dst_idx,
-        [in] UINT vertex_count,
-        [in] struct wined3d_buffer *dst_buffer,
-        [in] struct wined3d_vertex_declaration *declaration,
-        [in] DWORD flags,
-        [in] DWORD DestFVF
-    );
-    HRESULT BeginStateBlock(
-    );
-    HRESULT EndStateBlock(
-        [out] struct wined3d_stateblock **stateblock
-    );
-    HRESULT BeginScene(
-    );
-    HRESULT EndScene(
-    );
-    HRESULT Present(
-        [in] const RECT *src_rect,
-        [in] const RECT *dst_rect,
-        [in] HWND dst_window_override,
-        [in] const RGNDATA *dirty_region
-    );
-    HRESULT Clear(
-        [in] DWORD rect_count,
-        [in] const RECT *rects,
-        [in] DWORD flags,
-        [in] WINED3DCOLOR color,
-        [in] float z,
-        [in] DWORD stencil
-    );
-    void ClearRendertargetView(
-        [in] struct wined3d_rendertarget_view *rendertarget_view,
-        [in] const WINED3DCOLORVALUE *color
-    );
-    void SetPrimitiveType(
-        [in] WINED3DPRIMITIVETYPE primitive_topology
-    );
-    void GetPrimitiveType(
-        [out] WINED3DPRIMITIVETYPE *primitive_topology
-    );
-    HRESULT DrawPrimitive(
-        [in] UINT start_vertex,
-        [in] UINT vertex_count
-    );
-    HRESULT DrawIndexedPrimitive(
-        [in] UINT start_idx,
-        [in] UINT index_count
-    );
-    HRESULT DrawPrimitiveUP(
-        [in] UINT vertex_count,
-        [in] const void *stream_data,
-        [in] UINT stream_stride
-    );
-    HRESULT DrawIndexedPrimitiveUP(
-        [in] UINT index_count,
-        [in] const void *index_data,
-        [in] enum wined3d_format_id index_data_format_id,
-        [in] const void *stream_data,
-        [in] UINT stream_stride
-    );
-    HRESULT DrawPrimitiveStrided(
-        [in] UINT vertex_count,
-        [in] const WineDirect3DVertexStridedData *strided_data
-    );
-    HRESULT DrawIndexedPrimitiveStrided(
-        [in] UINT index_count,
-        [in] const WineDirect3DVertexStridedData *strided_data,
-        [in] UINT vertex_count,
-        [in] const void *index_data,
-        [in] enum wined3d_format_id index_data_format_id
-    );
-    HRESULT DrawRectPatch(
-        [in] UINT handle,
-        [in] const float *num_segs,
-        [in] const WINED3DRECTPATCH_INFO *rect_patch_info
-    );
-    HRESULT DrawTriPatch(
-        [in] UINT handle,
-        [in] const float *num_segs,
-        [in] const WINED3DTRIPATCH_INFO *tri_patch_info
-    );
-    HRESULT DeletePatch(
-        [in] UINT handle
-    );
-    HRESULT ColorFill(
-        [in] struct wined3d_surface *surface,
-        [in] const RECT *rect,
-        [in] const WINED3DCOLORVALUE *color
-    );
-    HRESULT UpdateTexture(
-        [in] struct wined3d_texture *src_texture,
-        [in] struct wined3d_texture *dst_texture
-    );
-    HRESULT UpdateSurface(
-        [in] struct wined3d_surface *src_surface,
-        [in] const RECT *src_rect,
-        [in] struct wined3d_surface *dst_surface,
-        [in] const POINT *dst_point
-    );
-    HRESULT GetFrontBufferData(
-        [in] UINT swapchain_idx,
-        [in] struct wined3d_surface *dst_surface
-    );
-    HRESULT EnumResources(
-        [in] D3DCB_ENUMRESOURCES callback,
-        [in] void *data
-    );
-    HRESULT GetSurfaceFromDC(
-        [in] HDC dc,
-        [out] struct wined3d_surface **surface
-    );
-    HRESULT AcquireFocusWindow(
-        [in] HWND window
-    );
-    void ReleaseFocusWindow(
-    );
-    void SetupFullscreenWindow(
-        [in] HWND window,
-        [in] UINT w,
-        [in] UINT h
-    );
-    void RestoreFullscreenWindow(
-        [in] HWND window
-    );
-}
-
 void __stdcall wined3d_mutex_lock(void);
 void __stdcall wined3d_mutex_unlock(void);
 
@@ -2410,11 +2200,11 @@ void * __cdecl wined3d_get_parent(const struct wined3d *wined3d);
 ULONG __cdecl wined3d_incref(struct wined3d *wined3d);
 HRESULT __cdecl wined3d_register_software_device(struct wined3d *wined3d, void *init_function);
 
-HRESULT __cdecl wined3d_buffer_create(IWineD3DDevice *device, struct wined3d_buffer_desc *desc, const void *data,
+HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, struct wined3d_buffer_desc *desc,
+        const void *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
+HRESULT __cdecl wined3d_buffer_create_ib(struct wined3d_device *device, UINT length, DWORD usage, WINED3DPOOL pool,
         void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
-HRESULT __cdecl wined3d_buffer_create_ib(IWineD3DDevice *device, UINT length, DWORD usage, WINED3DPOOL pool,
-        void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
-HRESULT __cdecl wined3d_buffer_create_vb(IWineD3DDevice *device, UINT length, DWORD usage, WINED3DPOOL pool,
+HRESULT __cdecl wined3d_buffer_create_vb(struct wined3d_device *device, UINT length, DWORD usage, WINED3DPOOL pool,
         void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
 ULONG __cdecl wined3d_buffer_decref(struct wined3d_buffer *buffer);
 HRESULT __cdecl wined3d_buffer_free_private_data(struct wined3d_buffer *buffer, REFGUID guid);
@@ -2441,102 +2231,188 @@ HRESULT __cdecl wined3d_clipper_is_clip_list_changed(const struct wined3d_clippe
 HRESULT __cdecl wined3d_clipper_set_clip_list(struct wined3d_clipper *clipper, const RGNDATA *clip_list, DWORD flags);
 HRESULT __cdecl wined3d_clipper_set_window(struct wined3d_clipper *clipper, DWORD flags, HWND hwnd);
 
+HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window);
+HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags,
+        WINED3DCOLOR color, float z, DWORD stencil);
+void __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
+        struct wined3d_rendertarget_view *rendertarget_view, const WINED3DCOLORVALUE *color);
+HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface,
+        const RECT *rect, const WINED3DCOLORVALUE *color);
 HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx,
         WINED3DDEVTYPE device_type, HWND focus_window, DWORD behaviour_flags,
-        IWineD3DDeviceParent *device_parent, IWineD3DDevice **device);
-INT __cdecl wined3d_device_get_base_vertex_index(IWineD3DDevice *device);
-HRESULT __cdecl wined3d_device_get_clip_plane(IWineD3DDevice *device, UINT plane_idx, float *plane);
-HRESULT __cdecl wined3d_device_get_clip_status(IWineD3DDevice *device, WINED3DCLIPSTATUS *clip_status);
-HRESULT __cdecl wined3d_device_get_current_texture_palette(IWineD3DDevice *device, UINT *palette_idx);
-HRESULT __cdecl wined3d_device_get_depth_stencil(IWineD3DDevice *device, struct wined3d_surface **depth_stencil);
-void __cdecl wined3d_device_get_gamma_ramp(IWineD3DDevice *device, UINT swapchain_idx, WINED3DGAMMARAMP *ramp);
-HRESULT __cdecl wined3d_device_get_index_buffer(IWineD3DDevice *device, struct wined3d_buffer **index_buffer);
-HRESULT __cdecl wined3d_device_get_light(IWineD3DDevice *device, UINT light_idx, WINED3DLIGHT *light);
-HRESULT __cdecl wined3d_device_get_light_enable(IWineD3DDevice *device, UINT light_idx, BOOL *enable);
-HRESULT __cdecl wined3d_device_get_material(IWineD3DDevice *device, WINED3DMATERIAL *material);
-float __cdecl wined3d_device_get_npatch_mode(IWineD3DDevice *device);
-HRESULT __cdecl wined3d_device_get_palette_entries(IWineD3DDevice *device, UINT palette_idx, PALETTEENTRY *entries);
-struct wined3d_shader * __cdecl wined3d_device_get_pixel_shader(IWineD3DDevice *device);
-HRESULT __cdecl wined3d_device_get_ps_consts_b(IWineD3DDevice *device,
+        IWineD3DDeviceParent *device_parent, struct wined3d_device **device);
+ULONG __cdecl wined3d_device_decref(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_delete_patch(struct wined3d_device *device, UINT handle);
+HRESULT __cdecl wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count);
+HRESULT __cdecl wined3d_device_draw_indexed_primitive_strided(struct wined3d_device *device, UINT index_count,
+        const WineDirect3DVertexStridedData *strided_data, UINT vertex_count, const void *index_data,
+        enum wined3d_format_id index_data_format_id);
+HRESULT __cdecl wined3d_device_draw_indexed_primitive_up(struct wined3d_device *device,
+        UINT index_count, const void *index_data, enum wined3d_format_id index_data_format_id,
+        const void *stream_data, UINT stream_stride);
+HRESULT __cdecl wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count);
+HRESULT __cdecl wined3d_device_draw_primitive_strided(struct wined3d_device *device,
+        UINT vertex_count, const WineDirect3DVertexStridedData *strided_data);
+HRESULT __cdecl wined3d_device_draw_primitive_up(struct wined3d_device *device,
+        UINT vertex_count, const void *stream_data, UINT stream_stride);
+HRESULT __cdecl wined3d_device_draw_rect_patch(struct wined3d_device *device, UINT handle,
+        const float *num_segs, const WINED3DRECTPATCH_INFO *rect_patch_info);
+HRESULT __cdecl wined3d_device_draw_tri_patch(struct wined3d_device *device, UINT handle,
+        const float *num_segs, const WINED3DTRIPATCH_INFO *tri_patch_info);
+HRESULT __cdecl wined3d_device_end_scene(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_end_stateblock(struct wined3d_device *device, struct wined3d_stateblock **stateblock);
+HRESULT __cdecl wined3d_device_enum_resources(struct wined3d_device *device, D3DCB_ENUMRESOURCES callback, void *data);
+HRESULT __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *device);
+UINT __cdecl wined3d_device_get_available_texture_mem(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_back_buffer(struct wined3d_device *device, UINT swapchain_idx,
+        UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, struct wined3d_surface **backbuffer);
+INT __cdecl wined3d_device_get_base_vertex_index(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_clip_plane(struct wined3d_device *device, UINT plane_idx, float *plane);
+HRESULT __cdecl wined3d_device_get_clip_status(struct wined3d_device *device, WINED3DCLIPSTATUS *clip_status);
+HRESULT __cdecl wined3d_device_get_creation_parameters(struct wined3d_device *device,
+        WINED3DDEVICE_CREATION_PARAMETERS *creation_parameters);
+HRESULT __cdecl wined3d_device_get_current_texture_palette(struct wined3d_device *device, UINT *palette_idx);
+HRESULT __cdecl wined3d_device_get_depth_stencil(struct wined3d_device *device,
+        struct wined3d_surface **depth_stencil);
+HRESULT __cdecl wined3d_device_get_device_caps(struct wined3d_device *device, WINED3DCAPS *caps);
+HRESULT __cdecl wined3d_device_get_display_mode(struct wined3d_device *device,
+        UINT swapchain_idx, WINED3DDISPLAYMODE *mode);
+HRESULT __cdecl wined3d_device_get_front_buffer_data(struct wined3d_device *device,
+        UINT swapchain_idx, struct wined3d_surface *dst_surface);
+void __cdecl wined3d_device_get_gamma_ramp(struct wined3d_device *device, UINT swapchain_idx, WINED3DGAMMARAMP *ramp);
+HRESULT __cdecl wined3d_device_get_index_buffer(struct wined3d_device *device, struct wined3d_buffer **index_buffer);
+HRESULT __cdecl wined3d_device_get_light(struct wined3d_device *device, UINT light_idx, WINED3DLIGHT *light);
+HRESULT __cdecl wined3d_device_get_light_enable(struct wined3d_device *device, UINT light_idx, BOOL *enable);
+HRESULT __cdecl wined3d_device_get_material(struct wined3d_device *device, WINED3DMATERIAL *material);
+float __cdecl wined3d_device_get_npatch_mode(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_palette_entries(struct wined3d_device *device,
+        UINT palette_idx, PALETTEENTRY *entries);
+struct wined3d_shader * __cdecl wined3d_device_get_pixel_shader(struct wined3d_device *device);
+void __cdecl wined3d_device_get_primitive_type(struct wined3d_device *device, WINED3DPRIMITIVETYPE *primitive_topology);
+HRESULT __cdecl wined3d_device_get_ps_consts_b(struct wined3d_device *device,
         UINT start_register, BOOL *constants, UINT bool_count);
-HRESULT __cdecl wined3d_device_get_ps_consts_f(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_ps_consts_f(struct wined3d_device *device,
         UINT start_register, float *constants, UINT vector4f_count);
-HRESULT __cdecl wined3d_device_get_ps_consts_i(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_ps_consts_i(struct wined3d_device *device,
         UINT start_register, int *constants, UINT vector4i_count);
-HRESULT __cdecl wined3d_device_get_render_state(IWineD3DDevice *device, WINED3DRENDERSTATETYPE state, DWORD *value);
-HRESULT __cdecl wined3d_device_get_render_target(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_raster_status(struct wined3d_device *device,
+        UINT swapchain_idx, WINED3DRASTER_STATUS *raster_status);
+HRESULT __cdecl wined3d_device_get_render_state(struct wined3d_device *device,
+        WINED3DRENDERSTATETYPE state, DWORD *value);
+HRESULT __cdecl wined3d_device_get_render_target(struct wined3d_device *device,
         UINT render_target_idx, struct wined3d_surface **render_target);
-HRESULT __cdecl wined3d_device_get_sampler_state(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_sampler_state(struct wined3d_device *device,
         UINT sampler_idx, WINED3DSAMPLERSTATETYPE state, DWORD *value);
-HRESULT __cdecl wined3d_device_get_scissor_rect(IWineD3DDevice *device, RECT *rect);
-BOOL __cdecl wined3d_device_get_software_vertex_processing(IWineD3DDevice *device);
-HRESULT __cdecl wined3d_device_get_stream_source(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_scissor_rect(struct wined3d_device *device, RECT *rect);
+BOOL __cdecl wined3d_device_get_software_vertex_processing(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_stream_source(struct wined3d_device *device,
         UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride);
-HRESULT __cdecl wined3d_device_get_stream_source_freq(IWineD3DDevice *device, UINT stream_idx, UINT *divider);
-HRESULT __cdecl wined3d_device_get_texture(IWineD3DDevice *device, UINT stage, struct wined3d_texture **texture);
-HRESULT __cdecl wined3d_device_get_texture_stage_state(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT *divider);
+HRESULT __cdecl wined3d_device_get_surface_from_dc(struct wined3d_device *device,
+        HDC dc, struct wined3d_surface **surface);
+HRESULT __cdecl wined3d_device_get_swapchain(struct wined3d_device *device,
+        UINT swapchain_idx, struct wined3d_swapchain **swapchain);
+UINT __cdecl wined3d_device_get_swapchain_count(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_texture(struct wined3d_device *device,
+        UINT stage, struct wined3d_texture **texture);
+HRESULT __cdecl wined3d_device_get_texture_stage_state(struct wined3d_device *device,
         UINT stage, WINED3DTEXTURESTAGESTATETYPE state, DWORD *value);
-HRESULT __cdecl wined3d_device_get_transform(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_transform(struct wined3d_device *device,
         WINED3DTRANSFORMSTATETYPE state, WINED3DMATRIX *matrix);
-HRESULT __cdecl wined3d_device_get_vertex_declaration(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_vertex_declaration(struct wined3d_device *device,
         struct wined3d_vertex_declaration **declaration);
-struct wined3d_shader * __cdecl wined3d_device_get_vertex_shader(IWineD3DDevice *device);
-HRESULT __cdecl wined3d_device_get_viewport(IWineD3DDevice *device, WINED3DVIEWPORT *viewport);
-HRESULT __cdecl wined3d_device_get_vs_consts_b(IWineD3DDevice *device,
+struct wined3d_shader * __cdecl wined3d_device_get_vertex_shader(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_viewport(struct wined3d_device *device, WINED3DVIEWPORT *viewport);
+HRESULT __cdecl wined3d_device_get_vs_consts_b(struct wined3d_device *device,
         UINT start_register, BOOL *constants, UINT bool_count);
-HRESULT __cdecl wined3d_device_get_vs_consts_f(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_vs_consts_f(struct wined3d_device *device,
         UINT start_register, float *constants, UINT vector4f_count);
-HRESULT __cdecl wined3d_device_get_vs_consts_i(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_vs_consts_i(struct wined3d_device *device,
         UINT start_register, int *constants, UINT vector4i_count);
-HRESULT __cdecl wined3d_device_set_base_vertex_index(IWineD3DDevice *device, INT base_index);
-HRESULT __cdecl wined3d_device_set_clip_plane(IWineD3DDevice *device, UINT plane_idx, const float *plane);
-HRESULT __cdecl wined3d_device_set_clip_status(IWineD3DDevice *device, const WINED3DCLIPSTATUS *clip_status);
-HRESULT __cdecl wined3d_device_set_current_texture_palette(IWineD3DDevice *device, UINT palette_idx);
-HRESULT __cdecl wined3d_device_set_depth_stencil(IWineD3DDevice *device, struct wined3d_surface *depth_stencil);
-void __cdecl wined3d_device_set_gamma_ramp(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_get_wined3d(struct wined3d_device *device, struct wined3d **d3d);
+ULONG __cdecl wined3d_device_incref(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_init_3d(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
+HRESULT __cdecl wined3d_device_init_gdi(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
+HRESULT __cdecl wined3d_device_multiply_transform(struct wined3d_device *device,
+        WINED3DTRANSFORMSTATETYPE state, const WINED3DMATRIX *matrix);
+HRESULT __cdecl wined3d_device_present(struct wined3d_device *device, const RECT *src_rect,
+        const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region);
+HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,
+        UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
+        struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf);
+void __cdecl wined3d_device_release_focus_window(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
+void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window);
+HRESULT __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index);
+HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const float *plane);
+HRESULT __cdecl wined3d_device_set_clip_status(struct wined3d_device *device, const WINED3DCLIPSTATUS *clip_status);
+HRESULT __cdecl wined3d_device_set_current_texture_palette(struct wined3d_device *device, UINT palette_idx);
+void __cdecl wined3d_device_set_cursor_position(struct wined3d_device *device,
+        int x_screen_space, int y_screen_space, DWORD flags);
+HRESULT __cdecl wined3d_device_set_cursor_properties(struct wined3d_device *device,
+        UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_surface);
+HRESULT __cdecl wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil);
+HRESULT __cdecl wined3d_device_set_dialog_box_mode(struct wined3d_device *device, BOOL enable_dialogs);
+HRESULT __cdecl wined3d_device_set_display_mode(struct wined3d_device *device,
+        UINT swapchain_idx, const WINED3DDISPLAYMODE *mode);
+void __cdecl wined3d_device_set_gamma_ramp(struct wined3d_device *device,
         UINT swapchain_idx, DWORD flags, const WINED3DGAMMARAMP *ramp);
-HRESULT __cdecl wined3d_device_set_index_buffer(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_index_buffer(struct wined3d_device *device,
         struct wined3d_buffer *index_buffer, enum wined3d_format_id format_id);
-HRESULT __cdecl wined3d_device_set_light(IWineD3DDevice *device, UINT light_idx, const WINED3DLIGHT *light);
-HRESULT __cdecl wined3d_device_set_light_enable(IWineD3DDevice *device, UINT light_idx, BOOL enable);
-HRESULT __cdecl wined3d_device_set_material(IWineD3DDevice *device, const WINED3DMATERIAL *material);
-HRESULT __cdecl wined3d_device_set_npatch_mode(IWineD3DDevice *device, float segments);
-HRESULT __cdecl wined3d_device_set_palette_entries(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const WINED3DLIGHT *light);
+HRESULT __cdecl wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable);
+HRESULT __cdecl wined3d_device_set_material(struct wined3d_device *device, const WINED3DMATERIAL *material);
+void __cdecl wined3d_device_set_multithreaded(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_set_npatch_mode(struct wined3d_device *device, float segments);
+HRESULT __cdecl wined3d_device_set_palette_entries(struct wined3d_device *device,
         UINT palette_idx, const PALETTEENTRY *entries);
-HRESULT __cdecl wined3d_device_set_pixel_shader(IWineD3DDevice *device, struct wined3d_shader *shader);
-HRESULT __cdecl wined3d_device_set_ps_consts_b(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader);
+void __cdecl wined3d_device_set_primitive_type(struct wined3d_device *device, WINED3DPRIMITIVETYPE primitive_topology);
+HRESULT __cdecl wined3d_device_set_ps_consts_b(struct wined3d_device *device,
         UINT start_register, const BOOL *constants, UINT bool_count);
-HRESULT __cdecl wined3d_device_set_ps_consts_f(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_ps_consts_f(struct wined3d_device *device,
         UINT start_register, const float *constants, UINT vector4f_count);
-HRESULT __cdecl wined3d_device_set_ps_consts_i(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_ps_consts_i(struct wined3d_device *device,
         UINT start_register, const int *constants, UINT vector4i_count);
-HRESULT __cdecl wined3d_device_set_render_state(IWineD3DDevice *device, WINED3DRENDERSTATETYPE state, DWORD value);
-HRESULT __cdecl wined3d_device_set_render_target(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_render_state(struct wined3d_device *device,
+        WINED3DRENDERSTATETYPE state, DWORD value);
+HRESULT __cdecl wined3d_device_set_render_target(struct wined3d_device *device,
         UINT render_target_idx, struct wined3d_surface *render_target, BOOL set_viewport);
-HRESULT __cdecl wined3d_device_set_sampler_state(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_sampler_state(struct wined3d_device *device,
         UINT sampler_idx, WINED3DSAMPLERSTATETYPE state, DWORD value);
-HRESULT __cdecl wined3d_device_set_scissor_rect(IWineD3DDevice *device, const RECT *rect);
-HRESULT __cdecl wined3d_device_set_software_vertex_processing(IWineD3DDevice *device, BOOL software);
-HRESULT __cdecl wined3d_device_set_stream_source(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_scissor_rect(struct wined3d_device *device, const RECT *rect);
+HRESULT __cdecl wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software);
+HRESULT __cdecl wined3d_device_set_stream_source(struct wined3d_device *device,
         UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride);
-HRESULT __cdecl wined3d_device_set_stream_source_freq(IWineD3DDevice *device, UINT stream_idx, UINT divider);
-HRESULT __cdecl wined3d_device_set_texture(IWineD3DDevice *device, UINT stage, struct wined3d_texture *texture);
-HRESULT __cdecl wined3d_device_set_texture_stage_state(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider);
+HRESULT __cdecl wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture);
+HRESULT __cdecl wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         UINT stage, WINED3DTEXTURESTAGESTATETYPE state, DWORD value);
-HRESULT __cdecl wined3d_device_set_transform(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_transform(struct wined3d_device *device,
         WINED3DTRANSFORMSTATETYPE state, const WINED3DMATRIX *matrix);
-HRESULT __cdecl wined3d_device_set_vertex_declaration(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_vertex_declaration(struct wined3d_device *device,
         struct wined3d_vertex_declaration *declaration);
-HRESULT __cdecl wined3d_device_set_vertex_shader(IWineD3DDevice *device, struct wined3d_shader *shader);
-HRESULT __cdecl wined3d_device_set_viewport(IWineD3DDevice *device, const WINED3DVIEWPORT *viewport);
-HRESULT __cdecl wined3d_device_set_vs_consts_b(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader);
+HRESULT __cdecl wined3d_device_set_viewport(struct wined3d_device *device, const WINED3DVIEWPORT *viewport);
+HRESULT __cdecl wined3d_device_set_vs_consts_b(struct wined3d_device *device,
         UINT start_register, const BOOL *constants, UINT bool_count);
-HRESULT __cdecl wined3d_device_set_vs_consts_f(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_vs_consts_f(struct wined3d_device *device,
         UINT start_register, const float *constants, UINT vector4f_count);
-HRESULT __cdecl wined3d_device_set_vs_consts_i(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device,
         UINT start_register, const int *constants, UINT vector4i_count);
-
-HRESULT __cdecl wined3d_palette_create(IWineD3DDevice *device, DWORD flags,
+void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h);
+BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show);
+HRESULT __cdecl wined3d_device_uninit_3d(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_uninit_gdi(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_update_surface(struct wined3d_device *device, struct wined3d_surface *src_surface,
+        const RECT *src_rect, struct wined3d_surface *dst_surface, const POINT *dst_point);
+HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
+        struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
+HRESULT __cdecl wined3d_device_validate_device(struct wined3d_device *device, DWORD *num_passes);
+
+HRESULT __cdecl wined3d_palette_create(struct wined3d_device *device, DWORD flags,
         const PALETTEENTRY *entries, void *parent, struct wined3d_palette **palette);
 ULONG __cdecl wined3d_palette_decref(struct wined3d_palette *palette);
 HRESULT __cdecl wined3d_palette_get_entries(const struct wined3d_palette *palette,
@@ -2547,7 +2423,8 @@ ULONG __cdecl wined3d_palette_incref(struct wined3d_palette *palette);
 HRESULT __cdecl wined3d_palette_set_entries(struct wined3d_palette *palette,
         DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries);
 
-HRESULT __cdecl wined3d_query_create(IWineD3DDevice *device, WINED3DQUERYTYPE type, struct wined3d_query **query);
+HRESULT __cdecl wined3d_query_create(struct wined3d_device *device,
+        WINED3DQUERYTYPE type, struct wined3d_query **query);
 ULONG __cdecl wined3d_query_decref(struct wined3d_query *query);
 HRESULT __cdecl wined3d_query_get_data(struct wined3d_query *query, void *data, UINT data_size, DWORD flags);
 UINT __cdecl wined3d_query_get_data_size(const struct wined3d_query *query);
@@ -2566,13 +2443,13 @@ void * __cdecl wined3d_rendertarget_view_get_parent(const struct wined3d_rendert
 struct wined3d_resource * __cdecl wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view);
 ULONG __cdecl wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view);
 
-HRESULT __cdecl wined3d_shader_create_gs(IWineD3DDevice *device, const DWORD *byte_code,
+HRESULT __cdecl wined3d_shader_create_gs(struct wined3d_device *device, const DWORD *byte_code,
         const struct wined3d_shader_signature *output_signature, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
-HRESULT __cdecl wined3d_shader_create_ps(IWineD3DDevice *device, const DWORD *byte_code,
+HRESULT __cdecl wined3d_shader_create_ps(struct wined3d_device *device, const DWORD *byte_code,
         const struct wined3d_shader_signature *output_signature, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
-HRESULT __cdecl wined3d_shader_create_vs(IWineD3DDevice *device, const DWORD *byte_code,
+HRESULT __cdecl wined3d_shader_create_vs(struct wined3d_device *device, const DWORD *byte_code,
         const struct wined3d_shader_signature *output_signature, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
 ULONG __cdecl wined3d_shader_decref(struct wined3d_shader *shader);
@@ -2585,7 +2462,7 @@ HRESULT __cdecl wined3d_shader_set_local_constants_float(struct wined3d_shader *
 
 HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
 HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
-HRESULT __cdecl wined3d_stateblock_create(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device,
         WINED3DSTATEBLOCKTYPE type, struct wined3d_stateblock **stateblock);
 ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
 ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
@@ -2595,7 +2472,7 @@ HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const R
         const WINEDDBLTFX *blt_fx, WINED3DTEXTUREFILTERTYPE filter);
 HRESULT __cdecl wined3d_surface_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
         struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans);
-HRESULT __cdecl wined3d_surface_create(IWineD3DDevice *device, UINT width, UINT height,
+HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
         enum wined3d_format_id format_id, BOOL lockable, BOOL discard, UINT level, DWORD usage, WINED3DPOOL pool,
         WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, WINED3DSURFTYPE surface_type,
         void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface);
@@ -2637,13 +2514,13 @@ HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface,
 HRESULT __cdecl wined3d_surface_update_overlay_z_order(struct wined3d_surface *surface,
         DWORD flags, struct wined3d_surface *ref);
 
-HRESULT __cdecl wined3d_swapchain_create(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_swapchain_create(struct wined3d_device *device,
         WINED3DPRESENT_PARAMETERS *present_parameters, WINED3DSURFTYPE surface_type, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
 ULONG __cdecl wined3d_swapchain_decref(struct wined3d_swapchain *swapchain);
 HRESULT __cdecl wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain,
         UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, struct wined3d_surface **backbuffer);
-IWineD3DDevice * __cdecl wined3d_swapchain_get_device(const struct wined3d_swapchain *swapchain);
+struct wined3d_device * __cdecl wined3d_swapchain_get_device(const struct wined3d_swapchain *swapchain);
 HRESULT __cdecl wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain,
         WINED3DDISPLAYMODE *mode);
 HRESULT __cdecl wined3d_swapchain_get_front_buffer_data(const struct wined3d_swapchain *swapchain,
@@ -2665,13 +2542,13 @@ HRESULT __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain
 
 HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
         UINT layer, const WINED3DBOX *dirty_region);
-HRESULT __cdecl wined3d_texture_create_2d(IWineD3DDevice *device, UINT width, UINT height,
+HRESULT __cdecl wined3d_texture_create_2d(struct wined3d_device *device, UINT width, UINT height,
         UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
-HRESULT __cdecl wined3d_texture_create_3d(IWineD3DDevice *device, UINT width, UINT height, UINT depth,
+HRESULT __cdecl wined3d_texture_create_3d(struct wined3d_device *device, UINT width, UINT height, UINT depth,
         UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
-HRESULT __cdecl wined3d_texture_create_cube(IWineD3DDevice *device, UINT edge_length,
+HRESULT __cdecl wined3d_texture_create_cube(struct wined3d_device *device, UINT edge_length,
         UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
 ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
@@ -2696,17 +2573,17 @@ DWORD __cdecl wined3d_texture_set_priority(struct wined3d_texture *texture, DWOR
 HRESULT __cdecl wined3d_texture_set_private_data(struct wined3d_texture *texture,
         REFGUID guid, const void *data, DWORD data_size, DWORD flags);
 
-HRESULT __cdecl wined3d_vertex_declaration_create(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_vertex_declaration_create(struct wined3d_device *device,
         const WINED3DVERTEXELEMENT *elements, UINT element_count, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_vertex_declaration **declaration);
-HRESULT __cdecl wined3d_vertex_declaration_create_from_fvf(IWineD3DDevice *device,
+HRESULT __cdecl wined3d_vertex_declaration_create_from_fvf(struct wined3d_device *device,
         DWORD fvf, void *parent, const struct wined3d_parent_ops *parent_ops,
         struct wined3d_vertex_declaration **declaration);
 ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration);
 void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
 ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
 
-HRESULT __cdecl wined3d_volume_create(IWineD3DDevice *device, UINT width, UINT height, UINT depth,
+HRESULT __cdecl wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height, UINT depth,
         DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
         const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume);
 ULONG __cdecl wined3d_volume_decref(struct wined3d_volume *volume);
diff --git a/include/wine/winedxgi.idl b/include/wine/winedxgi.idl
index 24a3714..63aba60 100644
--- a/include/wine/winedxgi.idl
+++ b/include/wine/winedxgi.idl
@@ -45,7 +45,7 @@ interface IWineDXGIAdapter : IDXGIAdapter
 ]
 interface IWineDXGIDevice : IDXGIDevice
 {
-    struct IWineD3DDevice *get_wined3d_device();
+    struct wined3d_device *get_wined3d_device();
     HRESULT create_surface(
         [in] const DXGI_SURFACE_DESC *desc,
         [in] DXGI_USAGE usage,
-- 
1.7.3.4




More information about the wine-patches mailing list