Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Add a couple of small comments. v3: Split the test out to a separate patch, remove comment again since it doesn't apply anymore.
dlls/d3d8/d3d8_private.h | 2 ++ dlls/d3d8/device.c | 29 +++++++++++++++++++++++++++-- dlls/d3d8/vertexdeclaration.c | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 7c44f07c5ea..f3cab96f9d8 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -255,6 +255,8 @@ struct d3d8_vertex_declaration DWORD shader_handle; };
+UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, + struct wined3d_vertex_element **wined3d_elements) DECLSPEC_HIDDEN; void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration) DECLSPEC_HIDDEN; HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration, struct d3d8_device *device, const DWORD *elements, DWORD shader_handle) DECLSPEC_HIDDEN; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index d367f4200cc..140df07a033 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2269,15 +2269,40 @@ static HRESULT WINAPI d3d8_device_GetCurrentTexturePalette(IDirect3DDevice8 *ifa static void d3d8_device_upload_sysmem_vertex_buffers(struct d3d8_device *device, unsigned int start_vertex, unsigned int vertex_count) { + struct wined3d_vertex_declaration *wined3d_decl; struct wined3d_box box = {0, 0, 0, 1, 0, 1}; + unsigned int i, offset, stride, map, count; + struct wined3d_vertex_element *elements; struct d3d8_vertexbuffer *d3d8_buffer; struct wined3d_resource *dst_resource; - unsigned int i, offset, stride, map; + struct d3d8_vertex_declaration *decl; struct wined3d_buffer *dst_buffer; struct wined3d_resource_desc desc; HRESULT hr;
- map = device->sysmem_vb; + if (!device->sysmem_vb) + return; + + wined3d_decl = wined3d_device_get_vertex_declaration(device->wined3d_device); + if (!wined3d_decl) + return; + + decl = wined3d_vertex_declaration_get_parent(wined3d_decl); + if (!decl->elements) + { + map = 1; + } + else + { + map = 0; + count = convert_to_wined3d_declaration(decl->elements, &decl->elements_size, &elements); + if (!count) + return; + for (i = 0; i < count; ++i) + map |= 1u << elements[i].input_slot; + heap_free(elements); + } + map &= device->sysmem_vb; while (map) { i = wined3d_bit_scan(&map); diff --git a/dlls/d3d8/vertexdeclaration.c b/dlls/d3d8/vertexdeclaration.c index 709e04bace4..3c05101cb7f 100644 --- a/dlls/d3d8/vertexdeclaration.c +++ b/dlls/d3d8/vertexdeclaration.c @@ -249,7 +249,7 @@ wined3d_usage_lookup[] = };
/* TODO: find out where rhw (or positionT) is for declaration8 */ -static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, +UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, struct wined3d_vertex_element **wined3d_elements) { struct wined3d_vertex_element *element;