UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.4 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import{NestedMap as t}from"../../../../../core/NestedMap.js";import{ShaderTechniqueConfiguration as c}from"./ShaderTechniqueConfiguration.js";class o{constructor(e){this._context=e,this._debug=!1,this._precompiling=this._debug?0:1,this._cache=new t}get context(){return this._context}get precompiling(){return this._precompiling}set precompiling(e){this._precompiling=e,0===e&&this.context.rctx.gl.flush()}destroy(){this._cache.forAll(e=>e.destroy()),this._cache.clear(),this._context=null}precompile(e,t=r){++this.precompiling,this.get(e,t),--this.precompiling}get(t,c=r,o){const i=c.key.code;let n=this._cache.get(t,i);if(null==n){if(0===this._precompiling){let o=`Uncached shader compile in ${(new Error).stack}\n for configuration\n${c.decode()}`;const i=this._cache.getInner(t);throw i?.size&&(o+="\n\n cached configurations:\n",o+=Array.from(i.values()).map(e=>c.decode(e.key)).sort().join("\n\n")),console.log(o),new e("shader:uncached-compile",o)}n=new t(this.context,c,o),this._cache.set(t,i,n)}return n}async reloadAll(){const e=new Array;this._cache.forEach(t=>e.push(i(t))),await Promise.all(e)}}async function i(e){let t=!0;e.forEach(async e=>{await e.reload(t),t=!1})}const r=new c;export{r as NoConfiguration,o as ShaderTechniqueRepository};