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

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Matteo Bruni 2019-03-05 18:47:20 +01:00 committed by Alexandre Julliard
parent 90460f2042
commit c79fbdd3bf
3 changed files with 19 additions and 3 deletions

View File

@ -251,6 +251,7 @@ struct d3d8_vertex_declaration
{
DWORD *elements;
DWORD elements_size; /* Size of elements, in bytes */
DWORD stream_map;
struct wined3d_vertex_declaration *wined3d_vertex_declaration;
DWORD shader_handle;
};

View File

@ -2269,15 +2269,25 @@ 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};
struct d3d8_vertexbuffer *d3d8_buffer;
struct wined3d_resource *dst_resource;
struct d3d8_vertex_declaration *decl;
unsigned int i, offset, stride, map;
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);
map = decl->stream_map & device->sysmem_vb;
while (map)
{
i = wined3d_bit_scan(&map);

View File

@ -250,7 +250,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,
struct wined3d_vertex_element **wined3d_elements)
struct wined3d_vertex_element **wined3d_elements, DWORD *stream_map)
{
struct wined3d_vertex_element *element;
const DWORD *token = d3d8_elements;
@ -261,6 +261,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3
TRACE("d3d8_elements %p, d3d8_elements_size %p, wined3d_elements %p\n", d3d8_elements, d3d8_elements_size, wined3d_elements);
*stream_map = 0;
/* 128 should be enough for anyone... */
*wined3d_elements = heap_alloc_zero(128 * sizeof(**wined3d_elements));
while (D3DVSD_END() != *token)
@ -288,6 +289,8 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3
element->usage = wined3d_usage_lookup[reg].usage;
element->usage_idx = wined3d_usage_lookup[reg].usage_idx;
*stream_map |= 1u << stream;
offset += wined3d_type_sizes[type];
} else if (token_type == D3DVSD_TOKEN_STREAMDATA && (*token & D3DVSD_DATALOADTYPEMASK)) {
TRACE(" 0x%08x SKIP(%u)\n", token_type, ((token_type & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT));
@ -337,7 +340,8 @@ HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration
declaration->shader_handle = shader_handle;
wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size, &wined3d_elements);
wined3d_element_count = convert_to_wined3d_declaration(elements, &declaration->elements_size,
&wined3d_elements, &declaration->stream_map);
if (!(declaration->elements = heap_alloc(declaration->elements_size)))
{
ERR("Failed to allocate vertex declaration elements memory.\n");
@ -369,6 +373,7 @@ HRESULT d3d8_vertex_declaration_init_fvf(struct d3d8_vertex_declaration *declara
declaration->elements = NULL;
declaration->elements_size = 0;
declaration->stream_map = 1;
declaration->shader_handle = fvf;
hr = wined3d_vertex_declaration_create_from_fvf(device->wined3d_device, fvf, declaration,