Commit 4ccbc948 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Set the initial buffer data, when present.

parent 05914424
...@@ -620,7 +620,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface, ...@@ -620,7 +620,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
wined3d_desc.misc_flags = desc->MiscFlags; wined3d_desc.misc_flags = desc->MiscFlags;
hr = IWineD3DDevice_CreateBuffer(This->wined3d_device, &wined3d_desc, hr = IWineD3DDevice_CreateBuffer(This->wined3d_device, &wined3d_desc,
(IUnknown *)object, &object->wined3d_buffer); data ? data->pSysMem : NULL, (IUnknown *)object, &object->wined3d_buffer);
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("CreateBuffer failed, returning %#x\n", hr); ERR("CreateBuffer failed, returning %#x\n", hr);
......
...@@ -435,13 +435,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetParent(IWineD3DDevice *iface, IUnkno ...@@ -435,13 +435,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetParent(IWineD3DDevice *iface, IUnkno
} }
static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface,
struct wined3d_buffer_desc *desc, IUnknown *parent, IWineD3DBuffer **buffer) struct wined3d_buffer_desc *desc, const void *data, IUnknown *parent, IWineD3DBuffer **buffer)
{ {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_buffer *object; struct wined3d_buffer *object;
HRESULT hr; HRESULT hr;
TRACE("iface %p, desc %p, parent %p, buffer %p\n", iface, desc, parent, buffer); TRACE("iface %p, desc %p, data %p, parent %p, buffer %p\n", iface, desc, data, parent, buffer);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object) if (!object)
...@@ -471,6 +471,29 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, ...@@ -471,6 +471,29 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface,
TRACE("size %#x, usage=%#x, format %s, memory @ %p, iface @ %p\n", object->resource.size, object->resource.usage, TRACE("size %#x, usage=%#x, format %s, memory @ %p, iface @ %p\n", object->resource.size, object->resource.usage,
debug_d3dformat(object->resource.format_desc->format), object->resource.allocatedMemory, object); debug_d3dformat(object->resource.format_desc->format), object->resource.allocatedMemory, object);
if (data)
{
BYTE *ptr;
hr = IWineD3DBuffer_Map((IWineD3DBuffer *)object, 0, desc->byte_width, &ptr, 0);
if (FAILED(hr))
{
ERR("Failed to map buffer, hr %#x\n", hr);
IWineD3DBuffer_Release((IWineD3DBuffer *)object);
return hr;
}
memcpy(ptr, data, desc->byte_width);
hr = IWineD3DBuffer_Unmap((IWineD3DBuffer *)object);
if (FAILED(hr))
{
ERR("Failed to unmap buffer, hr %#x\n", hr);
IWineD3DBuffer_Release((IWineD3DBuffer *)object);
return hr;
}
}
*buffer = (IWineD3DBuffer *)object; *buffer = (IWineD3DBuffer *)object;
return WINED3D_OK; return WINED3D_OK;
......
...@@ -2909,6 +2909,7 @@ interface IWineD3DDevice : IWineD3DBase ...@@ -2909,6 +2909,7 @@ interface IWineD3DDevice : IWineD3DBase
{ {
HRESULT CreateBuffer( HRESULT CreateBuffer(
[in] struct wined3d_buffer_desc *desc, [in] struct wined3d_buffer_desc *desc,
[in] const void *data,
[in] IUnknown *parent, [in] IUnknown *parent,
[out] IWineD3DBuffer **buffer [out] IWineD3DBuffer **buffer
); );
......
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