[PATCH v3 5/6] d3d9: Don't upload unused system memory vertex buffers.
Matteo Bruni
mbruni at codeweavers.com
Wed Feb 27 11:30:12 CST 2019
Signed-off-by: Matteo Bruni <mbruni at 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/d3d9/d3d9_private.h | 2 ++
dlls/d3d9/device.c | 24 ++++++++++++++++++++++--
dlls/d3d9/vertexdeclaration.c | 2 +-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 3fe0376e5c1..50b18b1ed36 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -256,6 +256,8 @@ struct d3d9_vertex_declaration
IDirect3DDevice9Ex *parent_device;
};
+HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements,
+ struct wined3d_vertex_element **wined3d_elements, UINT *element_count) DECLSPEC_HIDDEN;
HRESULT d3d9_vertex_declaration_create(struct d3d9_device *device,
const D3DVERTEXELEMENT9 *elements, struct d3d9_vertex_declaration **declaration) DECLSPEC_HIDDEN;
struct d3d9_vertex_declaration *unsafe_impl_from_IDirect3DVertexDeclaration9(
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 6cc3f180b09..8ff83f148d6 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2730,23 +2730,43 @@ 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};
+ unsigned int i, offset, stride, map, count;
+ struct wined3d_vertex_element *elements;
struct d3d9_vertexbuffer *d3d9_buffer;
struct wined3d_resource *dst_resource;
- unsigned int i, offset, stride, map;
+ struct d3d9_vertex_declaration *decl;
struct wined3d_buffer *dst_buffer;
struct wined3d_resource_desc desc;
HRESULT hr;
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);
+ if (!decl->elements)
+ {
+ map = 1;
+ }
+ else
+ {
+ map = 0;
+ if (FAILED(convert_to_wined3d_declaration(decl->elements, &elements, &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/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c
index b6445255238..5f07207a482 100644
--- a/dlls/d3d9/vertexdeclaration.c
+++ b/dlls/d3d9/vertexdeclaration.c
@@ -320,7 +320,7 @@ static const struct wined3d_parent_ops d3d9_vertexdeclaration_wined3d_parent_ops
d3d9_vertexdeclaration_wined3d_object_destroyed,
};
-static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements,
+HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elements,
struct wined3d_vertex_element **wined3d_elements, UINT *element_count)
{
const D3DVERTEXELEMENT9* element;
--
2.19.2
More information about the wine-devel
mailing list