Commit 59de77ea authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Use resource mapping functions in d3d_device7_DrawIndexedPrimitive().

parent 215e3481
......@@ -3689,8 +3689,10 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
HRESULT hr;
UINT stride = get_flexible_vertex_size(fvf);
UINT vtx_size = stride * vertex_count, idx_size = index_count * sizeof(*indices);
struct wined3d_map_desc wined3d_map_desc;
struct wined3d_box wined3d_box = {0};
struct wined3d_resource *ib, *vb;
UINT vb_pos, ib_pos, align;
BYTE *data;
TRACE("iface %p, primitive_type %#x, fvf %#x, vertices %p, vertex_count %u, "
"indices %p, index_count %u, flags %#x.\n",
......@@ -3717,12 +3719,14 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
else
vb_pos += align;
hr = wined3d_buffer_map(device->vertex_buffer, vb_pos, vtx_size, &data,
vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD);
if (FAILED(hr))
wined3d_box.left = vb_pos;
wined3d_box.right = vb_pos + vtx_size;
vb = wined3d_buffer_get_resource(device->vertex_buffer);
if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box,
vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
goto done;
memcpy(data, vertices, vtx_size);
wined3d_buffer_unmap(device->vertex_buffer);
memcpy(wined3d_map_desc.data, vertices, vtx_size);
wined3d_resource_unmap(vb, 0);
device->vertex_buffer_pos = vb_pos + vtx_size;
hr = d3d_device_prepare_index_buffer(device, idx_size);
......@@ -3732,12 +3736,14 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
if (device->index_buffer_size - idx_size < ib_pos)
ib_pos = 0;
hr = wined3d_buffer_map(device->index_buffer, ib_pos, idx_size, &data,
ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD);
if (FAILED(hr))
wined3d_box.left = ib_pos;
wined3d_box.right = ib_pos + idx_size;
ib = wined3d_buffer_get_resource(device->index_buffer);
if (FAILED(hr = wined3d_resource_map(ib, 0, &wined3d_map_desc, &wined3d_box,
ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD)))
goto done;
memcpy(data, indices, idx_size);
wined3d_buffer_unmap(device->index_buffer);
memcpy(wined3d_map_desc.data, indices, idx_size);
wined3d_resource_unmap(ib, 0);
device->index_buffer_pos = ib_pos + idx_size;
hr = wined3d_device_set_stream_source(device->wined3d_device, 0, device->vertex_buffer, 0, stride);
......
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