From df5a0976e9f28836489e8977122844fe053278b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Fri, 6 Sep 2013 00:11:12 +0200 Subject: [PATCH] wined3d: Check the format block size before creating textures. Sizes of textures and stand-alone surfaces must be multiples of the format's block size for DXTN formats. Since we create a texture for everything (except in ddraw), this check also takes care of stand-alone surfaces. --- dlls/wined3d/texture.c | 8 ++++++++ dlls/wined3d/utils.c | 19 +++++++++++-------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 75ae8afbea6..e60a426d88d 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -41,6 +41,14 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc debug_d3dusage(desc->usage), debug_d3dpool(desc->pool), desc->width, desc->height, desc->depth, device, parent, parent_ops, resource_ops); + if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY)) == WINED3DFMT_FLAG_BLOCKS) + { + UINT width_mask = format->block_width - 1; + UINT height_mask = format->block_height - 1; + if (desc->width & width_mask || desc->height & height_mask) + return WINED3DERR_INVALIDCALL; + } + if (FAILED(hr = resource_init(&texture->resource, device, desc->resource_type, format, desc->multisample_type, desc->multisample_quality, desc->usage, desc->pool, desc->width, desc->height, desc->depth, 0, parent, parent_ops, resource_ops))) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 61f7df0d553..9a560318768 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -191,18 +191,19 @@ struct wined3d_format_block_info UINT block_width; UINT block_height; UINT block_byte_count; + BOOL verify; }; static const struct wined3d_format_block_info format_block_info[] = { - {WINED3DFMT_DXT1, 4, 4, 8}, - {WINED3DFMT_DXT2, 4, 4, 16}, - {WINED3DFMT_DXT3, 4, 4, 16}, - {WINED3DFMT_DXT4, 4, 4, 16}, - {WINED3DFMT_DXT5, 4, 4, 16}, - {WINED3DFMT_ATI2N, 4, 4, 16}, - {WINED3DFMT_YUY2, 2, 1, 4}, - {WINED3DFMT_UYVY, 2, 1, 4}, + {WINED3DFMT_DXT1, 4, 4, 8, TRUE}, + {WINED3DFMT_DXT2, 4, 4, 16, TRUE}, + {WINED3DFMT_DXT3, 4, 4, 16, TRUE}, + {WINED3DFMT_DXT4, 4, 4, 16, TRUE}, + {WINED3DFMT_DXT5, 4, 4, 16, TRUE}, + {WINED3DFMT_ATI2N, 4, 4, 16, FALSE}, + {WINED3DFMT_YUY2, 2, 1, 4, FALSE}, + {WINED3DFMT_UYVY, 2, 1, 4, FALSE}, }; struct wined3d_format_vertex_info @@ -1023,6 +1024,8 @@ static BOOL init_format_block_info(struct wined3d_gl_info *gl_info) format->block_height = format_block_info[i].block_height; format->block_byte_count = format_block_info[i].block_byte_count; format->flags |= WINED3DFMT_FLAG_BLOCKS; + if (!format_block_info[i].verify) + format->flags |= WINED3DFMT_FLAG_BLOCKS_NO_VERIFY; } return TRUE; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 28df2c98347..5a8ced0aaf8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2916,6 +2916,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN #define WINED3DFMT_FLAG_BLOCKS 0x00020000 #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000 #define WINED3DFMT_FLAG_TEXTURE 0x00080000 +#define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000 struct wined3d_rational { -- 2.11.4.GIT