wined3d: Move box validation to wined3d_device_context_map().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-06-25 18:21:26 -05:00 committed by Alexandre Julliard
parent 2e06677570
commit 08c96a4888
2 changed files with 10 additions and 7 deletions

View File

@ -4866,6 +4866,16 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
wined3d_box_set(&b, 0, 0, desc.width, desc.height, 0, desc.depth);
box = &b;
}
else if (FAILED(wined3d_resource_check_box_dimensions(resource, sub_resource_idx, box)))
{
WARN("Map box is invalid.\n");
if (resource->type != WINED3D_RTYPE_BUFFER && resource->type != WINED3D_RTYPE_TEXTURE_2D)
return WINED3DERR_INVALIDCALL;
if ((resource->format_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
return WINED3DERR_INVALIDCALL;
}
if (SUCCEEDED(hr = context->ops->map(context, resource, sub_resource_idx, &map_desc->data, box, flags)))
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx,

View File

@ -3513,13 +3513,6 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
texture_level = sub_resource_idx % texture->level_count;
if (FAILED(wined3d_resource_check_box_dimensions(resource, sub_resource_idx, box)))
{
WARN("Map box is invalid.\n");
if (((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
|| resource->type != WINED3D_RTYPE_TEXTURE_2D)
return WINED3DERR_INVALIDCALL;
}
if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
{