Commit b500ae04 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Implement d3d11_device_CreateBuffer().

parent 4444917f
......@@ -376,8 +376,8 @@ static const struct wined3d_parent_ops d3d10_buffer_wined3d_parent_ops =
d3d10_buffer_wined3d_object_released,
};
HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *device,
const D3D11_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data)
static HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *device,
const D3D11_BUFFER_DESC *desc, const D3D11_SUBRESOURCE_DATA *data)
{
struct wined3d_buffer_desc wined3d_desc;
HRESULT hr;
......@@ -414,3 +414,25 @@ HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *device,
return S_OK;
}
HRESULT d3d_buffer_create(struct d3d_device *device, const D3D11_BUFFER_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d_buffer **buffer)
{
struct d3d_buffer *object;
HRESULT hr;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d_buffer_init(object, device, desc, data)))
{
WARN("Failed to initialize buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created buffer %p.\n", object);
*buffer = object;
return S_OK;
}
......@@ -145,8 +145,8 @@ struct d3d_buffer
ID3D11Device *device;
};
HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *device,
const D3D11_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data) DECLSPEC_HIDDEN;
HRESULT d3d_buffer_create(struct d3d_device *device, const D3D11_BUFFER_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d_buffer **buffer) DECLSPEC_HIDDEN;
struct d3d_buffer *unsafe_impl_from_ID3D10Buffer(ID3D10Buffer *iface) DECLSPEC_HIDDEN;
/* ID3D10DepthStencilView */
......
......@@ -59,9 +59,18 @@ static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface)
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer)
{
FIXME("iface %p, desc %p, data %p, buffer %p stub!\n", iface, desc, data, buffer);
struct d3d_device *device = impl_from_ID3D11Device(iface);
struct d3d_buffer *object;
HRESULT hr;
return E_NOTIMPL;
TRACE("iface %p, desc %p, data %p, buffer %p.\n", iface, desc, data, buffer);
if (FAILED(hr = d3d_buffer_create(device, desc, data, &object)))
return hr;
*buffer = &object->ID3D11Buffer_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
......@@ -1985,7 +1994,7 @@ static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Buffer **buffer)
{
struct d3d_device *This = impl_from_ID3D10Device(iface);
struct d3d_device *device = impl_from_ID3D10Device(iface);
D3D11_BUFFER_DESC d3d11_desc;
struct d3d_buffer *object;
HRESULT hr;
......@@ -1999,22 +2008,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
d3d11_desc.StructureByteStride = 0;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
hr = d3d_buffer_init(object, This, &d3d11_desc, data);
if (FAILED(hr))
{
WARN("Failed to initialize buffer, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
if (FAILED(hr = d3d_buffer_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
return hr;
}
*buffer = &object->ID3D10Buffer_iface;
TRACE("Created ID3D10Buffer %p\n", object);
return S_OK;
}
......
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