Commit 90460f20 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3d9: Don't upload unused system memory vertex buffers.

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