Module: wine Branch: master Commit: 15d3155e595a6afa26b7775cf54027c7d141c08a URL: https://source.winehq.org/git/wine.git/?a=commit;h=15d3155e595a6afa26b7775cf...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Mar 21 13:18:49 2018 +0330
wined3d: Always pass a valid source box to texture3d_upload_data().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/texture.c | 35 +++++++++++++++++------------------ dlls/wined3d/wined3d_private.h | 9 +++++++++ 2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index e8f5af3..f589243 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2549,22 +2549,13 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int texture, sub_resource_idx, context, debug_d3dformat(format->id), debug_box(src_box), data->buffer_object, data->addr, row_pitch, slice_pitch, dst_x, dst_y, dst_z, srgb);
- if (src_box) - { - addr += src_box->front * slice_pitch; - addr += src_box->top * row_pitch; - addr += src_box->left * format->byte_count; + addr += src_box->front * slice_pitch; + addr += src_box->top * row_pitch; + addr += src_box->left * format->byte_count;
- update_w = src_box->right - src_box->left; - update_h = src_box->bottom - src_box->top; - update_d = src_box->back - src_box->front; - } - else - { - update_w = wined3d_texture_get_level_width(texture, level); - update_h = wined3d_texture_get_level_height(texture, level); - update_d = wined3d_texture_get_level_depth(texture, level); - } + update_w = src_box->right - src_box->left; + update_h = src_box->bottom - src_box->top; + update_d = src_box->back - src_box->front;
if (format->conv_byte_count) { @@ -2646,6 +2637,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx]; unsigned int row_pitch, slice_pitch; struct wined3d_bo_address data; + struct wined3d_box src_box;
/* Optimisations are possible, but the effort should be put into either * implementing EXT_SRGB_DECODE in the driver or finding out why we @@ -2659,11 +2651,12 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in return;
wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); + wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb); texture3d_download_data(texture, sub_resource_idx, context, &data); wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb); texture3d_upload_data(texture, sub_resource_idx, context, texture->resource.format, - NULL, wined3d_const_bo_address(&data), row_pitch, slice_pitch, 0, 0, 0, FALSE); + &src_box, wined3d_const_bo_address(&data), row_pitch, slice_pitch, 0, 0, 0, FALSE);
heap_free(data.addr); } @@ -2685,21 +2678,27 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in if (sub_resource->locations & WINED3D_LOCATION_SYSMEM) { struct wined3d_const_bo_address data = {0, texture->resource.heap_memory}; + struct wined3d_box src_box; + data.addr += sub_resource->offset; wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); + wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); texture3d_upload_data(texture, sub_resource_idx, context, texture->resource.format, - NULL, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE); + &src_box, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE); } else if (sub_resource->locations & WINED3D_LOCATION_BUFFER) { struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL}; + struct wined3d_box src_box; + wined3d_texture_bind_and_dirtify(texture, context, location == WINED3D_LOCATION_TEXTURE_SRGB); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); + wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box); texture3d_upload_data(texture, sub_resource_idx, context, texture->resource.format, - NULL, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE); + &src_box, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE); } else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 311e292..cb2938b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3241,6 +3241,15 @@ static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wi return max(1, texture->pow2_height >> level); }
+static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture, + unsigned int level, struct wined3d_box *box) +{ + wined3d_box_set(box, 0, 0, + wined3d_texture_get_level_width(texture, level), + wined3d_texture_get_level_height(texture, level), + 0, wined3d_texture_get_level_depth(texture, level)); +} + HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,