|
1 |
| -/* webgl-memory@1.0.16, license MIT */ |
| 1 | +/* webgl-memory@1.1.1, license MIT */ |
2 | 2 | (function (factory) {
|
3 | 3 | typeof define === 'function' && define.amd ? define(factory) :
|
4 | 4 | factory();
|
|
396 | 396 | return typeof v === 'number';
|
397 | 397 | }
|
398 | 398 |
|
| 399 | + function collectObjects(state, type) { |
| 400 | + const list = [...state.webglObjectToMemory.keys()] |
| 401 | + .filter(obj => obj instanceof type) |
| 402 | + .map((obj) => state.webglObjectToMemory.get(obj)); |
| 403 | + |
| 404 | + return list; |
| 405 | + } |
| 406 | + |
| 407 | + function getStackTrace() { |
| 408 | + const stack = (new Error()).stack; |
| 409 | + const lines = stack.split('\n'); |
| 410 | + // Remove the first two entries, the error message and this function itself, or the webgl-memory itself. |
| 411 | + const userLines = lines.slice(2).filter((l) => !l.includes('webgl-memory.js')); |
| 412 | + return userLines.join('\n'); |
| 413 | + } |
| 414 | + |
399 | 415 | /*
|
400 | 416 | The MIT License (MIT)
|
401 | 417 |
|
|
419 | 435 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
420 | 436 | */
|
421 | 437 |
|
422 |
| - |
423 | 438 | //------------ [ from https://github.com/KhronosGroup/WebGLDeveloperTools ]
|
424 | 439 |
|
425 | 440 | /*
|
|
487 | 502 | },
|
488 | 503 | };
|
489 | 504 | },
|
| 505 | + getResourcesInfo(type) { |
| 506 | + return collectObjects(sharedState, type); |
| 507 | + }, |
490 | 508 | },
|
491 | 509 | },
|
492 | 510 | },
|
|
592 | 610 | ++resources[typeName];
|
593 | 611 | webglObjectToMemory.set(webglObj, {
|
594 | 612 | size: 0,
|
| 613 | + stackCreated: getStackTrace(), |
595 | 614 | });
|
596 | 615 | };
|
597 | 616 | }
|
|
634 | 653 |
|
635 | 654 | memory.renderbuffer -= info.size;
|
636 | 655 | info.size = newSize;
|
| 656 | + info.stackUpdated = getStackTrace(); |
637 | 657 | memory.renderbuffer += newSize;
|
638 | 658 | }
|
639 | 659 |
|
|
703 | 723 |
|
704 | 724 | memory.texture -= oldSize;
|
705 | 725 | memory.texture += info.size;
|
| 726 | + |
| 727 | + info.stackUpdated = getStackTrace(); |
706 | 728 | }
|
707 | 729 |
|
708 | 730 | function updateTexStorage(target, levels, internalFormat, width, height, depth) {
|
|
789 | 811 |
|
790 | 812 | memory.buffer -= info.size;
|
791 | 813 | info.size = newSize;
|
| 814 | + info.stackUpdated = getStackTrace(); |
792 | 815 | memory.buffer += newSize;
|
793 | 816 | },
|
794 | 817 |
|
|
1121 | 1144 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1122 | 1145 | */
|
1123 | 1146 |
|
1124 |
| - |
1125 | 1147 | function wrapGetContext(Ctor) {
|
1126 | 1148 | const oldFn = Ctor.prototype.getContext;
|
1127 | 1149 | Ctor.prototype.getContext = function(type, ...args) {
|
|
0 commit comments