/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{PixelType as r,SizedPixelFormat as e,PrimitiveType as t}from"./enums.js";import{FramebufferObject 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 c}from"./VertexAttributeLayouts.js";import{VertexBuffer as f}from"./VertexBuffer.js";import{WebGLDriverTestModule as l}from"./WebGLDriverTestModule.js";class m extends l{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.acquire(e,t,p)}_test(p){const l=this._rctx,m=new s(1);m.wrapMode=33071,m.dataType=r.FLOAT,m.internalFormat=e.RGBA32F,m.samplingMode=9728;const u=new o(l,m),b=new f(l,c,new Uint16Array([0,0,1,0,0,1,1,1])),d=new a(l,b);l.gl.getError(),l.useProgram(p);const g=l.getBoundFramebufferObject(),{x:w,y:A,width:j,height:x}=l.getViewport();l.bindFramebuffer(u),l.setViewport(0,0,1,1),l.bindVAO(d),l.drawArrays(t.TRIANGLE_STRIP,0,4);const h=i({blending:n});l.setPipelineState(h),l.drawArrays(t.TRIANGLE_STRIP,0,4);const F=l.gl.getError();return l.setViewport(w,A,j,x),l.bindFramebuffer(g),d.dispose(),u.dispose(),F!==l.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};
