UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.46 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import{NestedMap as t}from"../../../../../core/NestedMap.js";import{ShaderTechniqueConfiguration as i}from"./ShaderTechniqueConfiguration.js";class o{constructor(e){this.context=e,this._debug=!1,this._precompiling=this._debug?0:1,this._cache=new t}get precompiling(){return this._precompiling}set precompiling(e){this._precompiling=e,0===e&&this.context.rctx.gl.flush()}get viewingMode(){return this.context.viewingMode}destroy(){this._cache.forAll((e=>e.destroy())),this._cache.clear()}precompile(e,t=r){++this.precompiling,this.get(e,t),--this.precompiling}get(t,i=r){const o=i.key.code;let c=this._cache.get(t,o);if(null==c){if(0===this._precompiling){let o=`Uncached shader compile in ${(new Error).stack}\n for configuration\n${i.decode()}`;const c=this._cache.getInner(t);throw c?.size&&(o+="\n\n cached configurations:\n",o+=Array.from(c.values()).map((e=>i.decode(e.key))).sort().join("\n\n")),console.log(o),new e(o)}c=new t(this.context,i),this._cache.set(t,o,c)}return c}async reloadAll(){const e=new Array;this._cache.forEach((t=>e.push(c(t)))),await Promise.all(e)}}async function c(e){let t=!0;e.forEach((async e=>{await e.reload(t),t=!1}))}const r=new i;export{r as NoConfiguration,o as ShaderTechniqueRepository};