Page 1 of 1

Various performance questions

Posted: Wed Apr 26, 2017 4:36 am
by Tormentor667
Concerning GZDoom I have various performance questions, I hope some of the developers team can give me an answer :)

PK3 - Uncompressed or compressed?
Does it make a performance difference ingame (after the game has startet) if a PK3 is heavily compressed or uncompressed? From my understanding, the data gets decompressed before the game starts and loaded into the memory, so it shouldn't make any difference, right?

Shaders or ROLLSPRITE for rotating sprites?
What is more performance intensive when it comes to rotating sprites? If I do this through shaders or if I do this through a ROLLSPRITE flag and rotating the sprite in the actor states?

Ambient Sounds
Imagine I have a map with about 100 ambient sounds placed, but the player is only at a position where he can hear about 10 of them at the same time, are the others still "calculated" and impact performance or are they ignored?

Thanks already for answering these, we are currently improving the performance in BoA so these might be good to know.

Re: Various performance questions

Posted: Wed Apr 26, 2017 5:45 am
by Nevander
I don't know much from the technical side but I can say that I would prefer to use an uncompressed file so that everything is already decompressed. I'd imagine it would save the engine some work but I don't know how much. And for ambient sounds, what I would do is build my map in such a way that the sounds that you will hear will get activated when the player gets close enough to hear them, I think you can do that with Thing_(De)Activate but I could be mistaken. Changing this for existing maps might be a PITA though, but I'm speaking as a novice on these subjects and not as an engine developer, we need Graf or somebody to truly confirm.

Re: Various performance questions

Posted: Wed Apr 26, 2017 7:27 am
by D2JK
...what I would do is build my map in such a way that the sounds that you will hear will get activated when the player gets close enough to hear them...
This sort of optimizing isn't always beneficial; you have to consider the total performance cost of constantly checking distances from each sound source to each player vs the cost of simply letting all the sounds stay active regardless.

Re: Various performance questions

Posted: Wed Apr 26, 2017 11:08 am
by Tormentor667
The question simply is: How much performance does this draw if there are 100 ambient sounds scattered around and you only are in the range of 10 of them?

Re: Various performance questions

Posted: Wed Apr 26, 2017 6:38 pm
by Nevander
How did Duke Nukem 3D do it's ambient sounds? There are some maps where there are quite a few (can't name one off the top of my head) going off around the map. I never remember any performance hits because of it.

Re: Various performance questions

Posted: Fri Apr 28, 2017 8:08 am
by Marinelol
http://infosuite.duke4.net/index.php?page=ae_sfx_a2 Seems to be sector based. Explains the strange sudden stop of ambient sounds in some places in Blood.

Re: Various performance questions

Posted: Fri Apr 28, 2017 9:01 am
by kodi
Shaders or ROLLSPRITE for rotating sprites?
I think shaders are less performance intensive because they don't have to change or store any values ever tic, but the difference should be very small.

Re: Various performance questions

Posted: Sat Apr 29, 2017 7:45 am
by Ozymandias81
Would be better if a dev could give us a reply in this particular case

Re: Various performance questions

Posted: Sat Apr 29, 2017 10:15 am
by Kinsie
How long is a piece of string?

Re: Various performance questions

Posted: Sat Apr 29, 2017 12:02 pm
by Enjay
Twice the distance from its middle to its end.

Re: Various performance questions

Posted: Sat Apr 29, 2017 9:14 pm
by Rachael
Ozymandias81 wrote:Would be better if a dev could give us a reply in this particular case
Here you go.

Re: Various performance questions

Posted: Sat Apr 29, 2017 9:28 pm
by Rachael
Tormentor667 wrote:Concerning GZDoom I have various performance questions, I hope some of the developers team can give me an answer :)

PK3 - Uncompressed or compressed?
Does it make a performance difference ingame (after the game has startet) if a PK3 is heavily compressed or uncompressed? From my understanding, the data gets decompressed before the game starts and loaded into the memory, so it shouldn't make any difference, right?

Shaders or ROLLSPRITE for rotating sprites?
What is more performance intensive when it comes to rotating sprites? If I do this through shaders or if I do this through a ROLLSPRITE flag and rotating the sprite in the actor states?

Ambient Sounds
Imagine I have a map with about 100 ambient sounds placed, but the player is only at a position where he can hear about 10 of them at the same time, are the others still "calculated" and impact performance or are they ignored?

Thanks already for answering these, we are currently improving the performance in BoA so these might be good to know.
- PK3 - Do not know, sorry. You have to ask Graf. I think ultimately they come out the same in memory no matter what, so in terms of performance leaving it uncompressed would be better since that's less CPU overhead when hot-loading resources during intensive play. But if a user has a very slow hard drive, compressed will obviously be much more efficient since a CPU can crack a compressed file quicker than a hard drive can load one uncompressed.
- GPU dependent, but if you're really concerned about performance on older systems then rollsprite is faster.
D2JK wrote:
...what I would do is build my map in such a way that the sounds that you will hear will get activated when the player gets close enough to hear them...
This sort of optimizing isn't always beneficial; you have to consider the total performance cost of constantly checking distances from each sound source to each player vs the cost of simply letting all the sounds stay active regardless.
If that was the case then dynamic lights in QZDoom (or now GZDoom's software renderer) would not be possible. Imagine checking distances for 2 million individual pixels per frame per light. I think 100 ambient sounds aren't going to be a huge issue.

- Leaving ambient sounds alone should be fine. Performance issues with them are likely going to come more from actor overhead, itself, than actual sound calculations. That's inavoidable - but you can mark a sound object +NOINTERACTION and "RenderStyle None" to reduce some of that.

Re: Various performance questions

Posted: Sun Apr 30, 2017 5:22 am
by Graf Zahl
- compression: The only thing where it really matters is streaming music. The game can stream directly from an uncompressed archive so the load time is shorter, but in return the callback takes longer (but this is on a second thread so on modern hardware irrelevant.)
- shaders: The sprite rotation is a single matrix multiplication. Setting up a shader for this takes disproportionately longer than having a handful of multiplications.
- sound: Mostly irrelevant. Sound mixing is done on a separate thread, you only need to be careful that you do not run out of sound channels. I would recommend against too much checking here, maps that try to do too much preemptive actions tend to sound bad. The AmbientSound actor is doing this automatically for you if you set the parameters accordingly, so there's absolutely no point adding a second check on the user side.
- no flag hacks for AmbientSound things, please. They are already set to the invisible sprite and use the NOSECTOR flag and since they do not move they barely need processing time. NOINTERACTION won't do much for them.

Re: Various performance questions

Posted: Sun Apr 30, 2017 10:46 am
by Nash
Regarding +ROLLSPRITE vs shaders, one important difference is the former is in playsim context. Which means each individual rolled actor can have different rotations, and you can script things that will affect the rotation directly.

A shader is uniformly applied globally across every copy of the actor; same speed, same angle, etc. There is no way to influence the rotation via scripting.

Something to be aware of when deciding your visual goals.

Re: Various performance questions

Posted: Sun Apr 30, 2017 12:24 pm
by Ozymandias81
Thank you kindly friends, we'll take in consideration all of your advices then. :wub: