[PATCH] wined3d: Fix ATI1 buffer size, try 3
Patrick Rudolph
siro at das-labor.org
Thu Aug 25 12:33:48 CDT 2016
Apitrace crashes on WINE when trying to playback a trace containing ATI1 textures.
Add a tests to show that "unknown" formats like ATI1 are backed by a buffer
of size pitch * height. Without the attaced fix the tests will crash.
Allocate more memory for formats that have WINED3DFMT_FLAG_BROKEN_PITCH flag set.
Changes since try 2:
Fix failing WINE tests.
Don't touch pitch calculation.
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
dlls/d3d9/tests/device.c | 8 ++++++++
dlls/wined3d/texture.c | 13 +++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index fbafa14..7f61560 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -11049,6 +11049,8 @@ static void test_miptree_layout(void)
{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
{
@@ -11111,6 +11113,9 @@ static void test_miptree_layout(void)
ok(map_desc.pBits == base + offset,
"%s, %s, level %u: Got unexpected pBits %p, expected %p.\n",
pools[pool_idx].name, formats[format_idx].name, i, map_desc.pBits, base + offset);
+
+ memset(base, 0, (base_dimension >> i) * (base_dimension >> i));
+
offset += (base_dimension >> i) * map_desc.Pitch;
hr = IDirect3DTexture9_UnlockRect(texture_2d, i);
@@ -11150,6 +11155,9 @@ static void test_miptree_layout(void)
ok(map_desc.pBits == base + offset,
"%s, %s, face %u, level %u: Got unexpected pBits %p, expected %p.\n",
pools[pool_idx].name, formats[format_idx].name, i, j, map_desc.pBits, base + offset);
+
+ memset(base, 0, (base_dimension >> j) * (base_dimension >> j));
+
offset += (base_dimension >> j) * map_desc.Pitch;
hr = IDirect3DCubeTexture9_UnlockRect(texture_cube, i, j);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index d2b1be5..86cc0b0 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -283,8 +283,17 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
{
unsigned int idx = i * level_count + j;
- size = wined3d_format_calculate_size(format, device->surface_alignment,
- max(1, desc->width >> j), max(1, desc->height >> j), max(1, desc->depth >> j));
+ if (format->flags[desc->resource_type] & WINED3DFMT_FLAG_BROKEN_PITCH)
+ {
+ size = max(1, desc->depth >> j) * max(1, desc->height >> j) *
+ max(1, desc->width >> j) * format->byte_count;
+ }
+ else
+ {
+ size = wined3d_format_calculate_size(format, device->surface_alignment,
+ max(1, desc->width >> j), max(1, desc->height >> j), max(1, desc->depth >> j));
+ }
+
texture->sub_resources[idx].offset = offset;
texture->sub_resources[idx].size = size;
offset += size;
--
2.7.4
More information about the wine-patches
mailing list