From ea2bea166bae858616105101ba4534cb64d356db Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 4 Feb 2022 14:19:09 -0500 Subject: [PATCH] perf: Reduce texture memory checks. --- src/webgl/quadFeature.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/webgl/quadFeature.js b/src/webgl/quadFeature.js index ee157ad147..63ef66231f 100644 --- a/src/webgl/quadFeature.js +++ b/src/webgl/quadFeature.js @@ -3,6 +3,8 @@ var registerFeature = require('../registry').registerFeature; var quadFeature = require('../quadFeature'); var timestamp = require('../timestamp'); +let _memoryCheckLargestTested = 4096 * 4096; + /** * Create a new instance of class quadFeature. * @@ -373,8 +375,11 @@ var webgl_quadFeature = function (arg) { quad.texture.bind(renderState); // only check if the context is out of memory when using modestly large // textures. The check is slow. - if ((quad.image.width > 4096 || quad.image.height > 4096 || quad.image.width * quad.image.height > 4194304) && context.getError() === context.OUT_OF_MEMORY) { - console.log('Insufficient GPU memory for texture'); + if (quad.image.width * quad.image.height > _memoryCheckLargestTested) { + _memoryCheckLargestTested = quad.image.width * quad.image.height; + if (context.getError() === context.OUT_OF_MEMORY) { + console.log('Insufficient GPU memory for texture'); + } } if (quad.opacity !== opacity) { opacity = quad.opacity;