From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/device.c | 6 ++++++ dlls/wined3d/resource.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 19489db3ca9..9c0a6344229 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4403,6 +4403,12 @@ void CDECL wined3d_device_context_update_sub_resource(struct wined3d_device_cont WARN("Invalid box %s specified.\n", debug_box(box)); return; } + else if ((resource->format->attrs & WINED3D_FORMAT_ATTR_PLANAR) + && ((box->left & 1) || (box->right & 1) || (box->top & 1) || (box->bottom & 1))) + { + WARN("Invalid box %s for planar resource.\n", debug_box(box)); + return; + }
wined3d_device_context_lock(context); wined3d_device_context_emit_update_sub_resource(context, resource, diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index fcfe05db835..2b02424633a 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -502,14 +502,22 @@ HRESULT wined3d_resource_check_box_dimensions(struct wined3d_resource *resource, return WINEDDERR_INVALIDRECT; }
- if (resource->format_attrs & WINED3D_FORMAT_ATTR_BLOCKS) + if (resource->format_attrs & (WINED3D_FORMAT_ATTR_BLOCKS | WINED3D_FORMAT_ATTR_PLANAR)) { /* This assumes power of two block sizes, but NPOT block sizes would * be silly anyway. * * This also assumes that the format's block depth is 1. */ - width_mask = format->block_width - 1; - height_mask = format->block_height - 1; + if (resource->format_attrs & WINED3D_FORMAT_ATTR_BLOCKS) + { + width_mask = format->block_width - 1; + height_mask = format->block_height - 1; + } + else + { + width_mask = format->uv_width - 1; + height_mask = format->uv_height - 1; + }
if ((box->left & width_mask) || (box->top & height_mask) || (box->right & width_mask && box->right != desc.width)