Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/buffer.c | 12 ------------ dlls/wined3d/device.c | 12 ++++++++++++ dlls/wined3d/texture.c | 6 ++---- 3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 33f2bf7994b..28007076ea6 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -853,12 +853,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n", resource, sub_resource_idx, map_desc, debug_box(box), flags);
- if (sub_resource_idx) - { - WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); - return E_INVALIDARG; - } - if (box) { offset = box->left; @@ -973,12 +967,6 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
- if (sub_resource_idx) - { - WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); - return E_INVALIDARG; - } - if (!resource->map_count) { WARN("Unmap called without a previous map call.\n"); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index fa035af2e13..8bb70ac77ab 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4865,6 +4865,12 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
flags = sanitise_map_flags(resource, flags);
+ if (!wined3d_resource_get_sub_resource(resource, sub_resource_idx)) + { + WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); + return E_INVALIDARG; + } + return context->ops->map(context, resource, sub_resource_idx, map_desc, box, flags); }
@@ -4873,6 +4879,12 @@ HRESULT CDECL wined3d_device_context_unmap(struct wined3d_device_context *contex { TRACE("context %p, resource %p, sub_resource_idx %u.\n", context, resource, sub_resource_idx);
+ if (!wined3d_resource_get_sub_resource(resource, sub_resource_idx)) + { + WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); + return E_INVALIDARG; + } + return context->ops->unmap(context, resource, sub_resource_idx); }
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 62788419ede..d69adc4a315 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -3554,8 +3554,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour resource, sub_resource_idx, map_desc, debug_box(box), flags);
texture = texture_from_resource(resource); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) - return E_INVALIDARG; + sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
texture_level = sub_resource_idx % texture->level_count; if (box && FAILED(wined3d_texture_check_box_dimensions(texture, texture_level, box))) @@ -3676,8 +3675,7 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
texture = texture_from_resource(resource); - if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx))) - return E_INVALIDARG; + sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
if (!sub_resource->map_count) {