wined3d: Use wined3d_texture_upload_data() in wined3d_device_update_sub_resource().
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>
This commit is contained in:
parent
e0d30e8e03
commit
76d101b85c
|
@ -4063,15 +4063,10 @@ 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)
|
||||
{
|
||||
struct wined3d_texture_sub_resource *sub_resource;
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_const_bo_address addr;
|
||||
unsigned int width, height, level;
|
||||
struct wined3d_context *context;
|
||||
struct wined3d_texture *texture;
|
||||
struct wined3d_surface *surface;
|
||||
POINT dst_point;
|
||||
RECT src_rect;
|
||||
|
||||
TRACE("device %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, depth_pitch %u.\n",
|
||||
device, resource, sub_resource_idx, debug_box(box), data, row_pitch, depth_pitch);
|
||||
|
@ -4100,57 +4095,37 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
|
|||
}
|
||||
|
||||
texture = texture_from_resource(resource);
|
||||
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
|
||||
if (sub_resource_idx >= texture->level_count * texture->layer_count)
|
||||
{
|
||||
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
|
||||
return;
|
||||
}
|
||||
surface = sub_resource->u.surface;
|
||||
|
||||
level = sub_resource_idx % texture->level_count;
|
||||
width = wined3d_texture_get_level_width(texture, level);
|
||||
height = wined3d_texture_get_level_height(texture, level);
|
||||
|
||||
src_rect.left = 0;
|
||||
src_rect.top = 0;
|
||||
if (box)
|
||||
if (box && (box->left >= box->right || box->right > width
|
||||
|| box->top >= box->bottom || box->bottom > height
|
||||
|| box->front >= box->back))
|
||||
{
|
||||
if (box->left >= box->right || box->right > width
|
||||
|| box->top >= box->bottom || box->bottom > height
|
||||
|| box->front >= box->back)
|
||||
{
|
||||
WARN("Invalid box %s specified.\n", debug_box(box));
|
||||
return;
|
||||
}
|
||||
|
||||
src_rect.right = box->right - box->left;
|
||||
src_rect.bottom = box->bottom - box->top;
|
||||
dst_point.x = box->left;
|
||||
dst_point.y = box->top;
|
||||
}
|
||||
else
|
||||
{
|
||||
src_rect.right = width;
|
||||
src_rect.bottom = height;
|
||||
dst_point.x = 0;
|
||||
dst_point.y = 0;
|
||||
WARN("Invalid box %s specified.\n", debug_box(box));
|
||||
return;
|
||||
}
|
||||
|
||||
addr.buffer_object = 0;
|
||||
addr.addr = data;
|
||||
|
||||
context = context_acquire(resource->device, NULL);
|
||||
gl_info = context->gl_info;
|
||||
|
||||
/* Only load the surface for partial updates. */
|
||||
if (!dst_point.x && !dst_point.y && src_rect.right == width && src_rect.bottom == height)
|
||||
if (!box || (!box->left && !box->top && box->right == width && box->bottom == height))
|
||||
wined3d_texture_prepare_texture(texture, context, FALSE);
|
||||
else
|
||||
wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
|
||||
wined3d_texture_bind_and_dirtify(texture, context, FALSE);
|
||||
|
||||
wined3d_surface_upload_data(surface, gl_info, resource->format,
|
||||
&src_rect, row_pitch, &dst_point, FALSE, &addr);
|
||||
wined3d_texture_upload_data(texture, sub_resource_idx, context, box, &addr, row_pitch, depth_pitch);
|
||||
|
||||
context_release(context);
|
||||
|
||||
|
|
Loading…
Reference in New Issue