Changed index and vertex buffer so that internal references are
counted separately to external ones.
This commit is contained in:
parent
defdb25d9a
commit
9c676e6c19
|
@ -790,6 +790,7 @@ struct IDirect3DVertexBuffer8Impl
|
||||||
/* IUnknown fields */
|
/* IUnknown fields */
|
||||||
const IDirect3DVertexBuffer8Vtbl *lpVtbl;
|
const IDirect3DVertexBuffer8Vtbl *lpVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
LONG refInt;
|
||||||
|
|
||||||
/* IDirect3DResource8 fields */
|
/* IDirect3DResource8 fields */
|
||||||
IDirect3DDevice8Impl *Device;
|
IDirect3DDevice8Impl *Device;
|
||||||
|
@ -805,6 +806,10 @@ extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT
|
||||||
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface);
|
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface);
|
||||||
extern ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(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) */
|
/* IDirect3DVertexBuffer8: (Inherited from IDirect3DResource8) */
|
||||||
extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8** ppDevice);
|
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);
|
extern HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
|
||||||
|
@ -838,6 +843,7 @@ struct IDirect3DIndexBuffer8Impl
|
||||||
/* IUnknown fields */
|
/* IUnknown fields */
|
||||||
const IDirect3DIndexBuffer8Vtbl *lpVtbl;
|
const IDirect3DIndexBuffer8Vtbl *lpVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
LONG refInt;
|
||||||
|
|
||||||
/* IDirect3DResource8 fields */
|
/* IDirect3DResource8 fields */
|
||||||
IDirect3DDevice8Impl *Device;
|
IDirect3DDevice8Impl *Device;
|
||||||
|
@ -853,6 +859,10 @@ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3
|
||||||
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface);
|
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface);
|
||||||
extern ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(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) */
|
/* IDirect3DIndexBuffer8: (Inherited from IDirect3DResource8) */
|
||||||
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice);
|
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);
|
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;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldIdxs) IDirect3DIndexBuffer8Impl_Release(oldIdxs);
|
if (pIndexData) IDirect3DIndexBuffer8Impl_AddRefInt(This->StateBlock->pIndexData);
|
||||||
if (pIndexData) IDirect3DIndexBuffer8Impl_AddRef(This->StateBlock->pIndexData);
|
if (oldIdxs) IDirect3DIndexBuffer8Impl_ReleaseInt(oldIdxs);
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
|
HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
|
||||||
|
@ -4337,8 +4337,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, U
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldSrc != NULL) IDirect3DVertexBuffer8Impl_Release(oldSrc);
|
if (pStreamData != NULL) IDirect3DVertexBuffer8Impl_AddRefInt(pStreamData);
|
||||||
if (pStreamData != NULL) IDirect3DVertexBuffer8Impl_AddRef(pStreamData);
|
if (oldSrc != NULL) IDirect3DVertexBuffer8Impl_ReleaseInt(oldSrc);
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
|
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);
|
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->allocatedMemory);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
return ref;
|
|
||||||
|
return refInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* IDirect3DResource Interface follow: */
|
/* IDirect3DResource Interface follow: */
|
||||||
HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
|
HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
|
||||||
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
|
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
|
||||||
|
|
|
@ -64,11 +64,38 @@ ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
|
||||||
|
|
||||||
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
|
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->allocatedMemory);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
}
|
}
|
||||||
return ref;
|
|
||||||
|
return refInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IDirect3DResource Interface follow: */
|
/* IDirect3DResource Interface follow: */
|
||||||
|
|
Loading…
Reference in New Issue