|
3 registered members (Quad, EvanTJ, AndrewAMD),
4,218
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Number of functions affect fps?
[Re: sivan]
#421371
04/16/13 09:51
04/16/13 09:51
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
very true words! I have not known this is because of wait(), but [...] it really does matter! This isn't really surprising. JCL was so kind to share some more insight about wait a few months ago: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=410383#Post410383They way wait() works is inherently counter productive for any modern processor, aside from the fact that it might have to copy a non trivial amount of data. The real pain is the jumping around, while in theory it's not that bad to use a jump (or function call), it is bad if the CPU can't predict it. CPUs like to use otherwise unused time trying to predict the future, which is a little bit of black magic vodoo, a lot of caching, and juggling with heuristics. I have briefly mentioned this in my last blogpost, and there is a famous StackOverflow question about this very thing. The problem is, executing your actual function might not even take long, in fact, it's probably incredibly fast. A vec_dist() here, some more math there, peanuts for a modern CPU. But the real killer is the jump that has to be done in and out of your function, the CPU is unable to predict the target and thus when the jump occurs, it has to empty more or less the complete cache. Cache misses are incredibly expensive, and working with a cold cache for most of the time is a horrible performance killer.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Number of functions affect fps?
[Re: DLively]
#421478
04/18/13 02:26
04/18/13 02:26
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You can use a shader for these kinds of things.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Number of functions affect fps?
[Re: Superku]
#421530
04/18/13 22:13
04/18/13 22:13
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
I am using wdl, so void doesnt work  But like I said, I don't need animated flowers  I'm accually working on a lookdown style game, and although it does look good with animated flowers, its not needed if it means I can add different kinds of effects instead.
|
|
|
Re: Number of functions affect fps?
[Re: DLively]
#421624
04/21/13 18:22
04/21/13 18:22
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
In lite-C it could look as follows, should be almost the same with C-Script:
var flower_num = 0; //reset this variable before level_load
action flower()
{
ent_flowers[flower_num] = me; // fill the array on level initialization
flower_num++;
... // some settings such as PASSABLE but no while
}
void flower_animate(ENTITY* ent)
{
ent.skill20 += 3*time_step;
ent.skill20 %= 100;
ent_animate(ent,"wobble",ent.skill20,ANM_CYCLE);
}
void flower_handle() //
{
while(1)
{
for(i = 0; i < flower_num; i++) flower_animate(ent_flowers[i]);
wait(1);
}
}
Alternatively you can write the content of flower_animate into the for loop in flower_handle.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|