[PATCH] wined3d: Fix ATI1 buffer size
Patrick Rudolph
siro at das-labor.org
Fri Aug 19 07:51:37 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.
Calculate correct buffer size if flag WINED3DFMT_FLAG_BROKEN_PITCH is set.
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
dlls/d3d9/tests/device.c | 6 ++++++
dlls/wined3d/utils.c | 8 +++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index fbafa14..a163ed9 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -7141,6 +7141,12 @@ static void test_lockrect_offset(void)
ok(locked_rect.Pitch == expected_pitch, "Got unexpected pitch %d for format %s, expected %d.\n",
locked_rect.Pitch, dxt_formats[i].name, expected_pitch);
+ /* Make sure that for "unknown" formats like ATIx the buffer has a
+ * size of pitch * height bytes */
+ if ((dxt_formats[i].format == MAKEFOURCC('A','T','I','1')) ||
+ (dxt_formats[i].format == MAKEFOURCC('A','T','I','2')))
+ memset(base, 0, expected_pitch * 128);
+
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index f02220c..a7a9bf6 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3518,9 +3518,15 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch)
{
+ /* For "unknown" formats like ATIx the pitch equals width. */
+ if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BROKEN_PITCH)
+ {
+ *row_pitch = width;
+ *slice_pitch = *row_pitch * height;
+ }
/* For block based formats, pitch means the amount of bytes to the next
* row of blocks rather than the next row of pixels. */
- if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
+ else if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
{
unsigned int row_block_count = (width + format->block_width - 1) / format->block_width;
unsigned int slice_block_count = (height + format->block_height - 1) / format->block_height;
--
2.7.4
More information about the wine-patches
mailing list