Commit df5a0976 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

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.
parent 80638b6d
......@@ -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)))
......
......@@ -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;
......
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment