diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index 3fe0376e5c1..b07d72a0662 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -251,6 +251,7 @@ struct d3d9_vertex_declaration LONG refcount; D3DVERTEXELEMENT9 *elements; UINT element_count; + DWORD stream_map; struct wined3d_vertex_declaration *wined3d_declaration; DWORD fvf; IDirect3DDevice9Ex *parent_device; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 6cc3f180b09..5d59fd570ce 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2730,9 +2730,11 @@ static void d3d9_generate_auto_mipmaps(struct d3d9_device *device) static void d3d9_device_upload_sysmem_vertex_buffers(struct d3d9_device *device, int base_vertex, unsigned int start_vertex, unsigned int vertex_count) { + struct wined3d_vertex_declaration *wined3d_decl; struct wined3d_box box = {0, 0, 0, 1, 0, 1}; struct d3d9_vertexbuffer *d3d9_buffer; struct wined3d_resource *dst_resource; + struct d3d9_vertex_declaration *decl; unsigned int i, offset, stride, map; struct wined3d_buffer *dst_buffer; struct wined3d_resource_desc desc; @@ -2740,13 +2742,17 @@ static void d3d9_device_upload_sysmem_vertex_buffers(struct d3d9_device *device, if (!device->sysmem_vb) return; + wined3d_decl = wined3d_device_get_vertex_declaration(device->wined3d_device); + if (!wined3d_decl) + return; if (base_vertex >= 0 || start_vertex >= -base_vertex) start_vertex += base_vertex; else FIXME("System memory vertex data offset is negative.\n"); - map = device->sysmem_vb; + decl = wined3d_vertex_declaration_get_parent(wined3d_decl); + map = decl->stream_map & device->sysmem_vb; while (map) { i = wined3d_bit_scan(&map); diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c index b6445255238..130383e5d1e 100644 --- a/dlls/d3d9/vertexdeclaration.c +++ b/dlls/d3d9/vertexdeclaration.c @@ -321,7 +321,7 @@ static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops }; static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements, - struct wined3d_vertex_element **wined3d_elements, UINT *element_count) + struct wined3d_vertex_element **wined3d_elements, UINT *element_count, DWORD *stream_map) { const D3DVERTEXELEMENT9* element; UINT count = 1; @@ -329,6 +329,8 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem TRACE("d3d9_elements %p, wined3d_elements %p, element_count %p\n", d3d9_elements, wined3d_elements, element_count); + *stream_map = 0; + element = d3d9_elements; while (element++->Stream != 0xff && count++ < 128); @@ -360,6 +362,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem (*wined3d_elements)[i].method = d3d9_elements[i].Method; (*wined3d_elements)[i].usage = d3d9_elements[i].Usage; (*wined3d_elements)[i].usage_idx = d3d9_elements[i].UsageIndex; + *stream_map |= 1u << d3d9_elements[i].Stream; } *element_count = count; @@ -375,7 +378,8 @@ static HRESULT vertexdeclaration_init(struct d3d9_vertex_declaration *declaratio UINT element_count; HRESULT hr; - hr = convert_to_wined3d_declaration(elements, &wined3d_elements, &wined3d_element_count); + hr = convert_to_wined3d_declaration(elements, &wined3d_elements, &wined3d_element_count, + &declaration->stream_map); if (FAILED(hr)) { WARN("Failed to create wined3d vertex declaration elements, hr %#x.\n", hr);