Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/texture.c | 34 +++++++++++++++++++++++----------- dlls/wined3d/wined3d_private.h | 2 ++ 2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 165d83eb035..ad34e44b406 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1711,6 +1711,20 @@ void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, width, height, row_pitch, slice_pitch); }
+static void wined3d_texture_get_map_pitch(const struct wined3d_texture *texture, + unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch) +{ + if (texture->resource.format_flags & WINED3DFMT_FLAG_BROKEN_PITCH) + { + *row_pitch = wined3d_texture_get_level_width(texture, level) * texture->resource.format->byte_count; + *slice_pitch = wined3d_texture_get_level_height(texture, level) * (*row_pitch); + } + else + { + wined3d_texture_get_pitch(texture, level, row_pitch, slice_pitch); + } +} + DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) { struct wined3d_resource *resource; @@ -1992,6 +2006,8 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, unsig sub_resource->size = texture->slice_pitch; sub_resource->locations = WINED3D_LOCATION_DISCARDED;
+ wined3d_texture_get_map_pitch(texture, level, &sub_resource->map_row_pitch, &sub_resource->map_slice_pitch); + if (texture->texture_ops == &texture_gl_ops) { if (multisample_type && gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) @@ -3587,15 +3603,8 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
context_release(context);
- if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH) - { - map_desc->row_pitch = wined3d_texture_get_level_width(texture, texture_level) * format->byte_count; - map_desc->slice_pitch = wined3d_texture_get_level_height(texture, texture_level) * map_desc->row_pitch; - } - else - { - wined3d_texture_get_pitch(texture, texture_level, &map_desc->row_pitch, &map_desc->slice_pitch); - } + map_desc->row_pitch = sub_resource->map_row_pitch; + map_desc->slice_pitch = sub_resource->map_slice_pitch;
if (!box) { @@ -3950,6 +3959,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc for (i = 0; i < sub_count; ++i) { struct wined3d_texture_sub_resource *sub_resource; + unsigned int level = i % texture->level_count; + unsigned int layer = i / texture->level_count;
sub_resource = &texture->sub_resources[i]; sub_resource->locations = WINED3D_LOCATION_DISCARDED; @@ -3959,6 +3970,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_SYSMEM); }
+ wined3d_texture_get_map_pitch(texture, level, &sub_resource->map_row_pitch, &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))) { @@ -3970,8 +3983,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
TRACE("parent %p, parent_ops %p.\n", sub_resource->parent, sub_resource->parent_ops);
- TRACE("Created sub-resource %u (level %u, layer %u).\n", - i, i % texture->level_count, i / texture->level_count); + TRACE("Created sub-resource %u (level %u, layer %u).\n", i, level, layer);
if (desc->usage & WINED3DUSAGE_OWNDC) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index da1cf638606..1e6a315e72c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4259,6 +4259,8 @@ struct wined3d_texture DWORD locations; struct wined3d_bo_gl bo;
+ unsigned int map_row_pitch, map_slice_pitch; + void *user_memory; } *sub_resources; };