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;
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: 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: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/adapter_gl.c | 6 +++--- dlls/wined3d/adapter_vk.c | 14 +++++++------- dlls/wined3d/buffer.c | 8 ++++++-- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/directx.c | 4 ++-- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 12 ++++++------ 7 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index 902b9620f30..7c2e0460df7 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4588,10 +4588,10 @@ static void adapter_gl_unmap_bo_address(struct wined3d_context *context, wined3d_context_gl_unmap_bo_address(wined3d_context_gl(context), data, range_count, ranges); }
-static void adapter_gl_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) +static void adapter_gl_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, + const struct wined3d_bo_address *src, size_t size, uint32_t map_flags) { - wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), dst, src, size); + wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), dst, src, size, map_flags); }
static HRESULT adapter_gl_create_swapchain(struct wined3d_device *device, diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 9f36ee39080..7e7a6b4b0bd 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -999,8 +999,8 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context, wined3d_bo_vk_unmap(bo, context_vk); }
-static 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) +static 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, uint32_t map_flags) { struct wined3d_context_vk *context_vk = wined3d_context_vk(context); const struct wined3d_vk_info *vk_info = context_vk->vk_info; @@ -1084,8 +1084,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = (uintptr_t)&staging_bo; staging.addr = NULL; - adapter_vk_copy_bo_address(context, &staging, src, size); - adapter_vk_copy_bo_address(context, dst, &staging, size); + adapter_vk_copy_bo_address(context, &staging, src, size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD); + adapter_vk_copy_bo_address(context, dst, &staging, size, map_flags);
wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
@@ -1104,8 +1104,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = (uintptr_t)&staging_bo; staging.addr = NULL; - adapter_vk_copy_bo_address(context, &staging, src, size); - adapter_vk_copy_bo_address(context, dst, &staging, size); + adapter_vk_copy_bo_address(context, &staging, src, size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD); + adapter_vk_copy_bo_address(context, dst, &staging, size, map_flags);
wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
@@ -1113,7 +1113,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);
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 7b8c8904961..01e1aad8bad 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1012,13 +1012,17 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou 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) { + DWORD map_flags = WINED3D_MAP_WRITE; struct wined3d_bo_address dst_addr; DWORD dst_location;
+ if (!dst_offset && size == dst_buffer->resource.size) + map_flags |= WINED3D_MAP_DISCARD; + 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_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, size, map_flags); wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); }
@@ -1526,7 +1530,7 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc
src.addr = (uint8_t *)data + range->offset - data_offset; dst.addr = (void *)(uintptr_t)range->offset; - wined3d_context_copy_bo_address(context, &dst, &src, range->size); + wined3d_context_copy_bo_address(context, &dst, &src, range->size, flags); }
return; diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 43c086ac758..3f5c492d8b7 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2759,7 +2759,7 @@ void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, }
void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size, uint32_t map_flags) { const struct wined3d_gl_info *gl_info; struct wined3d_bo_gl *src_bo, *dst_bo; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index a39c6d75750..3cc06e683fc 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2785,8 +2785,8 @@ static void adapter_no3d_unmap_bo_address(struct wined3d_context *context, ERR("Unsupported buffer object %#lx.\n", data->buffer_object); }
-static void adapter_no3d_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) +static void adapter_no3d_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, + const struct wined3d_bo_address *src, size_t size, uint32_t map_flags) { if (dst->buffer_object) ERR("Unsupported dst buffer object %#lx.\n", dst->buffer_object); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index e8c91ec6413..3ce26fa9c98 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1597,7 +1597,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v dst.buffer_object = view->counter_bo; dst.addr = NULL;
- wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t)); + wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t), WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
context_release(context); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index da1cf638606..95d1a2f6dab 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2309,8 +2309,8 @@ void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *con void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLenum target, GLuint name) DECLSPEC_HIDDEN; void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN; -void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN; +void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *dst, + const struct wined3d_bo_address *src, size_t size, uint32_t map_flags) DECLSPEC_HIDDEN; bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN; void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; @@ -3317,8 +3317,8 @@ struct wined3d_adapter_ops const struct wined3d_bo_address *data, size_t size, uint32_t map_flags); void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges); - void (*adapter_copy_bo_address)(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size); + void (*adapter_copy_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *dst, + const struct wined3d_bo_address *src, size_t size, uint32_t map_flags); HRESULT (*adapter_create_swapchain)(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, @@ -6111,9 +6111,9 @@ static inline void wined3d_context_unmap_bo_address(struct wined3d_context *cont }
static inline void wined3d_context_copy_bo_address(struct wined3d_context *context, - const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) + const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size, uint32_t map_flags) { - context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, size); + context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, size, map_flags); }
static inline void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk,
On Fri, 18 Jun 2021 at 06:20, Zebediah Figura z.figura12@gmail.com wrote:
dlls/wined3d/adapter_gl.c | 6 +++--- dlls/wined3d/adapter_vk.c | 14 +++++++------- dlls/wined3d/buffer.c | 8 ++++++-- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/directx.c | 4 ++-- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 12 ++++++------ 7 files changed, 26 insertions(+), 22 deletions(-)
This may be ok, but I'm curious about the reasoning. In particular, is there ever a case where you'd want to pass WINED3D_MAP_DISCARD to wined3d_context_copy_bo_address(), instead of just using wined3d_context_map_bo_address() with WINED3D_MAP_DISCARD?
And mostly to illustrate the point:
@@ -1084,8 +1084,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = (uintptr_t)&staging_bo; staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
adapter_vk_copy_bo_address(context, &staging, src, size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
adapter_vk_copy_bo_address(context, dst, &staging, size, map_flags);
We just created the staging bo, so it's idle by definition.
@@ -1104,8 +1104,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = (uintptr_t)&staging_bo; staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
adapter_vk_copy_bo_address(context, &staging, src, size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
adapter_vk_copy_bo_address(context, dst, &staging, size, map_flags);
Likewise.
@@ -1012,13 +1012,17 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou 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) {
DWORD map_flags = WINED3D_MAP_WRITE; struct wined3d_bo_address dst_addr; DWORD dst_location;
if (!dst_offset && size == dst_buffer->resource.size)
map_flags |= WINED3D_MAP_DISCARD;
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_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, size, map_flags); wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size);
}
Sure, but if that's worth doing, we may as well do it in the wined3d_context_copy_bo_address() implementations.
@@ -1526,7 +1530,7 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc
src.addr = (uint8_t *)data + range->offset - data_offset; dst.addr = (void *)(uintptr_t)range->offset;
wined3d_context_copy_bo_address(context, &dst, &src, range->size);
wined3d_context_copy_bo_address(context, &dst, &src, range->size, flags); }
"flags" never contains DISCARD here if "dst" is mappable, and if it's not, it doesn't matter.
@@ -1597,7 +1597,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v dst.buffer_object = view->counter_bo; dst.addr = NULL;
- wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t));
wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t), WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
context_release(context);
}
Sure, but like further above, this could be caught in the wined3d_context_copy_bo_address() implementations.
On 6/18/21 7:24 AM, Henri Verbeet wrote:
On Fri, 18 Jun 2021 at 06:20, Zebediah Figura z.figura12@gmail.com wrote:
dlls/wined3d/adapter_gl.c | 6 +++--- dlls/wined3d/adapter_vk.c | 14 +++++++------- dlls/wined3d/buffer.c | 8 ++++++-- dlls/wined3d/context_gl.c | 2 +- dlls/wined3d/directx.c | 4 ++-- dlls/wined3d/view.c | 2 +- dlls/wined3d/wined3d_private.h | 12 ++++++------ 7 files changed, 26 insertions(+), 22 deletions(-)
This may be ok, but I'm curious about the reasoning. In particular, is there ever a case where you'd want to pass WINED3D_MAP_DISCARD to wined3d_context_copy_bo_address(), instead of just using wined3d_context_map_bo_address() with WINED3D_MAP_DISCARD?
And mostly to illustrate the point:
@@ -1084,8 +1084,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = (uintptr_t)&staging_bo; staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
adapter_vk_copy_bo_address(context, &staging, src, size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
adapter_vk_copy_bo_address(context, dst, &staging, size, map_flags);
We just created the staging bo, so it's idle by definition.
@@ -1104,8 +1104,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = (uintptr_t)&staging_bo; staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
adapter_vk_copy_bo_address(context, &staging, src, size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
adapter_vk_copy_bo_address(context, dst, &staging, size, map_flags);
Likewise.
@@ -1012,13 +1012,17 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou 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) {
DWORD map_flags = WINED3D_MAP_WRITE; struct wined3d_bo_address dst_addr; DWORD dst_location;
if (!dst_offset && size == dst_buffer->resource.size)
map_flags |= WINED3D_MAP_DISCARD;
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_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, size, map_flags); wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); }
Sure, but if that's worth doing, we may as well do it in the wined3d_context_copy_bo_address() implementations.
This is the case I care about mostly. I didn't actually bother to check whether we had access to the BO size, but evidently we do. I'll alter the implementation accordingly.
@@ -1526,7 +1530,7 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc
src.addr = (uint8_t *)data + range->offset - data_offset; dst.addr = (void *)(uintptr_t)range->offset;
wined3d_context_copy_bo_address(context, &dst, &src, range->size);
wined3d_context_copy_bo_address(context, &dst, &src, range->size, flags); }
"flags" never contains DISCARD here if "dst" is mappable, and if it's not, it doesn't matter.
@@ -1597,7 +1597,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v dst.buffer_object = view->counter_bo; dst.addr = NULL;
- wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t));
wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t), WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
context_release(context); }
Sure, but like further above, this could be caught in the wined3d_context_copy_bo_address() implementations.
As in wined3d_buffer_vk_upload_ranges().
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/adapter_vk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 7e7a6b4b0bd..615dc6040f4 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1092,8 +1092,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, const st 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)))