From 63ed42ac39440cc914397c70ed0c43aa747ceb4e Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 3 Jan 2018 16:06:55 +0100 Subject: [PATCH] wined3d: Ignore WINED3D_MAP_DISCARD when used together with WINED3D_MAP_NOOVERWRITE. This fixes a performance issue exposed by commit afb2aa2512d4c5ffa7256ce5137bc2c142a5d065. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/resource.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 40890cc99e8..dcaa0727075 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -335,17 +335,19 @@ static DWORD wined3d_resource_sanitise_map_flags(const struct wined3d_resource * return 0; } } - else if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) - == (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) { - WARN("WINED3D_MAP_DISCARD and WINED3D_MAP_NOOVERWRITE used together, ignoring.\n"); - return 0; - } - else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE) - && !(resource->usage & WINED3DUSAGE_DYNAMIC)) - { - WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n"); - return 0; + if (!(resource->usage & WINED3DUSAGE_DYNAMIC)) + { + WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n"); + return 0; + } + if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + == (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + { + WARN("WINED3D_MAP_NOOVERWRITE used with WINED3D_MAP_DISCARD, ignoring WINED3D_MAP_DISCARD.\n"); + flags &= ~WINED3D_MAP_DISCARD; + } } return flags;