http://bugs.winehq.org/show_bug.cgi?id=22478
Summary: Major performance drop in King's Bounty games with shadows enabled Product: Wine Version: 1.1.43 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: minor Priority: P2 Component: directx-d3d AssignedTo: wine-bugs@winehq.org ReportedBy: gyebro69@gmail.com
Since Wine-1.1.43 both King's Bounty: The Legend and the sequel, King's Bounty: Armored Princess are unplayable when shadows are enabled in the game. Both games suffer severe performance drops with shadows enabled. This was not the case prior to 1.1.43: I was able to play both games at reasonable framerates with 'normal' shadows enabled on my mediocre hardware. Tested with the Steam version of the games.
Workaround: disable shadows completely in the game. The issue doesn't seem to affect the gameplay any other way.
Howto test the issue: Start King's Bounty-Armored Princess, click on 'Options' and set shadow quality anything beyond 'Neutral'. See the performance drops on the animated background behind the princess in the menu. The main game itself also becomes unplayable due to low framerates.
Bisecting between 1.1.42 and 1.1.43 came up with the following commit:
738ca2f5fcf6e9deea42363382dca2ec7626aee0 is the first bad commit commit 738ca2f5fcf6e9deea42363382dca2ec7626aee0 Author: Henri Verbeet hverbeet@codeweavers.com Date: Fri Apr 16 12:41:02 2010 +0200
wined3d: Allow offscreen depth/stencil clears again with FBOs.
This fixes a regression introduced by 10f58c14bcdeba9f7ea82701b9d9ab8f2bb3414b.
:040000 040000 5e87b8acc9f665d579fe268b44c59e59db1990d8 0ce8660d89f207fd0281b0e2ed259eb4851a937d M dlls
Reverting that patch was successful, the game runs at normal framerates now, but whole textures are missing in the game now (after the reverted patch).
I couldn't add the author of the patch to CC.
Fedora 12 x86 Wine-1.1.43 Nvidia 7600 GT with driver 195.36.15
http://bugs.winehq.org/show_bug.cgi?id=22478
GyB gyebro69@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression
http://bugs.winehq.org/show_bug.cgi?id=22478
Henri Verbeet hverbeet@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |thunderbird2k@gmail.com
--- Comment #1 from Henri Verbeet hverbeet@gmail.com 2010-04-24 06:26:51 --- That's not the patch that caused the performance drop, it just fixed depth clears again. The regression you're looking for is 10f58c14bcdeba9f7ea82701b9d9ab8f2bb3414b.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #2 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-25 13:14:20 --- Hi,
I have tried to reproduce the issues you described. First, I downloaded the demo of "King's Bounty: The Legend" and with or without shadows the game is quite slow (I would guess 20-25fps). I tried with and without my ClearSurface patch but it felt like it didn't make a real difference. I'm here on a Intel i5 with a Geforce GTS360M and the GPU supports more 3d features and is a lot faster. Can you confirm that the same performance issues occur in the demo? Do you have suggestions for places where the patch made a difference?
Next I tried the demo of "King's Bounty: Armored Princess" but I haven't been able to get it working. I'm getting an error like this http://moikartinki.ru/view_image/806dc2217/snapshot1.jpg (this is actually an error someone posted to appdb for the first game but I'm seeing it for the sequel). I don't know what the actual issue is here.
Thanks, Roderick
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #3 from GyB gyebro69@gmail.com 2010-04-25 14:30:03 --- I think the demo of KB: Armored Princess contains Starforce, that's why it doesn't start in Wine, but it would be a good "benchmark" for this issue, because it has an animated background in the menu.
As for KB: The Legend, the slowdown can be seen right in the tutorial, when you start a new game. With shadows disabled both 1.1.42 and 1.1.43 gives nearly the same performance. The difference is visible when shadows are on 'normal' setting: with 1.1.42, well, it's slightly below the playable level on my hardware. With 1.1.43 the situation relapsed: as if I could see still images. I guess the issue is more noticeable for me, because of my low-end hardware. I used 'normal' settings in every graphical options, with FSAA disabled.
Anyway, does it matter if I compiled 1.1.43 with cflags -O0 this time? 1.1.42 was compiled with the default -O2. Might it cause the performance loss when shadows are enabled?
http://bugs.winehq.org/show_bug.cgi?id=22478
GyB gyebro69@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download URL| |http://www.gamershell.com/d | |ownload_32652.shtml
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #4 from GyB gyebro69@gmail.com 2010-04-25 14:43:04 --- Forgot to mention: I tried the demo version of KB:The Legend,too, and it shows the same behaviour between 1.1.42 and 1.1.43, so I added a link to the demo.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #5 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-25 14:56:37 --- (In reply to comment #3)
I think the demo of KB: Armored Princess contains Starforce, that's why it doesn't start in Wine, but it would be a good "benchmark" for this issue, because it has an animated background in the menu.
As for KB: The Legend, the slowdown can be seen right in the tutorial, when you start a new game. With shadows disabled both 1.1.42 and 1.1.43 gives nearly the same performance. The difference is visible when shadows are on 'normal' setting: with 1.1.42, well, it's slightly below the playable level on my hardware. With 1.1.43 the situation relapsed: as if I could see still images. I guess the issue is more noticeable for me, because of my low-end hardware. I used 'normal' settings in every graphical options, with FSAA disabled.
Anyway, does it matter if I compiled 1.1.43 with cflags -O0 this time? 1.1.42 was compiled with the default -O2. Might it cause the performance loss when shadows are enabled?
Well compiling without these optimizations can matter but only if the game is cpu limited. Since recompiling Wine is easy, give it a try anyway. I'll take a closer look at the demo and write down some performance numbers.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #6 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-25 15:18:48 --- Alright here are my results. I ran the game at 1024x768 @ 32-bit and I disabled the in game option multisampling which by default was set to 2 which made the game quite a bit slower and made performance testing trickier. In all cases I tested in the tutorial map (so inside a castle on a horse I guess) and I moved around a bit in the room.
Without ClearSurface FBO patch: * 27-30fps with shadows=none * 20-25fps with shadows=high
With FBO patch: * 35-40fps with shadows=none (yes, really I got better performance but more later) * 20-25fps with shadows=high
At least on my system performance is the same with and without the patch when shadows are set to high. Perhaps there is a 1-2fps difference but I really can't say as there is no timedemo mode and I time you make different movements. Without shadows performance is actually quite a bit better for some reason.
One thing I should mention is that usually after a few seconds (when shadows=none with fbo patch) I receive some GL_INVALID_OPERATION errors from glsl_shader.c 4572. Can it be that perhaps you are also seeing such error lines after the patch? When I get them the performance drops a lot to about 10fps.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #7 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-26 09:08:55 --- I (hackily) fixed the shader issue just to make sure it isn't related to the performance drop. Whether I use the FBO patch or not I get a big performance drop within lets say 10 seconds in game when not using shadows. The same issue might also occur with shadows and thus might be the same issue you are seeing.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #8 from GyB gyebro69@gmail.com 2010-04-26 10:50:47 --- In the meantime I recompiled 1.1.43 with cflags=-O2 now, but it really doesn't matter. Frankly, I was not quite thorough in my testing: with shadows disabled only the opening scene is playable, entering the first tutorial mission gives a lot of those err: ...glsl_shader.c 4572 lines for me, too, and performance dropped significantly. Moreover, those erroneous lines were present in 1.1.42, too. Now I'm a bit confused: originally I only observed the huge slowdown with shadows=normal, and that wasn't so significant in 1.1.42.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #9 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-26 12:56:13 --- Can you add the glxinfo output of your geforce7? Perhaps it is related to GL_ARB_map_buffer_range but I'm not sure if it is supported on your GPU. I'll try to disable the extension here. It would also be useful to try some other Wine versions to see if the issue existed there as well. If you find a version which didn't have it, perform a regression test.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #10 from GyB gyebro69@gmail.com 2010-04-26 13:14:34 --- Created an attachment (id=27567) --> (http://bugs.winehq.org/attachment.cgi?id=27567) output of glxinfo -l
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #11 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-27 06:02:32 --- Yesterday I looked at this issue with GyB on IRC. On his system there is really a performance drop related to this patch. I have also checked behavior on my Radeon 3450 based laptop but the game is unplayable there (I guess less than 5fps).
The console is flooded with: fixme:d3d_surface:IWineD3DBaseSurfaceImpl_Blt Filters not supported in software blit
When you look at the +d3d_surface log the reason is: trace:d3d_surface:IWineD3DSurfaceImpl_BltOverride No surface is render target, not using hardware blit. Src = 0x5e47a20, dst = 0x21df58
Because of this a gpu -> cpu copy is performed followed by an upload and the game is doing this constantly. Before looking back at ClearSurface I will try to solve this issue (perhaps using a hack for now) as perhaps this is the real issue.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #12 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-27 06:34:43 --- Created an attachment (id=27576) --> (http://bugs.winehq.org/attachment.cgi?id=27576) Hack
This hacky patch prevents the software fallback by using FBOs for StretchRect. As mentioned before on my Nvidia system I see a huge performance drop after I'm in game for lets say 10 seconds. The performance before the performance drop is similar but the performance drop itself never occurs for me anymore. Give this hack a try. If it works fine I'll see if I can fit in the blit_shader design already.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #13 from GyB gyebro69@gmail.com 2010-04-27 14:12:23 --- Created an attachment (id=27580) --> (http://bugs.winehq.org/attachment.cgi?id=27580) rzipped +d3d,+d3d_surface log (348 Mb uncompressed)
A +d3d,+d3d_surface log after your hack applied.
http://bugs.winehq.org/show_bug.cgi?id=22478
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jskartman@gmail.com
--- Comment #14 from Vitaliy Margolen vitaliy@kievinfo.com 2010-04-29 09:01:56 --- *** Bug 22528 has been marked as a duplicate of this bug. ***
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #15 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-29 09:18:23 --- Jaimie what Wine version are you using? There are several slowness issues related to this game and the software blit is one of the major ones. This bug is mainly about a performance regression which was introduced between 1.1.42 and 1.1.43. Do you notice any performance difference between 1.1.42 and 1.1.43? If not then I would prefer to move it back to the other bug report. (http://www.winehq.org/pipermail/wine-patches/2010-April/087852.html solves the software blit fall backs and can help quite a bit but it needs some more work before it enters GIT)
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #16 from Jaime jskartman@gmail.com 2010-04-29 15:51:31 ---
Yeah I think 22528 is not a duplicate. I have always observed this slowdow (on the second scenario, not the first) since wine 1.1.38. Maybe is something related to water, in the second scenario there is water, or maybe another thing ¿? i dont know. But the first scenario is perfect 20-30fps! and the second is 1-2 fps. Disable shadows doesn't help. I tried various version of wine and always observed the same behavior
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #17 from Jaime jskartman@gmail.com 2010-04-29 15:57:31 --- i didnt notice any noticeable diference between 1.1.42 and 1.1.43. (but i am not measuring FPS seriously). Tomorrow i will try the patch, and I will post the results, thx.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #18 from Jaime jskartman@gmail.com 2010-04-30 02:35:48 --- I like to report a bug and get it solved in less than a day!! XD
Roderick the patch you pointed solved totally the slowdowns i was experiencing with Kings Bounty Armored Princess.
All versions of wine without the patch (i tried 36,37,38,40,42,43):
First scenario 20 fps Second scenario 2 fps
Git with the patch applied:
First scenario 20 fps Second scenario 20 fps
Speed increase 1000%. Yeah!!
There is another bug not related to this. I experience graphics glitches on some scenarios since wine 1.1.38, wine 1.1.37 and .36 were perfect. For this one i will fill a new bug and try to do a regression test.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #19 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-30 10:48:07 --- Henri mentioned that he noticed this issue as well, so I have done some additional testing. During testing I used a patch similar the 'hack' attached to this thread to stabilize the fps. Further I made sure I ran using WINEDEBUG=+fps,-all. Between turning shadows on / off, I quit back to the main menu and started a new game (this is what I did before as well).
The framerate with the ClearSurface FBO patch: * 25-30fps with shadows=high (20% faster than before due to the stretch_rect_fbo patch)
The framerate withou the ClearSurface FBO patch: * 33-38fps with shadows=high
Except for the stretch_rect_fbo patch (which should be ignored for now) I do notice a big performance difference now. I have no idea what changed (except that this is a newer wine build but I doubt it matters). It should now be easier to locate the cause.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #20 from Roderick Colenbrander thunderbird2k@gmail.com 2010-04-30 12:52:32 --- Just for testing I added a patch to fix the shader compile issue the nvidia drivers report errors about. When using that patch in combination with the stretch_rect_fbo patch I get the same performance with and without the ClearSurface patch, so I must have used that patch (better call it hack since it renamed tmp0.xyz in the shader to tmp0.xy) when I did the performance testing.
I haven't had that much time yet to investigate the performance issue but it at least seems to be related to context_attach_surface_fbo. I moved the context_fbo bind, context_attach_surface_fbo and an unbind line to the end of the function, so it wouldn't affect rendering and it caused a similar performance drop, so it might be this one. I haven't investigated it more yet.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #21 from Roderick Colenbrander thunderbird2k@gmail.com 2010-05-02 15:40:01 --- Created an attachment (id=27678) --> (http://bugs.winehq.org/attachment.cgi?id=27678) Possible fix?
I think the issue is that context_acquire(CTXUSAGE_CLEAR) already binds an FBO for us and we are doing a redundant bind (which at least for this game, it is the only thing I have installed at the moment) binds another FBO which I guess is expensive.
Taking out the redundant fbo bind restores the performance for me. Originally I copied this FBO code from color_fill_fbo to fix test failures in a test I wrote. This particular test still passes (E.g. try to call ClearSurface through ColorFill->Blt->blit_shader->ClearSurface or call it directly from ColorFill to see the incorrect colors in the d3d9 color_fill_test due to lack of a context_attach_surface_fbo).
Hopefully this is the right fix.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #22 from GyB gyebro69@gmail.com 2010-05-02 21:06:55 --- Your patch (in comment #21) fixed the issue in both games when shadows are on, and now have reasonable framerates with shadows. Thank you for taking the time to fix this.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #23 from Roderick Colenbrander thunderbird2k@gmail.com 2010-05-03 03:10:58 --- Good that it works. It might be nicer if context_acquire set these lines. I'll see if that is easy.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #24 from Roderick Colenbrander thunderbird2k@gmail.com 2010-05-03 09:56:52 --- Created an attachment (id=27689) --> (http://bugs.winehq.org/attachment.cgi?id=27689) Improved fix
I think this fix is already a bit better. Performance should be similar. I must say that the issue is still hard to reproduce so now and then. Lets say half of the runs are with performance in the 25fps but when performance is good it is around 30-35fps. I have no idea what causes it but I guess the Nvidia drivers haven't clocked the GPU up yet.
I hope to have a new version ready soon (I think the change needs to be moved to context_apply_fbo_entry) but can't promise when since something bad has happened in the family :(
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #25 from GyB gyebro69@gmail.com 2010-05-03 12:33:34 --- (In reply to comment #24)
Created an attachment (id=27689)
--> (http://bugs.winehq.org/attachment.cgi?id=27689) [details]
Improved fix
I think this fix is already a bit better. Performance should be similar. I must say that the issue is still hard to reproduce so now and then. Lets say half of the runs are with performance in the 25fps but when performance is good it is around 30-35fps. I have no idea what causes it but I guess the Nvidia drivers haven't clocked the GPU up yet.
Yes, this patch resulted nearly the same performance as your previous one. Of course I got lower fps than you (with shadows=on it's hardly above 10 fps, but that wasn't higher in the previous versions either). What is more important: the original issue when shadows are enabled is now gone. Just imagine the whole game became totally unresponsive with <1 fps . With your patch the situation is now back to 'normal'. Interestingly I can't notice the mentioned fluctuation in performance. Hopefully, others can also benefit from the improvement the patch does. Isn't it strange no one else reported similar performance issues in other games?
I hope to have a new version ready soon (I think the change needs to be moved to context_apply_fbo_entry) but can't promise when since something bad has happened in the family :(
I'm sorry to hear about that. Best wishes to you and your family as well.
Regards, Béla Gyebrószki
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #26 from Henri Verbeet hverbeet@gmail.com 2010-05-05 11:27:30 --- Please give current git a try, there's a good chance ed75f5ca7aae3de6afeca5dc97be9f54a140104d will have fixed this.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #27 from Henri Verbeet hverbeet@gmail.com 2010-05-05 11:31:14 --- (In reply to comment #24)
context_apply_fbo_state(context);
if(context->render_offscreen && context->current_rt != device->render_targets[0])
context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, context->current_rt);
In the cases where it matters that change would corrupt the FBO cache, and still give you the performance hit of FBO setup.
http://bugs.winehq.org/show_bug.cgi?id=22478
--- Comment #28 from GyB gyebro69@gmail.com 2010-05-05 12:31:21 --- (In reply to comment #26)
Please give current git a try, there's a good chance ed75f5ca7aae3de6afeca5dc97be9f54a140104d will have fixed this.
In the current git (wine-1.1.43-564-g1af1784) the issue, that caused the excessive slowdown for me, is no longer present. Thank you.
http://bugs.winehq.org/show_bug.cgi?id=22478
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED
--- Comment #29 from Juan Lang juan_lang@yahoo.com 2010-05-05 13:13:38 --- Reported fixed.
http://bugs.winehq.org/show_bug.cgi?id=22478
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #30 from Alexandre Julliard julliard@winehq.org 2010-05-07 13:30:29 --- Closing bugs fixed in 1.1.44.