|
1 |
| -/* webgl-memory@1.0.14, license MIT */ |
| 1 | +/* webgl-memory@1.0.15, license MIT */ |
2 | 2 | (function (factory) {
|
3 | 3 | typeof define === 'function' && define.amd ? define(factory) :
|
4 | 4 | factory();
|
|
361 | 361 |
|
362 | 362 | function getDrawingbufferInfo(gl) {
|
363 | 363 | return {
|
364 |
| - samples: gl.getParameter(gl.SAMPLES), |
| 364 | + samples: gl.getParameter(gl.SAMPLES) || 1, |
365 | 365 | depthBits: gl.getParameter(gl.DEPTH_BITS),
|
| 366 | + stencilBits: gl.getParameter(gl.STENCIL_BITS), |
366 | 367 | contextAttributes: gl.getContextAttributes(),
|
367 | 368 | };
|
368 | 369 | }
|
| 370 | + |
| 371 | + function computeDepthStencilSize(drawingBufferInfo) { |
| 372 | + const {depthBits, stencilBits} = drawingBufferInfo; |
| 373 | + const depthSize = (depthBits + stencilBits + 7) / 8 | 0; |
| 374 | + return depthSize === 3 ? 4 : depthSize; |
| 375 | + } |
| 376 | + |
369 | 377 | function computeDrawingbufferSize(gl, drawingBufferInfo) {
|
370 |
| - // this will need to change for hi-color support |
371 | 378 | if (gl.isContextLost()) {
|
372 | 379 | return 0;
|
373 | 380 | }
|
374 |
| - const {samples, depthBits, contextAttributes} = drawingBufferInfo; |
375 |
| - const size = gl.drawingBufferWidth * gl.drawingBufferHeight * 4 || 0; |
376 |
| - const depth = contextAttributes.depth ? 1 : 0; |
377 |
| - const stencil = contextAttributes.stencil ? 1 : 0; |
378 |
| - const depthSize = Math.min(stencil + depthBits > 16 ? 4 : 2, 4); |
379 |
| - return size + size * samples + size * depth * depthSize; |
| 381 | + const {samples} = drawingBufferInfo; |
| 382 | + // this will need to change for hi-color support |
| 383 | + const colorSize = 4; |
| 384 | + const size = gl.drawingBufferWidth * gl.drawingBufferHeight; |
| 385 | + const depthStencilSize = computeDepthStencilSize(drawingBufferInfo); |
| 386 | + return size * colorSize + size * samples * colorSize + size * depthStencilSize; |
380 | 387 | }
|
381 | 388 |
|
382 | 389 | // I know this is not a full check
|
|
0 commit comments