Module: wine Branch: master Commit: 685246b4a17732cb2f7f3f483e3bd5a4f61c8f41 URL: http://source.winehq.org/git/wine.git/?a=commit;h=685246b4a17732cb2f7f3f483e...
Author: Józef Kucia jkucia@codeweavers.com Date: Mon Nov 14 17:31:18 2016 +0100
wined3d: Implement wined3d_update_sub_resource() for 3D textures.
Fixes a regression introduced by commit e58689a3981fae5b312b12e9f6801adf289d04c0.
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/device.c | 12 +++++++----- dlls/wined3d/texture.c | 33 ++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 6e10dce..90ac18a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4063,8 +4063,8 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int depth_pitch) { + unsigned int width, height, depth, level; struct wined3d_const_bo_address addr; - unsigned int width, height, level; struct wined3d_context *context; struct wined3d_texture *texture;
@@ -4088,7 +4088,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str return; }
- if (resource->type != WINED3D_RTYPE_TEXTURE_2D) + if (resource->type != WINED3D_RTYPE_TEXTURE_2D && resource->type != WINED3D_RTYPE_TEXTURE_3D) { FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); return; @@ -4104,10 +4104,11 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str level = sub_resource_idx % texture->level_count; width = wined3d_texture_get_level_width(texture, level); height = wined3d_texture_get_level_height(texture, level); + depth = wined3d_texture_get_level_depth(texture, level);
if (box && (box->left >= box->right || box->right > width || box->top >= box->bottom || box->bottom > height - || box->front >= box->back)) + || box->front >= box->back || box->back > depth)) { WARN("Invalid box %s specified.\n", debug_box(box)); return; @@ -4118,8 +4119,9 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
context = context_acquire(resource->device, NULL);
- /* Only load the surface for partial updates. */ - if (!box || (!box->left && !box->top && box->right == width && box->bottom == height)) + /* Only load the sub-resource for partial updates. */ + if (!box || (!box->left && !box->top && !box->front + && box->right == width && box->bottom == height && box->back == depth)) wined3d_texture_prepare_texture(texture, context, FALSE); else wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 59468f5..4a572ab 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2112,6 +2112,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int const struct wined3d_format *format = texture->resource.format; unsigned int level = sub_resource_idx % texture->level_count; const struct wined3d_gl_info *gl_info = context->gl_info; + unsigned int x, y, z, update_w, update_h, update_d; unsigned int dst_row_pitch, dst_slice_pitch; unsigned int width, height, depth; const void *mem = data->addr; @@ -2121,13 +2122,27 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int texture, sub_resource_idx, context, debug_box(box), data->buffer_object, data->addr, row_pitch, slice_pitch);
- if (box) - FIXME("Partial upload not supported yet.\n"); - width = wined3d_texture_get_level_width(texture, level); height = wined3d_texture_get_level_height(texture, level); depth = wined3d_texture_get_level_depth(texture, level);
+ if (!box) + { + x = y = z = 0; + update_w = width; + update_h = height; + update_d = depth; + } + else + { + x = box->left; + y = box->top; + z = box->front; + update_w = box->right - box->left; + update_h = box->bottom - box->top; + update_d = box->back - box->front; + } + if (format->convert) { if (data->buffer_object) @@ -2135,12 +2150,12 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS) ERR("Converting a block-based format.\n");
- dst_row_pitch = width * format->conv_byte_count; - dst_slice_pitch = dst_row_pitch * height; + dst_row_pitch = update_w * format->conv_byte_count; + dst_slice_pitch = dst_row_pitch * update_h;
- converted_mem = wined3d_calloc(depth, dst_slice_pitch); + converted_mem = wined3d_calloc(update_d, dst_slice_pitch); format->convert(data->addr, converted_mem, row_pitch, slice_pitch, - dst_row_pitch, dst_slice_pitch, width, height, depth); + dst_row_pitch, dst_slice_pitch, update_w, update_h, update_d); mem = converted_mem; } else @@ -2156,8 +2171,8 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int checkGLcall("glBindBuffer"); }
- GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, level, 0, 0, 0, - width, height, depth, format->glFormat, format->glType, mem)); + GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, level, x, y, z, + update_w, update_h, update_d, format->glFormat, format->glType, mem)); checkGLcall("glTexSubImage3D");
if (data->buffer_object)