wined3d: Handle WINED3DFMT_FLAG_BROKEN_PITCH in wined3d_format_calculate_size().

The broken pitch calculation also affects the resource memory layout, as
evidenced by the mip-tree layout tests. Found using apitrace, which crashes on
Wine when playing back traces containing ATI1 textures.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Patrick Rudolph 2016-08-26 13:51:20 +02:00 committed by Alexandre Julliard
parent 09b09b307a
commit 3f7e5d647e
3 changed files with 13 additions and 6 deletions

View File

@ -7924,9 +7924,11 @@ static void test_miptree_layout(void)
}
formats[] =
{
{D3DFMT_A8R8G8B8, "D3DFMT_A8R8G8B8"},
{D3DFMT_A8, "D3DFMT_A8"},
{D3DFMT_L8, "D3DFMT_L8"},
{D3DFMT_A8R8G8B8, "D3DFMT_A8R8G8B8"},
{D3DFMT_A8, "D3DFMT_A8"},
{D3DFMT_L8, "D3DFMT_L8"},
{MAKEFOURCC('A','T','I','1'), "D3DFMT_ATI1"},
{MAKEFOURCC('A','T','I','2'), "D3DFMT_ATI2"},
};
static const struct
{

View File

@ -11046,9 +11046,11 @@ static void test_miptree_layout(void)
}
formats[] =
{
{D3DFMT_A8R8G8B8, "D3DFMT_A8R8G8B8"},
{D3DFMT_A8, "D3DFMT_A8"},
{D3DFMT_L8, "D3DFMT_L8"},
{D3DFMT_A8R8G8B8, "D3DFMT_A8R8G8B8"},
{D3DFMT_A8, "D3DFMT_A8"},
{D3DFMT_L8, "D3DFMT_L8"},
{MAKEFOURCC('A','T','I','1'), "D3DFMT_ATI1"},
{MAKEFOURCC('A','T','I','2'), "D3DFMT_ATI2"},
};
static const struct
{

View File

@ -3577,6 +3577,9 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
if (format->id == WINED3DFMT_UNKNOWN)
return 0;
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BROKEN_PITCH)
return width * height * depth * format->byte_count;
wined3d_format_calculate_pitch(format, alignment, width, height, &row_pitch, &slice_pitch);
return slice_pitch * depth;