Module: wine Branch: master Commit: 55b63fe095894d2135e2c04436d0d728c8540575 URL: http://source.winehq.org/git/wine.git/?a=commit;h=55b63fe095894d2135e2c04436...
Author: Stefan Dösinger stefan@codeweavers.com Date: Tue Aug 14 14:49:39 2007 +0200
wined3d: Reinstall the internal reference on vertex buffers.
---
dlls/wined3d/device.c | 8 ++++++++ dlls/wined3d/stateblock.c | 7 +++++++ 2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 86507a0..8852e4a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2240,9 +2240,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface, if (pStreamData != NULL) { IWineD3DVertexBufferImpl *vbImpl = (IWineD3DVertexBufferImpl *) pStreamData; InterlockedIncrement(&vbImpl->bindCount); + IWineD3DVertexBuffer_AddRef(pStreamData); } if (oldSrc != NULL) { InterlockedDecrement(&((IWineD3DVertexBufferImpl *) oldSrc)->bindCount); + IWineD3DVertexBuffer_Release(oldSrc); }
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); @@ -4752,13 +4754,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + IWineD3DVertexBuffer *vb;
TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType), PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */ + vb = This->stateBlock->streamSource[0]; This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData; + if(vb) IWineD3DVertexBuffer_Release(vb); This->stateBlock->streamOffset[0] = 0; This->stateBlock->streamStride[0] = VertexStreamZeroStride; This->stateBlock->streamIsUP = TRUE; @@ -4787,6 +4792,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice * UINT VertexStreamZeroStride) { int idxStride; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + IWineD3DVertexBuffer *vb; IWineD3DIndexBuffer *ib;
TRACE("(%p) : Type=(%d,%s), MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n", @@ -4801,7 +4807,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice * }
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */ + vb = This->stateBlock->streamSource[0]; This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData; + if(vb) IWineD3DVertexBuffer_Release(vb); This->stateBlock->streamIsUP = TRUE; This->stateBlock->streamOffset[0] = 0; This->stateBlock->streamStride[0] = VertexStreamZeroStride; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 772bd78..6ab6247 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -262,6 +262,13 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) { } } } + for (counter = 0; counter < MAX_STREAMS; counter++) { + if(This->streamSource[counter]) { + if(0 != IWineD3DVertexBuffer_Release(This->streamSource[counter])) { + TRACE("Vertex buffer still referenced by stateblock, applications has leaked Stream %u, buffer %p\n", counter, This->streamSource[counter]); + } + } + } if(This->pIndexData) IWineD3DIndexBuffer_Release(This->pIndexData);
}