Large number of draw rects for off screen tiles

Bugs will be moved here once resolved.

Post » Wed Jan 29, 2014 1:01 am

Link to .capx file (required! If link is blocked remove the http and www parts):
https://skydrive.live.com/redir?resid=ABE7C5AEBE3DDDDD!4796&authkey=!AD0x7LipQUhBLcU&ithint=file%2c.capx

Steps to reproduce:
1. Open Capx
2. Run in debug mode
3. Look at draw rect count for tile maps

Observed result:
One of the tile maps has nearly 80,000 draw rect even though most tiles are off screen and the CPU usage is very high even though there is very little going on. (Try clicking around to move the sprite)

Expected result:
Much lower CPU usage.

Browsers affected:
Chrome: yes
Firefox: don't know
Internet Explorer: yes (much worse)

Operating system & service pack:
Windows 7 SP1

Construct 2 version:
158.2
    ggibson12014-01-29 01:03:22
B
21
S
5
Posts: 196
Reputation: 1,974

Post » Wed Jan 29, 2014 5:19 pm

It is working correctly. It does not draw all of the draw rects every tick. The high count is because your use of tilemaps is extraordinarily inefficient. If you want to display images, fragmenting them in to tiny tiles means it requires an extreme number of draw calls to render. You should not use tilemaps like this.Ashley2014-01-29 17:20:30
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842

Post » Thu Jan 30, 2014 12:16 am

The image was just a random picture I threw into the capx instead of putting in my real tile map images.

Is there a size of tile map that is known to be too big? As in too many tiles?

Is 12800 x 10240 just way too big?

In my real tile map the image is 640 x 1280.ggibson12014-01-30 00:20:43
B
21
S
5
Posts: 196
Reputation: 1,974

Post » Thu Jan 30, 2014 2:42 pm

@ggibson1, there are no correct answer for your question. Because this depends on the machines you run on.

No matter what size of your tiles or sprites are, you must test on the devices you will exported to, to ensure that such devices can run your app satisfactorily according to your standard.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Thu Jan 30, 2014 5:36 pm

It is entirely inappropriate to use the tilemap object to display large images. See this blog post for details:
https://www.scirra.com/blog/ashley/3/tech-blog-tilemap-tidbits

When you do this, it has to issue a separate draw call for every tile, because every tile is different. This adds a massive CPU overhead compared to just being able to draw the image once with say a tiled background or sprite.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842

Post » Thu Jan 30, 2014 11:23 pm

Ok I do not think I am making myself clear. I am not displaying a single large image in a tile map. The image I used in the sample capx I linked in this post was just some random image I grabbed to use as an example... take this image for example as a tile map that when I use it to create paths across a 12800 x 10440 layout I get very bad performance.

https://skydrive.live.com/redir?resid=ABE7C5AEBE3DDDDD!4799&authkey=!AI1KS3i9sMLgkoc&v=3&ithint=photo%2c.png

Since my total video memory usage as reported by C2 is around 20 meg and the view port is 800x480 I would expect that this would work well on a modern smart phone or tablet.

I would think that there is at least a known ballpark number that would let know if the size I am using is far over the line or not.ggibson12014-01-30 23:24:36
B
21
S
5
Posts: 196
Reputation: 1,974

Post » Fri Jan 31, 2014 12:53 pm

You'll still notice that in your tilemap, assuming a relatively small tile size, every tile is different. Therefore it is not possible for the engine to optimise it and it dutifully renders each tile one at a time. You should consider using tiled backgrounds instead perhaps, or using a tilemap which can re-use the same tiles more.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 13 guests