From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/cs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 029ca5d884d..5fc2bf64074 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -4211,7 +4211,7 @@ static bool wined3d_deferred_context_unmap_upload_bo(struct wined3d_device_conte struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *bo) { struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context); - const struct wined3d_deferred_upload *upload; + struct wined3d_deferred_upload *upload;
if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx))) { @@ -4219,6 +4219,7 @@ static bool wined3d_deferred_context_unmap_upload_bo(struct wined3d_device_conte bo->addr.buffer_object = 0; bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); bo->flags = upload->upload_flags; + upload->upload_flags = 0; return true; }
From: Zebediah Figura zfigura@codeweavers.com
This is a step towards implementing D3D11_COPY_FLAGS. --- dlls/wined3d/adapter_gl.c | 4 ++-- dlls/wined3d/adapter_vk.c | 14 +++++--------- dlls/wined3d/buffer.c | 22 ++++++++++++++++++---- dlls/wined3d/context_gl.c | 6 +----- dlls/wined3d/directx.c | 2 +- dlls/wined3d/texture.c | 3 ++- dlls/wined3d/view.c | 5 +++-- dlls/wined3d/wined3d_private.h | 8 ++++---- dlls/wined3d/wined3d_vk.h | 2 +- 9 files changed, 37 insertions(+), 29 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index f1216ddd89b..4b30b8aa94c 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4600,9 +4600,9 @@ static void adapter_gl_unmap_bo_address(struct wined3d_context *context,
static void adapter_gl_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, - unsigned int range_count, const struct wined3d_range *ranges) + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags) { - wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), dst, src, range_count, ranges); + wined3d_context_gl_copy_bo_address(wined3d_context_gl(context), dst, src, range_count, ranges, map_flags); }
static void adapter_gl_flush_bo_address(struct wined3d_context *context, diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index a27e8e41d88..a03ec37161e 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -1029,14 +1029,13 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context,
void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, - unsigned int range_count, const struct wined3d_range *ranges) + unsigned int range_count, const struct wined3d_range *ranges, 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; 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; const struct wined3d_range *range; struct wined3d_bo_address staging; VkCommandBuffer vk_command_buffer; @@ -1048,9 +1047,6 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context, src_bo = src->buffer_object ? wined3d_bo_vk(src->buffer_object) : NULL; dst_bo = dst->buffer_object ? wined3d_bo_vk(dst->buffer_object) : NULL;
- if (dst_bo && !dst->addr && !ranges->offset && ranges->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))) @@ -1131,8 +1127,8 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = &staging_bo.b; staging.addr = NULL; - adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges); - adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges); + adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges, WINED3D_MAP_WRITE); + adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges, WINED3D_MAP_WRITE);
wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
@@ -1151,8 +1147,8 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
staging.buffer_object = &staging_bo.b; staging.addr = NULL; - adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges); - adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges); + adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges, WINED3D_MAP_WRITE); + adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges, WINED3D_MAP_WRITE);
wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index f1b4a3d44c3..2c99e5872ca 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -562,7 +562,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined dst.addr = NULL; src.buffer_object = NULL; src.addr = data; - wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps); + wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps, WINED3D_MAP_WRITE);
heap_free(data); } @@ -629,7 +629,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, src.addr = NULL; range.offset = 0; range.size = buffer->resource.size; - wined3d_context_copy_bo_address(context, &dst, &src, 1, &range); + wined3d_context_copy_bo_address(context, &dst, &src, 1, &range, WINED3D_MAP_WRITE); } break;
@@ -648,9 +648,19 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, src.addr = buffer->resource.heap_memory;
if (!buffer->conversion_map) - wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps); + { + uint32_t map_flags = WINED3D_MAP_WRITE; + + if (buffer->modified_areas == 1 && !buffer->maps[0].offset + && buffer->maps[0].size == buffer->resource.size) + map_flags |= WINED3D_MAP_DISCARD; + + wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps, map_flags); + } else + { buffer_conversion_upload(buffer, context); + } break;
default: @@ -1134,16 +1144,20 @@ static void wined3d_buffer_set_bo(struct wined3d_buffer *buffer, struct wined3d_ 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) { + uint32_t map_flags = WINED3D_MAP_WRITE; struct wined3d_bo_address dst_addr; struct wined3d_range range; 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;
range.offset = 0; range.size = size; - wined3d_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, 1, &range); + wined3d_context_copy_bo_address(context, &dst_addr, (const struct wined3d_bo_address *)src_addr, 1, &range, map_flags); wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); }
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index c2ebca8e99f..29910cb29cf 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3067,9 +3067,8 @@ void wined3d_context_gl_flush_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, - unsigned int range_count, const struct wined3d_range *ranges) + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags) { - uint32_t map_flags = WINED3D_MAP_WRITE; const struct wined3d_gl_info *gl_info; struct wined3d_bo_gl *src_bo, *dst_bo; BYTE *dst_ptr, *src_ptr; @@ -3079,9 +3078,6 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, src_bo = src->buffer_object ? wined3d_bo_gl(src->buffer_object) : NULL; dst_bo = dst->buffer_object ? wined3d_bo_gl(dst->buffer_object) : NULL;
- if (dst_bo && !dst->addr && !ranges->offset && ranges->size == dst_bo->size) - map_flags |= WINED3D_MAP_DISCARD; - if (dst_bo && src_bo) { if (gl_info->supported[ARB_COPY_BUFFER]) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 7827e65f948..eb0e5e9bad0 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2981,7 +2981,7 @@ static void adapter_no3d_unmap_bo_address(struct wined3d_context *context,
static void adapter_no3d_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, - unsigned int range_count, const struct wined3d_range *ranges) + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags) { unsigned int i;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 186110f4d12..2b9d6e3a8b3 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -867,7 +867,8 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture, { wined3d_texture_get_bo_address(texture, sub_resource_idx, &source, (current & wined3d_texture_sysmem_locations)); - wined3d_context_copy_bo_address(context, &destination, &source, 1, &range); + wined3d_context_copy_bo_address(context, &destination, &source, 1, &range, + WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD); } ret = TRUE; } diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 05d607649bc..e862f54bc10 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1689,7 +1689,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v
range.offset = 0; range.size = sizeof(value); - wined3d_context_copy_bo_address(context, &dst, &src, 1, &range); + wined3d_context_copy_bo_address(context, &dst, &src, 1, &range, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
context_release(context); } @@ -2175,7 +2175,8 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
range.offset = 0; range.size = sizeof(constants); - adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address, &cb_source_address, 1, &range); + adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address, + &cb_source_address, 1, &range, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
buffer_info.buffer = constants_bo.vk_buffer; buffer_info.range = constants_bo.size; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2ddb2271d9d..6866474375a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2342,7 +2342,7 @@ void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, 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, - unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN; + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags) DECLSPEC_HIDDEN; void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN; void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl, @@ -3081,7 +3081,7 @@ struct wined3d_adapter_ops 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, - unsigned int range_count, const struct wined3d_range *ranges); + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags); void (*adapter_flush_bo_address)(struct wined3d_context *context, const struct wined3d_const_bo_address *data, size_t size); bool (*adapter_alloc_bo)(struct wined3d_device *device, struct wined3d_resource *resource, @@ -5803,9 +5803,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, - unsigned int range_count, const struct wined3d_range *ranges) + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags) { - context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, range_count, ranges); + context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, range_count, ranges, map_flags); }
static inline void wined3d_context_flush_bo_address(struct wined3d_context *context, diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 170d0cc3a79..821dfa74d37 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -704,7 +704,7 @@ static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapt
void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, - unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN; + unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags) DECLSPEC_HIDDEN; unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk, uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN; BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk,
From: Zebediah Figura zfigura@codeweavers.com
Don't load the buffer location if we are clearing the whole buffer, and never load the texture location (for Vulkan; GL already did this). Only prepare them instead. --- dlls/wined3d/buffer.c | 2 +- dlls/wined3d/view.c | 57 +++++++++++++++++++++++++++------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 2c99e5872ca..efbd3233428 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -103,7 +103,7 @@ static BOOL buffer_is_fully_dirty(const struct wined3d_buffer *buffer) && !buffer->maps->offset && buffer->maps->size == buffer->resource.size; }
-static void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, DWORD location) +void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location) { TRACE("buffer %p, location %s.\n", buffer, wined3d_debug_location(location));
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index e862f54bc10..fb6f5d545ba 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -1657,11 +1657,15 @@ void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view }
buffer = buffer_from_resource(resource); - wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER); + get_buffer_view_range(buffer, &view_gl->v.desc, &format_gl->f, &offset, &size); + + if (!offset && size == buffer->resource.size) + wined3d_buffer_prepare_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER); + else + wined3d_buffer_load_location(buffer, &context_gl->c, WINED3D_LOCATION_BUFFER); wined3d_unordered_access_view_invalidate_location(&view_gl->v, ~WINED3D_LOCATION_BUFFER);
bo_gl = wined3d_bo_gl(buffer->buffer_object); - get_buffer_view_range(buffer, &view_gl->v.desc, &format_gl->f, &offset, &size); wined3d_context_gl_bind_bo(context_gl, bo_gl->binding, bo_gl->id); GL_EXTCALL(glClearBufferSubData(bo_gl->binding, format_gl->internal, bo_gl->b.buffer_offset + offset, size, format_gl->format, format_gl->type, clear_value)); @@ -1979,8 +1983,6 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view struct wined3d_range range; VkMemoryBarrier vk_barrier; VkPipeline vk_pipeline; - DWORD uav_location; - unsigned int level; bool is_array;
device_vk = wined3d_device_vk(device); @@ -2048,8 +2050,8 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view if (resource->type == WINED3D_RTYPE_BUFFER) { struct wined3d_buffer *buffer = buffer_from_resource(resource); + unsigned int offset, size;
- uav_location = WINED3D_LOCATION_BUFFER; layout = state->buffer_layout; vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
@@ -2058,19 +2060,53 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view else constants.extent.width = view_desc->u.buffer.count; constants.extent.height = 1; + + get_buffer_view_range(buffer, view_desc, view_format, &offset, &size); + if (!offset && size == buffer->resource.size) + wined3d_buffer_prepare_location(buffer, &context_vk->c, WINED3D_LOCATION_BUFFER); + else + wined3d_buffer_load_location(buffer, &context_vk->c, WINED3D_LOCATION_BUFFER); + wined3d_buffer_validate_location(buffer, WINED3D_LOCATION_BUFFER); + wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER); } else { + unsigned int layer_count, level_count, base_level, base_layer, i, j; + texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(resource));
- uav_location = WINED3D_LOCATION_TEXTURE_RGB; layout = state->image_layout; vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
- level = view_desc->u.texture.level_idx; - constants.extent.width = wined3d_texture_get_level_width(&texture_vk->t, level); - constants.extent.height = wined3d_texture_get_level_height(&texture_vk->t, level); + level_count = view_desc->u.texture.level_count; + base_level = view_desc->u.texture.level_idx; + if (resource->type == WINED3D_RTYPE_TEXTURE_3D) + { + layer_count = 1; + base_layer = 0; + } + else + { + layer_count = view_desc->u.texture.layer_count; + base_layer = view_desc->u.texture.layer_idx; + } + + constants.extent.width = wined3d_texture_get_level_width(&texture_vk->t, base_level); + constants.extent.height = wined3d_texture_get_level_height(&texture_vk->t, base_level); group_count.z = (view_desc->u.texture.layer_count + group_count.z - 1) / group_count.z; + + for (i = 0; i < layer_count; ++i) + { + for (j = 0; j < level_count; ++j) + { + unsigned int sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level + j; + + wined3d_texture_prepare_location(&texture_vk->t, sub_resource_idx, + &context_vk->c, WINED3D_LOCATION_TEXTURE_RGB); + wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); + wined3d_texture_invalidate_location(&texture_vk->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB); + } + } }
group_count.x = (constants.extent.width + group_count.x - 1) / group_count.x; @@ -2108,9 +2144,6 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view return; }
- wined3d_view_load_location(resource, view_desc, &context_vk->c, uav_location); - wined3d_unordered_access_view_invalidate_location(&view_vk->v, ~uav_location); - if (resource->type == WINED3D_RTYPE_BUFFER) { if (format_id == view_format->id) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6866474375a..c2d9bfe1450 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4739,6 +4739,7 @@ BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location) DECLSPEC_HIDDEN; void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct upload_bo *upload_bo, unsigned int offset, unsigned int size) DECLSPEC_HIDDEN; +void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location) DECLSPEC_HIDDEN;
HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device, const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
This merge request was approved by Jan Sikorski.