Module: wine Branch: master Commit: 08aded431b2eaba2509b24f49f8e3abf2db2480e URL: http://source.winehq.org/git/wine.git/?a=commit;h=08aded431b2eaba2509b24f49f...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Jan 5 13:24:57 2015 +0100
wined3d: Reject wined3d_texture_create() calls without explicit level count.
---
dlls/wined3d/texture.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 6ecd414..dfcf02d 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1022,18 +1022,11 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi return WINED3DERR_INVALIDCALL; }
- if (levels > 1) + if (levels != 1) { - WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n"); + WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning D3DERR_INVALIDCALL.\n"); return WINED3DERR_INVALIDCALL; } - - levels = 1; - } - else if (!levels) - { - levels = wined3d_log2i(desc->width) + 1; - TRACE("Calculated levels = %u.\n", levels); }
if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) @@ -1168,18 +1161,11 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 return WINED3DERR_INVALIDCALL; }
- if (levels > 1) + if (levels != 1) { - WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning WINED3DERR_INVALIDCALL.\n"); + WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning WINED3DERR_INVALIDCALL.\n"); return WINED3DERR_INVALIDCALL; } - - levels = 1; - } - else if (!levels) - { - levels = wined3d_log2i(max(desc->width, desc->height)) + 1; - TRACE("Calculated levels = %u.\n", levels); }
if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels, desc, @@ -1366,18 +1352,11 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct return WINED3DERR_INVALIDCALL; }
- if (levels > 1) + if (levels != 1) { - WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n"); + WARN("WINED3DUSAGE_AUTOGENMIPMAP is set, and level count != 1, returning D3DERR_INVALIDCALL.\n"); return WINED3DERR_INVALIDCALL; } - - levels = 1; - } - else if (!levels) - { - levels = wined3d_log2i(max(max(desc->width, desc->height), desc->depth)) + 1; - TRACE("Calculated levels = %u.\n", levels); }
if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) @@ -1456,6 +1435,12 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct TRACE("device %p, desc %p, level_count %u, surface_flags %#x, parent %p, parent_ops %p, texture %p.\n", device, desc, level_count, surface_flags, parent, parent_ops, texture);
+ if (!level_count) + { + WARN("Invalid level count.\n"); + return WINED3DERR_INVALIDCALL; + } + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY;