Bug 59086

Summary: Slow spell effects with Planeshift on Intel Sandybridge HD 3000 graphics
Product: Mesa Reporter: Martin Steigerwald <Martin>
Component: Drivers/DRI/i965Assignee: Kenneth Graunke <kenneth>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: idr
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Martin Steigerwald 2013-01-06 19:36:35 UTC
Hi! I get fluent graphics in Planeshift, client version PlaneShift Arcane Chrysalis (0.5.9.3), except for spell effects. I reported this as 

http://www.hydlaaplaza.com/flyspray/index.php?do=details&task_id=5867

on Planeshift bug tracker, but I also want to report it here, so you Intel gfx developers can have a look at it. I understand a result could be that with current quality spell effects cannot be much faster on Sandybridge HD 3000 gfx, but I thought I at least try.

Everything is fluent at 1680x1050 except for spell effects. I know I can disable spell effects by making a copy of the effects directory and deleting some effect files in it. I also found that I can disable all spell effects by setting shaders to "lowest", but this worsens the gfx quality overall in the game.

Once a player casts a spell effect, it does not matter what shader quality is set, except for "lowest" then they are off, the fps goes down to almost a halt. Especially on more complex effects like Azure way Defensive Wind. This harms role play experience in events and so, cause whenever other players cast spell effects, I am not able to do much anymore.


I use an ThinkPad T520 with Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz with integrated HD 3000 graphics with the following gfx settings:

- Graphics quality: Custom
- Aspect Ratio: 16:10
- Resolution: 1680x1050
- Texture Q: Highest
- Shaders: Highest
- Particles: Medium
- No grass due to bug #5805
- Weather
- No shadows, cause client doesn´t remember enabled state.
- No bloom, no HDR
- Color depth 32
- Anti Aliasing 2xQ
- Anisotropic Filtering 2x
- Loader cache enabled, background loading of models
- VBO enabled

In game I have:
- Distance 1000
- FPS Cap 35

Additionally I have disabled GLSL:

Video.OpenGL.UseExtension.GL_ARB_shader_objects = false

as recommended by:

http://www.hydlaaplaza.com/smf/index.php?topic=40795.msg458094#msg458094

Which makes for a huge difference as then textures are displayed where I otherwise would only see simple single colored areas.


That makes:

martin@merkaba:~> egrep -i "(graphics|weather|video|loading)" .PlaneShift/planeshift.cfg
PlaneShift.Graphics.Preset = Custom
Video.ScreenDepth = 32
Video.OpenGL.MultiSamples = 2
Video.OpenGL.TextureFilterAnisotropy = 2
Video.OpenGL.TextureLODBias = -0.1
Video.OpenGL.TextureDownsample = 0
PlaneShift.Graphics.EnableGrass = false
PlaneShift.Weather.Enabled = true
Video.OpenGL.UseExtension.GL_ARB_vertex_buffer_object = true
Video.OpenGL.UseExtension.GL_ARB_shader_objects = false
PlaneShift.Graphics.Particles = Medium
PlaneShift.Graphics.Shaders = Highest
Planeshift.Loading.Cache = true
PlaneShift.Loading.BackgroundWorldLoading = false
Video.AspectRatio = 16:10
Video.ScreenWidth = 1680
Video.ScreenHeight = 1050
Video.FullScreen = false
Video.frameLimit = 35


This is on Debian Sid, Linux kernel 3.7 and 3.8-rc2 with:

martin@merkaba:~> apt-show-versions | egrep "(xserver-xorg/|xserver-xorg-core/|video-intel|libgl1-mesa-dri|libdrm)"
libdrm-dev/experimental uptodate 2.4.40-1
libdrm-intel1/experimental uptodate 2.4.40-1
libdrm-nouveau1a/sid uptodate 2.4.33-3
libdrm-nouveau2/experimental uptodate 2.4.40-1
libdrm-radeon1/experimental uptodate 2.4.40-1
libdrm2/experimental uptodate 2.4.40-1
libgl1-mesa-dri/sid uptodate 8.0.5-3
xserver-xorg/sid uptodate 1:7.7+1
xserver-xorg-core/sid uptodate 2:1.12.4-4
xserver-xorg-video-intel/experimental uptodate 2:2.20.14-1
xserver-xorg-video-intel-dbg/experimental uptodate 2:2.20.14-1


Any ideas?


The C++ source code for Planeshift is available at

http://www.planeshift.it/sources.html
http://www.sf.net/projects/planeshift

It uses the crystalspace 3d engine, version 1.4 I believe.


Or short via:

svn co https://planeshift.svn.sourceforge.net/svnroot/planeshift/trunk planeshift 

(without trunk added the the URL you get a whole lot more stuff)

The effects code is in:

src/common/effects

and it uses instructions for the engine which are, in a globally installed client in:

/opt/PlaneShift/data/effects/spells

The effects are proprietary as is in game gfx/music, see http://www.planeshift.it/license.html for an explaination.



Its also possible to try out the effects by doing a part of the tutorial till learning the first spell effect. Playing a Nolthrir with azure way affinity may give "defensive wind" easily, which is a quite complex effect. In case in compatible game zone, I could try to help with that, although I cannot access tutorial area once regular in game I think.

Ah and I am using SNA, but it doesn´t make a notable difference, played it without it as well. As far as I understand SNA is 2D only anyway.


I can try to make a photo of more complex spell effects so you get an idea what they are like.

Thanks,
Martin
Comment 1 Martin Steigerwald 2013-01-06 21:44:13 UTC
Its crystalspace3d 2.0/2.2 as a PS developer told me.
Comment 2 Kenneth Graunke 2013-01-14 07:09:44 UTC
Hi Martin,

Have you compiled PlaneShift from SVN?  I don't see a 0.5.9.3 on their website...only 0.5.9.2.

For what it's worth, disabling GLSL should only be useful on old, non-programmable Intel hardware, like GMA950/945/Pineview.  I would highly recommend using GLSL on Sandybridge.  That said, from your description it sounds like there are issues when running with GLSL.  I'll try to reproduce those.

Thanks for the detailed information.  Having the exact graphics setting you used is very helpful.

I'll try and take a look soon.
Comment 3 Martin Steigerwald 2013-01-15 21:15:37 UTC
Kenneth, thank you very much for your answer. No I didn´t compile from SVN, but the client can update itself. It offered two client updates after I first installed it. So I suggest, you just try it and see whether it offers you an update and let it install it.

Note that the first client version I tried, I think it was 0.5.9.1, had working grass, whereas in current clients it flickers, also on other graphics cards, so you may want to disable it[1].

Disabling GLSL gave me beautiful textures where there only have been single colored areas or wierd psychedelic patterns. I think I can dig out two screenshots for comparison and I am willing to provide a separate bug report for this if you want.

As for gfx settings I noted them in my bug report in detail. If there is something missing please tell me. My X.org configuration is minimal:

merkaba:~> cat /etc/X11/xorg.conf.d/anzeige.conf 
Section "Device"
        Identifier      "Grafikkern"

        Driver          "intel"

        # Monitore
        Option          "Monitor-LVDS1" "Notebook-Display"

        # Optionen
# [Bug 54195] [sna] crashes sometimes with two KDE sessions
# https://bugs.freedesktop.org/show_bug.cgi?id=54195
        Option          "AccelMethod"   "sna"

EndSection

Section "Monitor"
        Identifier      "Notebook-Display"

        DisplaySize     340 192
EndSection

The crash mentioned in the config does not seem to happen anymore, I will close this bug report, if not already done.

[1]http://www.hydlaaplaza.com/flyspray/index.php?opened=1484&type[0]=&sev[0]=&due[0]=&cat[0]=&status[0]=open&percent[0]=&reported[0]=&sort=asc&do=details&task_id=5805

Thanks,
Martin
Comment 4 Kenneth Graunke 2013-01-16 02:51:10 UTC
Alright, I can reproduce this (albeit on Ivybridge).  I cast Defensive Wind and immediately got 99% CPU usage...basically all in a swrast CopyTexSubImage fallback.

Which is odd, because something extremely similar happened a year ago and I fixed it then.  I'll continue investigating.
Comment 5 Kenneth Graunke 2013-01-16 03:07:10 UTC
The game is attempting to CopyTexSubImage between two MESA_FORMAT_X8_Z24 buffers, which are Y-tiled.

Currently we only have two implementations of CopyTexSubImage: first we try the GPU's BLT engine, and then fall back to the meta/software path.  Right now our BLT path can't handle Y-tiled buffers, so we're forced to software.

Now I remember the problem: I wrote some preliminary patches to do Y-tiled blits, but they were broken and rejected.  Paul's blorp engine can handle this, we just need to adapt it to work for CopyTexSubImage in addition to BlitFramebuffer.
Comment 6 Martin Steigerwald 2013-01-16 20:52:37 UTC
Kenneth, great, I love it, thanks. In case you have anything for testing, just tell me, and I might try to make a new xserver-xorg-video-intel package for my Debian Sid install. Also please tell me whether you want me to file a bug regarding disabling GLSL. In case you want to the a gross difference just go into the Laanx temple in Hydlaa, reachable from the plaza, with your char. Thanks, Martin
Comment 7 Kenneth Graunke 2013-01-19 21:40:21 UTC
Here's a preliminary spin of a patch to fix the issue:
http://lists.freedesktop.org/archives/mesa-dev/2013-January/033013.html
Comment 8 Martin Steigerwald 2013-01-20 12:29:10 UTC
Kenneth, this makes a huge difference. I had to build mesa 9 packages for Debian Sid from their git, the patch did apply with some offsets, but Planeshift didn´t start. Then I applied your patch to fdo mesa git master where it applied without offsetting. This worked. I also build a current xserver-xorg-video-intel package 2.20.18 instead of 2.20.14 from Debian git, but I am not sure whether this was necessary. This is with Linux 3.8-rc4 now.

Thus I now have:

- mesa git master at f9f5c92f734c517c1bd486f5a3b1931ea6f871a5
- + the patch (I also subscribed to mesa-dev now)
- on top of

martin@merkaba:~> dpkg -l | egrep "(mesa|xserver-xorg-video-intel)" | cut -c1-70
ii  libgl1-mesa-dev                        9.0.1-1~test               
ii  libgl1-mesa-dri:amd64                  9.0.1-1~test               
ii  libgl1-mesa-glx:amd64                  9.0.1-1~test               
ii  libglapi-mesa:amd64                    9.0.1-1~test               
pi  libglu1-mesa:amd64                     8.0.5-3                    
ii  libopenvg1-mesa:amd64                  9.0.1-1~test               
ii  mesa-common-dev                        9.0.1-1~test               
ii  mesa-utils                             8.0.1-2+b3                 
ii  xserver-xorg-video-intel               2:2.20.18-1                
ii  xserver-xorg-video-intel-dbg           2:2.20.18-1

Observed results:
- spell effects are way faster
- defensive wind and flame spire work faster than ever before
- CPU during flame spire which makes a huge cloud of fire is between 12-20%
  I think it was similar with defensive wind.

It is a tad bit jerky on certain spell effects still, but this works way better than before. This is a huge improvement. PS is playable with enabled spell effects now on Sandybridge. A bit jerky still sometimes, but playable.

I had to remove

Video.OpenGL.UseExtension.GL_ARB_shader_objects = false

from planeshift.cfg, otherwise Planeshift didn´t start. So this is with using GLSL.

Also GLSL is way better: The differing gfx output I described above is gone. I see textures where with Mesa 8 with GLSL has just been blank areas or psychedelic patterns. I have the impression that with GLSL and Mesa 9 in high detail areas like the Red Crystal Den´s it is a bit more jerky than before.


Feel free to link to this bug report in your commit message and add my 

Tested-by: Martin Steigerwald <martin@lichtvoll.de>

Thank you,
Martin
Comment 9 Martin Steigerwald 2013-01-20 19:53:13 UTC
Let me comment on the jeckyness. It does not seem to be related to the spells. I now had four spells simultaneously. Two from my char and two from another char with 50% CPU usage. Fluently!

I raised minimum FPS cap from 35 to 40. Maybe will go to 50 to see whether it makes a difference.
Comment 10 Kenneth Graunke 2013-01-21 00:22:05 UTC
(In reply to comment #8)
> Kenneth, this makes a huge difference. I had to build mesa 9 packages for
> Debian Sid from their git, the patch did apply with some offsets, but
> Planeshift didn´t start. Then I applied your patch to fdo mesa git master
> where it applied without offsetting. This worked. I also build a current
> xserver-xorg-video-intel package 2.20.18 instead of 2.20.14 from Debian git,
> but I am not sure whether this was necessary. This is with Linux 3.8-rc4 now.

The 2D driver (xserver-xorg-video-intel/xf86-video-intel) version shouldn't matter.  Just Mesa.

> Observed results:
> - spell effects are way faster
> - defensive wind and flame spire work faster than ever before
> - CPU during flame spire which makes a huge cloud of fire is between 12-20%
>   I think it was similar with defensive wind.
> 
> It is a tad bit jerky on certain spell effects still, but this works way
> better than before. This is a huge improvement. PS is playable with enabled
> spell effects now on Sandybridge. A bit jerky still sometimes, but playable.

Excellent.  If there's something in particular that triggers a slowdown that you'd like me to look at, just let me know.  Sadly, it looks like the main performance gains might come from optimizing Crystal Space though.

> Also GLSL is way better: The differing gfx output I described above is gone.
> I see textures where with Mesa 8 with GLSL has just been blank areas or
> psychedelic patterns.

Great.  I'm glad it's working now.

> I have the impression that with GLSL and Mesa 9 in
> high detail areas like the Red Crystal Den´s it is a bit more jerky than
> before.
> 
> Feel free to link to this bug report in your commit message and add my 
> 
> Tested-by: Martin Steigerwald <martin@lichtvoll.de>
> 
> Thank you,
> Martin

Will do.  Thanks!
Comment 11 Martin Steigerwald 2013-01-23 20:18:34 UTC
Kenneth, I found that after I updated mesa from 8 to 9.0.1 + your patch I have something strange in X.org:

Samples: 150K of event 'cycles', Event count (approx.): 75195405698                                         
 70,89%  libc-2.13.so                                                 [.] __memcpy_ssse3                   ◆
  8,09%  psclient.bin                                                 [.] 0x0000000000d99fcb               ▒
  2,88%  i965_dri.so                                                  [.] 0x000000000003113d               ▒
  0,83%  libdrm_intel.so.1.0.0                                        [.] 0x0000000000008164               ▒
  0,74%  libspeexdsp.so.1.5.0                                         [.] 0x0000000000009bc3               ▒
  0,46%  [kernel]                                                     [k] lzo1x_decompress_safe            ▒
  0,42%  libc-2.13.so                                                 [.] __memmove_ssse3                  ▒
  0,36%  libc-2.13.so                                                 [.] _int_malloc                      ▒
  0,32%  libpthread-2.13.so                                           [.] pthread_mutex_lock   

It is spinning on 75-90% CPU.

This just happened after running PS for a while.

Could that be related to your patch? Maybe not, cause the dri driver is only listed with 3%.

Immmediately gone after ending PS.

I already downngraded xf86-video-intel to 2.20.14 due to severe issues with SNA on the newer one. I now also have refresh issues, but only after having played PS for a while. Using SNA on 2.20.14 has been without issues until then.

After once triggered I just have to start PS till the screen where I can login. Immediately X.org goes up to 95% CPU.

Sorry, need to send, cause SNA messes up heavily with iceweasel text input field.

Thanks

Marti
Comment 12 Martin Steigerwald 2013-01-23 20:39:05 UTC
Well after a reboot it doesn´t trigger after the first spell effect being cast. And the SNA refresh issues appear to be unrelated. I have wierd SNA refresh issues but X.org is still behaving fine CPU-wise.

I will just disable SNA again and next occassion just to really test whether there is no relation ship. It doesn´t work really nicely anyway here at the moment after having worked for weeks.
Comment 13 Martin Steigerwald 2013-01-23 22:51:16 UTC
Okay, all I can say is that this CPU hog issue doesn´t seem to happen without SNA. I still get some slight flickering that I did you see before.

As for sluggyness in game I has an area, the Red Crystal Den´s. I can explain you where it is.

But my suggestion is: Keep this for the spell effects and thus close it, cause they are really fast enough. I will open requests for other things I find. Unless of course the SNA issues and the patch might be related, which I doubt meanwhile.

Do you happen to know in which mesa version your fine patch will be? 9.1?
Comment 14 Martin Steigerwald 2013-02-01 19:54:10 UTC
Bug 60172 - Planeshift: triangles where grass would be

may be related to the patches fixing the spell effects issue. Or not. And then related to the switch from mesa 8.0.5 to 9.x or the enabling of GLSL.
Comment 15 Kenneth Graunke 2013-02-06 23:34:06 UTC
Fixed in master by:

commit 0b3bebbaacf42ae07f712b5693f7b00fad3ff35e
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Tue Jan 15 22:17:23 2013 -0800

    i965: Implement CopyTexSubImage2D via BLORP (and use it by default).

    ...

Thanks for your help testing all of this, Martin.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.