Commit 6f292cf3 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Avoid accessing the "bo" member of struct wined3d_buffer_vk.

So as to allow the "buffer_object" field to point to other another wined3d_bo_vk; namely, one allocated and still in use by the client thread. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 88f0afd9
......@@ -1745,7 +1745,7 @@ static void adapter_vk_draw_primitive(struct wined3d_device *device,
if (parameters->indirect)
{
struct wined3d_bo_vk *bo = &indirect_vk->bo;
struct wined3d_bo_vk *bo = (struct 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 = &indirect_vk->bo;
struct wined3d_bo_vk *bo = (struct 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,
......
......@@ -1459,11 +1459,13 @@ 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;
if (buffer_vk->b.bo_user.valid)
return &buffer_vk->buffer_info;
buffer_vk->buffer_info.buffer = buffer_vk->bo.vk_buffer;
buffer_vk->buffer_info.offset = buffer_vk->bo.buffer_offset;
buffer_vk->buffer_info.buffer = bo->vk_buffer;
buffer_vk->buffer_info.offset = bo->buffer_offset;
buffer_vk->buffer_info.range = buffer_vk->b.resource.size;
buffer_vk->b.bo_user.valid = true;
......@@ -1537,7 +1539,7 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc
if (!ranges->offset && ranges->size == resource->size)
flags |= WINED3D_MAP_DISCARD;
dst_bo = &wined3d_buffer_vk(buffer)->bo;
dst_bo = (struct 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))
{
......@@ -1629,6 +1631,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_vk_info *vk_info = context_vk->vk_info;
VkBufferMemoryBarrier vk_barrier;
......@@ -1643,8 +1646,8 @@ void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk,
vk_barrier.dstAccessMask = vk_access_mask_from_bind_flags(bind_mask);
vk_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
vk_barrier.buffer = buffer_vk->bo.vk_buffer;
vk_barrier.offset = buffer_vk->bo.buffer_offset;
vk_barrier.buffer = bo->vk_buffer;
vk_barrier.offset = bo->buffer_offset;
vk_barrier.size = buffer_vk->b.resource.size;
VK_CALL(vkCmdPipelineBarrier(wined3d_context_vk_get_command_buffer(context_vk),
vk_pipeline_stage_mask_from_bind_flags(src_bind_mask),
......
......@@ -2496,7 +2496,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, &buffer_vk->bo);
wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer->buffer_object);
buffers[count] = buffer_info->buffer;
offsets[count] = buffer_info->offset + stream->offset;
++count;
......@@ -2535,7 +2535,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, &buffer_vk->bo);
wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer->buffer_object);
buffers[count] = buffer_info->buffer;
if ((offsets[count] = stream->offset) == ~0u)
{
......@@ -2737,7 +2737,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, &buffer_vk->bo);
wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer->buffer_object);
return true;
}
......@@ -3385,7 +3385,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, &buffer_vk->bo);
wined3d_context_vk_reference_bo(context_vk, (struct 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));
}
......
......@@ -672,17 +672,19 @@ static VkBufferView wined3d_view_vk_create_vk_buffer_view(struct wined3d_context
struct wined3d_device_vk *device_vk;
VkBufferView vk_buffer_view;
unsigned int offset, size;
struct wined3d_bo_vk *bo;
VkResult vr;
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;
create_info.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
create_info.pNext = NULL;
create_info.flags = 0;
create_info.buffer = buffer_vk->bo.vk_buffer;
create_info.buffer = bo->vk_buffer;
create_info.format = view_format_vk->vk_format;
create_info.offset = buffer_vk->bo.buffer_offset + offset;
create_info.offset = bo->buffer_offset + offset;
create_info.range = size;
device_vk = wined3d_device_vk(buffer_vk->b.resource.device);
......@@ -1082,6 +1084,7 @@ static void wined3d_shader_resource_view_vk_cs_init(void *object)
VkBufferView vk_buffer_view;
uint32_t default_flags = 0;
VkImageView vk_image_view;
struct wined3d_bo_vk *bo;
TRACE("srv_vk %p.\n", srv_vk);
......@@ -1099,12 +1102,13 @@ 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;
TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
srv_vk->view_vk.u.vk_buffer_view = vk_buffer_view;
srv_vk->view_vk.bo_user.valid = true;
list_add_head(&buffer_vk->bo.b.users, &srv_vk->view_vk.bo_user.entry);
list_add_head(&bo->b.users, &srv_vk->view_vk.bo_user.entry);
return;
}
......@@ -2204,11 +2208,13 @@ 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;
TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
uav_vk->view_vk.u.vk_buffer_view = vk_buffer_view;
uav_vk->view_vk.bo_user.valid = true;
list_add_head(&buffer_vk->bo.b.users, &view_vk->bo_user.entry);
list_add_head(&bo->b.users, &view_vk->bo_user.entry);
}
if (desc->flags & (WINED3D_VIEW_BUFFER_COUNTER | WINED3D_VIEW_BUFFER_APPEND))
......
......@@ -6315,7 +6315,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, &wined3d_buffer_vk(buffer_from_resource(resource))->bo);
wined3d_context_vk_reference_bo(context_vk, (struct wined3d_bo_vk *)buffer_from_resource(resource)->buffer_object);
else
wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment