Commit 498f0f11 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ddraw: Use system memory for version 4 vertex buffers.

parent cb723c6d
...@@ -595,6 +595,7 @@ struct d3d_vertex_buffer ...@@ -595,6 +595,7 @@ struct d3d_vertex_buffer
DWORD size; DWORD size;
BOOL dynamic; BOOL dynamic;
bool discarded; bool discarded;
bool sysmem;
}; };
HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **buffer, struct ddraw *ddraw, HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **buffer, struct ddraw *ddraw,
......
...@@ -4128,7 +4128,7 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE ...@@ -4128,7 +4128,7 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE
stride = get_flexible_vertex_size(vb_impl->fvf); stride = get_flexible_vertex_size(vb_impl->fvf);
if (vb_impl->Caps & D3DVBCAPS_SYSTEMMEMORY) if (vb_impl->sysmem)
{ {
TRACE("Drawing from D3DVBCAPS_SYSTEMMEMORY vertex buffer, forwarding to DrawPrimitive().\n"); TRACE("Drawing from D3DVBCAPS_SYSTEMMEMORY vertex buffer, forwarding to DrawPrimitive().\n");
wined3d_mutex_lock(); wined3d_mutex_lock();
...@@ -4246,7 +4246,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4246,7 +4246,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
vb_impl->discarded = false; vb_impl->discarded = false;
if (vb_impl->Caps & D3DVBCAPS_SYSTEMMEMORY) if (vb_impl->sysmem)
{ {
TRACE("Drawing from D3DVBCAPS_SYSTEMMEMORY vertex buffer, forwarding to DrawIndexedPrimitive().\n"); TRACE("Drawing from D3DVBCAPS_SYSTEMMEMORY vertex buffer, forwarding to DrawIndexedPrimitive().\n");
wined3d_mutex_lock(); wined3d_mutex_lock();
......
...@@ -120,7 +120,7 @@ static HRESULT d3d_vertex_buffer_create_wined3d_buffer(struct d3d_vertex_buffer ...@@ -120,7 +120,7 @@ static HRESULT d3d_vertex_buffer_create_wined3d_buffer(struct d3d_vertex_buffer
if (dynamic) if (dynamic)
desc.usage |= WINED3DUSAGE_DYNAMIC; desc.usage |= WINED3DUSAGE_DYNAMIC;
desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
if (buffer->Caps & D3DVBCAPS_SYSTEMMEMORY) if (buffer->sysmem)
desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
else else
desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
...@@ -466,6 +466,19 @@ HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **vertex_buf, ...@@ -466,6 +466,19 @@ HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **vertex_buf,
buffer->fvf = desc->dwFVF; buffer->fvf = desc->dwFVF;
buffer->size = get_flexible_vertex_size(desc->dwFVF) * desc->dwNumVertices; buffer->size = get_flexible_vertex_size(desc->dwFVF) * desc->dwNumVertices;
/* ddraw4 vertex buffers ignore DISCARD and NOOVERWRITE, even on
* pretransformed geometry, which means that a GPU-based buffer cannot
* perform well.
*
* While at least one contemporaneous card (Geforce 4) does seem to show a
* difference in its performance characteristics based on whether
* D3DVBCAPS_SYSTEMMEMORY is set, it also doesn't *improve* performance to
* use a non-SYSTEMMEMORY buffer with ddraw4. For wined3d it should always
* be better to use sysmem.
*
* This improves performance in Prince of Persia 3D. */
buffer->sysmem = ((buffer->Caps & D3DVBCAPS_SYSTEMMEMORY) || buffer->version < 7);
wined3d_mutex_lock(); wined3d_mutex_lock();
if (FAILED(hr = d3d_vertex_buffer_create_wined3d_buffer(buffer, FALSE, &buffer->wined3d_buffer))) if (FAILED(hr = d3d_vertex_buffer_create_wined3d_buffer(buffer, FALSE, &buffer->wined3d_buffer)))
......
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