Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This is scuffed, but ultimately this code path should go away anyway, and be replaced by an unconditional update_sub_resource.
dlls/wined3d/buffer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 12d038c0120..6cfeb4f510d 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1041,7 +1041,6 @@ static void wined3d_buffer_init_data(struct wined3d_buffer *buffer, struct wined3d_device *device, const struct wined3d_sub_resource_data *data) { struct wined3d_resource *resource = &buffer->resource; - struct wined3d_bo_address bo; struct wined3d_box box;
if (buffer->flags & WINED3D_BUFFER_USE_BO) @@ -1052,8 +1051,7 @@ static void wined3d_buffer_init_data(struct wined3d_buffer *buffer, } else { - wined3d_buffer_get_memory(buffer, &bo, WINED3D_LOCATION_SYSMEM); - memcpy(bo.addr, data->data, resource->size); + memcpy(buffer->resource.heap_memory, data->data, resource->size); wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_SYSMEM); wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_SYSMEM); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/buffer.c | 9 +++++---- dlls/wined3d/context.c | 2 +- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 3 +-- 4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 6cfeb4f510d..267a8a0bd9c 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -603,9 +603,10 @@ BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_c return buffer->resource.heap_memory; }
-DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, - struct wined3d_bo_address *data, DWORD locations) +DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_bo_address *data) { + unsigned int locations = buffer->locations; + TRACE("buffer %p, data %p, locations %s.\n", buffer, data, wined3d_debug_location(locations));
@@ -1005,10 +1006,10 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off TRACE("dst_buffer %p, dst_offset %u, src_buffer %p, src_offset %u, size %u.\n", dst_buffer, dst_offset, src_buffer, src_offset, size);
- dst_location = wined3d_buffer_get_memory(dst_buffer, &dst, dst_buffer->locations); + dst_location = wined3d_buffer_get_memory(dst_buffer, &dst); dst.addr += dst_offset;
- wined3d_buffer_get_memory(src_buffer, &src, src_buffer->locations); + wined3d_buffer_get_memory(src_buffer, &src); src.addr += src_offset;
context = context_acquire(dst_buffer->resource.device, NULL, 0); diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 7f50126204b..8b35b9da17f 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -304,7 +304,7 @@ void context_update_stream_info(struct wined3d_context *context, const struct wi else { wined3d_buffer_load(buffer, context, state); - wined3d_buffer_get_memory(buffer, &data, buffer->locations); + wined3d_buffer_get_memory(buffer, &data); element->data.buffer_object = data.buffer_object; element->data.addr += (ULONG_PTR)data.addr; } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 7900df3c246..9baa0ae0cd3 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1611,7 +1611,7 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_ if (!view->counter_bo) return;
- dst_location = wined3d_buffer_get_memory(buffer, &dst, buffer->locations); + dst_location = wined3d_buffer_get_memory(buffer, &dst); dst.addr += offset;
src.buffer_object = view->counter_bo; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index bbc2f4f4db7..6ada1fa3642 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4899,8 +4899,7 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset, struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN; -DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, - struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN; +DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_bo_address *data) DECLSPEC_HIDDEN; void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN; void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
This can't currently happen. However, we'd like to use wined3d_buffer_get_memory() in wined3d_cs_exec_update_sub_resource(). This would probably also help in implementing ID3D11DeviceContext1::DiscardResource().
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/buffer.c | 26 ++++++++++++++++++++------ dlls/wined3d/context.c | 2 +- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 3 ++- 4 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 267a8a0bd9c..cbf33df5539 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -603,13 +603,26 @@ BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_c return buffer->resource.heap_memory; }
-DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_bo_address *data) +DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context, + struct wined3d_bo_address *data) { unsigned int locations = buffer->locations;
- TRACE("buffer %p, data %p, locations %s.\n", - buffer, data, wined3d_debug_location(locations)); + TRACE("buffer %p, context %p, data %p, locations %s.\n", + buffer, context, data, wined3d_debug_location(locations));
+ if (locations & WINED3D_LOCATION_DISCARDED) + { + locations = ((buffer->flags & WINED3D_BUFFER_USE_BO) ? WINED3D_LOCATION_BUFFER : WINED3D_LOCATION_SYSMEM); + if (!wined3d_buffer_prepare_location(buffer, context, locations)) + { + data->buffer_object = 0; + data->addr = NULL; + return 0; + } + wined3d_buffer_validate_location(buffer, locations); + wined3d_buffer_invalidate_location(buffer, WINED3D_LOCATION_DISCARDED); + } if (locations & WINED3D_LOCATION_BUFFER) { data->buffer_object = buffer->buffer_object; @@ -1006,13 +1019,14 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off TRACE("dst_buffer %p, dst_offset %u, src_buffer %p, src_offset %u, size %u.\n", dst_buffer, dst_offset, src_buffer, src_offset, size);
- dst_location = wined3d_buffer_get_memory(dst_buffer, &dst); + context = context_acquire(dst_buffer->resource.device, NULL, 0); + + dst_location = wined3d_buffer_get_memory(dst_buffer, context, &dst); dst.addr += dst_offset;
- wined3d_buffer_get_memory(src_buffer, &src); + wined3d_buffer_get_memory(src_buffer, context, &src); src.addr += src_offset;
- context = context_acquire(dst_buffer->resource.device, NULL, 0); wined3d_context_copy_bo_address(context, &dst, &src, size); context_release(context);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 8b35b9da17f..a44e979d32c 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -304,7 +304,7 @@ void context_update_stream_info(struct wined3d_context *context, const struct wi else { wined3d_buffer_load(buffer, context, state); - wined3d_buffer_get_memory(buffer, &data); + wined3d_buffer_get_memory(buffer, context, &data); element->data.buffer_object = data.buffer_object; element->data.addr += (ULONG_PTR)data.addr; } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 9baa0ae0cd3..67f4b03e9d3 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1611,7 +1611,7 @@ void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_ if (!view->counter_bo) return;
- dst_location = wined3d_buffer_get_memory(buffer, &dst); + dst_location = wined3d_buffer_get_memory(buffer, context, &dst); dst.addr += offset;
src.buffer_object = view->counter_bo; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6ada1fa3642..400d20b94b4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4899,7 +4899,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset, struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN; -DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_bo_address *data) DECLSPEC_HIDDEN; +DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context, + struct wined3d_bo_address *data) DECLSPEC_HIDDEN; void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN; void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/buffer.c | 24 ++++++++++++++++-------- dlls/wined3d/view.c | 10 ++-------- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index cbf33df5539..7b8c8904961 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1009,28 +1009,36 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou return WINED3D_OK; }
+void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wined3d_context *context, + unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size) +{ + struct wined3d_bo_address dst_addr; + DWORD dst_location; + + dst_location = wined3d_buffer_get_memory(dst_buffer, context, &dst_addr); + dst_addr.addr += dst_offset; + + wined3d_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, size); + wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); +} + void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset, struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) { - struct wined3d_bo_address dst, src; struct wined3d_context *context; - DWORD dst_location; + struct wined3d_bo_address src;
TRACE("dst_buffer %p, dst_offset %u, src_buffer %p, src_offset %u, size %u.\n", dst_buffer, dst_offset, src_buffer, src_offset, size);
context = context_acquire(dst_buffer->resource.device, NULL, 0);
- dst_location = wined3d_buffer_get_memory(dst_buffer, context, &dst); - dst.addr += dst_offset; - wined3d_buffer_get_memory(src_buffer, context, &src); src.addr += src_offset;
- wined3d_context_copy_bo_address(context, &dst, &src, size); - context_release(context); + wined3d_buffer_copy_bo_address(dst_buffer, context, dst_offset, wined3d_const_bo_address(&src), size);
- wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); + context_release(context); }
void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context, diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 67f4b03e9d3..e8c91ec6413 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1605,21 +1605,15 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view, struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) { - struct wined3d_bo_address dst, src; - DWORD dst_location; + struct wined3d_const_bo_address src;
if (!view->counter_bo) return;
- dst_location = wined3d_buffer_get_memory(buffer, context, &dst); - dst.addr += offset; - src.buffer_object = view->counter_bo; src.addr = NULL;
- wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t)); - - wined3d_buffer_invalidate_location(buffer, ~dst_location); + wined3d_buffer_copy_bo_address(buffer, context, offset, &src, sizeof(uint32_t)); }
void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl *uav_gl, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 400d20b94b4..da1cf638606 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4899,6 +4899,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset, struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN; +void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wined3d_context *context, + unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size) DECLSPEC_HIDDEN; DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context, struct wined3d_bo_address *data) DECLSPEC_HIDDEN; void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
As in wined3d_buffer_vk_upload_ranges().
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/adapter_vk.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 9f36ee39080..850e2a6dfdb 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1007,6 +1007,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, struct wined3d_bo_vk staging_bo, *src_bo, *dst_bo; VkAccessFlags src_access_mask, dst_access_mask; VkBufferMemoryBarrier vk_barrier[2]; + DWORD map_flags = WINED3D_MAP_WRITE; struct wined3d_bo_address staging; VkCommandBuffer vk_command_buffer; struct wined3d_range range; @@ -1016,6 +1017,9 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, src_bo = (struct wined3d_bo_vk *)src->buffer_object; dst_bo = (struct wined3d_bo_vk *)dst->buffer_object;
+ if (dst_bo && !dst->addr && size == dst_bo->size) + map_flags |= WINED3D_MAP_DISCARD; + if (src_bo && dst_bo) { if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk))) @@ -1092,8 +1096,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, return; }
- if (dst_bo && (dst_bo->command_buffer_id > context_vk->completed_command_buffer_id - || !(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))) + 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, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_bo))) @@ -1113,7 +1117,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, }
src_ptr = adapter_vk_map_bo_address(context, src, size, WINED3D_MAP_READ); - dst_ptr = adapter_vk_map_bo_address(context, dst, size, WINED3D_MAP_WRITE); + dst_ptr = adapter_vk_map_bo_address(context, dst, size, map_flags);
memcpy(dst_ptr, src_ptr, size);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com