Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling lost gpu context on stage3d #289

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Antriel
Copy link
Contributor

@Antriel Antriel commented Aug 27, 2014

Primitive way to handle lost context. Keeps texture data in memory when created via createTextureFromImage. Custom made textures need to listen on hasGPU and recreate manually.
usage - add compiler flag:
-D stage3d_handle_context_loss

Notes:

  • Increases memory usage. If that is a problem it should be possible to reload the data from source, I didn't need it though and it would be more complicated. @purplepwny has implemented embedded assets with flash preloader, which I improved for my needs. There it would make more sense to load from source (since it's embedded).
  • For some reason my builds sometimes fail with flambe.platform.BasicTexture.R has no field readPixels/writePixels/createTexture. If I remove @:generic from BasicTexture it works. It also works if I return back again after it compiled first time. Not sure what is going on.
  • Fixes Error #3694 After locking the computer #217

purplepwny and others added 4 commits August 27, 2014 16:40
… initialization that may be asynchronous.

FlashPlatform's initialization is actually asynchronous, in that we must wait for Stage3DRenderer to acquire a Context3D before we're ready to roll. Since the Flash platform requires a Context3D before textures can be loaded, quickly loading textures after calling System.init was causing undesirable behavior, due a Context3D not yet being available. With this change, we can wait for a platform to become ready before continuing with other work.
…pdata and reuploading when context is regenerated
@markknol
Copy link
Contributor

Very nice! Could it be optional to store all bitmaps in memory? Maybe I'm okay just by restart+reloading the app.

@Antriel
Copy link
Contributor Author

Antriel commented Aug 27, 2014

Well now it shouldn't crash even if you don't enable handling of context loss. So you should be able to just listen to when GPU context is recreated and restart the game.

@markknol
Copy link
Contributor

Ah that is awesome! Will try soon! 👍

@elibroide
Copy link

Hey guys, did it work for anyone?
I'm having some trouble with context lost after showing the users a video commercial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error #3694 After locking the computer
4 participants