/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../chunks/_rollupPluginBabelHelpers","../../core/Logger","../../core/maybe","./BufferObject","./context-util","./enums","./UniformBufferLayout"],(function(t,e,i,n,r,s,o,a){"use strict";const f=i.getLogger("esri.views.webgl.UniformBufferObject");let u=function(){function t(t,e,i=o.Usage.DYNAMIC_DRAW){this._context=t,this._usage=i,this._dirtyRange={from:1/0,to:-1},this._initialized=!1,this._context.type!==s.ContextType.WEBGL2&&f.error("Attempting to create a uniform buffer without WebGL2!"),this._data=new a.UniformBufferLayout(e)}var i=t.prototype;return i.initialize=function(){this._initialized||(this.buffer=r.BufferObject.createUniform(this._context,this._usage,this._data.array),this._resetDirtyRange(),this._initialized=!0)},i.dispose=function(){this._context.unbindUBO(this),this.buffer=n.disposeMaybe(this.buffer)},i.set=function(t){this._data.setValues(t,this._dirtyRange)},i.setUniform=function(t,e){this._data.setValue(t,e,this._dirtyRange)},i.upload=function(){this.initialize();const{from:t,to:e}=this._dirtyRange;e>-1&&t<e&&(this.buffer.setSubDataFromView(this._data.arrayView32,t,t,e),this._resetDirtyRange())},i._resetDirtyRange=function(){this._dirtyRange.from=1/0,this._dirtyRange.to=-1},e._createClass(t,[{key:"byteLength",get:function(){return this._data.byteLength}}]),t}();t.UniformBufferObject=u,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
