Cell transisition

Everything about development and the OpenMW source code.
Post Reply
Digmaster
Posts: 22
Joined: 20 Apr 2014, 05:12

Cell transisition

Post by Digmaster »

Hey

So every time we switch cells in the world we have that annoying cell loading dialog. While it's short, it's annoying if you're doing something on the boundary and you switch back and forth and whatnot. In morrowind, if i recall correctly, I never even saw the boundary except when I'm moving very quickly. I have no idea how morrowind handles this, but I propose that we keep 12 cells, (9 around you plus the three you just came from) to make it so you can't back-and-forth with a billion load screens. This is a simple fix that I could implement in like ten minutes (Store which cells you should have unloaded this cell transition, unloaded the ones that you should have unloaded the last).

Of course the best way to do this above is to load new cells when you're within 1/4 cell of the cell boundary, and unload the cells when you're 1/4 of the way into the new cell. This makes the most sense anyways.

Alternatively, threading the cell loading so you don't see the loading screen at all. I tried to quickly implement this, but as far as I can tell there's no way to load a cell without adding it to the world (We could change things to permit this I'd guess, but the code is mostly undocumented so I don't want to figure that out haha)

I don't know how you guys want to handle this but it's definitively something that needs to be taken care of at some point, it's really annoying
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Cell transisition

Post by Zini »

The slow cell change only happens because we still have a good amount of optimisation to do. Having more cells loaded will not make it better, it will make it worse (not to mention that it could also break content that relies on the 3x3 scheme).

We will get to threaded cell loading eventually, but that is a post-1.0 feature.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Cell transisition

Post by Zini »

btw. if anyone wants to have a go at profiling cell transitions, now wouldn't be the worst time to start on it. I noticed that going into cells that have been loaded previously isn't noticeable faster than going into cells that haven't been loaded previously. At least on my box that is the case (some more testing on different hardware might be useful). If this finding holds true, the source of the slow cell transition is not found in the loading code. The world model data does not get unloaded when you leave a cell. I think that OGRE will also keep the graphics resources around (would have to check that first though). So it seems we might need to look elsewhere. Obvious candidates would be the building of the OGRE scene graph, building of batches and building of the physics data. But only careful profiling can tell us with certainty with what we are dealing here.
beta
Posts: 13
Joined: 24 Feb 2012, 13:34

Re: Cell transisition

Post by beta »

Hi,

A quick gprof give this two trees:

with lots of cell transition:

http://i.imgur.com/QhEgljH.png

without cell transition:

http://i.imgur.com/8vLe5YK.png


At least they are not the same, so it must be interresting for you.
User avatar
Jyby
Posts: 408
Joined: 10 Dec 2013, 04:16

Re: Cell transisition

Post by Jyby »

Beta your so good with the metrics!!!

I need some tools like that for Mac OS X... Or I just need to setup a windows environment.

EDIT: Good we can get refactoring done before v1, that will save a lot of time when we're working with cool modding people and feel like saying F*** refactoring lol.
User avatar
psi29a
Posts: 5356
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Cell transisition

Post by psi29a »

Jyby wrote:I need some tools like that for Mac OS X... Or I just need to setup a windows environment
Uh...isn't "Instruments" made for OSX?
https://stackoverflow.com/questions/114 ... n-mac-os-x

In addition to that, gprof "runs" on OSX as well but I'm aware they have some issues. Not sure if it has been fixed.

No one should ever say: To solve problem X (1), setup a windows environment. ;)

1) for all problems that are not exclusively a windows problem.
User avatar
cc9cii
Posts: 523
Joined: 28 Mar 2013, 04:01

Re: Cell transisition

Post by cc9cii »

beta wrote:Hi,

A quick gprof give this two trees:

with lots of cell transition:

http://i.imgur.com/QhEgljH.png

without cell transition:

http://i.imgur.com/8vLe5YK.png


At least they are not the same, so it must be interresting for you.
So, I was curious (and I've been in a rut, unable to get past some issues in AiTravel and needed a distraction) so I followed the hot paths to retrieveTextureAlias doing some STL operation 431,000+ times and had a look at what msvc was doing. It appears that msvc is not as smart as we would like (or I have wrong compiler optimisation flags set). With a simple re-ordering I was able to halve the STL calls. (I'll attach the assembler codes before/after later) I don't know if that actually does anything significant to performance, but certainly doesn't do any harm (and shouldn't lessen code legibility).

EDIT: before
Spoiler: Show
After:
Spoiler: Show
Similarly with searchInstance, before:
Spoiler: Show
and after:
Spoiler: Show
Interestingly there was no difference with findInstance.
Last edited by cc9cii on 29 Apr 2014, 09:01, edited 1 time in total.
corristo
Posts: 495
Joined: 12 Aug 2011, 08:29

Re: Cell transisition

Post by corristo »

Jyby wrote: I need some tools like that for Mac OS X... Or I just need to setup a windows environment.
BrotherBrick wrote:Uh...isn't "Instruments" made for OSX?
Yeah, Instruments. Also you can use dtrace directly (already installed on your system too).
Post Reply