WebGL map: take a lost context back, and let it go for Always 2D
The first loss of the WebGL context gave the card up for the session. A context can come back (a driver reset; on a phone, sometimes just leaving the app), so a phone that went to another app came back to the slower 2D map until the page was reloaded. Always 2D, chosen in Settings, kept the context and its 64 MB atlas for a map drawn in 2D. A loss now leaves the 2D map drawing while the context is away (glLost(): the event is cancelled so the browser may give it back), and everything on the card is built again on the same context when it comes back (glRestored(), glForget(): glInit() runs as for the first frame). A card lost more than GL_LOSSES (2) times is given up for the session, so a card that keeps failing does not keep the map switching. Always 2D lets the context go through WEBGL_lose_context and Auto asks for it back, the same path, never counted as a loss; a context the browser gives back after the player chose Always 2D is let go again. Without the extension, and for the GPU benchmark's switches (mapGl(on,false)), the context is kept as before. The listeners and the overlay's wrappers are set once. Diagnostic info says when the map waits for a lost context. Tests: webgl-context-restore (7), and the loss test of webgl-out-of-memory now waits for the context instead of giving it up.
This commit is contained in:
parent
57546ea18e
commit
351b3aa522
5 changed files with 177 additions and 12 deletions
|
|
@ -47,7 +47,9 @@ test('it says what draws the map, and why it is the 2D canvas', () => {
|
|||
assert.equal(map(), 'map: 2D (Always 2D)');
|
||||
ev('mapGl(true,false);glKill(new Error("the graphics card is out of memory (the pictures)"))');
|
||||
assert.equal(map(), 'map: 2D (the graphics card is out of memory (the pictures))');
|
||||
ev('GLX.dead=false;GLX.gl={};GLX.shown=true;GLX.gpu="ANGLE (NVIDIA GeForce GTX 980)"');
|
||||
ev('GLX.dead=false;GLX.lost=true');
|
||||
assert.equal(map(), 'map: 2D (graphics context lost, waiting for it back)');
|
||||
ev('GLX.lost=false;GLX.gl={};GLX.shown=true;GLX.gpu="ANGLE (NVIDIA GeForce GTX 980)"');
|
||||
assert.equal(map(), 'map: WebGL2 · ANGLE (NVIDIA GeForce GTX 980)');
|
||||
ev('const s=S;S=null;window.__S=s');
|
||||
assert.equal(map(), 'map: none (title screen)');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue