[PATCH 7/7] wined3d: Allow NOOVERWRITE maps to be accelerated on 32-bit architectures.

Zebediah Figura zfigura at codeweavers.com
Thu Feb 10 19:02:37 CST 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
These haven't been my favourite patches to write exactly. In some respects they
make the code nicer, in others I'm left racking my brains making sure that this
actually works.

The idea here is to avoid reasoning about whether a buffer will remain mapped
from the client thread, and in fact to avoid making implicit assumptions about
how long a buffer will be mapped in general, sort of in line with [1]. We want
to make the conditions for how long a buffer remains mapped more complex than
"always" or "never".

One consequence of this is that we have to refcount mapped BOs. Previously we
only mapped BOs from the CS thread, and never nested those mappings. That's not
true anymore. This is fine in itself, but where it gets awkward is that we
sometimes really do need BOs to be unmapped, in particular for GL draws if the
BO is mapped without MAP_PERSISTENT_BIT (i.e. when ARB_buffer_storage isn't
available). Thus we have to introduce another implicit agreement, and one that's
not exactly easy to reason about: don't ever increase the map count from the
client thread if we can't map persistently. There are multiple ways to do this
in practice, some more restrictive than others, but the one I elected to depend
on in this patch set (although it isn't actually there yet, because
wined3d_adapter_gl_alloc_bo() isn't implemented) is "just never accelerate maps
if we don't have ARB_buffer_storage". It's not my favourite solution, but I
couldn't find one that was less mentally taxing.

[1] https://www.winehq.org/pipermail/wine-devel/2022-January/206325.html

 dlls/wined3d/buffer.c | 3 +--
 dlls/wined3d/cs.c     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 50e3e9fe2b4..902ab720396 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1002,8 +1002,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
              * but it's safe because the client thread will wait for the
              * map to return, thus completely serializing this call with
              * other client code. */
-            if (wined3d_map_persistent())
-                buffer->resource.client.addr = addr;
+            buffer->resource.client.addr = addr;
 
             if (((DWORD_PTR)buffer->map_ptr) & (RESOURCE_ALIGNMENT - 1))
             {
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index f92c584500b..fefa4fde524 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -3089,8 +3089,7 @@ static bool wined3d_cs_map_upload_bo(struct wined3d_device_context *context, str
             if (!device->adapter->adapter_ops->adapter_alloc_bo(device, resource, sub_resource_idx, &addr))
                 return false;
 
-            if (wined3d_map_persistent())
-                client->addr = addr;
+            client->addr = addr;
         }
         else
         {
-- 
2.34.1




More information about the wine-devel mailing list