Index: dlls/d3d8/d3d8_main.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/d3d8_main.c,v
retrieving revision 1.18
diff -u -r1.18 d3d8_main.c
--- dlls/d3d8/d3d8_main.c	28 Sep 2004 02:12:12 -0000	1.18
+++ dlls/d3d8/d3d8_main.c	6 Nov 2004 21:37:04 -0000
@@ -56,7 +56,7 @@
     object->lpVtbl = &Direct3D8_Vtbl;
     object->direct3d8 = object;
     object->ref = 1;
-    object->WineD3D = WineDirect3DCreate(SDKVersion, 8);
+    object->WineD3D = WineDirect3DCreate(SDKVersion, 8, (IUnknown *)object);
 
     TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
 
Index: dlls/d3d8/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/directx.c,v
retrieving revision 1.81
diff -u -r1.81 directx.c
--- dlls/d3d8/directx.c	8 Oct 2004 20:52:33 -0000	1.81
+++ dlls/d3d8/directx.c	6 Nov 2004 21:37:06 -0000
@@ -583,7 +583,7 @@
     localParameters.Flags                          = &pPresentationParameters->Flags;                      
     localParameters.FullScreen_RefreshRateInHz     = &pPresentationParameters->FullScreen_RefreshRateInHz; 
     localParameters.PresentationInterval           = &pPresentationParameters->FullScreen_PresentationInterval;    /* Renamed in dx9 */
-    IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice);
+    IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object);
 
     /** use StateBlock Factory here, for creating the startup stateBlock */
     object->StateBlock = NULL;
Index: dlls/d3d9/d3d9_main.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d9/d3d9_main.c,v
retrieving revision 1.4
diff -u -r1.4 d3d9_main.c
--- dlls/d3d9/d3d9_main.c	23 Sep 2004 04:34:28 -0000	1.4
+++ dlls/d3d9/d3d9_main.c	6 Nov 2004 21:37:06 -0000
@@ -43,7 +43,7 @@
 
     object->lpVtbl = &Direct3D9_Vtbl;
     object->ref = 1;
-    object->WineD3D = WineDirect3DCreate(SDKVersion, 9);
+    object->WineD3D = WineDirect3DCreate(SDKVersion, 9, (IUnknown *)object);
 
     TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
 
Index: dlls/d3d9/device.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d9/device.c,v
retrieving revision 1.9
diff -u -r1.9 device.c
--- dlls/d3d9/device.c	21 Oct 2004 20:59:12 -0000	1.9
+++ dlls/d3d9/device.c	6 Nov 2004 21:37:07 -0000
@@ -606,35 +606,20 @@
 }
 
 HRESULT  WINAPI  IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
-    IDirect3DVertexBuffer9 *oldSrc;
     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
-
-    oldSrc = This->StateBlock->stream_source[StreamNumber];
-    TRACE("(%p) : StreamNo: %d, OldStream (%p), NewStream (%p), NewStride %d\n", This, StreamNumber, oldSrc, pStreamData, Stride);
-
-    This->UpdateStateBlock->Changed.stream_source[StreamNumber] = TRUE;
-    This->UpdateStateBlock->Set.stream_source[StreamNumber] = TRUE;
-    This->UpdateStateBlock->stream_stride[StreamNumber] = Stride;
-    This->UpdateStateBlock->stream_source[StreamNumber] = pStreamData;
-
-    /* Handle recording of state blocks */
-    if (This->isRecordingState) {
-        TRACE("Recording... not performing anything\n");
-        return D3D_OK;
-    }
-
-    if (oldSrc != NULL) IDirect3DVertexBuffer9Impl_Release(oldSrc);
-    if (pStreamData != NULL) IDirect3DVertexBuffer9Impl_AddRef(pStreamData);
-    return D3D_OK;
+    return IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber, 
+                                          pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer, 
+                                          OffsetInBytes, Stride);
 }
 
 HRESULT  WINAPI  IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, IDirect3DVertexBuffer9** pStream, UINT* OffsetInBytes, UINT* pStride) {
     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
-    TRACE("(%p) : StreamNo: %d, Stream (%p), Stride %d\n", This, StreamNumber, This->StateBlock->stream_source[StreamNumber], This->StateBlock->stream_stride[StreamNumber]);
-    *pStream = This->StateBlock->stream_source[StreamNumber];
-    *pStride = This->StateBlock->stream_stride[StreamNumber];
-    IDirect3DVertexBuffer9Impl_AddRef((LPDIRECT3DVERTEXBUFFER9) *pStream);
-    return D3D_OK;
+    IWineD3DVertexBuffer *retStream = NULL;
+    HRESULT rc = D3D_OK;
+
+    rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, OffsetInBytes, pStride);
+    if (rc == D3D_OK && NULL != *pStream) IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream);
+    return rc;
 }
 
 HRESULT  WINAPI  IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVICE9 iface, UINT StreamNumber, UINT Divider) {
Index: dlls/d3d9/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d9/directx.c,v
retrieving revision 1.13
diff -u -r1.13 directx.c
--- dlls/d3d9/directx.c	14 Oct 2004 00:32:04 -0000	1.13
+++ dlls/d3d9/directx.c	6 Nov 2004 21:37:07 -0000
@@ -191,7 +191,7 @@
     localParameters.Flags                          = &pPresentationParameters->Flags;                      
     localParameters.FullScreen_RefreshRateInHz     = &pPresentationParameters->FullScreen_RefreshRateInHz; 
     localParameters.PresentationInterval           = &pPresentationParameters->PresentationInterval;       
-    IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice);
+    IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object);
 
     FIXME("(%p) : incomplete stub\n", This);
     return D3D_OK;
Index: dlls/d3d9/vertexbuffer.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d9/vertexbuffer.c,v
retrieving revision 1.6
diff -u -r1.6 vertexbuffer.c
--- dlls/d3d9/vertexbuffer.c	14 Oct 2004 00:32:04 -0000	1.6
+++ dlls/d3d9/vertexbuffer.c	6 Nov 2004 21:37:08 -0000
@@ -147,7 +147,7 @@
     object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
     object->ref = 1;
     object->device = This;
-    IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, Pool, &(object->wineD3DVertexBuffer), pSharedHandle);
+    IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
     *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
 
     return D3D_OK;
Index: dlls/wined3d/device.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/device.c,v
retrieving revision 1.4
diff -u -r1.4 device.c
--- dlls/wined3d/device.c	22 Oct 2004 22:27:51 -0000	1.4
+++ dlls/wined3d/device.c	6 Nov 2004 21:37:11 -0000
@@ -34,8 +34,16 @@
 /**********************************************************
  * IWineD3DDevice implementation follows
  **********************************************************/
+HRESULT WINAPI IWineD3DDeviceImpl_GetParent(IWineD3DDevice *iface, IUnknown **pParent) {
+    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+    *pParent = This->parent;
+    IUnknown_AddRef(This->parent);
+    return D3D_OK;
+}
+
 HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Size, DWORD Usage, 
-                             DWORD FVF, D3DPOOL Pool, IWineD3DVertexBuffer** ppVertexBuffer, HANDLE *sharedHandle) {
+                             DWORD FVF, D3DPOOL Pool, IWineD3DVertexBuffer** ppVertexBuffer, HANDLE *sharedHandle,
+                             IUnknown *parent) {
 
     IWineD3DVertexBufferImpl *object;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -44,6 +52,8 @@
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DVertexBufferImpl));
     object->lpVtbl                = &IWineD3DVertexBuffer_Vtbl;
     object->resource.wineD3DDevice= iface;
+    IWineD3DDevice_AddRef(iface);
+    object->resource.parent       = parent;
     object->resource.resourceType = D3DRTYPE_VERTEXBUFFER;
     object->resource.ref          = 1;
     object->allocatedMemory       = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size);
@@ -58,7 +68,7 @@
     return D3D_OK;
 }
 
-HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock** ppStateBlock) {
+HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock** ppStateBlock, IUnknown *parent) {
   
     IWineD3DDeviceImpl     *This = (IWineD3DDeviceImpl *)iface;
     IWineD3DStateBlockImpl *object;
@@ -67,6 +77,8 @@
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DStateBlockImpl));
     object->lpVtbl        = &IWineD3DStateBlock_Vtbl;
     object->wineD3DDevice = iface;
+    IWineD3DDevice_AddRef(iface);
+    object->parent        = parent;
     object->ref           = 1;
     object->blockType     = Type;
     *ppStateBlock         = (IWineD3DStateBlock *)object;
@@ -109,6 +121,46 @@
     return D3D_OK;
 }
 
+/*****
+ * Get / Set Stream Source
+ *****/
+HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,IWineD3DVertexBuffer* pStreamData, UINT OffsetInBytes, UINT Stride) {
+    IWineD3DDeviceImpl       *This = (IWineD3DDeviceImpl *)iface;
+    IWineD3DVertexBuffer     *oldSrc;
+
+    oldSrc = This->stateBlock->stream_source[StreamNumber];
+    TRACE("(%p) : StreamNo: %d, OldStream (%p), NewStream (%p), NewStride %d\n", This, StreamNumber, oldSrc, pStreamData, Stride);
+
+    This->updateStateBlock->changed.stream_source[StreamNumber] = TRUE;
+    This->updateStateBlock->set.stream_source[StreamNumber]     = TRUE;
+    This->updateStateBlock->stream_stride[StreamNumber]         = Stride;
+    This->updateStateBlock->stream_source[StreamNumber]         = pStreamData;
+    This->updateStateBlock->stream_offset[StreamNumber]         = OffsetInBytes;
+
+    /* Handle recording of state blocks */
+    if (This->isRecordingState) {
+        TRACE("Recording... not performing anything\n");
+        return D3D_OK;
+    }
+
+    /* Not recording... */
+    if (oldSrc != NULL) IWineD3DVertexBuffer_Release(oldSrc);
+    if (pStreamData != NULL) IWineD3DVertexBuffer_AddRef(pStreamData);
+
+    return D3D_OK;
+}
+
+HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,IWineD3DVertexBuffer** pStream, UINT *pOffset, UINT* pStride) {
+    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+
+    TRACE("(%p) : StreamNo: %d, Stream (%p), Stride %d\n", This, StreamNumber, This->stateBlock->stream_source[StreamNumber], This->stateBlock->stream_stride[StreamNumber]);
+    *pStream = This->stateBlock->stream_source[StreamNumber];
+    *pStride = This->stateBlock->stream_stride[StreamNumber];
+    *pOffset = This->stateBlock->stream_offset[StreamNumber];
+    IWineD3DVertexBuffer_AddRef(*pStream); /* We have created a new reference to the VB */
+    return D3D_OK;
+}
+
 /**********************************************************
  * IUnknown parts follows
  **********************************************************/
@@ -130,6 +182,7 @@
     TRACE("(%p) : Releasing from %ld\n", This, This->ref);
     ref = InterlockedDecrement(&This->ref);
     if (ref == 0) {
+        IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
         IWineD3D_Release(This->WineD3D);
         HeapFree(GetProcessHeap(), 0, This);
     }
@@ -145,8 +198,11 @@
     IWineD3DDeviceImpl_QueryInterface,
     IWineD3DDeviceImpl_AddRef,
     IWineD3DDeviceImpl_Release,
+    IWineD3DDeviceImpl_GetParent,
     IWineD3DDeviceImpl_CreateVertexBuffer,
     IWineD3DDeviceImpl_CreateStateBlock,
     IWineD3DDeviceImpl_SetFVF,
-    IWineD3DDeviceImpl_GetFVF
+    IWineD3DDeviceImpl_GetFVF,
+    IWineD3DDeviceImpl_SetStreamSource,
+    IWineD3DDeviceImpl_GetStreamSource
 };
Index: dlls/wined3d/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/directx.c,v
retrieving revision 1.10
diff -u -r1.10 directx.c
--- dlls/wined3d/directx.c	22 Oct 2004 22:27:51 -0000	1.10
+++ dlls/wined3d/directx.c	6 Nov 2004 21:37:14 -0000
@@ -1310,7 +1310,7 @@
    and fields being inserted in the middle, a new structure is used in place    */
 HRESULT  WINAPI  IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
                                            DWORD BehaviourFlags, WINED3DPRESENT_PARAMETERS* pPresentationParameters,
-                                                            IWineD3DDevice** ppReturnedDeviceInterface) {
+                                           IWineD3DDevice** ppReturnedDeviceInterface, IUnknown *parent) {
 
     HWND                whichHWND;
     HDC                 hDc;
@@ -1337,6 +1337,7 @@
     object->ref     = 1;
     object->WineD3D = iface;
     IWineD3D_AddRef(object->WineD3D);
+    object->parent  = parent;
     
     TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
           hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface);
@@ -1468,7 +1469,8 @@
     /* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
     IWineD3DDevice_CreateStateBlock((IWineD3DDevice *)object, 
                                     (D3DSTATEBLOCKTYPE) 0, 
-                                    (IWineD3DStateBlock **)&object->stateBlock); 
+                                    (IWineD3DStateBlock **)&object->stateBlock,
+                                    NULL);   /* Note: No parent needed for initial internal stateblock */
     object->updateStateBlock = object->stateBlock;
 
     /* Setup surfaces for the backbuffer, frontbuffer and depthstencil buffer */
@@ -1581,6 +1583,13 @@
     return D3D_OK;
 }
 
+HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent) {
+    IWineD3DImpl *This = (IWineD3DImpl *)iface;
+    IUnknown_AddRef(This->parent);
+    *pParent = This->parent;
+    return D3D_OK;
+}
+
 /**********************************************************
  * IUnknown parts follows
  **********************************************************/
@@ -1614,6 +1623,7 @@
     IWineD3DImpl_QueryInterface,
     IWineD3DImpl_AddRef,
     IWineD3DImpl_Release,
+    IWineD3DImpl_GetParent,
     IWineD3DImpl_GetAdapterCount,
     IWineD3DImpl_RegisterSoftwareDevice,
     IWineD3DImpl_GetAdapterMonitor,
Index: dlls/wined3d/resource.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/resource.c,v
retrieving revision 1.1
diff -u -r1.1 resource.c
--- dlls/wined3d/resource.c	14 Oct 2004 00:32:04 -0000	1.1
+++ dlls/wined3d/resource.c	6 Nov 2004 21:37:14 -0000
@@ -45,6 +45,7 @@
     TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
     ref = InterlockedDecrement(&This->resource.ref);
     if (ref == 0) {
+        IWineD3DDevice_Release(This->resource.wineD3DDevice);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -97,11 +98,20 @@
     return This->resource.resourceType;
 }
 
+HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent) {
+    IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
+    IUnknown_AddRef(This->resource.parent);
+    *pParent = This->resource.parent;
+    return D3D_OK;
+}
+
+
 IWineD3DResourceVtbl IWineD3DResource_Vtbl =
 {
     IWineD3DResourceImpl_QueryInterface,
     IWineD3DResourceImpl_AddRef,
     IWineD3DResourceImpl_Release,
+    IWineD3DResourceImpl_GetParent,
     IWineD3DResourceImpl_GetDevice,
     IWineD3DResourceImpl_SetPrivateData,
     IWineD3DResourceImpl_GetPrivateData,
Index: dlls/wined3d/stateblock.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/stateblock.c,v
retrieving revision 1.1
diff -u -r1.1 stateblock.c
--- dlls/wined3d/stateblock.c	21 Oct 2004 20:59:12 -0000	1.1
+++ dlls/wined3d/stateblock.c	6 Nov 2004 21:37:14 -0000
@@ -24,6 +24,13 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 
+HRESULT WINAPI IWineD3DStateBlockImpl_GetParent(IWineD3DStateBlock *iface, IUnknown **pParent) {
+    IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
+    IUnknown_AddRef(This->parent);
+    *pParent = This->parent;
+    return D3D_OK;
+}
+
 HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock* iface) {
     IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
 
@@ -56,7 +63,10 @@
     ULONG ref;
     TRACE("(%p) : Releasing from %ld\n", This, This->ref);
     ref = InterlockedDecrement(&This->ref);
-    if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
+    if (ref == 0) {
+        IWineD3DDevice_Release(This->wineD3DDevice);
+        HeapFree(GetProcessHeap(), 0, This);
+    }
     return ref;
 }
 
@@ -69,5 +79,6 @@
     IWineD3DStateBlockImpl_QueryInterface,
     IWineD3DStateBlockImpl_AddRef,
     IWineD3DStateBlockImpl_Release,
+    IWineD3DStateBlockImpl_GetParent,
     IWineD3DStateBlockImpl_InitStartupStateBlock
 };
Index: dlls/wined3d/vertexbuffer.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/vertexbuffer.c,v
retrieving revision 1.1
diff -u -r1.1 vertexbuffer.c
--- dlls/wined3d/vertexbuffer.c	14 Oct 2004 00:32:04 -0000	1.1
+++ dlls/wined3d/vertexbuffer.c	6 Nov 2004 21:37:14 -0000
@@ -38,6 +38,7 @@
 ULONG WINAPI IWineD3DVertexBufferImpl_AddRef(IWineD3DVertexBuffer *iface) {
     IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
     TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
+    IUnknown_AddRef(This->resource.parent);
     return InterlockedIncrement(&This->resource.ref);
 }
 
@@ -48,7 +49,10 @@
     ref = InterlockedDecrement(&This->resource.ref);
     if (ref == 0) {
         if (NULL != This->allocatedMemory) HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
+        IWineD3DDevice_Release(This->resource.wineD3DDevice);
         HeapFree(GetProcessHeap(), 0, This);
+    } else {
+        IUnknown_Release(This->resource.parent);  /* Released the reference to the d3dx VB */
     }
     return ref;
 }
@@ -88,6 +92,9 @@
     return IWineD3DResource_GetType((IWineD3DResource *)iface);
 }
 
+HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent) {
+    return IWineD3DResource_GetParent((IWineD3DResource *)iface, pParent);
+}
 
 /* ******************************************************
    IWineD3DVertexBuffer IWineD3DVertexBuffer parts follow
@@ -122,6 +129,7 @@
     IWineD3DVertexBufferImpl_QueryInterface,
     IWineD3DVertexBufferImpl_AddRef,
     IWineD3DVertexBufferImpl_Release,
+    IWineD3DVertexBufferImpl_GetParent,
     IWineD3DVertexBufferImpl_GetDevice,
     IWineD3DVertexBufferImpl_SetPrivateData,
     IWineD3DVertexBufferImpl_GetPrivateData,
Index: dlls/wined3d/wined3d_main.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/wined3d_main.c,v
retrieving revision 1.3
diff -u -r1.3 wined3d_main.c
--- dlls/wined3d/wined3d_main.c	28 Sep 2004 02:12:12 -0000	1.3
+++ dlls/wined3d/wined3d_main.c	6 Nov 2004 21:37:14 -0000
@@ -32,11 +32,12 @@
 int vs_mode = VS_HW;   /* Hardware by default */
 int ps_mode = PS_NONE; /* Disabled by default */
 
-IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion) {
+IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) {
     IWineD3DImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
     object->lpVtbl = &IWineD3D_Vtbl;
     object->dxVersion = dxVersion;
     object->ref = 1;
+    object->parent = parent;
 
     TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
 
Index: dlls/wined3d/wined3d_private.h
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/wined3d_private.h,v
retrieving revision 1.10
diff -u -r1.10 wined3d_private.h
--- dlls/wined3d/wined3d_private.h	21 Oct 2004 20:59:12 -0000	1.10
+++ dlls/wined3d/wined3d_private.h	6 Nov 2004 21:37:14 -0000
@@ -26,6 +26,7 @@
 #include <stdarg.h>
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
+#define COBJMACROS
 #include "windef.h"
 #include "winbase.h"
 #include "winreg.h"
@@ -98,6 +99,7 @@
     DWORD                   ref;     /* Note: Ref counting not required */
 
     /* WineD3D Information */
+    IUnknown               *parent;
     UINT                    dxVersion;
 
     /* GL Information */
@@ -117,6 +119,7 @@
     DWORD                   ref;     /* Note: Ref counting not required */
 
     /* WineD3D Information  */
+    IUnknown               *parent;  /* TODO - to be a new interface eventually */
     IWineD3D               *WineD3D;
 
     /* X and GL Information */
@@ -159,6 +162,7 @@
     DWORD                   ref;     /* Note: Ref counting not required */
 
     /* WineD3DResource Information */
+    IUnknown               *parent;
     IWineD3DDevice         *wineD3DDevice;
     D3DRESOURCETYPE         resourceType;
 
@@ -200,6 +204,7 @@
 /*   to resolve everything we need, so doing it manually for now */
 typedef struct SAVEDSTATES {
         BOOL                      fvf;
+        BOOL                      stream_source[MAX_STREAMS];
 } SAVEDSTATES;
 
 struct IWineD3DStateBlockImpl
@@ -209,6 +214,7 @@
     DWORD                     ref;     /* Note: Ref counting not required */
     
     /* IWineD3DStateBlock information */
+    IUnknown                 *parent;
     IWineD3DDevice           *wineD3DDevice;
     D3DSTATEBLOCKTYPE         blockType;
 
@@ -219,6 +225,10 @@
     /* Drawing - Vertex Shader or FVF related */
     DWORD                     fvf;
 
+    /* Stream Source */
+    UINT                      stream_stride[MAX_STREAMS];
+    UINT                      stream_offset[MAX_STREAMS];
+    IWineD3DVertexBuffer     *stream_source[MAX_STREAMS];
 };
 
 extern IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
Index: include/wine/wined3d_interface.h
===================================================================
RCS file: /home/wine/wine/include/wine/wined3d_interface.h,v
retrieving revision 1.12
diff -u -r1.12 wined3d_interface.h
--- include/wine/wined3d_interface.h	21 Oct 2004 20:59:12 -0000	1.12
+++ include/wine/wined3d_interface.h	6 Nov 2004 21:37:16 -0000
@@ -88,6 +88,7 @@
     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
     STDMETHOD_(ULONG,Release)(THIS) PURE;
     /*** IWineD3D methods ***/
+    STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
     STDMETHOD_(UINT,GetAdapterCount)(THIS) PURE;
     STDMETHOD(RegisterSoftwareDevice)(THIS_ void * pInitializeFunction) PURE;
     STDMETHOD_(HMONITOR,GetAdapterMonitor)(THIS_ UINT Adapter) PURE;
@@ -101,7 +102,7 @@
     STDMETHOD(CheckDeviceFormat)(THIS_ UINT  Adapter, D3DDEVTYPE  DeviceType, D3DFORMAT  AdapterFormat, DWORD  Usage, D3DRESOURCETYPE  RType, D3DFORMAT  CheckFormat) PURE;
     STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) PURE;
     STDMETHOD(GetDeviceCaps)(THIS_ UINT  Adapter, D3DDEVTYPE  DeviceType, void * pCaps) PURE;
-    STDMETHOD(CreateDevice)(THIS_ UINT  Adapter, D3DDEVTYPE  DeviceType,HWND  hFocusWindow, DWORD  BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface) PURE;
+    STDMETHOD(CreateDevice)(THIS_ UINT  Adapter, D3DDEVTYPE  DeviceType,HWND  hFocusWindow, DWORD  BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface, IUnknown *parent) PURE;
 };
 #undef INTERFACE
 
@@ -111,6 +112,7 @@
 #define IWineD3D_AddRef(p)                                (p)->lpVtbl->AddRef(p)
 #define IWineD3D_Release(p)                               (p)->lpVtbl->Release(p)
 /*** IWineD3D methods ***/
+#define IWineD3D_GetParent(p,a)                           (p)->lpVtbl->GetParent(p,a)
 #define IWineD3D_GetAdapterCount(p)                       (p)->lpVtbl->GetAdapterCount(p)
 #define IWineD3D_RegisterSoftwareDevice(p,a)              (p)->lpVtbl->RegisterSoftwareDevice(p,a)
 #define IWineD3D_GetAdapterMonitor(p,a)                   (p)->lpVtbl->GetAdapterMonitor(p,a)
@@ -124,11 +126,11 @@
 #define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f)         (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)
 #define IWineD3D_CheckDeviceFormatConversion(p,a,b,c,d)   (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)
 #define IWineD3D_GetDeviceCaps(p,a,b,c)                   (p)->lpVtbl->GetDeviceCaps(p,a,b,c)
-#define IWineD3D_CreateDevice(p,a,b,c,d,e,f)              (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f)
+#define IWineD3D_CreateDevice(p,a,b,c,d,e,f,g)            (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f,g)
 #endif
 
 /* Define the main WineD3D entrypoint */
-IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion);
+IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent);
 
 /*****************************************************************************
  * WineD3DDevice interface 
@@ -141,10 +143,13 @@
     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
     STDMETHOD_(ULONG,Release)(THIS) PURE;
     /*** IWineD3D methods ***/
-    STDMETHOD(CreateVertexBuffer)(THIS_ UINT  Length,DWORD  Usage,DWORD  FVF,D3DPOOL  Pool,IWineD3DVertexBuffer **ppVertexBuffer, HANDLE *sharedHandle) PURE;
-    STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock **ppStateBlock) PURE;
+    STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
+    STDMETHOD(CreateVertexBuffer)(THIS_ UINT  Length,DWORD  Usage,DWORD  FVF,D3DPOOL  Pool,IWineD3DVertexBuffer **ppVertexBuffer, HANDLE *sharedHandle, IUnknown *parent) PURE;
+    STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock **ppStateBlock, IUnknown *parent) PURE;
     STDMETHOD(SetFVF)(THIS_ DWORD  fvf) PURE;
     STDMETHOD(GetFVF)(THIS_ DWORD * pfvf) PURE;
+    STDMETHOD(SetStreamSource)(THIS_ UINT  StreamNumber,IWineD3DVertexBuffer * pStreamData,UINT Offset,UINT  Stride) PURE;
+    STDMETHOD(GetStreamSource)(THIS_ UINT  StreamNumber,IWineD3DVertexBuffer ** ppStreamData,UINT *pOffset, UINT * pStride) PURE;
 };
 #undef INTERFACE
 
@@ -154,10 +159,13 @@
 #define IWineD3DDevice_AddRef(p)                                (p)->lpVtbl->AddRef(p)
 #define IWineD3DDevice_Release(p)                               (p)->lpVtbl->Release(p)
 /*** IWineD3DDevice methods ***/
-#define IWineD3DDevice_CreateVertexBuffer(p,a,b,c,d,e,f)        (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f)
-#define IWineD3DDevice_CreateStateBlock(p,a,b)                  (p)->lpVtbl->CreateStateBlock(p,a,b)
+#define IWineD3DDevice_GetParent(p,a)                           (p)->lpVtbl->GetParent(p,a)
+#define IWineD3DDevice_CreateVertexBuffer(p,a,b,c,d,e,f,g)      (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e,f,g)
+#define IWineD3DDevice_CreateStateBlock(p,a,b,c)                (p)->lpVtbl->CreateStateBlock(p,a,b,c)
 #define IWineD3DDevice_SetFVF(p,a)                              (p)->lpVtbl->SetFVF(p,a)
 #define IWineD3DDevice_GetFVF(p,a)                              (p)->lpVtbl->GetFVF(p,a)
+#define IWineD3DDevice_SetStreamSource(p,a,b,c,d)               (p)->lpVtbl->SetStreamSource(p,a,b,c,d)
+#define IWineD3DDevice_GetStreamSource(p,a,b,c,d)               (p)->lpVtbl->GetStreamSource(p,a,b,c,d)
 #endif
 
 /*****************************************************************************
@@ -171,6 +179,7 @@
     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
     STDMETHOD_(ULONG,Release)(THIS) PURE;
     /*** IWineD3DResource methods ***/
+    STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
     STDMETHOD(GetDevice)(THIS_ IWineD3DDevice ** ppDevice) PURE;
     STDMETHOD(SetPrivateData)(THIS_ REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags) PURE;
     STDMETHOD(GetPrivateData)(THIS_ REFGUID  refguid, void * pData, DWORD * pSizeOfData) PURE;
@@ -188,6 +197,7 @@
 #define IWineD3DResource_AddRef(p)                    (p)->lpVtbl->AddRef(p)
 #define IWineD3DResource_Release(p)                   (p)->lpVtbl->Release(p)
 /*** IWineD3DResource methods ***/
+#define IWineD3DResource_GetParent(p,a)               (p)->lpVtbl->GetParent(p,a)
 #define IWineD3DResource_GetDevice(p,a)               (p)->lpVtbl->GetDevice(p,a)
 #define IWineD3DResource_SetPrivateData(p,a,b,c,d)    (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
 #define IWineD3DResource_GetPrivateData(p,a,b,c)      (p)->lpVtbl->GetPrivateData(p,a,b,c)
@@ -209,6 +219,7 @@
     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
     STDMETHOD_(ULONG,Release)(THIS) PURE;
     /*** IWineD3DResource methods ***/
+    STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
     STDMETHOD(GetDevice)(THIS_ IWineD3DDevice ** ppDevice) PURE;
     STDMETHOD(SetPrivateData)(THIS_ REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags) PURE;
     STDMETHOD(GetPrivateData)(THIS_ REFGUID  refguid, void * pData, DWORD * pSizeOfData) PURE;
@@ -230,6 +241,7 @@
 #define IWineD3DVertexBuffer_AddRef(p)                    (p)->lpVtbl->AddRef(p)
 #define IWineD3DVertexBuffer_Release(p)                   (p)->lpVtbl->Release(p)
 /*** IWineD3DResource methods ***/
+#define IWineD3DVertexBuffer_GetParent(p,a)               (p)->lpVtbl->GetParent(p,a)
 #define IWineD3DVertexBuffer_GetDevice(p,a)               (p)->lpVtbl->GetDevice(p,a)
 #define IWineD3DVertexBuffer_SetPrivateData(p,a,b,c,d)    (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
 #define IWineD3DVertexBuffer_GetPrivateData(p,a,b,c)      (p)->lpVtbl->GetPrivateData(p,a,b,c)
@@ -255,6 +267,7 @@
     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
     STDMETHOD_(ULONG,Release)(THIS) PURE;
     /*** IWineD3DStateBlock methods ***/
+    STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
     STDMETHOD(InitStartupStateBlock)(THIS) PURE;
 };
 #undef INTERFACE
@@ -265,6 +278,7 @@
 #define IWineD3DStateBlock_AddRef(p)                            (p)->lpVtbl->AddRef(p)
 #define IWineD3DStateBlock_Release(p)                           (p)->lpVtbl->Release(p)
 /*** IWineD3DStateBlock methods ***/
+#define IWineD3DStateBlock_GetParent(p,a)                       (p)->lpVtbl->GetParent(p,a)
 #define IWineD3DStateBlock_InitStartupStateBlock(p)             (p)->lpVtbl->InitStartupStateBlock(p)
 #endif
 
