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

d3d8: Clamp vertex buffer upload range to buffer size.

parent a15d4de5
......@@ -2271,8 +2271,10 @@ static void d3d8_device_upload_sysmem_vertex_buffers(struct d3d8_device *device,
{
struct wined3d_box box = {0, 0, 0, 1, 0, 1};
struct d3d8_vertexbuffer *d3d8_buffer;
struct wined3d_resource *dst_resource;
unsigned int i, offset, stride, map;
struct wined3d_buffer *dst_buffer;
struct wined3d_resource_desc desc;
HRESULT hr;
map = device->sysmem_vb;
......@@ -2284,10 +2286,12 @@ static void d3d8_device_upload_sysmem_vertex_buffers(struct d3d8_device *device,
if (FAILED(hr = wined3d_device_get_stream_source(device->wined3d_device, i, &dst_buffer, &offset, &stride)))
ERR("Failed to get stream source.\n");
d3d8_buffer = wined3d_buffer_get_parent(dst_buffer);
dst_resource = wined3d_buffer_get_resource(dst_buffer);
wined3d_resource_get_desc(dst_resource, &desc);
box.left = offset + start_vertex * stride;
box.right = box.left + vertex_count * stride;
box.right = min(box.left + vertex_count * stride, desc.size);
if (FAILED(hr = wined3d_device_copy_sub_resource_region(device->wined3d_device,
wined3d_buffer_get_resource(dst_buffer), 0, box.left, 0, 0,
dst_resource, 0, box.left, 0, 0,
wined3d_buffer_get_resource(d3d8_buffer->wined3d_buffer), 0, &box, 0)))
ERR("Failed to update buffer.\n");
}
......
......@@ -10687,7 +10687,7 @@ static void test_sysmem_draw(void)
hr = IDirect3DDevice8_BeginScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 4, 0, 2);
hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 5, 0, 2);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice8_EndScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", 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