Commit 55b63fe0 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Reinstall the internal reference on vertex buffers.

parent a7a0d4df
...@@ -2240,9 +2240,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface, ...@@ -2240,9 +2240,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface,
if (pStreamData != NULL) { if (pStreamData != NULL) {
IWineD3DVertexBufferImpl *vbImpl = (IWineD3DVertexBufferImpl *) pStreamData; IWineD3DVertexBufferImpl *vbImpl = (IWineD3DVertexBufferImpl *) pStreamData;
InterlockedIncrement(&vbImpl->bindCount); InterlockedIncrement(&vbImpl->bindCount);
IWineD3DVertexBuffer_AddRef(pStreamData);
} }
if (oldSrc != NULL) { if (oldSrc != NULL) {
InterlockedDecrement(&((IWineD3DVertexBufferImpl *) oldSrc)->bindCount); InterlockedDecrement(&((IWineD3DVertexBufferImpl *) oldSrc)->bindCount);
IWineD3DVertexBuffer_Release(oldSrc);
} }
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
...@@ -4752,13 +4754,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, ...@@ -4752,13 +4754,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT PrimitiveCount, CONST void* pVertexStreamZeroData,
UINT VertexStreamZeroStride) { UINT VertexStreamZeroStride) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexBuffer *vb;
TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType, TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType,
debug_d3dprimitivetype(PrimitiveType), debug_d3dprimitivetype(PrimitiveType),
PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride); PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */ /* 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; This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
if(vb) IWineD3DVertexBuffer_Release(vb);
This->stateBlock->streamOffset[0] = 0; This->stateBlock->streamOffset[0] = 0;
This->stateBlock->streamStride[0] = VertexStreamZeroStride; This->stateBlock->streamStride[0] = VertexStreamZeroStride;
This->stateBlock->streamIsUP = TRUE; This->stateBlock->streamIsUP = TRUE;
...@@ -4787,6 +4792,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice * ...@@ -4787,6 +4792,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
UINT VertexStreamZeroStride) { UINT VertexStreamZeroStride) {
int idxStride; int idxStride;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexBuffer *vb;
IWineD3DIndexBuffer *ib; IWineD3DIndexBuffer *ib;
TRACE("(%p) : Type=(%d,%s), MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n", 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 * ...@@ -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 */ /* 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; This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
if(vb) IWineD3DVertexBuffer_Release(vb);
This->stateBlock->streamIsUP = TRUE; This->stateBlock->streamIsUP = TRUE;
This->stateBlock->streamOffset[0] = 0; This->stateBlock->streamOffset[0] = 0;
This->stateBlock->streamStride[0] = VertexStreamZeroStride; This->stateBlock->streamStride[0] = VertexStreamZeroStride;
......
...@@ -262,6 +262,13 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) { ...@@ -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); if(This->pIndexData) IWineD3DIndexBuffer_Release(This->pIndexData);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment