http://bugs.winehq.org/show_bug.cgi?id=29162
--- Comment #8 from Stefan Dösinger stefan@codeweavers.com 2011-12-06 04:08:46 CST --- (In reply to comment #7)
I did as you asked, then cross-compiled and tested on my XP VM; the full patch is attached. The tests for IDirectDrawSurface3, IDirectDrawSurface4 and IDirectDrawSurface7 all work on Windows; with my proposed patch above, they fail on Wine. There is clearly something strange going on in SetSurfaceDesc.
Great, thanks a lot! Yeah, it doesn't look like there is version specific behavior here.
Two suggestions: You QueryInterface IDirectDrawSurface4 from IDirectDrawSurface4 and IDirectDrawSurface7 from IDirectDrawSurface7. That's not necessary, you can just drop the QI calls(and the 2nd surface pointer). In the IDirectDrawSurface3 test this is necessary because IDirectDraw::CreateSurface and IDirectDraw2::CreateSurface return an IDirectDrawSurface, not an IDirectDrawSurface3. (And IDirectDraw3 does not exist in ddraw.dll. It exists on ly in ddrawex.dll, which is part of Internet Explorer and not used by other apps).
For IDirectDraw7, it is better to create it via DirectDrawCreateEx instead of QIing it from IDirectDraw. There's a difference between those creation methods, see the IDirect3D* QI tests in tests/refcount.c.
As you can see, it sets up a call to SetSurfaceDesc from lines 257-297 that clearly uses more that DDSD_LPSURFACE and DDSD_PIXELFORMAT; however, it explicitly checks the return code for failure, which means that the call succeeds on Windows.
The source code is pretty helpful. The Rend < 2 check looks suspicious. It looks that this is the switch that toggles between windowed and fullscreen mode. I'll boot my Windows box and see if the app works in Windowed mode there. It is possible that it never enters the SetSurfaceDesc codepath on Windows.
What *could* be happening is that SetSurfaceDesc fails is you *change* anything other than what DDSD_LPSURFACE and DDSD_PIXELFORMAT allow, but it works if they would result on no change. I will see if I can make a simpler test case this weekend to test this.
I tested what happens when you pass the original surface description to SetSurfaceDesc, and this fails. However, the change got lost when my harddrive died two weeks ago.
I can imagine that there are some flags in the original SetSurfaceDesc that fail even if the values are equal, but others like width, height and pitch are accepted.
Which means that, for now, I would not recommend actually applying the patch(es) I attached to the Wine source, even though they fix the problem.
Patches that break the tests aren't accepted anyway.