[suggestion] load the necessary images of layout

Discussion and feedback on Construct 2

Post » Fri Jan 10, 2014 4:48 am

+1 on Arima
B
35
S
11
G
3
Posts: 97
Reputation: 3,478

Post » Fri Jan 10, 2014 11:03 am

+1 Arima. This should be here from the beggining.
B
28
S
8
G
7
Posts: 643
Reputation: 6,457

Post » Fri Jan 10, 2014 11:36 am

@Arima - your example could double the peak texture memory usage. Take your example but going from level 1 to level 2 instead, which use different image sets (e.g. level 1 is "desert" world, level 2 is "ice" world).

Currently the C2 engine efficiently manages the peak memory usage like this. When switching layout:

- the engine stops running
- any images used on level 1 but not used on level 2 are released
- then any images used on level 2 but not used on level 1 are loaded
- then level 2 begins running

Therefore the peak memory usage is never higher than what level 1 or level 2 would use by themselves. This pretty much can only happen because the engine stops running while this happens, so it doesn't suddenly need an image after releasing it.

If you can load the next layout's images before the current layout finishes, you end up with a pattern like this:

- level 1's images are in memory
- you request to load level 2's images while level 1 keeps running
- briefly, both level 1 and level 2's images are in memory - this could be up to double the memory usage
- when switching to level 2, level 1's images are released and memory usage goes back down

For any games close to the memory limit of the system, this would probably crash the game when it changes layout.

For previewing, it's a different matter really. Maybe we could do something to speed it up, but it's a little complicated: you can't create objects from other layouts or go to a different layout until the rest of the game finishes loading. That could result in some weird preview issues. An advantage of loading the entire game in preview mode is you can jump to any layout at any time.
Scirra Founder
B
398
S
236
G
88
Posts: 24,441
Reputation: 194,661

Post » Fri Jan 10, 2014 7:04 pm

@Ashley - I'm aware of that situation. If a person was making a game where the intro/title screen was 50 mb and level 1 was 100 mb, there would be no problem having them both on a 512 mb card. Knowing what we could do would be made easier with 'remaining VRAM' or 'total system VRAM' expressions, if they're possible.

Another example is if someone was making a very resource intensive game, they could do this instead:

Game starts, intro_and_main_menu layout runs.

At start of layout, load images from disk to ram: "loading" and "Level 1"
C2 now has the "intro_and_main_menu" "loading" and "Level 1" layouts in RAM and "intro_and_main_menu" in VRAM.

Upon clicking new game, go to layout "Loading"
C2 then dumps all the textures from the "intro_and_main_menu" layout from VRAM, loads the very small amount of textures on the "loading" layout and runs it.

On start of layout: load images to VRAM: "Level 1"
C2 now has both layouts "loading" and "Level 1" in VRAM. This happens smoothly as the loading layout can keep running, being animated and there's no concern of the music stopping from it taking so long to move the textures to the gpu. The loading layout is small enough that it's not a concern having them both in VRAM at the same time.

On textures loaded to VRAM: "Level 1", go to layout "Level 1"
C2 dumps "loading" layout's textures. Level 1's textures are already in VRAM, it starts instantly.

This way we get flexibility and control over how we want it to run.

As for the pausing problem when creating objects from other layouts that haven't been loaded yet, we could just do the same for objects with 'load object files into ram' and 'load object files into VRAM' actions with triggers for when they're finished.

Having 'unload layout textures from VRAM', 'unload object textures from VRAM' and 'unload all unused textures from VRAM' actions would be useful as well.

I can understand why you might be reluctant to incorporate this at the risk of confusing less experienced users, but that's why it could be an advanced option so the more experienced users can use it instead. Professional games use loading screens in this manner quite often, it would be very useful for us to be able to do the same if we want to. While C2's memory management as it is is fine for many games, it isn't optimal for all types of games, and this way we could choose how we want it to run.Arima2014-01-10 19:12:55
Moderator
B
95
S
34
G
33
Posts: 3,006
Reputation: 27,874

Post » Fri Jan 24, 2014 3:32 am

@Arima-I am an avid supporter of this suggestion! The offline.appache feature makes my life a living hell whenever I am trying to edit and update my game. I fully support it being an option. Emac2014-01-24 13:12:28
B
15
S
2
Posts: 27
Reputation: 1,229

Post » Mon Feb 17, 2014 9:30 pm

we need MANUAL control of what assets to load and which ones to flush out, apart from the current autoloading mode. This is essential for exe & mobile exporting. More people are nowadays using C2 for making exe games than html online games
bjadams2014-02-17 21:38:34
B
43
S
11
G
4
Posts: 428
Reputation: 7,454

Post » Sat Apr 26, 2014 11:50 pm

+1 arima
B
18
S
3
G
1
Posts: 28
Reputation: 1,788

Post » Sun Apr 27, 2014 11:33 am

I'm not a programmer but I'd imagine that Ashley would have to write a completely new loader, that would request assets sequentially and not too fast - one by one, or part by part, but with some breaks, and somehow be integrated in to the event sheet loop ( and I don't mean events, but just making sure the game will run while and loadding assets wont take much away from games fps). It would be definitely very good to have.

Arima wrote:I can understand why you might be reluctant to incorporate this at the risk of confusing less experienced users, but that's why it could be an advanced option so the more experienced users can use it instead. Professional games use loading screens in this manner quite often, it would be very useful for us to be able to do the same if we want to. While C2's memory management as it is is fine for many games, it isn't optimal for all types of games, and this way we could choose how we want it to


The confusion could be solved by having a button that would toggle on/off advanced actions from the view. But I guess no point having that just for one action.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: AndreasR, lkatkins and 11 guests