Module: wine Branch: master Commit: 6176eb87de435a6d20399015aa603027f0a4062e URL: http://source.winehq.org/git/wine.git/?a=commit;h=6176eb87de435a6d20399015aa...
Author: Stefan Dösinger stefan@codeweavers.com Date: Tue Aug 30 12:46:41 2011 +0200
ddraw: Set dwZBufferBitDepth in old z buffers.
---
dlls/ddraw/tests/dsurface.c | 12 ++++++------ dlls/ddraw/utils.c | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c index e06956e..75646d6 100644 --- a/dlls/ddraw/tests/dsurface.c +++ b/dlls/ddraw/tests/dsurface.c @@ -3950,7 +3950,7 @@ static void zbufferbitdepth_test(void) IDirectDrawSurface_Release(surface);
ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n"); - todo_wine ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n"); + ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n"); /* Yet the ddpfPixelFormat member contains valid data */ if (memcmp(&ddsd.ddpfPixelFormat, &test_data[i].pf, ddsd.ddpfPixelFormat.dwSize)) { @@ -3982,8 +3982,8 @@ static void zbufferbitdepth_test(void) ok(ddsd.ddpfPixelFormat.dwZBufferBitDepth == 16, "Expected a 16bpp depth buffer, got %ubpp\n", ddsd.ddpfPixelFormat.dwZBufferBitDepth); ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n"); - todo_wine ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n"); - todo_wine ok(ddsd.dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %u\n", + ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n"); + ok(ddsd.dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %u\n", ddsd.dwZBufferBitDepth);
/* DDSD_PIXELFORMAT vs invalid ZBUFFERBITDEPTH */ @@ -4021,9 +4021,9 @@ static void zbufferbitdepth_test(void) IDirectDrawSurface_Release(surface); ok(ddsd.ddpfPixelFormat.dwZBufferBitDepth == 16, "Expected a 16bpp depth buffer, got %ubpp\n", ddsd.ddpfPixelFormat.dwZBufferBitDepth); - todo_wine ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n"); - todo_wine ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n"); - todo_wine ok(ddsd.dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %u\n", + ok(ddsd.dwFlags & DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH is not set\n"); + ok(!(ddsd.dwFlags & DDSD_PIXELFORMAT), "DDSD_PIXELFORMAT is set\n"); + ok(ddsd.dwZBufferBitDepth == 16, "Expected dwZBufferBitDepth=16, got %u\n", ddsd.dwZBufferBitDepth); }
diff --git a/dlls/ddraw/utils.c b/dlls/ddraw/utils.c index fce00eb..63c6a5e 100644 --- a/dlls/ddraw/utils.c +++ b/dlls/ddraw/utils.c @@ -1192,7 +1192,7 @@ void DDSD_to_DDSD2(const DDSURFACEDESC *in, DDSURFACEDESC2 *out) * though. Don't forget to set ddsCaps.dwCaps2/3/4 to 0 when removing this */ memset(out, 0x00, sizeof(*out)); out->dwSize = sizeof(*out); - out->dwFlags = in->dwFlags; + out->dwFlags = in->dwFlags & ~DDSD_ZBUFFERBITDEPTH; if (in->dwFlags & DDSD_WIDTH) out->dwWidth = in->dwWidth; if (in->dwFlags & DDSD_HEIGHT) out->dwHeight = in->dwHeight; if (in->dwFlags & DDSD_PIXELFORMAT) out->u4.ddpfPixelFormat = in->ddpfPixelFormat; @@ -1236,7 +1236,18 @@ void DDSD2_to_DDSD(const DDSURFACEDESC2 *in, DDSURFACEDESC *out) out->dwFlags = in->dwFlags; if (in->dwFlags & DDSD_WIDTH) out->dwWidth = in->dwWidth; if (in->dwFlags & DDSD_HEIGHT) out->dwHeight = in->dwHeight; - if (in->dwFlags & DDSD_PIXELFORMAT) out->ddpfPixelFormat = in->u4.ddpfPixelFormat; + if (in->dwFlags & DDSD_PIXELFORMAT) + { + out->ddpfPixelFormat = in->u4.ddpfPixelFormat; + if ((in->dwFlags & DDSD_CAPS) && (in->ddsCaps.dwCaps & DDSCAPS_ZBUFFER)) + { + /* Z buffers have DDSD_ZBUFFERBITDEPTH set, but not DDSD_PIXELFORMAT. They do + * have valid data in ddpfPixelFormat though */ + out->dwFlags &= ~DDSD_PIXELFORMAT; + out->dwFlags |= DDSD_ZBUFFERBITDEPTH; + out->u2.dwZBufferBitDepth = in->u4.ddpfPixelFormat.u1.dwZBufferBitDepth; + } + } /* ddsCaps is read even without DDSD_CAPS set. See dsurface:no_ddsd_caps_test */ out->ddsCaps.dwCaps = in->ddsCaps.dwCaps; if (in->dwFlags & DDSD_PITCH) out->u1.lPitch = in->u1.lPitch;