Asynchronous asset loading

About Monkey 2 Forums Monkey 2 Programming Help Asynchronous asset loading

This topic contains 9 replies, has 4 voices, and was last updated by  cocon 1 week, 1 day ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #13623

    Ethernaut
    Participant

    Hi,

    In Monkey-X we had the “OnLoading” App method, which you could use to detect whether images had finished loading or not, while the app was already rendering.

    Is there anything similar on Monkey2? I don’t really grasp Fibers and Futures yet… I guess now is a good chance to learn it? (°.°)

    Cheers.

    #13625

    Mark Sibly
    Keymaster

    Async image/sound loading is not currently supported, and fibers wont really help here as they are cooperative.

    #13626

    Ethernaut
    Participant

    Ok. I’ll try something like:

    1. Start game, but don’t load anything yet
    2. On first frame, render a loading screen
    3. On second frame, load all assets while the loading screen stays there
    4. After it’s all loaded, the next frame will be rendered normally and the game will start

    Cheers!

    #13627

    Mark Sibly
    Keymaster

    That’s probably the way to go for now.

    It should be possible to at least RequestRender/Yield between loads, I’ll have a look into that.

    #13628

    Mark Sibly
    Keymaster

    Here’s one possible approach – build it in the simplelight banana dir or use your own image.

    Note that it only syncs with OnRender every .1 seconds (shouold probably be slower?) – if you sync *every* load you substantially slow down loading time of course as waiting for OnRender can take up to 16ms.

    Writing truly async loaders should be substantially simpler now as most of the async framework stuff is already in there. The only tricky bits will be the loaders written in pure monkey2 as they will need to be rewritten in c++ to be threadable. The only one I can think of here is the WAV loader.

    #13632

    scurty
    Participant

    I would argue that we would need a feature that’s more like Threads in the near future. Game development of a higher scale would benefit from this. Although it’s not needed for most simple games, but I’m sure a new learning curve would emerge implementing it like data-races and such. And thoughts?

    #13633

    Ethernaut
    Participant

    Aw, I didn’t see the post with the code and ended up making the asset loading screen in my own caveman style. Will take a look at this approach tonight and see if I can borrow some ideas.

    At a glance, I’m still confused by “who-calls-what-in-which-order”, but I guess it’ll click at some point.

    Thanks!

    #13638

    Mark Sibly
    Keymaster

    I would argue that we would need a feature that’s more like Threads in the near future

    I agree with this, I think proper threading is the real fix for this instead of hacking in a bunch of async load functions.

    Aw, I didn’t see the post with the code and ended up making the asset loading screen in my own caveman style.

    Actually, after sleeping on it for a bit I think caveman style is probably the right approach for now!

    #13652

    Ethernaut
    Participant

    Ok, caveman grade asset management & loading screen is up!
    https://github.com/DoctorWhoof/Plane-Demo

    Now on to some more texturing.
    Cheers.

    #13655

    cocon
    Participant

    Is it possible to have multiple futures stacked? Such as a thread pool?

     

    @ethernaut, Now I downloaded the demo! AMAZING!

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.