Henri Verbeet : d3d9: Add a separate function for vertex buffer initialization.
Alexandre Julliard
julliard at winehq.org
Fri Sep 18 13:37:09 CDT 2009
Module: wine
Branch: master
Commit: de9b47924df6d479ba867da889b4e435b8f1ce86
URL: http://source.winehq.org/git/wine.git/?a=commit;h=de9b47924df6d479ba867da889b4e435b8f1ce86
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Sep 17 23:03:29 2009 +0200
d3d9: Add a separate function for vertex buffer initialization.
---
dlls/d3d9/d3d9_private.h | 6 +++---
dlls/d3d9/device.c | 31 +++++++++++++++++++++++++++++++
dlls/d3d9/vertexbuffer.c | 46 ++++++++++++++++------------------------------
3 files changed, 50 insertions(+), 33 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 99ad4b6..bea76d9 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -197,9 +197,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDe
extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface,
UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) DECLSPEC_HIDDEN;
extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface,
- UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool,
- IDirect3DVertexBuffer9 **ppVertexBuffer, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface,
D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9 **ppSB) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN;
@@ -354,6 +351,9 @@ typedef struct IDirect3DVertexBuffer9Impl
DWORD fvf;
} IDirect3DVertexBuffer9Impl;
+HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
+ UINT size, UINT usage, DWORD fvf, D3DPOOL pool) DECLSPEC_HIDDEN;
+
/* --------------------- */
/* IDirect3DIndexBuffer9 */
/* --------------------- */
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index a5d6858..86890ff 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -742,6 +742,37 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex
return D3D_OK;
}
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface, UINT size, DWORD usage,
+ DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer9 **buffer, HANDLE *shared_handle)
+{
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DVertexBuffer9Impl *object;
+ HRESULT hr;
+
+ TRACE("iface %p, size %u, usage %#x, fvf %#x, pool %#x, buffer %p, shared_handle %p.\n",
+ iface, size, usage, fvf, pool, buffer, shared_handle);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate buffer memory.\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = vertexbuffer_init(object, This, size, usage, fvf, pool);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created vertex buffer %p.\n", object);
+ *buffer = (IDirect3DVertexBuffer9 *)object;
+
+ return D3D_OK;
+}
+
static HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex *iface, UINT size, DWORD usage,
D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer9 **buffer, HANDLE *shared_handle)
{
diff --git a/dlls/d3d9/vertexbuffer.c b/dlls/d3d9/vertexbuffer.c
index 226e113..aead622 100644
--- a/dlls/d3d9/vertexbuffer.c
+++ b/dlls/d3d9/vertexbuffer.c
@@ -233,41 +233,27 @@ static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
IDirect3DVertexBuffer9Impl_GetDesc
};
-
-/* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
-HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface, UINT Size, DWORD Usage,
- DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle)
+HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
+ UINT size, UINT usage, DWORD fvf, D3DPOOL pool)
{
- IDirect3DVertexBuffer9Impl *object;
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hrc = D3D_OK;
-
- /* Allocate the storage for the device */
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
- if (NULL == object) {
- FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
- return D3DERR_OUTOFVIDEOMEMORY;
- }
+ HRESULT hr;
- object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
- object->ref = 1;
- object->fvf = FVF;
+ buffer->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
+ buffer->ref = 1;
+ buffer->fvf = fvf;
wined3d_mutex_lock();
- hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK,
- 0 /* fvf for ddraw only */, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), (IUnknown *)object);
+ hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+ 0 /* fvf for ddraw only */, (WINED3DPOOL)pool, &buffer->wineD3DVertexBuffer, (IUnknown *)buffer);
wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
+ return hr;
+ }
- if (hrc != D3D_OK) {
+ buffer->parentDevice = (IDirect3DDevice9Ex *)device;
+ IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
- /* free up object */
- WARN("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
- HeapFree(GetProcessHeap(), 0, object);
- } else {
- IDirect3DDevice9Ex_AddRef(iface);
- object->parentDevice = iface;
- TRACE("(%p) : Created vertex buffer %p\n", This, object);
- *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
- }
- return hrc;
+ return D3D_OK;
}
More information about the wine-cvs
mailing list