We can't do an asynchronous upload with just WINED3D_MAP_WRITE, but we can with update_sub_resource, and prepare_upload_bo doesn't know which it was called from.
Signed-off-by: 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 1cbbc43399a..376ee1a6c7e 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2465,7 +2465,8 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
- if ((*map_ptr = context->ops->prepare_upload_bo(context, resource, + if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + && (*map_ptr = context->ops->prepare_upload_bo(context, resource, sub_resource_idx, box, row_pitch, slice_pitch, flags, &addr))) { TRACE("Returning upload bo %s, map pointer %p, row pitch %u, slice pitch %u.\n",
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/cs.c | 58 +++++++++++++++++----------------- dlls/wined3d/wined3d_private.h | 9 ++++-- 2 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 376ee1a6c7e..41491c768cf 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -506,7 +506,7 @@ struct wined3d_cs_update_sub_resource struct wined3d_resource *resource; unsigned int sub_resource_idx; struct wined3d_box box; - struct wined3d_const_bo_address addr; + struct upload_bo bo; unsigned int row_pitch, slice_pitch; };
@@ -2425,19 +2425,20 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou
static void wined3d_device_context_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, - const struct wined3d_const_bo_address *addr, unsigned int row_pitch, unsigned int slice_pitch) + const struct upload_bo *bo, unsigned int row_pitch, unsigned int slice_pitch) { struct wined3d_cs_update_sub_resource *op;
- TRACE("context %p, resource %p, sub_resource_idx %u, box %s, addr %s, row_pitch %u, slice_pitch %u.\n", - context, resource, sub_resource_idx, debug_box(box), debug_const_bo_address(addr), row_pitch, slice_pitch); + TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, row_pitch %u, slice_pitch %u.\n", + context, resource, sub_resource_idx, debug_box(box), + debug_const_bo_address(&bo->addr), row_pitch, slice_pitch);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; op->resource = resource; op->sub_resource_idx = sub_resource_idx; op->box = *box; - op->addr = *addr; + op->bo = *bo; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
@@ -2458,19 +2459,19 @@ static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data) HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags) { - struct wined3d_const_bo_address addr; unsigned int row_pitch, slice_pitch; struct wined3d_cs_map *op; + struct upload_bo bo; HRESULT hr;
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) && (*map_ptr = context->ops->prepare_upload_bo(context, resource, - sub_resource_idx, box, row_pitch, slice_pitch, flags, &addr))) + sub_resource_idx, box, row_pitch, slice_pitch, flags, &bo))) { TRACE("Returning upload bo %s, map pointer %p, row pitch %u, slice pitch %u.\n", - debug_const_bo_address(&addr), *map_ptr, row_pitch, slice_pitch); + debug_const_bo_address(&bo.addr), *map_ptr, row_pitch, slice_pitch); return WINED3D_OK; }
@@ -2507,17 +2508,17 @@ static void wined3d_cs_exec_unmap(struct wined3d_cs *cs, const void *data) HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx) { - struct wined3d_const_bo_address addr; struct wined3d_cs_unmap *op; struct wined3d_box box; + struct upload_bo bo; HRESULT hr;
- if (context->ops->get_upload_bo(context, resource, sub_resource_idx, &box, &addr)) + if (context->ops->get_upload_bo(context, resource, sub_resource_idx, &box, &bo)) { unsigned int row_pitch, slice_pitch;
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch); - wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &addr, row_pitch, slice_pitch); + wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch); return WINED3D_OK; }
@@ -2690,7 +2691,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi { struct wined3d_buffer *buffer = buffer_from_resource(resource);
- wined3d_buffer_copy_bo_address(buffer, context, box->left, &op->addr, box->right - box->left); + wined3d_buffer_copy_bo_address(buffer, context, box->left, &op->bo.addr, box->right - box->left); goto done; }
@@ -2709,7 +2710,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_box_set(&src_box, 0, 0, box->right - box->left, box->bottom - box->top, 0, box->back - box->front); - texture->texture_ops->texture_upload_data(context, &op->addr, texture->resource.format, &src_box, + texture->texture_ops->texture_upload_data(context, &op->bo.addr, texture->resource.format, &src_box, op->row_pitch, op->slice_pitch, texture, op->sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB, box->left, box->top, box->front);
@@ -2727,15 +2728,15 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte const void *data, unsigned int row_pitch, unsigned int slice_pitch) { struct wined3d_cs_update_sub_resource *op; - struct wined3d_const_bo_address src_addr; + struct upload_bo bo; void *map_ptr;
if ((map_ptr = context->ops->prepare_upload_bo(context, resource, sub_resource_idx, box, - row_pitch, slice_pitch, WINED3D_MAP_WRITE, &src_addr))) + row_pitch, slice_pitch, WINED3D_MAP_WRITE, &bo))) { wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch, box->right - box->left, box->bottom - box->top, box->back - box->front); - wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &src_addr, row_pitch, slice_pitch); + wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &bo, row_pitch, slice_pitch); return; }
@@ -2746,8 +2747,8 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->resource = resource; op->sub_resource_idx = sub_resource_idx; op->box = *box; - op->addr.buffer_object = 0; - op->addr.addr = data; + op->bo.addr.buffer_object = 0; + op->bo.addr.addr = data; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
@@ -3050,14 +3051,14 @@ static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wi
static void *wined3d_cs_prepare_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch, - unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address) + unsigned int slice_pitch, uint32_t flags, struct upload_bo *bo) { /* FIXME: We would like to return mapped or newly allocated memory here. */ return NULL; }
static bool wined3d_cs_get_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, - unsigned int sub_resource_idx, struct wined3d_box *box, struct wined3d_const_bo_address *address) + unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *bo) { return false; } @@ -3492,7 +3493,7 @@ static const struct wined3d_deferred_upload *deferred_context_get_upload(struct
static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, - unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address) + unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct upload_bo *bo) { struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context); const struct wined3d_format *format = resource->format; @@ -3523,8 +3524,8 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx))) { map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); - address->buffer_object = 0; - address->addr = map_ptr; + bo->addr.buffer_object = 0; + bo->addr.addr = map_ptr; return map_ptr; }
@@ -3545,15 +3546,14 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co upload->sysmem = sysmem; upload->box = *box;
- address->buffer_object = 0; + bo->addr.buffer_object = 0; map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT); - address->addr = map_ptr; + bo->addr.addr = map_ptr; return map_ptr; }
static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context *context, - struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_box *box, struct wined3d_const_bo_address *address) + 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; @@ -3561,8 +3561,8 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx))) { *box = upload->box; - address->buffer_object = 0; - address->addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); + bo->addr.buffer_object = 0; + bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); return true; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8c49e694fa9..c801e5b3ce8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3324,6 +3324,11 @@ bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info, const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level, UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
+struct upload_bo +{ + struct wined3d_const_bo_address addr; +}; + struct wined3d_adapter_ops { void (*adapter_destroy)(struct wined3d_adapter *adapter); @@ -4732,9 +4737,9 @@ struct wined3d_device_context_ops unsigned int start_idx, unsigned int count, const void *constants); void *(*prepare_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch, - unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address); + unsigned int slice_pitch, uint32_t flags, struct upload_bo *upload_bo); bool (*get_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource, - unsigned int sub_resource_idx, struct wined3d_box *box, struct wined3d_const_bo_address *address); + unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *upload_bo); void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags); void (*flush)(struct wined3d_device_context *context); void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/cs.c | 20 ++++++++++++++------ dlls/wined3d/wined3d_private.h | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 41491c768cf..5944f7e6a91 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -34,6 +34,7 @@ struct wined3d_deferred_upload unsigned int sub_resource_idx; uint8_t *sysmem; struct wined3d_box box; + uint32_t map_flags; };
struct wined3d_command_list @@ -2429,9 +2430,9 @@ static void wined3d_device_context_upload_bo(struct wined3d_device_context *cont { struct wined3d_cs_update_sub_resource *op;
- TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, row_pitch %u, slice_pitch %u.\n", + TRACE("context %p, resource %p, sub_resource_idx %u, box %s, bo %s, flags %#x, row_pitch %u, slice_pitch %u.\n", context, resource, sub_resource_idx, debug_box(box), - debug_const_bo_address(&bo->addr), row_pitch, slice_pitch); + debug_const_bo_address(&bo->addr), bo->flags, row_pitch, slice_pitch);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; @@ -2518,7 +2519,8 @@ HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context unsigned int row_pitch, slice_pitch;
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch); - wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch); + if (bo.flags & UPLOAD_BO_UPLOAD_ON_UNMAP) + wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &bo, row_pitch, slice_pitch); return WINED3D_OK; }
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->box = *box; op->bo.addr.buffer_object = 0; op->bo.addr.addr = data; + op->bo.flags = UPLOAD_BO_UPLOAD_ON_UNMAP; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
@@ -3475,7 +3478,7 @@ static void wined3d_deferred_context_push_constants(struct wined3d_device_contex FIXME("context %p, p %#x, start_idx %u, count %u, constants %p, stub!\n", context, p, start_idx, count, constants); }
-static const struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred, +static struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred, struct wined3d_resource *resource, unsigned int sub_resource_idx) { SIZE_T i = deferred->upload_count; @@ -3519,13 +3522,13 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
if (flags & WINED3D_MAP_NOOVERWRITE) { - const struct wined3d_deferred_upload *upload; - if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx))) { + upload->map_flags = flags; map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); bo->addr.buffer_object = 0; bo->addr.addr = map_ptr; + bo->flags = 0; return map_ptr; }
@@ -3540,6 +3543,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co return NULL;
upload = &deferred->uploads[deferred->upload_count++]; + upload->map_flags = flags; upload->resource = resource; wined3d_resource_incref(resource); upload->sub_resource_idx = sub_resource_idx; @@ -3549,6 +3553,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co bo->addr.buffer_object = 0; map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT); bo->addr.addr = map_ptr; + bo->flags = UPLOAD_BO_UPLOAD_ON_UNMAP; return map_ptr; }
@@ -3563,6 +3568,9 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context *box = upload->box; bo->addr.buffer_object = 0; bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); + bo->flags = 0; + if (!(upload->map_flags & WINED3D_MAP_NOOVERWRITE)) + bo->flags |= UPLOAD_BO_UPLOAD_ON_UNMAP; return true; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c801e5b3ce8..520eb968eb6 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3324,9 +3324,12 @@ bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info, const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level, UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
+#define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1 + struct upload_bo { struct wined3d_const_bo_address addr; + uint32_t flags; };
struct wined3d_adapter_ops
On Tue, 28 Sept 2021 at 23:28, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->box = *box; op->bo.addr.buffer_object = 0; op->bo.addr.addr = data;
- op->bo.flags = UPLOAD_BO_UPLOAD_ON_UNMAP; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
Do we need UPLOAD_BO_UPLOAD_ON_UNMAP here? It seems a little out of place, and wined3d_cs_exec_update_sub_resource() doesn't appear to use it.
@@ -3519,13 +3522,13 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
if (flags & WINED3D_MAP_NOOVERWRITE) {
const struct wined3d_deferred_upload *upload;
if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx))) {
upload->map_flags = flags; map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); bo->addr.buffer_object = 0; bo->addr.addr = map_ptr;
bo->flags = 0; return map_ptr; }
@@ -3540,6 +3543,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co return NULL;
upload = &deferred->uploads[deferred->upload_count++];
- upload->map_flags = flags; upload->resource = resource; wined3d_resource_incref(resource); upload->sub_resource_idx = sub_resource_idx;
@@ -3549,6 +3553,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co bo->addr.buffer_object = 0; map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT); bo->addr.addr = map_ptr;
- bo->flags = UPLOAD_BO_UPLOAD_ON_UNMAP; return map_ptr;
}
@@ -3563,6 +3568,9 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context *box = upload->box; bo->addr.buffer_object = 0; bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
bo->flags = 0;
if (!(upload->map_flags & WINED3D_MAP_NOOVERWRITE))
}bo->flags |= UPLOAD_BO_UPLOAD_ON_UNMAP; return true;
In some ways, it would seem nicer to store the UPLOAD_BO flags directly in the wined3d_deferred_upload structure, instead of deriving them from the stored map flags. Perhaps there are other reasons to store the map flags in subsequent patches though?
On 9/29/21 10:48, Henri Verbeet wrote:
On Tue, 28 Sept 2021 at 23:28, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->box = *box; op->bo.addr.buffer_object = 0; op->bo.addr.addr = data;
- op->bo.flags = UPLOAD_BO_UPLOAD_ON_UNMAP; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
Do we need UPLOAD_BO_UPLOAD_ON_UNMAP here? It seems a little out of place, and wined3d_cs_exec_update_sub_resource() doesn't appear to use it.
No, I suppose we don't. Thinking too far ahead...
Although if we obsolesce UPLOAD_BO_UPLOAD_ON_UNMAP entirely, which is possible, that does mean we can't use it for deferred contexts as you suggest below. (And if we don't, it's mildly weird not to pass it here.)
@@ -3519,13 +3522,13 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
if (flags & WINED3D_MAP_NOOVERWRITE) {
const struct wined3d_deferred_upload *upload;
if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx))) {
upload->map_flags = flags; map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT); bo->addr.buffer_object = 0; bo->addr.addr = map_ptr;
bo->flags = 0; return map_ptr; }
@@ -3540,6 +3543,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co return NULL;
upload = &deferred->uploads[deferred->upload_count++];
- upload->map_flags = flags; upload->resource = resource; wined3d_resource_incref(resource); upload->sub_resource_idx = sub_resource_idx;
@@ -3549,6 +3553,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co bo->addr.buffer_object = 0; map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT); bo->addr.addr = map_ptr;
- bo->flags = UPLOAD_BO_UPLOAD_ON_UNMAP; return map_ptr; }
@@ -3563,6 +3568,9 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context *box = upload->box; bo->addr.buffer_object = 0; bo->addr.addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
bo->flags = 0;
if (!(upload->map_flags & WINED3D_MAP_NOOVERWRITE))
bo->flags |= UPLOAD_BO_UPLOAD_ON_UNMAP; return true; }
In some ways, it would seem nicer to store the UPLOAD_BO flags directly in the wined3d_deferred_upload structure, instead of deriving them from the stored map flags. Perhaps there are other reasons to store the map flags in subsequent patches though?
I suppose that works. I don't think there was any other instance I had planned that checks the map flags for deferred contexts.
On Wed, 29 Sept 2021 at 18:04, Zebediah Figura (she/her) zfigura@codeweavers.com wrote:
On 9/29/21 10:48, Henri Verbeet wrote:
On Tue, 28 Sept 2021 at 23:28, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->box = *box; op->bo.addr.buffer_object = 0; op->bo.addr.addr = data;
- op->bo.flags = UPLOAD_BO_UPLOAD_ON_UNMAP; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
Do we need UPLOAD_BO_UPLOAD_ON_UNMAP here? It seems a little out of place, and wined3d_cs_exec_update_sub_resource() doesn't appear to use it.
No, I suppose we don't. Thinking too far ahead...
Although if we obsolesce UPLOAD_BO_UPLOAD_ON_UNMAP entirely, which is possible, that does mean we can't use it for deferred contexts as you suggest below. (And if we don't, it's mildly weird not to pass it here.)
Is it? My understanding was that UPLOAD_ON_UNMAP was primarily for wined3d_device_context_emit_unmap(), to distinguish the case where we got a reference to the original buffer object. (As is the case with NOOVERWRITE maps on deferred contexts, but we could conceivably do that on immediate contexts as well in some cases.)
On 9/29/21 11:22, Henri Verbeet wrote:
On Wed, 29 Sept 2021 at 18:04, Zebediah Figura (she/her) zfigura@codeweavers.com wrote:
On 9/29/21 10:48, Henri Verbeet wrote:
On Tue, 28 Sept 2021 at 23:28, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -2749,6 +2751,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->box = *box; op->bo.addr.buffer_object = 0; op->bo.addr.addr = data;
- op->bo.flags = UPLOAD_BO_UPLOAD_ON_UNMAP; op->row_pitch = row_pitch; op->slice_pitch = slice_pitch;
Do we need UPLOAD_BO_UPLOAD_ON_UNMAP here? It seems a little out of place, and wined3d_cs_exec_update_sub_resource() doesn't appear to use it.
No, I suppose we don't. Thinking too far ahead...
Although if we obsolesce UPLOAD_BO_UPLOAD_ON_UNMAP entirely, which is possible, that does mean we can't use it for deferred contexts as you suggest below. (And if we don't, it's mildly weird not to pass it here.)
Is it? My understanding was that UPLOAD_ON_UNMAP was primarily for wined3d_device_context_emit_unmap(), to distinguish the case where we got a reference to the original buffer object. (As is the case with NOOVERWRITE maps on deferred contexts, but we could conceivably do that on immediate contexts as well in some cases.)
My plan had been to introduce a couple of other flags here, one such being FLUSH_ON_UNMAP, which would essentially be used for NOOVERWRITE maps of non-coherent BOs on the immediate context. That would need to get passed all the way to the CS thread. Then you end up with something like:
wined3d_cs_exec_update_sub_resource(...) { if (op->bo.flags & UPLOAD_BO_FLUSH_ON_UNMAP) ... else wined3d_buffer_copy_bo_address(...); }
wined3d_device_context_emit_unmap(...) { struct upload_bo bo;
if (context->ops->get_upload_bo(..., &bo)) { if (bo.flags & (UPLOAD_BO_FLUSH_ON_UNMAP | UPLOAD_BO_UPLOAD_ON_UNMAP)) wined3d_device_context_upload_bo(..., &bo); } }
Which is both kind of weird, and also less weird than this patch is.
But it's also not even hard to avoid introducing UPLOAD_BO_UPLOAD_ON_UNMAP until it's really used, so I might as well just restructure my patches a bit accordingly...