From c2a240e8c09fc38c484d36e7add5ef19cfc839f0 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 17 Sep 2009 23:03:27 +0200 Subject: [PATCH] d3d10core: Add a separate function for d3d10_buffer initialization. --- dlls/d3d10core/buffer.c | 30 +++++++++++++++++++++++++++++- dlls/d3d10core/d3d10core_private.h | 4 +++- dlls/d3d10core/device.c | 17 ++--------------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/dlls/d3d10core/buffer.c b/dlls/d3d10core/buffer.c index a4198c16351..d27e1ea5b0a 100644 --- a/dlls/d3d10core/buffer.c +++ b/dlls/d3d10core/buffer.c @@ -145,7 +145,7 @@ static void STDMETHODCALLTYPE d3d10_buffer_GetDesc(ID3D10Buffer *iface, D3D10_BU FIXME("iface %p, desc %p stub!\n", iface, desc); } -const struct ID3D10BufferVtbl d3d10_buffer_vtbl = +static const struct ID3D10BufferVtbl d3d10_buffer_vtbl = { /* IUnknown methods */ d3d10_buffer_QueryInterface, @@ -165,3 +165,31 @@ const struct ID3D10BufferVtbl d3d10_buffer_vtbl = d3d10_buffer_Unmap, d3d10_buffer_GetDesc, }; + +HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *device, + const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data) +{ + struct wined3d_buffer_desc wined3d_desc; + HRESULT hr; + + buffer->vtbl = &d3d10_buffer_vtbl; + buffer->refcount = 1; + + FIXME("Implement DXGI<->wined3d usage conversion\n"); + + wined3d_desc.byte_width = desc->ByteWidth; + wined3d_desc.usage = desc->Usage; + wined3d_desc.bind_flags = desc->BindFlags; + wined3d_desc.cpu_access_flags = desc->CPUAccessFlags; + wined3d_desc.misc_flags = desc->MiscFlags; + + hr = IWineD3DDevice_CreateBuffer(device->wined3d_device, &wined3d_desc, + data ? data->pSysMem : NULL, (IUnknown *)buffer, &buffer->wined3d_buffer); + if (FAILED(hr)) + { + WARN("Failed to create wined3d buffer, hr %#x.\n", hr); + return hr; + } + + return S_OK; +} diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 4257b2ea0be..ad03b47a839 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -96,7 +96,6 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic const D3D10_TEXTURE2D_DESC *desc); /* ID3D10Buffer */ -extern const struct ID3D10BufferVtbl d3d10_buffer_vtbl; struct d3d10_buffer { const struct ID3D10BufferVtbl *vtbl; @@ -105,6 +104,9 @@ struct d3d10_buffer IWineD3DBuffer *wined3d_buffer; }; +HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *device, + const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data); + /* ID3D10RenderTargetView */ extern const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl; struct d3d10_rendertarget_view diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 6b685b06b02..80cbc61b627 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -618,7 +618,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface, const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer) { struct d3d10_device *This = (struct d3d10_device *)iface; - struct wined3d_buffer_desc wined3d_desc; struct d3d10_buffer *object; HRESULT hr; @@ -631,22 +630,10 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface, return E_OUTOFMEMORY; } - object->vtbl = &d3d10_buffer_vtbl; - object->refcount = 1; - - FIXME("Implement DXGI<->wined3d usage conversion\n"); - - wined3d_desc.byte_width = desc->ByteWidth; - wined3d_desc.usage = desc->Usage; - wined3d_desc.bind_flags = desc->BindFlags; - wined3d_desc.cpu_access_flags = desc->CPUAccessFlags; - wined3d_desc.misc_flags = desc->MiscFlags; - - hr = IWineD3DDevice_CreateBuffer(This->wined3d_device, &wined3d_desc, - data ? data->pSysMem : NULL, (IUnknown *)object, &object->wined3d_buffer); + hr = d3d10_buffer_init(object, This, desc, data); if (FAILED(hr)) { - ERR("CreateBuffer failed, returning %#x\n", hr); + WARN("Failed to initialize buffer, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); return hr; }