|
2 registered members (JeyKey II, EvanTJ),
8,242
guests, and 1
spider. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Number of functions affect fps?
[Re: Superku]
#421650
04/22/13 01:06
04/22/13 01:06
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Thank you 3run for the initial information, first of all. and Thank you very much Superku, for writing it out in a fashion that I can sorta understand..  I am going to try it our right away.
|
|
|
Re: Number of functions affect fps?
[Re: DLively]
#421652
04/22/13 01:36
04/22/13 01:36
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Disclaimer: My answer is for Lite-C! The thing is, calling functions is expensive, you can tweak Superkus version a tiny bit by either inlining flower_animate() or by making flower_animate loop over the ENTITYs. And because we all love premature optimization, we can also do another thing: Since [] is just a substitution for the plus operator, we can take advantage of that by simply taking the pointer to the first flower entity and just incrementing it, thus maximizing cache hits on some older CPUs:
ENTITY *flowers[1024];
int numFlowers = 0;
action flower()
{
flowers[numFlowers ++] = me;
}
void flower_animate()
{
ENTITY *ent = *flowers;
ENTITY *lastFlower = ent + numFlowers;
while(ent < lastFlower)
{
ent->skill20 = (ent->skill20 + 3 * time_step) % 100;
ent_animate(ent, "wobble", ent->skill20, ANM_CYCLE);
ent ++;
}
}
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Number of functions affect fps?
[Re: sivan]
#421657
04/22/13 07:36
04/22/13 07:36
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
someone could explain me why, because I don't know It's because the Engine doesn't have to send new data to the GPU for every model rendered but can re-use the old data from the previous draw call.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|