Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/adapter_vk.c | 4 ++-- dlls/wined3d/buffer.c | 24 ++++++++++++------------ dlls/wined3d/context_vk.c | 8 ++++---- dlls/wined3d/cs.c | 2 +- dlls/wined3d/view.c | 6 +++--- dlls/wined3d/wined3d_private.h | 9 +++++++-- 6 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 8335a030b6b..62a9a342e9b 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1745,7 +1745,7 @@ static void adapter_vk_draw_primitive(struct wined3d_device *device,
if (parameters->indirect) { - struct wined3d_bo_vk *bo = (struct wined3d_bo_vk *)indirect_vk->b.buffer_object; + struct wined3d_bo_vk *bo = wined3d_bo_vk(indirect_vk->b.buffer_object); uint32_t stride, size;
wined3d_context_vk_reference_bo(context_vk, bo); @@ -1817,7 +1817,7 @@ static void adapter_vk_dispatch_compute(struct wined3d_device *device,
if (parameters->indirect) { - struct wined3d_bo_vk *bo = (struct wined3d_bo_vk *)indirect_vk->b.buffer_object; + struct wined3d_bo_vk *bo = wined3d_bo_vk(indirect_vk->b.buffer_object);
wined3d_context_vk_reference_bo(context_vk, bo); VK_CALL(vkCmdDispatchIndirect(vk_command_buffer, bo->vk_buffer, diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 56069cb9f16..be4d095eba0 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -190,7 +190,7 @@ static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *bu buffer_gl->b.bo_user.valid = false; list_remove(&buffer_gl->b.bo_user.entry); wined3d_context_gl_destroy_bo(context_gl, &buffer_gl->bo); - buffer_gl->b.buffer_object = 0; + buffer_gl->b.buffer_object = NULL; }
/* Context activation is done by the caller. */ @@ -226,7 +226,7 @@ static BOOL wined3d_buffer_gl_create_buffer_object(struct wined3d_buffer_gl *buf }
list_add_head(&buffer_gl->bo.b.users, &buffer_gl->b.bo_user.entry); - buffer_gl->b.buffer_object = (uintptr_t)bo; + buffer_gl->b.buffer_object = &bo->b; buffer_invalidate_bo_range(&buffer_gl->b, 0, 0);
return TRUE; @@ -657,7 +657,7 @@ DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_co } if (locations & WINED3D_LOCATION_BUFFER) { - data->buffer_object = buffer->buffer_object; + data->buffer_object = (uintptr_t)buffer->buffer_object; data->addr = NULL; return WINED3D_LOCATION_BUFFER; } @@ -969,7 +969,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
if (count == 1) { - addr.buffer_object = buffer->buffer_object; + addr.buffer_object = (uintptr_t)buffer->buffer_object; addr.addr = 0; buffer->map_ptr = wined3d_context_map_bo_address(context, &addr, resource->size, flags); /* We are accessing buffer->resource.client from the CS thread, @@ -1049,7 +1049,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
context = context_acquire(device, NULL, 0);
- addr.buffer_object = buffer->buffer_object; + addr.buffer_object = (uintptr_t)buffer->buffer_object; addr.addr = 0; wined3d_context_unmap_bo_address(context, &addr, range_count, buffer->maps);
@@ -1455,7 +1455,7 @@ static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buf
list_init(&buffer_vk->b.bo_user.entry); list_add_head(&bo_vk->b.users, &buffer_vk->b.bo_user.entry); - buffer_vk->b.buffer_object = (uintptr_t)bo_vk; + buffer_vk->b.buffer_object = &bo_vk->b; buffer_invalidate_bo_range(&buffer_vk->b, 0, 0);
return TRUE; @@ -1463,7 +1463,7 @@ static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buf
const VkDescriptorBufferInfo *wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk *buffer_vk) { - struct wined3d_bo_vk *bo = (struct wined3d_bo_vk *)buffer_vk->b.buffer_object; + struct wined3d_bo_vk *bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
if (buffer_vk->b.bo_user.valid) return &buffer_vk->buffer_info; @@ -1499,8 +1499,8 @@ static BOOL wined3d_buffer_vk_prepare_location(struct wined3d_buffer *buffer, static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location) { - struct wined3d_bo_vk *bo_vk = (struct wined3d_bo_vk *)buffer->buffer_object; struct wined3d_context_vk *context_vk = wined3d_context_vk(context); + struct wined3d_bo_vk *bo_vk = wined3d_bo_vk(buffer->buffer_object);
TRACE("buffer %p, context %p, location %s.\n", buffer, context, wined3d_debug_location(location));
@@ -1511,7 +1511,7 @@ static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer, list_remove(&buffer->bo_user.entry); wined3d_context_vk_destroy_bo(context_vk, bo_vk); heap_free(bo_vk); - buffer->buffer_object = 0u; + buffer->buffer_object = NULL; break;
default: @@ -1535,14 +1535,14 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc if (!range_count) return;
- dst.buffer_object = buffer->buffer_object; + dst.buffer_object = (uintptr_t)buffer->buffer_object; dst.addr = NULL;
flags = WINED3D_MAP_WRITE; if (!ranges->offset && ranges->size == resource->size) flags |= WINED3D_MAP_DISCARD;
- dst_bo = (struct wined3d_bo_vk *)buffer->buffer_object; + dst_bo = wined3d_bo_vk(buffer->buffer_object); if (!(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) || (!(flags & WINED3D_MAP_DISCARD) && dst_bo->command_buffer_id > context_vk->completed_command_buffer_id)) { @@ -1634,7 +1634,7 @@ void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk,
if (src_bind_mask) { - const struct wined3d_bo_vk *bo = (struct wined3d_bo_vk *)buffer_vk->b.buffer_object; + const struct wined3d_bo_vk *bo = wined3d_bo_vk(buffer_vk->b.buffer_object); const struct wined3d_vk_info *vk_info = context_vk->vk_info; VkBufferMemoryBarrier vk_barrier;
diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 46769be516e..ec3554ddc30 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -2519,7 +2519,7 @@ static void wined3d_context_vk_bind_vertex_buffers(struct wined3d_context_vk *co { buffer_vk = wined3d_buffer_vk(buffer); buffer_info = wined3d_buffer_vk_get_buffer_info(buffer_vk); - wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer->buffer_object); + wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer->buffer_object)); buffers[count] = buffer_info->buffer; offsets[count] = buffer_info->offset + stream->offset; ++count; @@ -2558,7 +2558,7 @@ static void wined3d_context_vk_bind_stream_output_buffers(struct wined3d_context { buffer_vk = wined3d_buffer_vk(buffer); buffer_info = wined3d_buffer_vk_get_buffer_info(buffer_vk); - wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer->buffer_object); + wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer->buffer_object)); buffers[count] = buffer_info->buffer; if ((offsets[count] = stream->offset) == ~0u) { @@ -2760,7 +2760,7 @@ static bool wined3d_shader_descriptor_writes_vk_add_cbv_write(struct wined3d_sha if (!wined3d_shader_descriptor_writes_vk_add_write(writes, vk_descriptor_set, binding->binding_idx, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, buffer_info, NULL, NULL)) return false; - wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer->buffer_object); + wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer->buffer_object)); return true; }
@@ -3408,7 +3408,7 @@ VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *c idx_type = VK_INDEX_TYPE_UINT32; buffer_vk = wined3d_buffer_vk(state->index_buffer); buffer_info = wined3d_buffer_vk_get_buffer_info(buffer_vk); - wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer_vk->b.buffer_object); + wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer_vk->b.buffer_object)); VK_CALL(vkCmdBindIndexBuffer(vk_command_buffer, buffer_info->buffer, buffer_info->offset + state->index_offset, idx_type)); } diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index e6ff448b028..3143865c469 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2747,7 +2747,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi struct wined3d_buffer *buffer = buffer_from_resource(resource); size_t size = box->right - box->left;
- if (op->bo.addr.buffer_object && op->bo.addr.buffer_object == buffer->buffer_object) + if (op->bo.addr.buffer_object && op->bo.addr.buffer_object == (uintptr_t)buffer->buffer_object) wined3d_context_flush_bo_address(context, &op->bo.addr, size); else wined3d_buffer_copy_bo_address(buffer, context, box->left, &op->bo.addr, size); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index ee398be15f0..8746d9168c2 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -677,7 +677,7 @@ static VkBufferView wined3d_view_vk_create_vk_buffer_view(struct wined3d_context
get_buffer_view_range(&buffer_vk->b, desc, &view_format_vk->f, &offset, &size); wined3d_buffer_prepare_location(&buffer_vk->b, &context_vk->c, WINED3D_LOCATION_BUFFER); - bo = (struct wined3d_bo_vk *)buffer_vk->b.buffer_object; + bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
create_info.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; create_info.pNext = NULL; @@ -1102,7 +1102,7 @@ static void wined3d_shader_resource_view_vk_cs_init(void *object)
if (!vk_buffer_view) return; - bo = (struct wined3d_bo_vk *)buffer_vk->b.buffer_object; + bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
@@ -2208,7 +2208,7 @@ static void wined3d_unordered_access_view_vk_cs_init(void *object)
if ((vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, desc, buffer_vk, format_vk))) { - struct wined3d_bo_vk *bo = (struct wined3d_bo_vk *)buffer_vk->b.buffer_object; + struct wined3d_bo_vk *bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 398bd73c5c0..63fea9da0e7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1642,6 +1642,11 @@ struct wined3d_bo_vk bool host_synced; };
+static inline struct wined3d_bo_vk *wined3d_bo_vk(struct wined3d_bo *bo) +{ + return CONTAINING_RECORD(bo, struct wined3d_bo_vk, b); +} + struct wined3d_bo_slab_vk_key { VkMemoryPropertyFlags memory_type; @@ -5033,7 +5038,7 @@ struct wined3d_buffer DWORD flags; DWORD locations; void *map_ptr; - uintptr_t buffer_object; + struct wined3d_bo *buffer_object; struct wined3d_bo_user bo_user;
struct wined3d_range *maps; @@ -6319,7 +6324,7 @@ static inline void wined3d_context_vk_reference_resource(const struct wined3d_co struct wined3d_resource *resource) { if (resource->type == WINED3D_RTYPE_BUFFER) - wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer_from_resource(resource)->buffer_object); + wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer_from_resource(resource)->buffer_object)); else wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource))); }