/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{PixelType as r,SizedPixelFormat as e,PrimitiveType as t}from"./enums.js";import{DisposableFramebufferObject as o}from"./FramebufferObject.js";import{makePipelineState as i,destinationTimesOneMinusSourceAlpha as n}from"./renderState.js";import{TextureDescriptor as s}from"./TextureDescriptor.js";import{VertexArrayObject as a}from"./VertexArrayObject.js";import{Pos2usLocations as p,Pos2us as f}from"./VertexAttributeLayouts.js";import{VertexBuffer as l}from"./VertexBuffer.js";import{WebGLDriverTestModule as c}from"./WebGLDriverTestModule.js";class m extends c{constructor(r){if(super(),this._rctx=r,!r.gl)return;if(!(r.capabilities.colorBufferFloat?.textureFloat&&r.capabilities.colorBufferFloat?.floatBlend))return;const e="\n    precision highp float;\n    attribute vec2 position;\n\n    void main() {\n      gl_Position = vec4(position * 2.0 - 1.0, 0.0, 1.0);\n    }\n    ",t="\n     precision highp float;\n\n     void main() {\n      gl_FragColor = vec4(0.5, 0.5, 0.5, 0.5);\n     }\n    ";this._program=r.programCache.get(e,t,p)}_test(p){const c=this._rctx,m=new s(1);m.wrapMode=33071,m.dataType=r.FLOAT,m.internalFormat=e.RGBA32F,m.samplingMode=9728;const u=new o(c,m),b=new l(c,f,new Uint16Array([0,0,1,0,0,1,1,1])),d=new a(c,b);c.gl.getError(),c.useProgram(p);const g=c.boundFramebuffer,{x:w,y:A,width:x,height:h}=c.getViewport();c.bindFramebuffer(u),c.setViewport(0,0,1,1),c.bindVAO(d),c.drawArrays(t.TRIANGLE_STRIP,0,4);const j=i({blending:n});c.setPipelineState(j),c.drawArrays(t.TRIANGLE_STRIP,0,4);const F=c.gl.getError();return c.setViewport(w,A,x,h),c.bindFramebuffer(g),d.dispose(),u.dispose(),F!==c.gl.INVALID_OPERATION||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}}export{m as FloatBufferBlend};
