Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/buffer.c | 14 +++++++------- dlls/wined3d/cs.c | 18 ++++++++---------- dlls/wined3d/device.c | 12 ++++++++++-- dlls/wined3d/texture.c | 34 ++++++++++++++++++---------------- dlls/wined3d/wined3d_private.h | 8 +++----- 5 files changed, 46 insertions(+), 40 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 28007076ea6..5e98a1eb3df 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -841,7 +841,7 @@ struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffe }
static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, uint32_t flags) + void **map_ptr, const struct wined3d_box *box, uint32_t flags) { struct wined3d_buffer *buffer = buffer_from_resource(resource); struct wined3d_device *device = resource->device; @@ -850,8 +850,8 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc uint8_t *base; LONG count;
- TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n", - resource, sub_resource_idx, map_desc, debug_box(box), flags); + TRACE("resource %p, sub_resource_idx %u, map_ptr %p, box %s, flags %#x.\n", + resource, sub_resource_idx, map_ptr, debug_box(box), flags);
if (box) { @@ -863,8 +863,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc offset = size = 0; }
- map_desc->row_pitch = map_desc->slice_pitch = resource->size; - count = ++resource->map_count;
if (buffer->buffer_object) @@ -950,9 +948,9 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc }
base = buffer->map_ptr ? buffer->map_ptr : resource->heap_memory; - map_desc->data = base + offset; + *map_ptr = base + offset;
- TRACE("Returning memory at %p (base %p, offset %u).\n", map_desc->data, base, offset); + TRACE("Returning memory at %p (base %p, offset %u).\n", *map_ptr, base, offset);
return WINED3D_OK; } @@ -1209,6 +1207,8 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d buffer->sub_resource.width = buffer->resource.size; buffer->sub_resource.height = 1; buffer->sub_resource.depth = 1; + buffer->sub_resource.map_row_pitch = buffer->resource.size; + buffer->sub_resource.map_slice_pitch = buffer->resource.size;
if (data) wined3d_buffer_init_data(buffer, device, data); diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 544b76534d0..ad393c203c4 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -455,7 +455,7 @@ struct wined3d_cs_map enum wined3d_cs_op opcode; struct wined3d_resource *resource; unsigned int sub_resource_idx; - struct wined3d_map_desc *map_desc; + void **map_ptr; const struct wined3d_box *box; DWORD flags; HRESULT *hr; @@ -2402,12 +2402,11 @@ static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data) struct wined3d_resource *resource = op->resource;
*op->hr = resource->resource_ops->resource_sub_resource_map(resource, - op->sub_resource_idx, op->map_desc, op->box, op->flags); + op->sub_resource_idx, op->map_ptr, op->box, op->flags); }
static HRESULT wined3d_cs_map(struct wined3d_device_context *context, struct wined3d_resource *resource, - unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, - unsigned int flags) + unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags) { struct wined3d_cs *cs = wined3d_cs_from_context(context); struct wined3d_cs_map *op; @@ -2423,7 +2422,7 @@ static HRESULT wined3d_cs_map(struct wined3d_device_context *context, struct win op->opcode = WINED3D_CS_OP_MAP; op->resource = resource; op->sub_resource_idx = sub_resource_idx; - op->map_desc = map_desc; + op->map_ptr = map_ptr; op->box = box; op->flags = flags; op->hr = &hr; @@ -3357,12 +3356,11 @@ 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 HRESULT wined3d_deferred_context_map(struct wined3d_device_context *context, - struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) +static HRESULT wined3d_deferred_context_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) { - FIXME("context %p, resource %p, sub_resource_idx %u, map_desc %p, box %p, flags %#x, stub!\n", - context, resource, sub_resource_idx, map_desc, box, flags); + FIXME("context %p, resource %p, sub_resource_idx %u, map_ptr %p, box %p, flags %#x, stub!\n", + context, resource, sub_resource_idx, map_ptr, box, flags); return E_NOTIMPL; }
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8bb70ac77ab..b93959089dd 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4842,6 +4842,9 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) { + struct wined3d_sub_resource *sub_resource; + HRESULT hr; + TRACE("context %p, resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n", context, resource, sub_resource_idx, map_desc, debug_box(box), flags);
@@ -4865,13 +4868,18 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
flags = sanitise_map_flags(resource, flags);
- if (!wined3d_resource_get_sub_resource(resource, sub_resource_idx)) + if (!(sub_resource = wined3d_resource_get_sub_resource(resource, sub_resource_idx))) { WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); return E_INVALIDARG; }
- return context->ops->map(context, resource, sub_resource_idx, map_desc, box, flags); + if (SUCCEEDED(hr = context->ops->map(context, resource, sub_resource_idx, &map_desc->data, box, flags))) + { + map_desc->row_pitch = sub_resource->map_row_pitch; + map_desc->slice_pitch = sub_resource->map_slice_pitch; + } + return hr; }
HRESULT CDECL wined3d_device_context_unmap(struct wined3d_device_context *context, diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index d69adc4a315..c5074ed7c21 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2010,7 +2010,8 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, unsig sub_resource->sub_resource.height = wined3d_texture_get_level_height(texture, level); sub_resource->sub_resource.depth = wined3d_texture_get_level_depth(texture, level);
- wined3d_texture_get_map_pitch(texture, level, &sub_resource->map_row_pitch, &sub_resource->map_slice_pitch); + wined3d_texture_get_map_pitch(texture, level, &sub_resource->sub_resource.map_row_pitch, + &sub_resource->sub_resource.map_slice_pitch);
if (texture->texture_ops == &texture_gl_ops) { @@ -3537,12 +3538,13 @@ static void texture_resource_unload(struct wined3d_resource *resource) }
static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) + void **map_ptr, const struct wined3d_box *box, DWORD flags) { const struct wined3d_format *format = resource->format; struct wined3d_texture_sub_resource *sub_resource; struct wined3d_device *device = resource->device; unsigned int fmt_flags = resource->format_flags; + unsigned int row_pitch, slice_pitch; struct wined3d_context *context; struct wined3d_texture *texture; struct wined3d_bo_address data; @@ -3550,8 +3552,8 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour BYTE *base_memory; BOOL ret;
- TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n", - resource, sub_resource_idx, map_desc, debug_box(box), flags); + TRACE("resource %p, sub_resource_idx %u, map_ptr %p, box %s, flags %#x.\n", + resource, sub_resource_idx, map_ptr, debug_box(box), flags);
texture = texture_from_resource(resource); sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx); @@ -3616,12 +3618,12 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
context_release(context);
- map_desc->row_pitch = sub_resource->map_row_pitch; - map_desc->slice_pitch = sub_resource->map_slice_pitch; + row_pitch = sub_resource->sub_resource.map_row_pitch; + slice_pitch = sub_resource->sub_resource.map_slice_pitch;
if (!box) { - map_desc->data = base_memory; + *map_ptr = base_memory; } else { @@ -3629,16 +3631,16 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour { /* Compressed textures are block based, so calculate the offset of * the block that contains the top-left pixel of the mapped box. */ - map_desc->data = base_memory - + (box->front * map_desc->slice_pitch) - + ((box->top / format->block_height) * map_desc->row_pitch) + *map_ptr = base_memory + + (box->front * slice_pitch) + + ((box->top / format->block_height) * row_pitch) + ((box->left / format->block_width) * format->block_byte_count); } else { - map_desc->data = base_memory - + (box->front * map_desc->slice_pitch) - + (box->top * map_desc->row_pitch) + *map_ptr = base_memory + + (box->front * slice_pitch) + + (box->top * row_pitch) + (box->left * format->byte_count); } } @@ -3657,8 +3659,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour ++resource->map_count; ++sub_resource->map_count;
- TRACE("Returning memory %p, row pitch %u, slice pitch %u.\n", - map_desc->data, map_desc->row_pitch, map_desc->slice_pitch); + TRACE("Returning memory %p.\n", *map_ptr);
return WINED3D_OK; } @@ -3987,7 +3988,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc sub_resource->sub_resource.height = wined3d_texture_get_level_height(texture, level); sub_resource->sub_resource.depth = wined3d_texture_get_level_depth(texture, level);
- wined3d_texture_get_map_pitch(texture, level, &sub_resource->map_row_pitch, &sub_resource->map_slice_pitch); + wined3d_texture_get_map_pitch(texture, level, &sub_resource->sub_resource.map_row_pitch, + &sub_resource->sub_resource.map_slice_pitch);
if (FAILED(hr = device_parent->ops->texture_sub_resource_created(device_parent, desc->resource_type, texture, i, &sub_resource->parent, &sub_resource->parent_ops))) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index dd73b564452..d6c526b2c6d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4047,6 +4047,7 @@ static inline BOOL wined3d_resource_access_is_managed(unsigned int access) struct wined3d_sub_resource { unsigned int width, height, depth; + unsigned int map_row_pitch, map_slice_pitch; };
struct wined3d_resource_ops @@ -4057,7 +4058,7 @@ struct wined3d_resource_ops void (*resource_preload)(struct wined3d_resource *resource); void (*resource_unload)(struct wined3d_resource *resource); HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); + void **map_ptr, const struct wined3d_box *box, DWORD flags); HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx); };
@@ -4273,8 +4274,6 @@ struct wined3d_texture DWORD locations; struct wined3d_bo_gl bo;
- unsigned int map_row_pitch, map_slice_pitch; - void *user_memory; } *sub_resources; }; @@ -4701,8 +4700,7 @@ 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); HRESULT (*map)(struct wined3d_device_context *context, struct wined3d_resource *resource, - unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, - unsigned int flags); + unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags); HRESULT (*unmap)(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx); void (*update_sub_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource,