Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wined3d/cs.c | 30 ++---------------------------- dlls/wined3d/texture.c | 26 ++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 3 +++ 3 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index ae1f4ad18e0..81cdb51f207 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2741,43 +2741,17 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi const struct wined3d_cs_update_sub_resource *op = data; struct wined3d_resource *resource = op->resource; const struct wined3d_box *box = &op->box; - unsigned int width, height, depth, level; struct wined3d_context *context; - struct wined3d_texture *texture; - struct wined3d_box src_box;
context = context_acquire(cs->c.device, NULL, 0);
if (resource->type == WINED3D_RTYPE_BUFFER) - { wined3d_buffer_update_sub_resource(buffer_from_resource(resource), context, &op->bo, box->left, box->right - box->left); - goto done; - } - - texture = wined3d_texture_from_resource(resource); - - level = op->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); - - /* Only load the sub-resource for partial updates. */ - if (!box->left && !box->top && !box->front - && box->right == width && box->bottom == height && box->back == depth) - wined3d_texture_prepare_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); else - wined3d_texture_load_location(texture, op->sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); - - wined3d_box_set(&src_box, 0, 0, box->right - box->left, box->bottom - box->top, 0, box->back - box->front); - texture->texture_ops->texture_upload_data(context, &op->bo.addr, texture->resource.format, &src_box, - op->row_pitch, op->slice_pitch, texture, op->sub_resource_idx, - WINED3D_LOCATION_TEXTURE_RGB, box->left, box->top, box->front); - - wined3d_texture_validate_location(texture, op->sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); - wined3d_texture_invalidate_location(texture, op->sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB); + wined3d_texture_update_sub_resource(texture_from_resource(resource), + op->sub_resource_idx, context, &op->bo, box, op->row_pitch, op->slice_pitch);
-done: context_release(context);
wined3d_resource_release(resource); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 7703de6c4ef..c1d04ceb119 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -4531,6 +4531,32 @@ void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_location); }
+void wined3d_texture_update_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_context *context, const struct upload_bo *upload_bo, const struct wined3d_box *box, + unsigned int row_pitch, unsigned int slice_pitch) +{ + unsigned int level = sub_resource_idx % texture->level_count; + unsigned int width = wined3d_texture_get_level_width(texture, level); + unsigned int height = wined3d_texture_get_level_height(texture, level); + unsigned int depth = wined3d_texture_get_level_depth(texture, level); + struct wined3d_box src_box; + + /* Only load the sub-resource for partial updates. */ + if (!box->left && !box->top && !box->front + && box->right == width && box->bottom == height && box->back == depth) + wined3d_texture_prepare_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); + else + wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB); + + wined3d_box_set(&src_box, 0, 0, box->right - box->left, box->bottom - box->top, 0, box->back - box->front); + texture->texture_ops->texture_upload_data(context, &upload_bo->addr, texture->resource.format, + &src_box, row_pitch, slice_pitch, texture, sub_resource_idx, + WINED3D_LOCATION_TEXTURE_RGB, box->left, box->top, box->front); + + wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); + wined3d_texture_invalidate_location(texture, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB); +} + static void wined3d_texture_no3d_upload_data(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr, const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch, unsigned int src_slice_pitch, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 989fd33d2bf..277d5a94fb0 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4643,6 +4643,9 @@ BOOL wined3d_texture_can_use_pbo(const struct wined3d_texture *texture, const st void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN; void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture, HWND window, RECT *rect) DECLSPEC_HIDDEN; +void wined3d_texture_update_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_context *context, const struct upload_bo *upload_bo, const struct wined3d_box *box, + unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN; void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;