From f3647c4b4faf2883548081af6aa9e12c4171a402 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 15 Nov 2021 16:30:18 -0600 Subject: [PATCH] wined3d: Make the "buffer_object" field of struct wined3d_const_bo_addr a wined3d_bo pointer. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/adapter_vk.c | 6 +++--- dlls/wined3d/buffer.c | 4 ++-- dlls/wined3d/context_gl.c | 3 ++- dlls/wined3d/texture.c | 10 +++++++--- dlls/wined3d/utils.c | 2 +- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 12811fd1482..e6f5bf108c7 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1211,12 +1211,12 @@ static void adapter_vk_flush_bo_address(struct wined3d_context *context, const struct wined3d_const_bo_address *data, size_t size) { struct wined3d_context_vk *context_vk = wined3d_context_vk(context); - struct wined3d_bo_vk *bo; + struct wined3d_bo *bo; - if (!(bo = (struct wined3d_bo_vk *)data->buffer_object)) + if (!(bo = data->buffer_object)) return; - flush_bo_range(context_vk, bo, (uintptr_t)data->addr, size); + flush_bo_range(context_vk, wined3d_bo_vk(bo), (uintptr_t)data->addr, size); } static bool adapter_vk_alloc_bo(struct wined3d_device *device, struct wined3d_resource *resource, diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index b07f1510b74..315ea05260e 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1132,12 +1132,12 @@ void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wi { if (upload_bo->flags & UPLOAD_BO_RENAME_ON_UNMAP) { - wined3d_buffer_set_bo(buffer, context, (struct wined3d_bo *)upload_bo->addr.buffer_object); + wined3d_buffer_set_bo(buffer, context, upload_bo->addr.buffer_object); wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_BUFFER); wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER); } - if (upload_bo->addr.buffer_object && upload_bo->addr.buffer_object == (uintptr_t)buffer->buffer_object) + if (upload_bo->addr.buffer_object && upload_bo->addr.buffer_object == buffer->buffer_object) wined3d_context_flush_bo_address(context, &upload_bo->addr, size); else wined3d_buffer_copy_bo_address(buffer, context, offset, &upload_bo->addr, size); diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index e91bff9328b..f7d4d9e8cb3 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2748,8 +2748,9 @@ static void flush_bo_ranges(struct wined3d_context_gl *context_gl, const struct struct wined3d_bo_gl *bo; unsigned int i; - if (!(bo = (struct wined3d_bo_gl *)data->buffer_object) || bo->b.coherent) + if (!data->buffer_object || data->buffer_object->coherent) return; + bo = wined3d_bo_gl(data->buffer_object); gl_info = context_gl->gl_info; wined3d_context_gl_bind_bo(context_gl, bo->binding, bo->id); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 370eaaf08e5..7e2da350f5a 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2476,7 +2476,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context, return; } - bo.buffer_object = (struct wined3d_bo *)src_bo_addr->buffer_object; + bo.buffer_object = src_bo_addr->buffer_object; bo.addr = (BYTE *)src_bo_addr->addr + src_box->front * src_slice_pitch; if (dst_texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS) { @@ -4720,7 +4720,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context, /* We need to be outside of a render pass for vkCmdPipelineBarrier() and vkCmdCopyBufferToImage() calls below. */ wined3d_context_vk_end_current_render_pass(context_vk); - if (!(src_bo = (struct wined3d_bo_vk *)src_bo_addr->buffer_object)) + if (!src_bo_addr->buffer_object) { if (!wined3d_context_vk_create_bo(context_vk, sub_resource->size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo)) @@ -4755,6 +4755,8 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context, } else { + src_bo = wined3d_bo_vk(src_bo_addr->buffer_object); + vk_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; vk_barrier.pNext = NULL; vk_barrier.srcAccessMask = vk_access_mask_from_buffer_usage(src_bo->usage) & ~WINED3D_READ_ONLY_ACCESS_FLAGS; @@ -4917,7 +4919,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context, /* We need to be outside of a render pass for vkCmdPipelineBarrier() and vkCmdCopyBufferToImage() calls below. */ wined3d_context_vk_end_current_render_pass(context_vk); - if (!(dst_bo = (struct wined3d_bo_vk *)dst_bo_addr->buffer_object)) + if (!dst_bo_addr->buffer_object) { if (!wined3d_context_vk_create_bo(context_vk, sub_resource->size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo)) @@ -4930,6 +4932,8 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context, } else { + dst_bo = wined3d_bo_vk(dst_bo_addr->buffer_object); + vk_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; vk_barrier.pNext = NULL; vk_barrier.srcAccessMask = vk_access_mask_from_buffer_usage(dst_bo->usage); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 26001775300..098b07ae35b 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4613,7 +4613,7 @@ const char *debug_const_bo_address(const struct wined3d_const_bo_address *addres { if (!address) return "(null)"; - return wine_dbg_sprintf("{%#lx:%p}", address->buffer_object, address->addr); + return wine_dbg_sprintf("{%p:%p}", address->buffer_object, address->addr); } const char *debug_bo_address(const struct wined3d_bo_address *address) diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 0d8001f5cbe..79dbc847249 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1632,7 +1632,7 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_ if (!view->counter_bo) return; - src.buffer_object = view->counter_bo; + src.buffer_object = (struct wined3d_bo *)view->counter_bo; src.addr = NULL; wined3d_buffer_copy_bo_address(buffer, context, offset, &src, sizeof(uint32_t)); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3e2b05ded28..826bdc6e4a9 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1685,7 +1685,7 @@ struct wined3d_bo_address struct wined3d_const_bo_address { - UINT_PTR buffer_object; + struct wined3d_bo *buffer_object; const BYTE *addr; };