[PATCH 2/5] wined3d: Move box validation to wined3d_device_context_map().
Zebediah Figura
z.figura12 at gmail.com
Fri Jun 25 18:21:26 CDT 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/wined3d/device.c | 10 ++++++++++
dlls/wined3d/texture.c | 7 -------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 5b2bd7ae03b..96657141419 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -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,
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 0f753e66704..62f38a1d592 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -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)
{
--
2.30.2
More information about the wine-devel
mailing list