Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53863
This fixes a regression introduced by ebbcc10b0593948657b8e684c3a9be8ace1a5d25. Prior to that commit, buffers which were not CPU-accessible would not have the WINED3D_BUFFER_USE_BO flag set, and accordingly buffer_resource_sub_resource_map() would simply return the SYSMEM location, ignoring the DISCARD and NOOVERWRITE flags.
However, the "accelerated" path in wined3d_cs_map_upload_bo() only checks for the DISCARD flag, assuming that it is only set for dynamic GPU-accessible buffers, and would subsequently try to allocate non-mappable memory and then map it.
This commit avoids the accelerated path for such buffers, once again matching our old behaviour. According to [1], this also matches Windows: DISCARD on SYSTEMMEM buffers is ignored on both AMD and NVidia, and NOOVERWRITE is ignored on NVidia (but not AMD).
[1] https://www.winehq.org/mailman3/hyperkitty/list/wine-devel@winehq.org/messag...
From: Zebediah Figura zfigura@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53863
This fixes a regression introduced by ebbcc10b0593948657b8e684c3a9be8ace1a5d25. Prior to that commit, buffers which were not CPU-accessible would not have the WINED3D_BUFFER_USE_BO flag set, and accordingly buffer_resource_sub_resource_map() would simply return the SYSMEM location, ignoring the DISCARD and NOOVERWRITE flags.
However, the "accelerated" path in wined3d_cs_map_upload_bo() only checks for the DISCARD flag, assuming that it is only set for dynamic GPU-accessible buffers, and would subsequently try to allocate non-mappable memory and then map it.
This commit avoids the accelerated path for such buffers, once again matching our old behaviour. According to [1], this also matches Windows: DISCARD on SYSTEMMEM buffers is ignored on both AMD and NVidia, and NOOVERWRITE is ignored on NVidia (but not AMD).
[1] https://www.winehq.org/mailman3/hyperkitty/list/wine-devel@winehq.org/messag... --- dlls/wined3d/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c0646148c4a..b294af3c5fa 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5167,9 +5167,9 @@ static unsigned int sanitise_map_flags(const struct wined3d_resource *resource, } else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) { - if (!(resource->usage & WINED3DUSAGE_DYNAMIC)) + if (!(resource->access & WINED3D_RESOURCE_ACCESS_GPU) || !(resource->usage & WINED3DUSAGE_DYNAMIC)) { - WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n"); + WARN("DISCARD or NOOVERWRITE map not on dynamic GPU-accessible buffer, ignoring.\n"); return flags & (WINED3D_MAP_READ | WINED3D_MAP_WRITE); } if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
This merge request was approved by Jan Sikorski.