WebGL map: give the card up for 2D when it runs out of memory without saying so
A card short of memory may refuse a texture or a buffer without throwing: the call only leaves OUT_OF_MEMORY for getError(), which nothing read. Refused, the 64 MB atlas drew every city, label and marker as a black box while the map stayed on the card (seen in Chromium by refusing it). The big uploads now read it (glMem()): the atlas, the land for each zoom level, the tubes once a day, the cables. The atlas tries 2048 px (16 MB) before giving up; any other refusal is the card's error, so draw() gives WebGL up for the session and draws the same frame again in 2D. getError() is never read on an ordinary frame: each read waits for the card. tests/webgl-out-of-memory.test.js: a 4096 px atlas refused gives a 2048 px one; both refused, or the land or the tubes refused, leave the map in 2D in that frame with no glitch for the player; panning reads no error.
This commit is contained in:
parent
fb76a1e6fd
commit
52c8aaffd6
5 changed files with 99 additions and 8 deletions
|
|
@ -71,7 +71,7 @@ function glBuild(LG,GM,looks){const gl=GLX.gl,N=LG.length;let ns=0,np=0,nk=0;
|
|||
for(let i=0;i<L.pk;i++){const o=ki*8;PK[o]=p0;PK[o+1]=pts.length;PK[o+2]=len;PK[o+3]=L.pk;PK[o+4]=i;PK[o+5]=L.w0;PK[o+6]=dep;ki++;}}
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,GLX.lv.b);gl.bufferData(gl.ARRAY_BUFFER,SEG,gl.DYNAMIC_DRAW);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,GLX.pv.b);gl.bufferData(gl.ARRAY_BUFFER,PK,gl.DYNAMIC_DRAW);
|
||||
gl.bindTexture(gl.TEXTURE_2D,GLX.tex);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA32F,GL_PTS_W,TH,0,gl.RGBA,gl.FLOAT,PT);
|
||||
gl.bindTexture(gl.TEXTURE_2D,GLX.tex);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA32F,GL_PTS_W,TH,0,gl.RGBA,gl.FLOAT,PT);glMem(gl,'the tubes');
|
||||
Object.assign(GLX,{nSeg:ns,nPk:nk});return {SEG,PK,PT};}
|
||||
// The selected tube's halo: its segments again, at its own depth (so later tubes still cover it), and nothing else.
|
||||
function glHalo(LG,GM,looks,selId){const gl=GLX.gl,N=LG.length,A=[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue