You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
27 KiB
57 lines
27 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("exports ../../core/maybe ../../core/promiseUtils ../../core/time ./checkWebGLError ./ContextState ./enums ./InstanceCounter ./Parameters ./ProgramCache ./renderState ./Texture ./Util ./WebGLDriverTest ./capabilities/Capabilities".split(" "),function(p,q,u,v,k,r,d,w,x,y,z,A,B,C,D){function h(a,b,c,e){b?e!==b&&a.bindBuffer(c,b.glName):a.bindBuffer(c,null);return b}function t(a,b){switch(a){case d.PrimitiveType.POINTS:return 2*b;case d.PrimitiveType.TRIANGLES:return b/3;case d.PrimitiveType.TRIANGLE_STRIP:return b- |
|
2;case d.PrimitiveType.TRIANGLE_FAN:return b-2;default:return 0}}p.RenderingContext=class{constructor(a,b){this.gl=a;this.instanceCounter=new w.InstanceCounter;this.programCache=new y.ProgramCache(this);this._transformFeedbackRequestInfo=null;this._state=new r.ContextState;this._numOfTriangles=this._numOfDrawCalls=0;this._loadExtensions();this.configure(b)}configure(a){this._capabilities=new D.Capabilities(this.gl,a);this._parameters=new x.Parameters(this.gl,this._capabilities,a);A.Texture.TEXTURE_UNIT_FOR_UPDATES= |
|
this._parameters.maxTextureImageUnits-1;a=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r.ContextState;this._state.viewport={x:a[0],y:a[1],width:a[2],height:a[3]};this._stateTracker=new z.StateTracker({setBlending:b=>{b?(this.setBlendingEnabled(!0),this.setBlendEquationSeparate(b.opRgb,b.opAlpha),this.setBlendFunctionSeparate(b.srcRgb,b.dstRgb,b.srcAlpha,b.dstAlpha),b=b.color,this.setBlendColor(b.r,b.g,b.b,b.a)):this.setBlendingEnabled(!1)},setCulling:b=>{b?(this.setFaceCullingEnabled(!0), |
|
this.setCullFace(b.face),this.setFrontFace(b.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:b=>{b?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(b.factor,b.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:b=>{b?(this.setDepthTestEnabled(!0),this.setDepthFunction(b.func)):this.setDepthTestEnabled(!1)},setStencilTest:b=>{if(b){this.setStencilTestEnabled(!0);const c=b.function;this.setStencilFunction(c.func,c.ref,c.mask);b=b.operation;this.setStencilOp(b.fail,b.zFail, |
|
b.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:b=>{b?(this.setDepthWriteEnabled(!0),this.setDepthRange(b.zNear,b.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:b=>{b?this.setColorMask(b.r,b.g,b.b,b.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:b=>{b?this.setStencilWriteMask(b.mask):this.setStencilWriteMask(0)},setDrawBuffers:b=>{b?this.setDrawBuffers(b.buffers):({drawFramebuffer:b}=this._state,null===b?this.setDrawBuffers([d.SpecialDrawBuffers.BACK]):0===b.colorAttachments.length? |
|
this.setDrawBuffers([d.SpecialDrawBuffers.NONE]):this.setDrawBuffers([d.ColorAttachment.COLOR_ATTACHMENT0]))}});this.enforceState();q.disposeMaybe(this._driverTest);this._driverTest=new C.WebGLDriverTest(this)}dispose(){q.disposeMaybe(this._driverTest);this.programCache.dispose();this.bindVAO(null);this.unbindBuffer(d.BufferType.ARRAY_BUFFER);this.unbindBuffer(d.BufferType.ELEMENT_ARRAY_BUFFER);this.unbindBuffer(d.BufferType.UNIFORM_BUFFER);this._state.uniformBufferBindingPoints.length=0;this.unbindBuffer(d.BufferType.PIXEL_PACK_BUFFER); |
|
this.unbindBuffer(d.BufferType.PIXEL_UNPACK_BUFFER);this.unbindBuffer(d.BufferType.COPY_READ_BUFFER);this.unbindBuffer(d.BufferType.COPY_WRITE_BUFFER);this._state.textureUnitMap.length=0;k.webglDebugEnabled()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(a){this._stateTracker.setPipeline(a)}setBlendingEnabled(a){this._state.blend!== |
|
a&&(!0===a?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=a,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop();this._state.program=null}externalTextureUnitUpdate(a,b){for(let c=0;c<a.length;++c)this._state.textureUnitMap[a[c]]=null;0<=b&&(this._state.activeTexture=b)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null);this._state.vertexArrayObject=null;this._state.vertexBuffer=null;this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer= |
|
null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(a,b,c,e){if(a!==this._state.blendColor.r||b!==this._state.blendColor.g||c!==this._state.blendColor.b||e!==this._state.blendColor.a)this.gl.blendColor(a,b,c,e),this._state.blendColor.r=a,this._state.blendColor.g=b,this._state.blendColor.b=c,this._state.blendColor.a=e,this._stateTracker.invalidateBlending()}setBlendFunction(a,b){if(a!==this._state.blendFunction.srcRGB||b!==this._state.blendFunction.dstRGB)this.gl.blendFunc(a, |
|
b),this._state.blendFunction.srcRGB=a,this._state.blendFunction.srcAlpha=a,this._state.blendFunction.dstRGB=b,this._state.blendFunction.dstAlpha=b,this._stateTracker.invalidateBlending()}setBlendFunctionSeparate(a,b,c,e){if(this._state.blendFunction.srcRGB!==a||this._state.blendFunction.srcAlpha!==c||this._state.blendFunction.dstRGB!==b||this._state.blendFunction.dstAlpha!==e)this.gl.blendFuncSeparate(a,b,c,e),this._state.blendFunction.srcRGB=a,this._state.blendFunction.srcAlpha=c,this._state.blendFunction.dstRGB= |
|
b,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending()}setBlendEquation(a){this._state.blendEquation.mode!==a&&(this.gl.blendEquation(a),this._state.blendEquation.mode=a,this._state.blendEquation.modeAlpha=a,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(a,b){if(this._state.blendEquation.mode!==a||this._state.blendEquation.modeAlpha!==b)this.gl.blendEquationSeparate(a,b),this._state.blendEquation.mode=a,this._state.blendEquation.modeAlpha=b,this._stateTracker.invalidateBlending()}setColorMask(a, |
|
b,c,e){if(this._state.colorMask.r!==a||this._state.colorMask.g!==b||this._state.colorMask.b!==c||this._state.colorMask.a!==e)this.gl.colorMask(a,b,c,e),this._state.colorMask.r=a,this._state.colorMask.g=b,this._state.colorMask.b=c,this._state.colorMask.a=e,this._stateTracker.invalidateColorWrite()}setClearColor(a,b,c,e){if(this._state.clearColor.r!==a||this._state.clearColor.g!==b||this._state.clearColor.b!==c||this._state.clearColor.a!==e)this.gl.clearColor(a,b,c,e),this._state.clearColor.r=a,this._state.clearColor.g= |
|
b,this._state.clearColor.b=c,this._state.clearColor.a=e}setFaceCullingEnabled(a){this._state.faceCulling!==a&&(!0===a?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=a,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(a){this._state.polygonOffsetFill!==a&&(!0===a?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=a,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(a, |
|
b){if(this._state.polygonOffset[0]!==a||this._state.polygonOffset[1]!==b)this._state.polygonOffset[0]=a,this._state.polygonOffset[1]=b,this.gl.polygonOffset(a,b),this._stateTracker.invalidatePolygonOffset()}setCullFace(a){this._state.cullFace!==a&&(this.gl.cullFace(a),this._state.cullFace=a,this._stateTracker.invalidateCulling())}setFrontFace(a){this._state.frontFace!==a&&(this.gl.frontFace(a),this._state.frontFace=a,this._stateTracker.invalidateCulling())}setScissorTestEnabled(a){this._state.scissorTest!== |
|
a&&(!0===a?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=a)}setScissorRect(a,b,c,e){if(this._state.scissorRect.x!==a||this._state.scissorRect.y!==b||this._state.scissorRect.width!==c||this._state.scissorRect.height!==e)this.gl.scissor(a,b,c,e),this._state.scissorRect.x=a,this._state.scissorRect.y=b,this._state.scissorRect.width=c,this._state.scissorRect.height=e}setDepthTestEnabled(a){this._state.depthTest!==a&&(!0===a?this.gl.enable(this.gl.DEPTH_TEST): |
|
this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=a,this._stateTracker.invalidateDepthTest())}setClearDepth(a){this._state.clearDepth!==a&&(this.gl.clearDepth(a),this._state.clearDepth=a)}setDepthFunction(a){this._state.depthFunction!==a&&(this.gl.depthFunc(a),this._state.depthFunction=a,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(a){this._state.depthWrite!==a&&(this.gl.depthMask(a),this._state.depthWrite=a,this._stateTracker.invalidateDepthWrite())}setDepthRange(a,b){if(this._state.depthRange.zNear!== |
|
a||this._state.depthRange.zFar!==b)this.gl.depthRange(a,b),this._state.depthRange.zNear=a,this._state.depthRange.zFar=b,this._stateTracker.invalidateDepthWrite()}setStencilTestEnabled(a){this._state.stencilTest!==a&&(!0===a?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=a,this._stateTracker.invalidateStencilTest())}setClearStencil(a){a!==this._state.clearStencil&&(this.gl.clearStencil(a),this._state.clearStencil=a)}setStencilFunction(a,b,c){if(this._state.stencilFunction.func!== |
|
a||this._state.stencilFunction.ref!==b||this._state.stencilFunction.mask!==c)this.gl.stencilFunc(a,b,c),this._state.stencilFunction.face=d.Face.FRONT_AND_BACK,this._state.stencilFunction.func=a,this._state.stencilFunction.ref=b,this._state.stencilFunction.mask=c,this._stateTracker.invalidateStencilTest()}setStencilFunctionSeparate(a,b,c,e){if(this._state.stencilFunction.face!==a||this._state.stencilFunction.func!==b||this._state.stencilFunction.ref!==c||this._state.stencilFunction.mask!==e)this.gl.stencilFuncSeparate(a, |
|
b,c,e),this._state.stencilFunction.face=a,this._state.stencilFunction.func=b,this._state.stencilFunction.ref=c,this._state.stencilFunction.mask=e,this._stateTracker.invalidateStencilTest()}setStencilWriteMask(a){this._state.stencilWriteMask!==a&&(this.gl.stencilMask(a),this._state.stencilWriteMask=a,this._stateTracker.invalidateStencilWrite())}setStencilOp(a,b,c){if(this._state.stencilOperation.face!==d.Face.FRONT_AND_BACK||this._state.stencilOperation.fail!==a||this._state.stencilOperation.zFail!== |
|
b||this._state.stencilOperation.zPass!==c)this.gl.stencilOp(a,b,c),this._state.stencilOperation.face=d.Face.FRONT_AND_BACK,this._state.stencilOperation.fail=a,this._state.stencilOperation.zFail=b,this._state.stencilOperation.zPass=c,this._stateTracker.invalidateStencilTest()}setStencilOpSeparate(a,b,c,e){if(this._state.stencilOperation.face!==a||this._state.stencilOperation.fail!==b||this._state.stencilOperation.zFail!==c||this._state.stencilOperation.zPass!==e)this.gl.stencilOpSeparate(a,b,c,e), |
|
this._state.stencilOperation.face=a,this._state.stencilOperation.fail=b,this._state.stencilOperation.zFail=c,this._state.stencilOperation.zPass=e,this._stateTracker.invalidateStencilTest()}setActiveTexture(a,b=!1){const c=this._state.activeTexture;0<=a&&(b||a!==this._state.activeTexture)&&(this.gl.activeTexture(d.baseTextureUnit+a),this._state.activeTexture=a);return c}setDrawBuffers(a){const {drawFramebuffer:b}=this._state,c=null===b,e=c?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(b); |
|
if(e?.length!==a.length||!e.every((f,g)=>f===a[g]))if(a.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(c){if(1<a.length){console.error("The default framebuffer can only have one active draw buffer.");return}if(a[0]!==d.SpecialDrawBuffers.BACK&&a[0]!==d.SpecialDrawBuffers.NONE){console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.");return}}!c&&a.includes(d.SpecialDrawBuffers.BACK)? |
|
console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers."):(this.gl.drawBuffers(a),c?this._state.drawBuffers.defaultFramebuffer=a:this._state.drawBuffers.fbos.set(b,a),this._stateTracker.invalidateDrawBuffers())}}clear(a,b=255){if(a){if(a&d.ClearBufferBit.COLOR_BUFFER_BIT){const c=this._state.drawFramebuffer?.colorAttachments;c&&this.setDrawBuffers(c);this.setColorMask(!0,!0,!0,!0)}a&d.ClearBufferBit.DEPTH_BUFFER_BIT&&this.setDepthWriteEnabled(!0); |
|
a&d.ClearBufferBit.STENCIL_BUFFER_BIT&&this.setStencilWriteMask(b);this.gl.clear(a)}}clearFramebuffer(a,b=!1,c=!1){let e=0;a&&(this.setClearColor(a[0],a[1],a[2],Math.max(1E-13,a[3])),e|=d.ClearBufferBit.COLOR_BUFFER_BIT);b&&(e|=d.ClearBufferBit.DEPTH_BUFFER_BIT);!1===c?c=0:(!0===c&&(c=255),e|=d.ClearBufferBit.STENCIL_BUFFER_BIT);e&&this.clear(e,c)}drawArrays(a,b,c){if(this._transformFeedbackRequestInfo){if(a!==this._transformFeedbackRequestInfo.primitiveType)throw Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request"); |
|
if(null==this._state.program?.hasTransformFeedbackVaryings)throw Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying");}if(k.webglDebugEnabled()){this._numOfDrawCalls++;this._numOfTriangles+=t(a,c);const e=this._state.textureUnitMap;for(let f=0;f<e.length;f++){const g=e[f];if(null!=g&&g===this._state.drawFramebuffer?.colorTexture)throw Error(`Detected readWrite. Texture already bound at index ${f}`);}}this.gl.drawArrays(a,b,c); |
|
k.checkWebGLError(this.gl)}drawArraysInstanced(a,b,c,e){this.gl.drawArraysInstanced(a,b,c,e);k.checkWebGLError(this.gl)}drawElements(a,b,c,e){if(this._transformFeedbackRequestInfo)throw Error("Cannot called drawElements during a transform feedback request");k.webglDebugEnabled()&&(this._numOfDrawCalls++,this._numOfTriangles+=t(a,b));this.gl.drawElements(a,b,c,e);if(k.webglDebugEnabled()){const f=B.getErrorString(this);if(f){const g=this.getBoundVAO(),l=g?.indexBuffer,m=l?.size??0,n=e+b;console.error(`drawElements: ${f}${m< |
|
n?`. Buffer is too small. Attempted to draw index ${n} of ${m}`:""}`,{args:{mode:a,count:b,type:c,offset:e},vao:{indexBuffer:l,vertexBuffers:g?.vertexBuffers}})}}}logInfo(){k.webglDebugEnabled()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){k.webglDebugEnabled()&&(this._numOfTriangles=this._numOfDrawCalls=0)}get capabilities(){return this._capabilities}setViewport(a,b,c,e){c=Math.max(Math.round(c),1);e=Math.max(Math.round(e),1);const f=this._state.viewport; |
|
if(f.x!==a||f.y!==b||f.width!==c||f.height!==e)f.x=a,f.y=b,f.width=c,f.height=e,this.gl.viewport(a,b,c,e)}setViewport4fv(a){this.setViewport(a[0],a[1],a[2],a[3])}restoreViewport({x:a,y:b,width:c,height:e}){this.setViewport(a,b,c,e)}getViewport(){const a=this._state.viewport;return{x:a.x,y:a.y,width:a.width,height:a.height}}useProgram(a){this._state.program!==a&&(this._state.program?.stop(),this._state.program=a,this.gl.useProgram(a?.glName??null))}bindTexture(a,b,c=!1){(b>=this.parameters.maxTextureImageUnits|| |
|
0>b)&&console.error("Input texture unit is out of range of available units!");const e=this._state.textureUnitMap[b];if(null==a?.glName)return null!=e&&(this.setActiveTexture(b,c),this.gl.bindTexture(e.descriptor.target,null)),this._state.textureUnitMap[b]=null,e;if(!c&&e===a)return a.isDirty&&(this.setActiveTexture(b,c),a.applyChanges()),e;this.setActiveTexture(b,c);this.gl.bindTexture(a.descriptor.target,a.glName);a.applyChanges();this._state.textureUnitMap[b]=a;return e}unbindTexture(a){if(null!= |
|
a)for(let b=0;b<this.parameters.maxTextureImageUnits;b++)this._state.textureUnitMap[b]===a&&(this.bindTexture(null,b),this._state.textureUnitMap[b]=null)}bindFramebuffer(a,b=!1){if(b||this._state.readFramebuffer!==a||this._state.drawFramebuffer!==a)this._stateTracker.invalidateDrawBuffers(),null==a?(this.gl.bindFramebuffer(d.FramebufferTarget.FRAMEBUFFER,null),this._state.readFramebuffer=this._state.drawFramebuffer=null):(a.initializeAndBind(d.FramebufferTarget.FRAMEBUFFER),this._state.readFramebuffer= |
|
a,this._state.drawFramebuffer=a)}bindFramebufferSeparate(a,b,c=!1){const e=b===d.FramebufferTarget.READ_FRAMEBUFFER,f=e?this._state.readFramebuffer:this._state.drawFramebuffer;if(c||f!==a)null==a?this.gl.bindFramebuffer(b,null):a.initializeAndBind(b),e?this._state.readFramebuffer=a??null:(this._stateTracker.invalidateDrawBuffers(),this._state.drawFramebuffer=a??null)}blitFramebuffer(a,b,c=0,e=0,f=a.width,g=a.height,l=0,m=0,n=b.width,E=b.height,F=d.ClearBufferBit.COLOR_BUFFER_BIT,G=d.TextureSamplingMode.NEAREST){this.bindFramebufferSeparate(a, |
|
d.FramebufferTarget.READ_FRAMEBUFFER);this.bindFramebufferSeparate(b,d.FramebufferTarget.DRAW_FRAMEBUFFER);this.gl.blitFramebuffer(c,e,f,g,l,m,n,E,F,G)}bindBuffer(a,b){if(a)switch(b??=a.bufferType,b){case d.BufferType.ARRAY_BUFFER:this._state.vertexBuffer=h(this.gl,a,b,this._state.vertexBuffer);break;case d.BufferType.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=h(this.gl,a,b,this._state.indexBuffer);break;case d.BufferType.UNIFORM_BUFFER:this._state.uniformBuffer=h(this.gl,a,b,this._state.uniformBuffer); |
|
break;case d.BufferType.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=h(this.gl,a,b,this._state.pixelPackBuffer);break;case d.BufferType.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=h(this.gl,a,b,this._state.pixelUnpackBuffer);break;case d.BufferType.COPY_READ_BUFFER:this._state.copyReadBuffer=h(this.gl,a,b,this._state.copyReadBuffer);break;case d.BufferType.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=h(this.gl,a,b,this._state.copyWriteBuffer);break;case d.BufferType.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer= |
|
h(this.gl,a,b,this._state.transformFeedbackBuffer)}}bindRenderbuffer(a){const b=this.gl;a||(b.bindRenderbuffer(b.RENDERBUFFER,null),this._state.renderbuffer=null);this._state.renderbuffer!==a&&(b.bindRenderbuffer(b.RENDERBUFFER,a.glName),this._state.renderbuffer=a)}_getBufferBinding(a,b){if(b>=this.parameters.maxUniformBufferBindings||0>b)return console.error("Uniform buffer binding point is out of range!"),null;a=a===d.BufferType.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints; |
|
let c=a[b];null==c&&(c={buffer:null,offset:0,size:0},a[b]=c);return c}bindBufferBase(a,b,c){const e=this._getBufferBinding(a,b);null==e||e.buffer===c&&0===e.offset&&0===e.size||(this.gl.bindBufferBase(a,b,c?c.glName:null),e.buffer=c,e.offset=0,e.size=0)}bindBufferRange(a,b,c,e,f){const g=this._getBufferBinding(a,b);null==g||g.buffer===c&&g.offset===e&&g.size===f||(0!==e%this._parameters.uniformBufferOffsetAlignment?console.error("Uniform buffer binding offset is not a multiple of the context offset alignment"): |
|
(this.gl.bindBufferRange(a,b,c.glName,e,f),g.buffer=c,g.offset=e,g.size=f))}bindUBO(a,b,c,e){null==b?this.bindBufferBase(d.BufferType.UNIFORM_BUFFER,a,null):(k.webglDebugEnabled()&&(e??b.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),b.initialize(),void 0!==c&&void 0!==e?this.bindBufferRange(d.BufferType.UNIFORM_BUFFER,a,b.buffer,c,e):this.bindBufferBase(d.BufferType.UNIFORM_BUFFER,a,b.buffer))}unbindUBO(a){for(let b= |
|
0,c=this._state.uniformBufferBindingPoints.length;b<c;b++){const e=this._state.uniformBufferBindingPoints[b];null!=e&&e.buffer===a.buffer&&this.bindBufferBase(d.BufferType.UNIFORM_BUFFER,b,null)}}unbindBuffer(a){switch(a){case d.BufferType.ARRAY_BUFFER:this._state.vertexBuffer=h(this.gl,null,a,this._state.vertexBuffer);break;case d.BufferType.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=h(this.gl,null,a,this._state.indexBuffer);break;case d.BufferType.UNIFORM_BUFFER:this._state.uniformBuffer=h(this.gl, |
|
null,a,this._state.uniformBuffer);break;case d.BufferType.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=h(this.gl,null,a,this._state.pixelPackBuffer);break;case d.BufferType.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=h(this.gl,null,a,this._state.pixelUnpackBuffer);break;case d.BufferType.COPY_READ_BUFFER:this._state.copyReadBuffer=h(this.gl,null,a,this._state.copyReadBuffer);break;case d.BufferType.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=h(this.gl,null,a,this._state.copyWriteBuffer)}}bindVAO(a= |
|
null){null==a?this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null):this._state.vertexArrayObject!==a&&(a.bind(),this._state.vertexArrayObject=a)}bindTransformFeedback(a){const {gl:b}=this;b.bindTransformFeedback(b.TRANSFORM_FEEDBACK,a.glName)}beginTransformFeedback(a,b){if(this._transformFeedbackRequestInfo)throw Error("Already in a transform feedback request");const {gl:c}=this;c.bindTransformFeedback(c.TRANSFORM_FEEDBACK,a.glName);c.beginTransformFeedback(b); |
|
this._transformFeedbackRequestInfo={primitiveType:b}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw Error("Not in a transform feedback request");const {gl:a}=this;a.endTransformFeedback();a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,null);this._transformFeedbackRequestInfo=null}async clientWaitAsync(a=v.Milliseconds(10)){const {gl:b}=this,c=b.fenceSync(d.SyncCondition.SYNC_GPU_COMMANDS_COMPLETE,0);if(!c)throw Error("Client wait failed, could not create sync object");this.instanceCounter.increment(d.ResourceType.Sync, |
|
c);b.flush();let e;do await u.after(a),e=b.clientWaitSync(c,0,0);while(e===d.ClientWaitSyncStatus.TIMEOUT_EXPIRED);this.instanceCounter.decrement(d.ResourceType.Sync,c);b.deleteSync(c);if(e===d.ClientWaitSyncStatus.WAIT_FAILED)throw Error("Client wait failed");}getBoundFramebufferObject(a=d.FramebufferTarget.FRAMEBUFFER){return a===d.FramebufferTarget.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null); |
|
this.bindVAO(null);this.bindFramebuffer(null,!0);this.unbindBuffer(d.BufferType.ARRAY_BUFFER);this.unbindBuffer(d.BufferType.ELEMENT_ARRAY_BUFFER);this.unbindBuffer(d.BufferType.UNIFORM_BUFFER);this._state.uniformBufferBindingPoints.length=0;this.unbindBuffer(d.BufferType.PIXEL_PACK_BUFFER);this.unbindBuffer(d.BufferType.PIXEL_UNPACK_BUFFER);this.unbindBuffer(d.BufferType.COPY_READ_BUFFER);this.unbindBuffer(d.BufferType.COPY_WRITE_BUFFER);for(let a=0;a<this.parameters.maxTextureImageUnits;++a)this.bindTexture(null, |
|
a);this.setBlendingEnabled(!1);this.setBlendFunction(d.BlendFactor.ONE,d.BlendFactor.ZERO);this.setBlendEquation(d.BlendOperation.ADD);this.setBlendColor(0,0,0,0);this.setFaceCullingEnabled(!1);this.setCullFace(d.Face.BACK);this.setFrontFace(d.CullMode.CCW);this.setPolygonOffsetFillEnabled(!1);this.setPolygonOffset(0,0);this.setScissorTestEnabled(!1);this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height);this.setDepthTestEnabled(!1);this.setDepthFunction(d.CompareFunction.LESS);this.setDepthRange(0, |
|
1);this.setStencilTestEnabled(!1);this.setStencilFunction(d.CompareFunction.ALWAYS,0,0);this.setStencilOp(d.StencilOperation.KEEP,d.StencilOperation.KEEP,d.StencilOperation.KEEP);this.setClearColor(0,0,0,0);this.setClearDepth(1);this.setClearStencil(0);this.setColorMask(!0,!0,!0,!0);this.setStencilWriteMask(4294967295);this.setDepthWriteEnabled(!0);this.setDrawBuffers([d.SpecialDrawBuffers.BACK]);this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const {gl:a}=this;a.bindVertexArray(null); |
|
for(var b=0;b<this.parameters.maxVertexAttributes;b++)a.disableVertexAttribArray(b);this._state.vertexBuffer?a.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):a.bindBuffer(d.BufferType.ARRAY_BUFFER,null);this._state.indexBuffer?a.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):a.bindBuffer(d.BufferType.ELEMENT_ARRAY_BUFFER,null);this._state.uniformBuffer?a.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName): |
|
a.bindBuffer(d.BufferType.UNIFORM_BUFFER,null);for(b=0;b<this._parameters.maxUniformBufferBindings;b++){var c=this._state.uniformBufferBindingPoints[b];if(null!=c){const {buffer:e,offset:f,size:g}=c;null!==e?0===f&&0===g?a.bindBufferBase(d.BufferType.UNIFORM_BUFFER,b,e.glName):a.bindBufferRange(d.BufferType.UNIFORM_BUFFER,b,e.glName,f,g):a.bindBufferBase(d.BufferType.UNIFORM_BUFFER,b,null)}}this._state.pixelPackBuffer?a.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName): |
|
a.bindBuffer(d.BufferType.PIXEL_PACK_BUFFER,null);this._state.pixelUnpackBuffer?a.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):a.bindBuffer(d.BufferType.PIXEL_UNPACK_BUFFER,null);this._state.copyReadBuffer?a.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):a.bindBuffer(d.BufferType.COPY_READ_BUFFER,null);this._state.copyWriteBuffer?a.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName): |
|
a.bindBuffer(d.BufferType.COPY_WRITE_BUFFER,null);a.bindFramebuffer(d.FramebufferTarget.READ_FRAMEBUFFER,null);a.readBuffer(a.BACK);this._state.readFramebuffer&&(a.bindFramebuffer(d.FramebufferTarget.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),a.readBuffer(d.ColorAttachment.COLOR_ATTACHMENT0));a.bindFramebuffer(d.FramebufferTarget.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null);null===this._state.drawFramebuffer?a.drawBuffers(this._state.drawBuffers.defaultFramebuffer??[d.SpecialDrawBuffers.BACK]): |
|
(b=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer),a.drawBuffers(b??[d.ColorAttachment.COLOR_ATTACHMENT0]));if(this._state.vertexArrayObject){if(b=this._state.vertexArrayObject)this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null;this.bindVAO(b)}a.useProgram(this._state.program?.glName??null);a.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a);a.bindRenderbuffer(a.RENDERBUFFER,this._state.renderbuffer?.glName?? |
|
null);!0===this._state.blend?a.enable(this.gl.BLEND):a.disable(this.gl.BLEND);a.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha);a.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha);a.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a);a.clearDepth(this._state.clearDepth);a.clearStencil(this._state.clearStencil); |
|
a.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a);a.cullFace(this._state.cullFace);a.depthFunc(this._state.depthFunction);a.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar);!0===this._state.depthTest?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST);a.depthMask(this._state.depthWrite);a.frontFace(this._state.frontFace);a.lineWidth(1);!0===this._state.faceCulling?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE);a.polygonOffset(this._state.polygonOffset[0], |
|
this._state.polygonOffset[1]);!0===this._state.polygonOffsetFill?a.enable(a.POLYGON_OFFSET_FILL):a.disable(a.POLYGON_OFFSET_FILL);a.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height);!0===this._state.scissorTest?a.enable(a.SCISSOR_TEST):a.disable(a.SCISSOR_TEST);a.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask);a.stencilOpSeparate(this._state.stencilOperation.face, |
|
this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass);!0===this._state.stencilTest?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST);a.stencilMask(this._state.stencilWriteMask);for(b=0;b<this.parameters.maxTextureImageUnits;b++)a.activeTexture(d.baseTextureUnit+b),a.bindTexture(d.TextureType.TEXTURE_2D,null),a.bindTexture(d.TextureType.TEXTURE_CUBE_MAP,null),a.bindTexture(d.TextureType.TEXTURE_3D,null),a.bindTexture(d.TextureType.TEXTURE_2D_ARRAY, |
|
null),c=this._state.textureUnitMap[b],null!=c&&a.bindTexture(c.descriptor.target,c.glName);a.activeTexture(d.baseTextureUnit+this._state.activeTexture);b=this._state.viewport;a.viewport(b.x,b.y,b.width,b.height);this.resetInfo()}_loadExtensions(){this.gl.getExtension("KHR_parallel_shader_compile")}};Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}); |