Commit 9c676e6c authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

Changed index and vertex buffer so that internal references are

counted separately to external ones.
parent defdb25d
......@@ -790,6 +790,7 @@ struct IDirect3DVertexBuffer8Impl
/* IUnknown fields */
const IDirect3DVertexBuffer8Vtbl *lpVtbl;
LONG ref;
LONG refInt;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
......@@ -805,6 +806,10 @@ extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface);
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface);
/* Internal */
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRefInt(LPDIRECT3DVERTEXBUFFER8 iface);
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_ReleaseInt(LPDIRECT3DVERTEXBUFFER8 iface);
/* IDirect3DVertexBuffer8: (Inherited from IDirect3DResource8) */
extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice);
extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
......@@ -838,6 +843,7 @@ struct IDirect3DIndexBuffer8Impl
/* IUnknown fields */
const IDirect3DIndexBuffer8Vtbl *lpVtbl;
LONG ref;
LONG refInt;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
......@@ -853,6 +859,10 @@ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface);
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface);
/* Internal */
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRefInt(LPDIRECT3DINDEXBUFFER8 iface);
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_ReleaseInt(LPDIRECT3DINDEXBUFFER8 iface);
/* IDirect3DIndexBuffer8: (Inherited from IDirect3DResource8) */
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice);
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
......
......@@ -4164,8 +4164,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirec
return D3D_OK;
}
if (oldIdxs) IDirect3DIndexBuffer8Impl_Release(oldIdxs);
if (pIndexData) IDirect3DIndexBuffer8Impl_AddRef(This->StateBlock->pIndexData);
if (pIndexData) IDirect3DIndexBuffer8Impl_AddRefInt(This->StateBlock->pIndexData);
if (oldIdxs) IDirect3DIndexBuffer8Impl_ReleaseInt(oldIdxs);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
......@@ -4337,8 +4337,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, U
return D3D_OK;
}
if (oldSrc != NULL) IDirect3DVertexBuffer8Impl_Release(oldSrc);
if (pStreamData != NULL) IDirect3DVertexBuffer8Impl_AddRef(pStreamData);
if (pStreamData != NULL) IDirect3DVertexBuffer8Impl_AddRefInt(pStreamData);
if (oldSrc != NULL) IDirect3DVertexBuffer8Impl_ReleaseInt(oldSrc);
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
......
......@@ -64,13 +64,42 @@ ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
if (ref == 0 && 0 == This->refInt) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
HeapFree(GetProcessHeap(), 0, This);
} else if (0 == ref) {
WARN("(%p) : The application failed to set indicies NULL before releasing the index buffer, leak\n", This);
}
return ref;
}
ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRefInt(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
ULONG refInt = InterlockedIncrement(&This->refInt);
TRACE("(%p) : AddRefInt from %ld\n", This, refInt - 1);
return refInt;
}
ULONG WINAPI IDirect3DIndexBuffer8Impl_ReleaseInt(LPDIRECT3DINDEXBUFFER8 iface) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
ULONG refInt = InterlockedDecrement(&This->refInt);
TRACE("(%p) : ReleaseRefInt to %ld\n", This, refInt);
if (0 == This->ref && 0 == refInt) {
WARN("(%p) : Cleaning up after the calling application failed to release the indicies properly\n", This);
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
HeapFree(GetProcessHeap(), 0, This);
}
return refInt;
}
/* IDirect3DResource Interface follow: */
HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
......
......@@ -64,13 +64,40 @@ ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
if (ref == 0 && 0 == This->refInt) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
HeapFree(GetProcessHeap(), 0, This);
} else if (0 == ref) {
WARN("(%p) : The application failed to set Stream source to NULL before releasing the vertex shader, leak\n", This);
}
return ref;
}
ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRefInt(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
ULONG refInt = InterlockedIncrement(&This->refInt);
TRACE("(%p) : AddRefInt from %ld\n", This, refInt - 1);
return refInt;
}
ULONG WINAPI IDirect3DVertexBuffer8Impl_ReleaseInt(LPDIRECT3DVERTEXBUFFER8 iface) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
ULONG refInt = InterlockedDecrement(&This->refInt);
TRACE("(%p) : ReleaseRefInt to %ld\n", This, refInt);
if (0 == This->ref && 0 == refInt) {
WARN("(%p) : Cleaning up after the calling application failed to release the stream source properly\n", This);
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
HeapFree(GetProcessHeap(), 0, This);
}
return refInt;
}
/* IDirect3DResource Interface follow: */
HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
......
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