The ultimate idea being to set a cap on the amount of persistent BO memory, in which case we need to arbitrarily mark BOs as persistent.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/adapter_vk.c | 4 +++- dlls/wined3d/context_gl.c | 19 +++++++++++-------- dlls/wined3d/cs.c | 2 +- dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 343abac1004..17ff6c2678f 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -811,6 +811,8 @@ static void *wined3d_bo_vk_map(struct wined3d_bo_vk *bo, struct wined3d_context_ return NULL; }
+ bo->b.persistent = wined3d_map_persistent(); + return bo->b.map_ptr; }
@@ -820,7 +822,7 @@ static void wined3d_bo_vk_unmap(struct wined3d_bo_vk *bo, struct wined3d_context struct wined3d_device_vk *device_vk; struct wined3d_bo_slab_vk *slab;
- if (wined3d_map_persistent()) + if (bo->b.persistent) return;
bo->b.map_ptr = NULL; diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 3a83027522a..6479413df47 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2674,7 +2674,6 @@ static void *wined3d_bo_gl_map(struct wined3d_bo_gl *bo, struct wined3d_context_ const struct wined3d_gl_info *gl_info; struct wined3d_bo_user *bo_user; struct wined3d_bo_gl tmp; - uint8_t *map_ptr;
if (flags & WINED3D_MAP_NOOVERWRITE) goto map; @@ -2715,6 +2714,8 @@ map: { GLbitfield gl_flags;
+ bo->b.persistent = wined3d_map_persistent(); + /* When mapping the bo persistently, we need to use the access flags * used to create the bo, instead of the access flags passed to the * map call. Otherwise, if for example the initial map call that @@ -2726,7 +2727,7 @@ map: * resources are mapped. On the other hand, we don't want to use the * access flags used to create the bo for non-persistent maps, because * that may imply dropping GL_MAP_UNSYNCHRONIZED_BIT. */ - if (wined3d_map_persistent()) + if (bo->b.persistent) { gl_flags = bo->flags & ~GL_CLIENT_STORAGE_BIT; if (!(gl_flags & GL_MAP_READ_BIT)) @@ -2740,29 +2741,31 @@ map: } gl_flags |= GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
- if ((map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, gl_flags))) && wined3d_map_persistent()) - bo->b.map_ptr = map_ptr; + bo->b.map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, gl_flags)); } else if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) { - map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, wined3d_resource_gl_map_flags(bo, flags))); + bo->b.map_ptr = GL_EXTCALL(glMapBufferRange(bo->binding, 0, bo->size, + wined3d_resource_gl_map_flags(bo, flags))); + bo->b.persistent = false; } else { - map_ptr = GL_EXTCALL(glMapBuffer(bo->binding, wined3d_resource_gl_legacy_map_flags(flags))); + bo->b.map_ptr = GL_EXTCALL(glMapBuffer(bo->binding, wined3d_resource_gl_legacy_map_flags(flags))); + bo->b.persistent = false; }
wined3d_context_gl_bind_bo(context_gl, bo->binding, 0); checkGLcall("Map buffer object");
- return map_ptr; + return bo->b.map_ptr; }
static void wined3d_bo_gl_unmap(struct wined3d_bo_gl *bo, struct wined3d_context_gl *context_gl) { const struct wined3d_gl_info *gl_info = context_gl->gl_info;
- if (bo->b.map_ptr) + if (bo->b.persistent) return;
wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id); diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index ed5b289b8d8..67933a90c5d 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -3088,7 +3088,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()) + if (!addr.buffer_object || addr.buffer_object->persistent) client->addr = addr; } else diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 1b3a13024f9..c0dd2cee037 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1610,6 +1610,7 @@ struct wined3d_bo size_t buffer_offset; size_t memory_offset; bool coherent; + bool persistent; };
struct wined3d_bo_gl