From d8e8ab21c0f9f00d295c035534637115a5d70f9f Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sun, 30 Jan 2022 21:05:25 -0600 Subject: [PATCH] wined3d: Allow DISCARD maps to be accelerated even on 32-bit architectures. We will still block on a subsequent NOOVERWRITE map, so in practice this probably doesn't remove any bottlenecks. However, it leads to clearer code, and it matches what will need to be done for textures. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/adapter_vk.c | 2 +- dlls/wined3d/cs.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index d389bafcbed..343abac1004 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1242,7 +1242,7 @@ static bool adapter_vk_alloc_bo(struct wined3d_device *device, struct wined3d_re if (!bo_vk->b.map_ptr) { - WARN_(d3d_perf)("BO %p (chunk %p, slab %p) is not persistently mapped.\n", + WARN_(d3d_perf)("BO %p (chunk %p, slab %p) is not mapped.\n", bo_vk, bo_vk->memory ? bo_vk->memory->chunk : NULL, bo_vk->slab); if (!wined3d_bo_vk_map(bo_vk, context_vk)) diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index e8eb8f313e3..90686e8d170 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -3073,34 +3073,41 @@ static bool wined3d_cs_map_upload_bo(struct wined3d_device_context *context, str { /* Limit NOOVERWRITE maps to buffers for now; there are too many ways that * a texture can be invalidated to even count. */ - if (wined3d_map_persistent() && resource->type == WINED3D_RTYPE_BUFFER - && (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))) + if (resource->type == WINED3D_RTYPE_BUFFER && (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))) { struct wined3d_client_resource *client = &resource->client; struct wined3d_device *device = context->device; + struct wined3d_bo_address addr; const struct wined3d_bo *bo; uint8_t *map_ptr; if (flags & WINED3D_MAP_DISCARD) { - if (!device->adapter->adapter_ops->adapter_alloc_bo(device, resource, sub_resource_idx, &client->addr)) + if (!device->adapter->adapter_ops->adapter_alloc_bo(device, resource, sub_resource_idx, &addr)) return false; + + if (wined3d_map_persistent()) + client->addr = addr; + } + else + { + addr = client->addr; } - bo = client->addr.buffer_object; + bo = addr.buffer_object; map_ptr = bo ? bo->map_ptr : NULL; - map_ptr += (uintptr_t)client->addr.addr; + map_ptr += (uintptr_t)addr.addr; if (!map_ptr) { - TRACE("Sub-resource is not persistently mapped.\n"); + TRACE("Sub-resource is not mapped.\n"); return false; } wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &map_desc->row_pitch, &map_desc->slice_pitch); - client->mapped_upload.addr = *wined3d_const_bo_address(&client->addr); + client->mapped_upload.addr = *wined3d_const_bo_address(&addr); client->mapped_upload.flags = 0; if (bo) {