https://bugs.winehq.org/show_bug.cgi?id=40441
Bug ID: 40441 Summary: Chicken tournament crashes when loading texture Product: Wine Version: 1.9.7 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d Assignee: wine-bugs@winehq.org Reporter: jeremielapuree@yahoo.fr Distribution: ---
Created attachment 54194 --> https://bugs.winehq.org/attachment.cgi?id=54194 console output with ddraw d3d7 d3d channels enabled
The game crashes when loading textures.
https://bugs.winehq.org/show_bug.cgi?id=40441
joaopa jeremielapuree@yahoo.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- URL| |http://saschahlusiak.de/ind | |ex.php?content=ct&lang=en
--- Comment #1 from joaopa jeremielapuree@yahoo.fr --- This bug report is a split-off of bug 17005 when the first problem was the wrong rendering.
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #2 from joaopa jeremielapuree@yahoo.fr --- Bug still there in current wine
https://bugs.winehq.org/show_bug.cgi?id=40441
winetest@luukku.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |winetest@luukku.com
--- Comment #3 from winetest@luukku.com --- (In reply to joaopa from comment #2)
Bug still there in current wine
Still valid 1.9.21-git and staging 1.9.21.
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #4 from winetest@luukku.com --- Still valid wine 2.0.rc2.
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #5 from joaopa jeremielapuree@yahoo.fr --- Bug still there in current wine
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #6 from joaopa jeremielapuree@yahoo.fr --- Created attachment 62434 --> https://bugs.winehq.org/attachment.cgi?id=62434 console output with wine-3.16
Bug still there in current wine(3.16)
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #7 from joaopa jeremielapuree@yahoo.fr --- I investigated this bug. In the function in /src/HelperLib/texturen.cpp void MakeTransparent(LPDIRECTDRAWSURFACE7 lpSurface,const BOOLEAN white) { DDSURFACEDESC2 ddsd; DWORD dwAlphaMask,dwRGBMask,dwColorkey; DWORD x,y; PWORD p16; PDWORD p32; DWORD texturenum=0; DWORD dwRGBBitCount;
nochmal: // For textures with real alpha (not palettized), set transparent bits printf("texturenum = %x, lpSurface = %p\n", texturenum, lpSurface); ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize=sizeof(ddsd); while (lpSurface->Lock(NULL, &ddsd, 0, 0) == DDERR_WASSTILLDRAWING) ;
if (texturenum==0) { dwAlphaMask = ddsd.ddpfPixelFormat.dwRGBAlphaBitMask; dwRGBMask = ddsd.ddpfPixelFormat.dwRBitMask | ddsd.ddpfPixelFormat.dwGBitMask | ddsd.ddpfPixelFormat.dwBBitMask; dwColorkey = 0x00000000; // Colorkey on black if (white) dwColorkey = dwRGBMask; // Colorkey on white dwRGBBitCount=ddsd.ddpfPixelFormat.dwRGBBitCount; }
printf("dwRGBBitCount = %x\n", dwRGBBitCount); // Add an opaque alpha value to each non-colorkeyed pixel if (dwRGBBitCount == 16) { for (y = 0;y<ddsd.dwHeight;y++) { p16 = LPWORD(DWORD(ddsd.lpSurface) + y * DWORD(ddsd.lPitch)); for (x = 0;x<ddsd.dwWidth;x++) { *p16 = *p16 & WORD(dwRGBMask); if (*p16!=dwColorkey) *p16 = *p16 | (WORD)(dwAlphaMask); p16++; } } } if (dwRGBBitCount == 32) { for (y = 0;y<ddsd.dwHeight;y++) { p32=PDWORD(DWORD(ddsd.lpSurface)+y*DWORD(ddsd.lPitch)); for (x=0;x<ddsd.dwWidth;x++) { *p32=*p32&dwRGBMask; if (*p32!=dwColorkey)*p32=*p32|DWORD(dwAlphaMask); p32++; } } } lpSurface->Unlock(NULL);
if (ddsd.dwMipMapCount>1) { texturenum++;
DDSCAPS2 ddsCaps; ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP; ddsCaps.dwCaps2 = 0; ddsCaps.dwCaps3 = 0; ddsCaps.dwCaps4 = 0; if (SUCCEEDED(lpSurface->GetAttachedSurface( &ddsCaps, &lpSurface ))) lpSurface->Release(); goto nochmal; } }
the surface lptexture becomes NULL. So, NULL->Lock(NULL, &ddsd, 0, 0) is called. That works in Windows, not in Wine.
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #8 from Henri Verbeet hverbeet@gmail.com --- (In reply to joaopa from comment #7)
the surface lptexture becomes NULL. So, NULL->Lock(NULL, &ddsd, 0, 0) is called. That works in Windows, not in Wine.
There's no "lptexture" in the code you quoted. In any case though, does that mean you have a testcase for this?
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #9 from Henri Verbeet hverbeet@gmail.com --- Actually, looking at the code you quoted, perhaps we're not setting dwMipMapCount correctly for sub-level surfaces. I don't think we have existing tests for that.
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #10 from joaopa jeremielapuree@yahoo.fr --- Indeed, it is a problem of mipmap count in IDirectDrawSurface7::Lock
----------------------------- Under Wine _____________________________
texturenum = 0, lpSurface = 00193258 mipmaps = 5 dwRGBBitCount = 10 texturenum = 1, lpSurface = 001B9D60 mipmaps = 5 dwRGBBitCount = 10 texturenum = 2, lpSurface = 001B9E90 mipmaps = 5 dwRGBBitCount = 10 texturenum = 3, lpSurface = 001951D0 mipmaps = 5 dwRGBBitCount = 10 texturenum = 4, lpSurface = 00195300 mipmaps = 5 dwRGBBitCount = 10 texturenum = 5, lpSurface = 00000000
----------------------------- Under Windows _____________________________
texturenum = 0, lpSurface = 01212328 ddsd.dwMipMapCount= 5 dwRGBBitCount = 10 texturenum = 1, lpSurface = 01212308 ddsd.dwMipMapCount= 4 dwRGBBitCount = 10 texturenum = 2, lpSurface = 01212348 ddsd.dwMipMapCount= 3 dwRGBBitCount = 10 texturenum = 3, lpSurface = 01211D08 ddsd.dwMipMapCount= 2 dwRGBBitCount = 10 texturenum = 4, lpSurface = 01211DE8 ddsd.dwMipMapCount= 1 dwRGBBitCount = 10
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #11 from joaopa jeremielapuree@yahoo.fr --- Created attachment 63329 --> https://bugs.winehq.org/attachment.cgi?id=63329 Patch fixing the issue
This patch fixes the problem. Henri, you were right. It is an issue with mipmap counter.
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #12 from joaopa jeremielapuree@yahoo.fr --- Comment on attachment 63329 --> https://bugs.winehq.org/attachment.cgi?id=63329 Patch fixing the issue
From 8e9381fc44a62b03904c272f79e7901216675823 Mon Sep 17 00:00:00 2001
From: David Adam david.adam.cnrs@gmail.com Date: Sun, 20 Jan 2019 11:25:54 -1000 Subject: [PATCH] ddraw: Mipmap sublevels have their own mipmap counter
Signed-off-by: David Adam david.adam.cnrs@gmail.com --- dlls/ddraw/surface.c | 1 + dlls/ddraw/tests/ddraw1.c | 8 +++++++- dlls/ddraw/tests/ddraw2.c | 8 +++++++- dlls/ddraw/tests/ddraw4.c | 8 +++++++- dlls/ddraw/tests/ddraw7.c | 8 +++++++- 5 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 819044214d..8203d5e3cc 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6339,6 +6339,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ { mip = wined3d_texture_get_sub_resource_parent(wined3d_texture, i * levels + j); mip_desc = &mip->surface_desc; + mip_desc->u2.dwMipMapCount = levels - j;
if (j) { diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index d52fc313c4..9fb5eeaa7b 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -5405,6 +5405,7 @@ static void test_mipmap(void) HRESULT hr; DDSCAPS caps = {DDSCAPS_COMPLEX}; DDCAPS hal_caps; + DWORD original_mipmap_count;
static const struct { @@ -5468,7 +5469,8 @@ static void test_mipmap(void) ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out, "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1) + original_mipmap_count = U2(surface_desc).dwMipMapCount; + if (original_mipmap_count > 1) { hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &surface2); ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr); @@ -5477,10 +5479,14 @@ static void test_mipmap(void) surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count, + "Test %u: unexpected change of mipmap count %u.\n", i, surface_desc.dwMipMapCount); memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface_Lock(surface2, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count - 1, + "Test %u: Child mipmap count unexpected %u\n", i, surface_desc.dwMipMapCount); IDirectDrawSurface_Unlock(surface2, NULL); IDirectDrawSurface_Unlock(surface, NULL);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index bacc35d31d..0739a3ea37 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -6431,6 +6431,7 @@ static void test_mipmap(void) HRESULT hr; DDSCAPS caps = {DDSCAPS_COMPLEX}; DDCAPS hal_caps; + DWORD original_mipmap_count;
static const struct { @@ -6498,7 +6499,8 @@ static void test_mipmap(void) ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out, "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1) + original_mipmap_count = U2(surface_desc).dwMipMapCount; + if (original_mipmap_count > 1) { hr = IDirectDrawSurface2_GetAttachedSurface(surface, &caps, &surface2); ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr); @@ -6507,10 +6509,14 @@ static void test_mipmap(void) surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface2_Lock(surface, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count, + "Test %u: unexpected change of mipmap count %u.\n", i, surface_desc.dwMipMapCount); memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface2_Lock(surface2, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count - 1, + "Test %u: Child mipmap count unexpected %u\n", i, surface_desc.dwMipMapCount); IDirectDrawSurface2_Unlock(surface2, NULL); IDirectDrawSurface2_Unlock(surface, NULL);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 0066bf770f..9f450b49d5 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -7963,6 +7963,7 @@ static void test_mipmap(void) HRESULT hr; DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, {0}}; DDCAPS hal_caps; + DWORD original_mipmap_count;
static const struct { @@ -8026,7 +8027,8 @@ static void test_mipmap(void) ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out, "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1) + original_mipmap_count = U2(surface_desc).dwMipMapCount; + if (original_mipmap_count > 1) { hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2); ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr); @@ -8035,10 +8037,14 @@ static void test_mipmap(void) surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count, + "Test %u: unexpected change of mipmap count %u.\n", i, surface_desc.dwMipMapCount); memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface4_Lock(surface2, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count - 1, + "Test %u: Child mipmap count unexpected %u\n", i, surface_desc.dwMipMapCount); IDirectDrawSurface4_Unlock(surface2, NULL); IDirectDrawSurface4_Unlock(surface, NULL);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 1f57420250..f70383fbd3 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -7797,6 +7797,7 @@ static void test_mipmap(void) HRESULT hr; DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, {0}}; DDCAPS hal_caps; + DWORD original_mipmap_count;
static const struct { @@ -7861,7 +7862,8 @@ static void test_mipmap(void) ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out, "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
- if (U2(surface_desc).dwMipMapCount > 1) + original_mipmap_count = U2(surface_desc).dwMipMapCount; + if (original_mipmap_count > 1) { hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2); ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr); @@ -7870,10 +7872,14 @@ static void test_mipmap(void) surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count, + "Test %u: unexpected change of mipmap count %u.\n", i, surface_desc.dwMipMapCount); memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface7_Lock(surface2, NULL, &surface_desc, 0, NULL); ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr); + ok(surface_desc.dwMipMapCount == original_mipmap_count - 1, + "Test %u: Child mipmap count unexpected %u\n", i, surface_desc.dwMipMapCount); IDirectDrawSurface7_Unlock(surface2, NULL); IDirectDrawSurface7_Unlock(surface, NULL);
https://bugs.winehq.org/show_bug.cgi?id=40441
--- Comment #13 from joaopa jeremielapuree@yahoo.fr --- Argh. Can an administrator reomve my last comment (and this one)?
https://bugs.winehq.org/show_bug.cgi?id=40441
joaopa jeremielapuree@yahoo.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #63329|0 |1 is obsolete| |
--- Comment #14 from joaopa jeremielapuree@yahoo.fr --- Created attachment 63344 --> https://bugs.winehq.org/attachment.cgi?id=63344 patch fixing a failing test
Patch fixing the issue. Fixing a failing test.
https://bugs.winehq.org/show_bug.cgi?id=40441
Alistair Leslie-Hughes leslie_alistair@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
https://bugs.winehq.org/show_bug.cgi?id=40441
joaopa jeremielapuree@yahoo.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #15 from joaopa jeremielapuree@yahoo.fr --- Fixed with a better patch by Henri. Thank you Henri
https://bugs.winehq.org/show_bug.cgi?id=40441
Gijs Vermeulen gijsvrm@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |f5d7d9cccc941024f1532a9ac23 | |427d07810f337
https://bugs.winehq.org/show_bug.cgi?id=40441
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #16 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 4.1.
https://bugs.winehq.org/show_bug.cgi?id=40441
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |4.0.x
https://bugs.winehq.org/show_bug.cgi?id=40441
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|4.0.x |---
--- Comment #17 from Michael Stefaniuc mstefani@winehq.org --- Removing the 4.0.x milestone from bug fixes included in 4.0.1.