wined3d-CSMT_Main: Use DISCARD when uploading full buffer.

This commit is contained in:
Sebastian Lackner 2017-02-20 02:02:26 +01:00
parent c32efc1a79
commit 60e835b183
3 changed files with 70 additions and 4 deletions

View File

@ -8357,10 +8357,10 @@ fi
# |
# | Modified files:
# | * dlls/d3d10core/tests/device.c, dlls/d3d11/tests/d3d11.c, dlls/d3d9/tests/visual.c, dlls/wined3d/arb_program_shader.c,
# | dlls/wined3d/context.c, dlls/wined3d/cs.c, dlls/wined3d/device.c, dlls/wined3d/drawprim.c, dlls/wined3d/glsl_shader.c,
# | dlls/wined3d/query.c, dlls/wined3d/resource.c, dlls/wined3d/shader.c, dlls/wined3d/state.c, dlls/wined3d/stateblock.c,
# | dlls/wined3d/surface.c, dlls/wined3d/swapchain.c, dlls/wined3d/texture.c, dlls/wined3d/utils.c, dlls/wined3d/view.c,
# | dlls/wined3d/wined3d_main.c, dlls/wined3d/wined3d_private.h
# | dlls/wined3d/buffer.c, dlls/wined3d/context.c, dlls/wined3d/cs.c, dlls/wined3d/device.c, dlls/wined3d/drawprim.c,
# | dlls/wined3d/glsl_shader.c, dlls/wined3d/query.c, dlls/wined3d/resource.c, dlls/wined3d/shader.c, dlls/wined3d/state.c,
# | dlls/wined3d/stateblock.c, dlls/wined3d/surface.c, dlls/wined3d/swapchain.c, dlls/wined3d/texture.c,
# | dlls/wined3d/utils.c, dlls/wined3d/view.c, dlls/wined3d/wined3d_main.c, dlls/wined3d/wined3d_private.h
# |
if test "$enable_wined3d_CSMT_Main" -eq 1; then
patch_apply wined3d-CSMT_Main/9999-IfDefined.patch
@ -8409,6 +8409,7 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then
printf '%s\n' '+ { "Sebastian Lackner", "wined3d: Synchronize before resizing swapchain context array.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Set all default state values to zero.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Improve wined3d_cs_emit_update_sub_resource.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Discard buffer during upload when replacing complete content.", 1 },';
) >> "$patchlist"
fi

View File

@ -0,0 +1,37 @@
From 7aaa4f9b8ca813f34256e74f7d676c4dbd5e09e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 20 Feb 2017 01:52:27 +0100
Subject: wined3d: Discard buffer during upload when replacing complete
content.
---
dlls/wined3d/buffer.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index d7c6b02a830..b320329e62d 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1270,6 +1270,7 @@ HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
const struct wined3d_box *box, const void *data)
{
UINT offset, size;
+ DWORD flags = 0;
HRESULT hr;
BYTE *ptr;
@@ -1284,7 +1285,10 @@ HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
size = buffer->resource.size;
}
- if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, 0)))
+ if (offset == 0 && size == buffer->resource.size)
+ flags = WINED3D_MAP_DISCARD;
+
+ if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, flags)))
return hr;
memcpy(ptr, data, size);
--
2.11.0

View File

@ -96,6 +96,34 @@ diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader
shader_arb_ps_local_constants(compiled, context, state, rt_height);
}
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1270,6 +1270,9 @@ HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
const struct wined3d_box *box, const void *data)
{
UINT offset, size;
+#if defined(STAGING_CSMT)
+ DWORD flags = 0;
+#endif /* STAGING_CSMT */
HRESULT hr;
BYTE *ptr;
@@ -1284,7 +1287,14 @@ HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer,
size = buffer->resource.size;
}
+#if !defined(STAGING_CSMT)
if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, 0)))
+#else /* STAGING_CSMT */
+ if (offset == 0 && size == buffer->resource.size)
+ flags = WINED3D_MAP_DISCARD;
+
+ if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, flags)))
+#endif /* STAGING_CSMT */
return hr;
memcpy(ptr, data, size);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c