/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import i from"../../../../../core/Accessor.js";import r from"../../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{isDepthOrShadowLikeOutput as o}from"../shaderLibrary/ShaderOutput.js";import{Pos2 as a}from"../../lib/DefaultVertexBufferLayouts.js";import{Program as n}from"../../lib/Program.js";import{PrimitiveType as l,DrawBufferNone as h}from"../../../../webgl/enums.js";import{makePipelineState as c,defaultColorWrite as p,premultipliedAlpha as m}from"../../../../webgl/renderState.js";import{fromLayout as u}from"../../../../webgl/VertexAttributeLocations.js";const d=()=>r.getLogger("esri.views.3d.webgl.ShaderTechnique");let g=class extends i{constructor(e,i,r){super({}),this._context=e,this._configuration=i,this.primitiveType=l.TRIANGLES,this.key=i.key,this.locations=u(r??a),this._pipeline=this.initializePipeline(i),this.reload=async r=>{if(r&&await this.shader.reload(),!this.key.equals(i.key))return void d().warn(`Configuration was changed after construction, cannot reload shader for ${this.declaredClass}.`);t(this._program);const s=this.shader.get().build(i);s.debugName=this.declaredClass,this._program=new n(e.rctx,s,this.locations),this._pipeline=this.initializePipeline(i)}}initialize(){const e=this.shader.get().build(this._configuration);e.debugName=this.declaredClass,this._program=new n(this._context.rctx,e,this.locations)}destroy(){this._program=t(this._program),this._pipeline=null}get program(){return this._program}get compiled(){return this.program.compiled}ensureAttributeLocations(e){this.program.assertCompatibleVertexAttributeLocations(e)}getPipeline(e,i){return this._pipeline}initializePipeline(e){return c({blending:m,colorWrite:p})}};function f(e,i){return o(e)?{buffers:[h]}:i??null}g=e([s("esri.views.3d.webgl-engine.core.shaderTechnique.ShaderTechnique")],g);export{g as ShaderTechnique,f as depthOnlyOutputBuffersOr};
