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.
This commit is contained in:
Stefan Dösinger 2013-09-06 00:11:12 +02:00 committed by Alexandre Julliard
parent 80638b6d2f
commit df5a0976e9
3 changed files with 20 additions and 8 deletions

View File

@ -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)))

View File

@ -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;

View File

@ -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
{