Question about Draw Calls ?

Discussion and feedback on Construct 2

Post » Mon Jul 02, 2012 10:46 am

I have some questions about draw calls:

- 1. Do we need to concern about draw call at all when making game in Construct ?

- 2. Is there any sort of indicator for draw call (just like what we have for fps)
so we can see how many draw call every frame ?

- 3. Is one sprite object always considered as 1 draw call ?

- 4. How about 5 instances from "one sprite object", does that also considered as 5 draw calls ?
(or is there some sort of batching happens in the background for same object type)

- 5. How about 5 instances from "one sprite object" that use different frame of animation ?
sprite 0 is using frame[0], sprite 1 using frame[1], and so on..

- 6. How about sprite that doesn't associate with any image (act as a collision object),
that probably doesn't cost any draw call right ?


aside from curiosity, i'm asking about this because
i have so many sprites that always appear on screen as the game HUD (act as button).

let say it's about 50-70 different sprites, and right now all of them are different objects
(sprite_ButtonSkill_01, sprite_ButtonSkill_02, sprite_ButtonPotion, sprite_ButtonInventory, sprite_ButtonMainMenu, sprite_ButtonMap, sprite_ButtonFriends, etc...).

I was wondering if combining all of them into one sprite object called "SpriteButton" and
each instance display different frame will actualy gain some performance.


Thanks a lot in advance.Potato2012-07-02 10:47:57
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Mon Jul 02, 2012 12:35 pm

I am not sure why you're so worried about "draw calls" - there is no clear definition of a draw call in the runtime. For example in the WebGL renderer drawing a sprite does not actually make a draw call - it just writes some vertices to a vertex buffer. Does that count? Also, more or fewer draw calls will be made depending on if the object uses effects, has a different opacity, and so on. These details are generally not interesting, because they have an almost negligable effect on performance. If you're concerned about performance, everything important is mentioned in the Performance Tips article, and anything not mentioned is not worth mentioning because it's probably not important.

As far as C2 draw calls are concerned (when it asks a plugin to draw itself), it makes a single draw call for every single visible object on-screen, and that's it. Offscreen objects are not drawn, and objects set invisible are not drawn (although objects with opacity 0 are still drawn). It doesn't matter if objects use different or the same frames, are from different or the same object types, there is one draw call per visible instance.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Jul 02, 2012 7:28 pm

ah thanks for the explanation Ashley,
that's great to hear that i don't have to worry about such things.

last time when trying Unity, it's really critical that we keep draw call as minimum as possible (by making as many object share same material):
http://docs.unity3d.com/Documentation/Manual/iphone-DrawCall-Batching.html

even with ImpactJS, the similar concept is still applicable
(it displays draw call on its debug view so we can keep it under a certain amount):
http://impactjs.com/documentation/impact-on-mobile-platforms/


that's why i was wondering about it in Construct too
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Mon Jul 02, 2012 8:25 pm

The way 2D and 3D games are rendered is completely different, so advice for 3D games generally is not applicable to 2D games.

Construct 2 does not let you make draw calls directly, so it's our job to minimise the overhead from calls in our engine, which we've spent a lot of time doing already. I think we've done a good job - with the WebGL renderer, even complex scenes can be rendered in a single vertex buffer.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Wed Aug 05, 2015 3:40 pm

hi , i have poblems with the draw calls percent in debug , is about 97% , this happend only when i add the character to the layout , the character have 11 frame without loop and pinpong S:, but if i delete the character the layout is about 60 and not 5 like whne i put the character.

The character is in the media bundle of scirra.

i not undestand this.

thankz and sorry about my english
B
6
Posts: 27
Reputation: 290

Post » Sat Apr 16, 2016 7:22 pm

dokannon wrote:hi , i have poblems with the draw calls percent in debug , is about 97% , this happend only when i add the character to the layout , the character have 11 frame without loop and pinpong S:, but if i delete the character the layout is about 60 and not 5 like whne i put the character.


@dokannon - I have something similar to Your scenario, but additionally - it's not caused just by animation, but platform behavior instead.
I was trying to check runtime.js file in platform behavior folder and I didn't find anything strange (except some commented/legacy code about checking overlapping jumpthru? - @Ashley -platform/runtime.js, line 655, c2 R227). I guess these objects with enabled platform behaviors make draw call request every tick with somekind of sub-pixel pressision... Is it a bug or maybe I do something wrong? I could switch enable/disable platform behavior for player by checking pressing nad releasing keys/buttons, but maybe it's overthinking?
B
22
S
3
G
2
Posts: 30
Reputation: 3,688


Return to Construct 2 General

Who is online

Users browsing this forum: DankP3, NetOne and 1 guest