Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/cs.c | 33 ++++++++++++++++++--------------- dlls/wined3d/wined3d_private.h | 4 ++-- 2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index cbe333fab95..c35e85c3cc2 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2492,11 +2492,9 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context, void *map_ptr; 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->map_upload_bo(context, resource, - sub_resource_idx, box, row_pitch, slice_pitch, flags))) + sub_resource_idx, box, &row_pitch, &slice_pitch, flags))) { TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n", map_ptr, row_pitch, slice_pitch); map_desc->data = map_ptr; @@ -2505,6 +2503,8 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context, return WINED3D_OK; }
+ wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch); + /* Mapping resources from the worker thread isn't an issue by itself, but * increasing the map count would be visible to applications. */ wined3d_not_from_cs(context->device->cs); @@ -2762,20 +2762,21 @@ done:
void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, - const void *data, unsigned int row_pitch, unsigned int slice_pitch) + const void *data, unsigned int src_row_pitch, unsigned int src_slice_pitch) { + unsigned int dst_row_pitch, dst_slice_pitch; struct wined3d_cs_update_sub_resource *op; struct wined3d_box dummy_box; struct upload_bo bo; void *map_ptr;
if ((map_ptr = context->ops->map_upload_bo(context, resource, sub_resource_idx, box, - row_pitch, slice_pitch, WINED3D_MAP_WRITE))) + &dst_row_pitch, &dst_slice_pitch, WINED3D_MAP_WRITE))) { - 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_format_copy_data(resource->format, data, src_row_pitch, src_slice_pitch, map_ptr, dst_row_pitch, + dst_slice_pitch, box->right - box->left, box->bottom - box->top, box->back - box->front); context->ops->unmap_upload_bo(context, resource, sub_resource_idx, &dummy_box, &bo); - wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &bo, row_pitch, slice_pitch); + wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &bo, dst_row_pitch, dst_slice_pitch); return; }
@@ -2789,8 +2790,8 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte op->bo.addr.buffer_object = 0; op->bo.addr.addr = data; op->bo.flags = 0; - op->row_pitch = row_pitch; - op->slice_pitch = slice_pitch; + op->row_pitch = src_row_pitch; + op->slice_pitch = src_slice_pitch;
wined3d_device_context_acquire_resource(context, resource);
@@ -3090,8 +3091,8 @@ static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wi }
static void *wined3d_cs_map_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) + unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int *row_pitch, + unsigned int *slice_pitch, uint32_t flags) { /* FIXME: We would like to return mapped or newly allocated memory here. */ return NULL; @@ -3536,7 +3537,7 @@ static struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3
static void *wined3d_deferred_context_map_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) + unsigned int *row_pitch, unsigned int *slice_pitch, uint32_t flags) { struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context); const struct wined3d_format *format = resource->format; @@ -3544,8 +3545,10 @@ static void *wined3d_deferred_context_map_upload_bo(struct wined3d_device_contex uint8_t *sysmem; size_t size;
- size = (box->back - box->front - 1) * slice_pitch - + ((box->bottom - box->top - 1) / format->block_height) * row_pitch + wined3d_format_calculate_pitch(format, 1, box->right - box->left, box->bottom - box->top, row_pitch, slice_pitch); + + size = (box->back - box->front - 1) * (*slice_pitch) + + ((box->bottom - box->top - 1) / format->block_height) * (*row_pitch) + ((box->right - box->left + format->block_width - 1) / format->block_width) * format->block_byte_count;
if (!(flags & WINED3D_MAP_WRITE)) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index acd3ded7a24..87d69b7b6fe 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4778,8 +4778,8 @@ struct wined3d_device_context_ops void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p, unsigned int start_idx, unsigned int count, const void *constants); void *(*map_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); + unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int *row_pitch, + unsigned int *slice_pitch, uint32_t flags); bool (*unmap_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource, 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);