wined3d: Introduce a wined3d_texture_update_sub_resource() helper.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e3c9d73cd1
commit
81068b89d8
|
@ -2739,43 +2739,17 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi
|
||||||
const struct wined3d_cs_update_sub_resource *op = data;
|
const struct wined3d_cs_update_sub_resource *op = data;
|
||||||
struct wined3d_resource *resource = op->resource;
|
struct wined3d_resource *resource = op->resource;
|
||||||
const struct wined3d_box *box = &op->box;
|
const struct wined3d_box *box = &op->box;
|
||||||
unsigned int width, height, depth, level;
|
|
||||||
struct wined3d_context *context;
|
struct wined3d_context *context;
|
||||||
struct wined3d_texture *texture;
|
|
||||||
struct wined3d_box src_box;
|
|
||||||
|
|
||||||
context = context_acquire(cs->c.device, NULL, 0);
|
context = context_acquire(cs->c.device, NULL, 0);
|
||||||
|
|
||||||
if (resource->type == WINED3D_RTYPE_BUFFER)
|
if (resource->type == WINED3D_RTYPE_BUFFER)
|
||||||
{
|
|
||||||
wined3d_buffer_update_sub_resource(buffer_from_resource(resource),
|
wined3d_buffer_update_sub_resource(buffer_from_resource(resource),
|
||||||
context, &op->bo, box->left, box->right - box->left);
|
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
|
else
|
||||||
wined3d_texture_load_location(texture, op->sub_resource_idx, context, 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);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
done:
|
|
||||||
context_release(context);
|
context_release(context);
|
||||||
|
|
||||||
wined3d_resource_release(resource);
|
wined3d_resource_release(resource);
|
||||||
|
|
|
@ -4533,6 +4533,32 @@ void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture,
|
||||||
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_location);
|
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,
|
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_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,
|
const struct wined3d_box *src_box, unsigned int src_row_pitch, unsigned int src_slice_pitch,
|
||||||
|
|
|
@ -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_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
|
||||||
void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
|
void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
|
||||||
HWND window, RECT *rect) DECLSPEC_HIDDEN;
|
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,
|
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 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;
|
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue