[PATCH 3/8] wined3d: Move the bo_slab_available field to struct wined3d_device_vk.
Zebediah Figura
zfigura at codeweavers.com
Tue Nov 2 18:20:08 CDT 2021
In order to allow slab allocation from the client thread.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/wined3d/adapter_vk.c | 13 +++++++++++++
dlls/wined3d/context_vk.c | 30 +++++++++---------------------
dlls/wined3d/wined3d_private.h | 2 +-
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index da1302265ca..218b7dc74ba 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -397,6 +397,18 @@ static const struct wined3d_allocator_ops wined3d_allocator_vk_ops =
.allocator_destroy_chunk = wined3d_allocator_vk_destroy_chunk,
};
+static int wined3d_bo_slab_vk_compare(const void *key, const struct wine_rb_entry *entry)
+{
+ const struct wined3d_bo_slab_vk *slab = WINE_RB_ENTRY_VALUE(entry, const struct wined3d_bo_slab_vk, entry);
+ const struct wined3d_bo_slab_vk_key *k = key;
+
+ if (k->memory_type != slab->requested_memory_type)
+ return k->memory_type - slab->requested_memory_type;
+ if (k->usage != slab->bo.usage)
+ return k->usage - slab->bo.usage;
+ return k->size - slab->bo.size;
+}
+
static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment,
const enum wined3d_feature_level *levels, unsigned int level_count,
@@ -512,6 +524,7 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi
hr = E_FAIL;
goto fail;
}
+ wine_rb_init(&device_vk->bo_slab_available, wined3d_bo_slab_vk_compare);
if (FAILED(hr = wined3d_device_init(&device_vk->d, wined3d, adapter->ordinal, device_type, focus_window,
flags, surface_alignment, levels, level_count, vk_info->supported, device_parent)))
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c
index 9854ca70ef0..a6a2ea8a44b 100644
--- a/dlls/wined3d/context_vk.c
+++ b/dlls/wined3d/context_vk.c
@@ -359,7 +359,7 @@ static bool wined3d_device_vk_create_slab_bo(struct wined3d_device_vk *device_vk
key.usage = usage;
key.size = 32 * object_size;
- if ((entry = wine_rb_get(&context_vk->bo_slab_available, &key)))
+ if ((entry = wine_rb_get(&device_vk->bo_slab_available, &key)))
{
slab = WINE_RB_ENTRY_VALUE(entry, struct wined3d_bo_slab_vk, entry);
TRACE("Using existing bo slab %p.\n", slab);
@@ -381,7 +381,7 @@ static bool wined3d_device_vk_create_slab_bo(struct wined3d_device_vk *device_vk
}
slab->map = ~0u;
- if (wine_rb_put(&context_vk->bo_slab_available, &key, &slab->entry) < 0)
+ if (wine_rb_put(&device_vk->bo_slab_available, &key, &slab->entry) < 0)
{
ERR("Failed to add slab to available tree.\n");
wined3d_context_vk_destroy_bo(context_vk, &slab->bo);
@@ -397,12 +397,12 @@ static bool wined3d_device_vk_create_slab_bo(struct wined3d_device_vk *device_vk
{
if (slab->next)
{
- wine_rb_replace(&context_vk->bo_slab_available, &slab->entry, &slab->next->entry);
+ wine_rb_replace(&device_vk->bo_slab_available, &slab->entry, &slab->next->entry);
slab->next = NULL;
}
else
{
- wine_rb_remove(&context_vk->bo_slab_available, &slab->entry);
+ wine_rb_remove(&device_vk->bo_slab_available, &slab->entry);
}
}
@@ -705,6 +705,7 @@ void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *conte
static void wined3d_bo_slab_vk_free_slice(struct wined3d_bo_slab_vk *slab,
SIZE_T idx, struct wined3d_context_vk *context_vk)
{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
struct wined3d_bo_slab_vk_key key;
struct wine_rb_entry *entry;
@@ -716,12 +717,12 @@ static void wined3d_bo_slab_vk_free_slice(struct wined3d_bo_slab_vk *slab,
key.usage = slab->bo.usage;
key.size = slab->bo.size;
- if ((entry = wine_rb_get(&context_vk->bo_slab_available, &key)))
+ if ((entry = wine_rb_get(&device_vk->bo_slab_available, &key)))
{
slab->next = WINE_RB_ENTRY_VALUE(entry, struct wined3d_bo_slab_vk, entry);
- wine_rb_replace(&context_vk->bo_slab_available, entry, &slab->entry);
+ wine_rb_replace(&device_vk->bo_slab_available, entry, &slab->entry);
}
- else if (wine_rb_put(&context_vk->bo_slab_available, &key, &slab->entry) < 0)
+ else if (wine_rb_put(&device_vk->bo_slab_available, &key, &slab->entry) < 0)
{
ERR("Unable to return slab %p (map 0x%08x) to available tree.\n", slab, slab->map);
}
@@ -1458,7 +1459,7 @@ void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk)
wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_timestamp_query_pools);
wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_pipeline_statistics_query_pools);
wined3d_context_vk_destroy_query_pools(context_vk, &context_vk->free_stream_output_statistics_query_pools);
- wine_rb_destroy(&context_vk->bo_slab_available, wined3d_context_vk_destroy_bo_slab, context_vk);
+ wine_rb_destroy(&device_vk->bo_slab_available, wined3d_context_vk_destroy_bo_slab, context_vk);
heap_free(context_vk->pending_queries.queries);
heap_free(context_vk->submitted.buffers);
heap_free(context_vk->retired.objects);
@@ -1825,18 +1826,6 @@ static int wined3d_graphics_pipeline_vk_compare(const void *key, const struct wi
return 0;
}
-static int wined3d_bo_slab_vk_compare(const void *key, const struct wine_rb_entry *entry)
-{
- const struct wined3d_bo_slab_vk *slab = WINE_RB_ENTRY_VALUE(entry, const struct wined3d_bo_slab_vk, entry);
- const struct wined3d_bo_slab_vk_key *k = key;
-
- if (k->memory_type != slab->requested_memory_type)
- return k->memory_type - slab->requested_memory_type;
- if (k->usage != slab->bo.usage)
- return k->usage - slab->bo.usage;
- return k->size - slab->bo.size;
-}
-
static void wined3d_context_vk_init_graphics_pipeline_key(struct wined3d_context_vk *context_vk)
{
struct wined3d_graphics_pipeline_key_vk *key;
@@ -3508,7 +3497,6 @@ HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, struct wi
wine_rb_init(&context_vk->render_passes, wined3d_render_pass_vk_compare);
wine_rb_init(&context_vk->pipeline_layouts, wined3d_pipeline_layout_vk_compare);
wine_rb_init(&context_vk->graphics_pipelines, wined3d_graphics_pipeline_vk_compare);
- wine_rb_init(&context_vk->bo_slab_available, wined3d_bo_slab_vk_compare);
return WINED3D_OK;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b2525110adc..d8b16c0d074 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2622,7 +2622,6 @@ struct wined3d_context_vk
struct wine_rb_tree render_passes;
struct wine_rb_tree pipeline_layouts;
struct wine_rb_tree graphics_pipelines;
- struct wine_rb_tree bo_slab_available;
};
static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
@@ -4085,6 +4084,7 @@ struct wined3d_device_vk
struct wined3d_allocator allocator;
struct wined3d_uav_clear_state_vk uav_clear_state;
+ struct wine_rb_tree bo_slab_available;
};
static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
--
2.33.0
More information about the wine-devel
mailing list