Commit c2a240e8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Add a separate function for d3d10_buffer initialization.

parent 22124bc5
......@@ -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;
}
......@@ -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
......
......@@ -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;
}
......
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