/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import i from"../../../../../core/Accessor.js";import t from"../../../../../core/Logger.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{Pos2 as s}from"../../lib/DefaultVertexBufferLayouts.js";import{Program as o}from"../../lib/Program.js";import{PrimitiveType as n}from"../../../../webgl/enums.js";import{makePipelineState as a,defaultColorWrite as h,premultipliedAlpha as l}from"../../../../webgl/renderState.js";import{fromLayout as c}from"../../../../webgl/VertexAttributeLocations.js";const u=()=>t.getLogger("esri.views.3d.webgl.ShaderTechnique");let d=class extends i{constructor(e,i,t){super({}),this._context=e,this._configuration=i,this.primitiveType=n.TRIANGLES,this._unused=!0,this.ignoreUnused=!1,this.key=i.key,this.locations=c(t??s),this._pipeline=this.initializePipeline(i),this.reload=async t=>{if(t&&await this.shader.reload(),!this.key.equals(i.key))return void u().warn(`Configuration was changed after construction, cannot reload shader for ${this.declaredClass}.`);const r=this.shader.get().build(i);r.debugName=this.declaredClass,this._program=new o(e.rctx,r,this.locations),this._pipeline=this.initializePipeline(i)}}initialize(){const e=this.shader.get().build(this._configuration);e.debugName=this.declaredClass,this._program=new o(this._context.rctx,e,this.locations)}get program(){return this._unused=!1,this._program}get compiled(){return this._unused=!1,this.program.compiled}get unused(){return this._unused}ensureAttributeLocations(e){this.program.assertCompatibleVertexAttributeLocations(e)}getPipeline(e,i,t){return this._pipeline}initializePipeline(e){return a({blending:l,colorWrite:h})}};d=e([r("esri.views.3d.webgl-engine.core.shaderTechnique.ShaderTechnique")],d);export{d as ShaderTechnique};
