With the goal of making the context_vk parameter optional, so that we can allocate new BOs from the client thread.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/adapter_vk.c | 10 ++++++---- dlls/wined3d/buffer.c | 3 ++- dlls/wined3d/context_vk.c | 11 +++++------ dlls/wined3d/device.c | 2 +- dlls/wined3d/texture.c | 9 ++++++--- dlls/wined3d/view.c | 6 +++--- dlls/wined3d/wined3d_private.h | 5 +++-- 7 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 02a359c4f07..da1302265ca 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -936,7 +936,7 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
if ((map_flags & WINED3D_MAP_DISCARD) && bo->command_buffer_id > context_vk->completed_command_buffer_id) { - if (wined3d_context_vk_create_bo(context_vk, bo->size, bo->usage, bo->memory_type, &tmp)) + if (wined3d_device_vk_create_bo(device_vk, context_vk, bo->size, bo->usage, bo->memory_type, &tmp)) { bool host_synced = bo->host_synced; list_move_head(&tmp.b.users, &bo->b.users); @@ -1045,6 +1045,7 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context, void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) { + struct wined3d_device_vk *device_vk = wined3d_device_vk(context->device); struct wined3d_context_vk *context_vk = wined3d_context_vk(context); const struct wined3d_vk_info *vk_info = context_vk->vk_info; struct wined3d_bo_vk staging_bo, *src_bo, *dst_bo; @@ -1122,7 +1123,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
if (src_bo && !(src_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { - if (!(wined3d_context_vk_create_bo(context_vk, size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, + if (!(wined3d_device_vk_create_bo(device_vk, context_vk, size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) { ERR("Failed to create staging bo.\n"); @@ -1142,7 +1143,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context, if (dst_bo && (!(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) || (!(map_flags & WINED3D_MAP_DISCARD) && dst_bo->command_buffer_id > context_vk->completed_command_buffer_id))) { - if (!(wined3d_context_vk_create_bo(context_vk, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, + if (!(wined3d_device_vk_create_bo(device_vk, context_vk, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) { ERR("Failed to create staging bo.\n"); @@ -1691,7 +1692,8 @@ static void adapter_vk_draw_primitive(struct wined3d_device *device, { struct wined3d_bo_vk *bo = &context_vk->vk_so_counter_bo;
- if (!wined3d_context_vk_create_bo(context_vk, ARRAY_SIZE(context_vk->vk_so_counters) * sizeof(uint32_t) * 2, + if (!wined3d_device_vk_create_bo(wined3d_device_vk(device), context_vk, + ARRAY_SIZE(context_vk->vk_so_counters) * sizeof(uint32_t) * 2, VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, bo)) ERR("Failed to create counter BO.\n"); for (i = 0; i < ARRAY_SIZE(context_vk->vk_so_counters); ++i) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 55dcd9e67e8..d4efecb2241 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1433,7 +1433,8 @@ static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buf else if (!(resource->usage & WINED3DUSAGE_DYNAMIC)) memory_type |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
- if (!(wined3d_context_vk_create_bo(context_vk, resource->size, usage, memory_type, &buffer_vk->bo))) + if (!(wined3d_device_vk_create_bo(wined3d_device_vk(resource->device), + context_vk, resource->size, usage, memory_type, &buffer_vk->bo))) { WARN("Failed to create Vulkan buffer.\n"); return FALSE; diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index ad7b0a8ba86..63de2f0f052 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -330,7 +330,7 @@ static struct wined3d_allocator_block *wined3d_context_vk_allocate_memory(struct return block; }
-static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context_vk, +static bool wined3d_context_vk_create_slab_bo(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) { const struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk(context_vk->c.device->adapter); @@ -374,7 +374,7 @@ static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context }
slab->requested_memory_type = memory_type; - if (!wined3d_context_vk_create_bo(context_vk, key.size, usage, memory_type, &slab->bo)) + if (!wined3d_device_vk_create_bo(device_vk, context_vk, key.size, usage, memory_type, &slab->bo)) { ERR("Failed to create slab bo.\n"); heap_free(slab); @@ -424,10 +424,9 @@ static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context return true; }
-BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size, - VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) +BOOL wined3d_device_vk_create_bo(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk, + VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) { - struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device); const struct wined3d_vk_info *vk_info = context_vk->vk_info; VkMemoryRequirements memory_requirements; struct wined3d_adapter_vk *adapter_vk; @@ -435,7 +434,7 @@ BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDevic unsigned int memory_type_idx; VkResult vr;
- if (wined3d_context_vk_create_slab_bo(context_vk, size, usage, memory_type, bo)) + if (wined3d_context_vk_create_slab_bo(device_vk, context_vk, size, usage, memory_type, bo)) return TRUE;
adapter_vk = wined3d_adapter_vk(device_vk->d.adapter); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c5de58c29c9..cdea0ec42cf 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -655,7 +655,7 @@ bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; memory_type = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - if (!wined3d_context_vk_create_bo(context_vk, 16, usage, memory_type, &r->bo)) + if (!wined3d_device_vk_create_bo(device_vk, context_vk, 16, usage, memory_type, &r->bo)) return false; VK_CALL(vkCmdFillBuffer(vk_command_buffer, r->bo.vk_buffer, r->bo.buffer_offset, r->bo.size, 0x00000000u)); r->buffer_info.buffer = r->bo.vk_buffer; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index df42f2d766b..02a5d96346f 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -4647,6 +4647,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z) { struct wined3d_texture_vk *dst_texture_vk = wined3d_texture_vk(dst_texture); + struct wined3d_device_vk *device_vk = wined3d_device_vk(context->device); struct wined3d_context_vk *context_vk = wined3d_context_vk(context); unsigned int dst_level, dst_row_pitch, dst_slice_pitch; struct wined3d_texture_sub_resource *sub_resource; @@ -4722,7 +4723,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context,
if (!(src_bo = (struct wined3d_bo_vk *)src_bo_addr->buffer_object)) { - if (!wined3d_context_vk_create_bo(context_vk, sub_resource->size, + if (!wined3d_device_vk_create_bo(device_vk, context_vk, sub_resource->size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo)) { ERR("Failed to create staging bo.\n"); @@ -4833,6 +4834,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context, unsigned int dst_row_pitch, unsigned int dst_slice_pitch) { struct wined3d_texture_vk *src_texture_vk = wined3d_texture_vk(src_texture); + struct wined3d_device_vk *device_vk = wined3d_device_vk(context->device); struct wined3d_context_vk *context_vk = wined3d_context_vk(context); unsigned int src_level, src_width, src_height, src_depth; struct wined3d_texture_sub_resource *sub_resource; @@ -4919,7 +4921,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context,
if (!(dst_bo = (struct wined3d_bo_vk *)dst_bo_addr->buffer_object)) { - if (!wined3d_context_vk_create_bo(context_vk, sub_resource->size, + if (!wined3d_device_vk_create_bo(device_vk, context_vk, sub_resource->size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo)) { ERR("Failed to create staging bo.\n"); @@ -5191,6 +5193,7 @@ BOOL wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk *texture_vk, static BOOL wined3d_texture_vk_prepare_buffer_object(struct wined3d_texture_vk *texture_vk, unsigned int sub_resource_idx, struct wined3d_context_vk *context_vk) { + struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device); struct wined3d_texture_sub_resource *sub_resource; struct wined3d_bo_vk *bo;
@@ -5199,7 +5202,7 @@ static BOOL wined3d_texture_vk_prepare_buffer_object(struct wined3d_texture_vk * if (bo->vk_buffer) return TRUE;
- if (!wined3d_context_vk_create_bo(context_vk, sub_resource->size, + if (!wined3d_device_vk_create_bo(device_vk, context_vk, sub_resource->size, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, bo)) return FALSE; diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 374e693b17d..6a88286b861 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -2078,8 +2078,8 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view vk_writes[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; vk_writes[1].pBufferInfo = &buffer_info;
- if (!wined3d_context_vk_create_bo(context_vk, sizeof(constants), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &constants_bo)) + if (!wined3d_device_vk_create_bo(device_vk, context_vk, sizeof(constants), + VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &constants_bo)) { ERR("Failed to create constants BO.\n"); goto out; @@ -2213,7 +2213,7 @@ static void wined3d_unordered_access_view_vk_cs_init(void *object)
if (desc->flags & (WINED3D_VIEW_BUFFER_COUNTER | WINED3D_VIEW_BUFFER_APPEND)) { - if (!wined3d_context_vk_create_bo(context_vk, sizeof(uint32_t), VK_BUFFER_USAGE_TRANSFER_SRC_BIT + if (!wined3d_device_vk_create_bo(device_vk, context_vk, sizeof(uint32_t), VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &uav_vk->counter_bo)) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index aa8974366a6..b2525110adc 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2642,8 +2642,6 @@ VkCommandBuffer wined3d_context_vk_apply_compute_state(struct wined3d_context_vk VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *context_vk, const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk, bool indexed) DECLSPEC_HIDDEN; void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; -BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size, - VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN; BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type, VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth, unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags, @@ -4094,6 +4092,9 @@ static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device return CONTAINING_RECORD(device, struct wined3d_device_vk, d); }
+BOOL wined3d_device_vk_create_bo(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk, + VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, + struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN; bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; bool wined3d_device_vk_create_null_views(struct wined3d_device_vk *device_vk,