{ "version": 3, "sources": ["../src/index.ts", "../src/adapter/webgl-adapter.ts", "../src/adapter/webgl-device.ts", "../src/context/parameters/webgl-parameter-tables.ts", "../src/context/parameters/unified-parameter-api.ts", "../src/context/state-tracker/deep-array-equal.ts", "../src/context/state-tracker/webgl-state-tracker.ts", "../src/context/helpers/create-browser-context.ts", "../src/adapter/device-helpers/webgl-device-info.ts", "../src/context/helpers/webgl-extensions.ts", "../src/adapter/device-helpers/webgl-device-features.ts", "../src/adapter/converters/webgl-texture-table.ts", "../src/adapter/converters/vertex-formats.ts", "../src/adapter/device-helpers/webgl-device-limits.ts", "../src/adapter/webgl-canvas-context.ts", "../src/adapter/resources/webgl-framebuffer.ts", "../src/context/debug/spector.ts", "../src/utils/load-script.ts", "../src/context/debug/webgl-developer-tools.ts", "../src/utils/uid.ts", "../src/adapter/resources/webgl-buffer.ts", "../src/adapter/resources/webgl-shader.ts", "../src/adapter/helpers/parse-shader-compiler-log.ts", "../src/adapter/resources/webgl-sampler.ts", "../src/adapter/converters/sampler-parameters.ts", "../src/adapter/converters/device-parameters.ts", "../src/adapter/resources/webgl-texture.ts", "../src/adapter/resources/webgl-texture-view.ts", "../src/adapter/helpers/webgl-texture-utils.ts", "../src/adapter/helpers/typed-array-utils.ts", "../src/adapter/helpers/format-utils.ts", "../src/context/state-tracker/with-parameters.ts", "../src/adapter/resources/webgl-render-pass.ts", "../src/adapter/resources/webgl-render-pipeline.ts", "../src/adapter/helpers/get-shader-layout.ts", "../src/adapter/helpers/decode-webgl-types.ts", "../src/adapter/helpers/set-uniform.ts", "../src/utils/split-uniforms-and-bindings.ts", "../src/adapter/helpers/webgl-topology-utils.ts", "../src/adapter/resources/webgl-command-encoder.ts", "../src/adapter/resources/webgl-command-buffer.ts", "../src/adapter/resources/webgl-vertex-array.ts", "../src/utils/fill-array.ts", "../src/adapter/resources/webgl-transform-feedback.ts", "../src/adapter/resources/webgl-query-set.ts", "../src/context/polyfills/polyfill-webgl1-extensions.ts", "../src/deprecated/accessor.ts"], "sourcesContent": ["// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Types\nexport type {WebGLDeviceLimits} from './adapter/device-helpers/webgl-device-limits';\n\n// WebGL adapter classes\nexport {webgl2Adapter} from './adapter/webgl-adapter';\nexport type {WebGLAdapter} from './adapter/webgl-adapter';\n\n// WebGL Device classes\nexport {WebGLDevice} from './adapter/webgl-device';\nexport {WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {WEBGLShader} from './adapter/resources/webgl-shader';\nexport {WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n// export {WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\nexport {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';\n\n// WebGL adapter classes\nexport {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';\n\n// WebGL adapter classes\nexport {Accessor} from './deprecated/accessor';\nexport type {AccessorObject} from './types';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayoutFromGLSL} from './adapter/helpers/get-shader-layout';\nexport {WebGLStateTracker} from './context/state-tracker/webgl-state-tracker';\n\n// DEPRECATED TEST EXPORTS\nexport {\n resetGLParameters,\n setGLParameters,\n getGLParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {withGLParameters} from './context/state-tracker/with-parameters';\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Adapter, Device, DeviceProps, log} from '@luma.gl/core';\nimport {WebGLDevice} from './webgl-device';\nimport {enforceWebGL2} from '../context/polyfills/polyfill-webgl1-extensions';\nimport {loadSpectorJS, DEFAULT_SPECTOR_PROPS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools} from '../context/debug/webgl-developer-tools';\n\nconst LOG_LEVEL = 1;\n\nexport class WebGLAdapter extends Adapter {\n /** type of device's created by this adapter */\n readonly type: Device['type'] = 'webgl';\n\n constructor() {\n super();\n\n // Add spector default props to device default props, so that runtime settings are observed\n Device.defaultProps = {...Device.defaultProps, ...DEFAULT_SPECTOR_PROPS};\n\n // @ts-ignore DEPRECATED For backwards compatibility luma.registerDevices\n WebGLDevice.adapter = this;\n }\n\n /** Check if WebGL 2 is available */\n isSupported(): boolean {\n return typeof WebGL2RenderingContext !== 'undefined';\n }\n\n /** Force any created WebGL contexts to be WebGL2 contexts, polyfilled with WebGL1 extensions */\n enforceWebGL2(enable: boolean): void {\n enforceWebGL2(enable);\n }\n\n /**\n * Get a device instance from a GL context\n * Creates a WebGLCanvasContext against the contexts canvas\n * @note autoResize will be disabled, assuming that whoever created the external context will be handling resizes.\n * @param gl\n * @returns\n */\n async attach(gl: Device | WebGL2RenderingContext): Promise {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGL2RenderingContext');\n }\n\n // We create a new device using the provided WebGL context and its canvas\n // Assume that whoever created the external context will be handling resizes.\n return new WebGLDevice({\n _handle: gl,\n createCanvasContext: {canvas: gl.canvas, autoResize: false}\n });\n }\n\n async create(props: DeviceProps = {}): Promise {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();\n\n const promises: Promise[] = [];\n\n // Load webgl and spector debug scripts from CDN if requested\n if (props.debugWebGL || props.debug) {\n promises.push(loadWebGLDeveloperTools());\n }\n\n if (props.debugSpectorJS) {\n promises.push(loadSpectorJS(props));\n }\n\n // Wait for all the loads to settle before creating the context.\n // The Device.create() functions are async, so in contrast to the constructor, we can `await` here.\n const results = await Promise.allSettled(promises);\n for (const result of results) {\n if (result.status === 'rejected') {\n log.error(`Failed to initialize debug libraries ${result.reason}`)();\n }\n }\n\n const device = new WebGLDevice(props);\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${device.type}${device.debug ? ' debug' : ''} context: \\\n${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n log.table(LOG_LEVEL, device.info)();\n\n log.groupEnd(LOG_LEVEL)();\n\n return device;\n }\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL(gl: any): gl is WebGL2RenderingContext {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\nexport const webgl2Adapter = new WebGLAdapter();\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray} from '@math.gl/types';\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceTextureFormatCapabilities,\n CanvasContextProps,\n Buffer,\n Texture,\n Framebuffer,\n VertexArray,\n VertexArrayProps,\n BufferProps,\n ShaderProps,\n // Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n // RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n // RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps,\n // CommandEncoder,\n CommandEncoderProps,\n TransformFeedbackProps,\n QuerySetProps\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log} from '@luma.gl/core';\nimport type {GLExtensions} from '@luma.gl/constants';\nimport {WebGLStateTracker} from '../context/state-tracker/webgl-state-tracker';\nimport {createBrowserContext} from '../context/helpers/create-browser-context';\nimport {getDeviceInfo} from './device-helpers/webgl-device-info';\nimport {WebGLDeviceFeatures} from './device-helpers/webgl-device-features';\nimport {WebGLDeviceLimits} from './device-helpers/webgl-device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport type {Spector} from '../context/debug/spector-types';\nimport {initializeSpectorJS} from '../context/debug/spector';\nimport {makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {getTextureFormatCapabilitiesWebGL} from './converters/webgl-texture-table';\nimport {uid} from '../utils/uid';\n\nimport {WEBGLBuffer} from './resources/webgl-buffer';\nimport {WEBGLShader} from './resources/webgl-shader';\nimport {WEBGLSampler} from './resources/webgl-sampler';\nimport {WEBGLTexture} from './resources/webgl-texture';\nimport {WEBGLFramebuffer} from './resources/webgl-framebuffer';\nimport {WEBGLRenderPass} from './resources/webgl-render-pass';\nimport {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';\nimport {WEBGLCommandEncoder} from './resources/webgl-command-encoder';\nimport {WEBGLVertexArray} from './resources/webgl-vertex-array';\nimport {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';\nimport {WEBGLQuerySet} from './resources/webgl-query-set';\n\nimport {readPixelsToArray, readPixelsToBuffer} from './helpers/webgl-texture-utils';\nimport {\n setGLParameters,\n getGLParameters,\n resetGLParameters\n} from '../context/parameters/unified-parameter-api';\nimport {withGLParameters} from '../context/state-tracker/with-parameters';\nimport {getWebGLExtension} from '../context/helpers/webgl-extensions';\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n /** type of this device */\n readonly type = 'webgl';\n\n /** The underlying WebGL context */\n readonly handle: WebGL2RenderingContext;\n features: WebGLDeviceFeatures;\n limits: WebGLDeviceLimits;\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n\n /** WebGL2 context. */\n readonly gl: WebGL2RenderingContext;\n readonly debug: boolean = false;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** State used by luma.gl classes - TODO - not used? */\n readonly _extensions: GLExtensions = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spectorJS: Spector;\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // WebGL requires a canvas to be created before creating the context\n if (!props.createCanvasContext) {\n throw new Error('WebGLDevice requires props.createCanvasContext to be set');\n }\n const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n let device: WebGLDevice | undefined = canvasContextProps.canvas?.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, canvasContextProps);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const webglContextAttributes: WebGLContextAttributes = {...props.webgl};\n // Copy props from CanvasContextProps\n if (canvasContextProps.alphaMode === 'premultiplied') {\n webglContextAttributes.premultipliedAlpha = true;\n }\n if (props.powerPreference !== undefined) {\n webglContextAttributes.powerPreference = props.powerPreference;\n }\n\n // Check if we should attach to an externally created context or create a new context\n const externalGLContext = this.props._handle as WebGL2RenderingContext | null;\n\n const gl =\n externalGLContext ||\n createBrowserContext(\n this.canvasContext.canvas,\n {\n onContextLost: (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'\n }),\n // eslint-disable-next-line no-console\n onContextRestored: (event: Event) => console.log('WebGL context restored')\n },\n webglContextAttributes\n );\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n // @ts-expect-error device is attached to context\n device = gl.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n this.handle = gl;\n this.gl = gl;\n\n // Add spector debug instrumentation to context\n // We need to trust spector integration to decide if spector should be initialized\n // We also run spector instrumentation first, otherwise spector can clobber luma instrumentation.\n this.spectorJS = initializeSpectorJS({...this.props, gl: this.handle});\n\n // Instrument context\n (this.gl as any).device = this; // Update GL context: Link webgl context back to device\n (this.gl as any)._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)\n\n // initialize luma Device fields\n this.info = getDeviceInfo(this.gl, this._extensions);\n this.limits = new WebGLDeviceLimits(this.gl);\n this.features = new WebGLDeviceFeatures(\n this.gl,\n this._extensions,\n this.props._disabledFeatures\n );\n if (this.props._initializeFeatures) {\n this.features.initializeFeatures();\n }\n\n if (canvasContextProps.autoResize !== false) {\n this.canvasContext.resize();\n }\n\n // Install context state tracking\n const glState = new WebGLStateTracker(this.gl, {\n log: (...args: any[]) => log.log(1, ...args)()\n });\n glState.trackState(this.gl, {copyState: false});\n\n // DEBUG contexts: Add luma debug instrumentation to the context, force log level to at least 1\n const debugWebGL = props.debugWebGL || props.debug;\n const traceWebGL = props.debugWebGL;\n if (debugWebGL) {\n this.gl = makeDebugContext(this.gl, {debugWebGL, traceWebGL});\n log.warn('WebGL debug mode activated. Performance reduced.')();\n if (props.debugWebGL) {\n log.level = Math.max(log.level, 1);\n }\n }\n }\n\n /**\n * Destroys the context\n * @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {}\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {\n const newProps = this._normalizeBufferProps(props);\n return new WEBGLBuffer(this, newProps);\n }\n\n createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(this, props);\n }\n\n createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {\n return new WEBGLTransformFeedback(this, props);\n }\n\n createQuerySet(props: QuerySetProps): WEBGLQuerySet {\n return new WEBGLQuerySet(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('ComputePass not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n override createCommandEncoder(props: CommandEncoderProps = {}): WEBGLCommandEncoder {\n return new WEBGLCommandEncoder(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.end();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // TEMPORARY HACKS - will be removed in v9.1\n //\n\n /** @deprecated - should use command encoder */\n override readPixelsToArrayWebGL(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Uint8Array | Uint16Array | Float32Array {\n return readPixelsToArray(source, options);\n }\n\n /** @deprecated - should use command encoder */\n override readPixelsToBufferWebGL(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Buffer {\n return readPixelsToBuffer(source, options);\n }\n\n override setParametersWebGL(parameters: any): void {\n setGLParameters(this.gl, parameters);\n }\n\n override getParametersWebGL(parameters: any): any {\n return getGLParameters(this.gl, parameters);\n }\n\n override withParametersWebGL(parameters: any, func: any): any {\n return withGLParameters(this.gl, parameters, func);\n }\n\n override resetWebGL(): void {\n log.warn('WebGLDevice.resetWebGL is deprecated, use only for debugging')();\n resetGLParameters(this.gl);\n }\n\n override _getDeviceSpecificTextureFormatCapabilities(\n capabilities: DeviceTextureFormatCapabilities\n ): DeviceTextureFormatCapabilities {\n return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this._extensions);\n }\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /**\n * Triggers device (or WebGL context) loss.\n * @note primarily intended for testing how application reacts to device loss\n */\n override loseDevice(): boolean {\n let deviceLossTriggered = false;\n const extensions = this.getExtension('WEBGL_lose_context');\n const ext = extensions.WEBGL_lose_context;\n if (ext) {\n deviceLossTriggered = true;\n ext.loseContext();\n // ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly\n }\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n return deviceLossTriggered;\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n const webglState = WebGLStateTracker.get(this.gl);\n webglState.push();\n }\n\n /** Restores previously saved context state */\n popState(): void {\n const webglState = WebGLStateTracker.get(this.gl);\n webglState.pop();\n }\n\n /**\n * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension\n * luma.gl ids and props can be inspected\n */\n setSpectorMetadata(handle: unknown, props: Record) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL. constant that corresponds to a numeric value of a GL constant\n * Be aware that there are some duplicates especially for constants that are 0,\n * so this isn't guaranteed to return the right key in all cases.\n */\n getGLKey(value: unknown, options?: {emptyIfUnknown?: boolean}): string {\n const number = Number(value);\n for (const key in this.gl) {\n // @ts-ignore expect-error depends on settings\n if (this.gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return options?.emptyIfUnknown ? '' : String(value);\n }\n\n /**\n * Returns a map with any GL. constants mapped to strings, both for keys and values\n */\n getGLKeys(glParameters: Record): Record {\n const opts = {emptyIfUnknown: true};\n return Object.entries(glParameters).reduce>((keys, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n keys[`${key}:${this.getGLKey(key, opts)}`] = `${value}:${this.getGLKey(value, opts)}`;\n return keys;\n }, {});\n }\n\n /** Store constants */\n _constants: (TypedArray | null)[];\n\n /**\n * Set a constant value for a location. Disabled attributes at that location will read from this value\n * @note WebGL constants are stored globally on the WebGL context, not the VertexArray\n * so they need to be updated before every render\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstantAttributeWebGL(location: number, constant: TypedArray): void {\n const maxVertexAttributes = this.limits.maxVertexAttributes;\n this._constants = this._constants || new Array(maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(\n 1,\n `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`\n )();\n }\n this._constants[location] = constant;\n\n switch (constant.constructor) {\n case Float32Array:\n setConstantFloatArray(this, location, constant as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this, location, constant as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this, location, constant as Uint32Array);\n break;\n default:\n throw new Error('constant');\n }\n }\n\n /** Ensure extensions are only requested once */\n getExtension(name: keyof GLExtensions): GLExtensions {\n getWebGLExtension(this.gl, name, this._extensions);\n return this._extensions;\n }\n}\n\n/** Set constant float array attribute */\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n // assert(false);\n }\n}\n\n/** Set constant signed int array attribute */\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.gl.vertexAttribI4iv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** Set constant unsigned int array attribute */\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.gl.vertexAttribI4uiv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/**\n * Compares contents of two typed arrays\n * @todo max length?\n */\nfunction compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Tables describing WebGL parameters\nimport {GL, GLParameters} from '@luma.gl/constants';\n\n// DEFAULT SETTINGS - FOR FAST CACHE INITIALIZATION AND CONTEXT RESETS\n\n/* eslint-disable no-shadow */\n\nexport const GL_PARAMETER_DEFAULTS: GLParameters = {\n [GL.BLEND]: false,\n [GL.BLEND_COLOR]: new Float32Array([0, 0, 0, 0]),\n [GL.BLEND_EQUATION_RGB]: GL.FUNC_ADD,\n [GL.BLEND_EQUATION_ALPHA]: GL.FUNC_ADD,\n [GL.BLEND_SRC_RGB]: GL.ONE,\n [GL.BLEND_DST_RGB]: GL.ZERO,\n [GL.BLEND_SRC_ALPHA]: GL.ONE,\n [GL.BLEND_DST_ALPHA]: GL.ZERO,\n [GL.COLOR_CLEAR_VALUE]: new Float32Array([0, 0, 0, 0]), // TBD\n [GL.COLOR_WRITEMASK]: [true, true, true, true],\n [GL.CULL_FACE]: false,\n [GL.CULL_FACE_MODE]: GL.BACK,\n [GL.DEPTH_TEST]: false,\n [GL.DEPTH_CLEAR_VALUE]: 1,\n [GL.DEPTH_FUNC]: GL.LESS,\n [GL.DEPTH_RANGE]: new Float32Array([0, 1]), // TBD\n [GL.DEPTH_WRITEMASK]: true,\n [GL.DITHER]: true,\n [GL.CURRENT_PROGRAM]: null,\n // FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.\n [GL.FRAMEBUFFER_BINDING]: null,\n [GL.RENDERBUFFER_BINDING]: null,\n [GL.VERTEX_ARRAY_BINDING]: null,\n [GL.ARRAY_BUFFER_BINDING]: null,\n [GL.FRONT_FACE]: GL.CCW,\n [GL.GENERATE_MIPMAP_HINT]: GL.DONT_CARE,\n [GL.LINE_WIDTH]: 1,\n [GL.POLYGON_OFFSET_FILL]: false,\n [GL.POLYGON_OFFSET_FACTOR]: 0,\n [GL.POLYGON_OFFSET_UNITS]: 0,\n [GL.SAMPLE_ALPHA_TO_COVERAGE]: false,\n [GL.SAMPLE_COVERAGE]: false,\n [GL.SAMPLE_COVERAGE_VALUE]: 1.0,\n [GL.SAMPLE_COVERAGE_INVERT]: false,\n [GL.SCISSOR_TEST]: false,\n // Note: Dynamic value. If scissor test enabled we expect users to set correct scissor box\n [GL.SCISSOR_BOX]: new Int32Array([0, 0, 1024, 1024]),\n [GL.STENCIL_TEST]: false,\n [GL.STENCIL_CLEAR_VALUE]: 0,\n [GL.STENCIL_WRITEMASK]: 0xffffffff,\n [GL.STENCIL_BACK_WRITEMASK]: 0xffffffff,\n [GL.STENCIL_FUNC]: GL.ALWAYS,\n [GL.STENCIL_REF]: 0,\n [GL.STENCIL_VALUE_MASK]: 0xffffffff,\n [GL.STENCIL_BACK_FUNC]: GL.ALWAYS,\n [GL.STENCIL_BACK_REF]: 0,\n [GL.STENCIL_BACK_VALUE_MASK]: 0xffffffff,\n [GL.STENCIL_FAIL]: GL.KEEP,\n [GL.STENCIL_PASS_DEPTH_FAIL]: GL.KEEP,\n [GL.STENCIL_PASS_DEPTH_PASS]: GL.KEEP,\n [GL.STENCIL_BACK_FAIL]: GL.KEEP,\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]: GL.KEEP,\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]: GL.KEEP,\n // Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.\n [GL.VIEWPORT]: [0, 0, 1024, 1024],\n\n [GL.TRANSFORM_FEEDBACK_BINDING]: null,\n [GL.COPY_READ_BUFFER_BINDING]: null,\n [GL.COPY_WRITE_BUFFER_BINDING]: null,\n [GL.PIXEL_PACK_BUFFER_BINDING]: null,\n [GL.PIXEL_UNPACK_BUFFER_BINDING]: null,\n [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: GL.DONT_CARE,\n [GL.READ_FRAMEBUFFER_BINDING]: null,\n [GL.RASTERIZER_DISCARD]: false,\n\n [GL.PACK_ALIGNMENT]: 4,\n [GL.UNPACK_ALIGNMENT]: 4,\n [GL.UNPACK_FLIP_Y_WEBGL]: false,\n [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: false,\n [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: GL.BROWSER_DEFAULT_WEBGL,\n [GL.PACK_ROW_LENGTH]: 0,\n [GL.PACK_SKIP_PIXELS]: 0,\n [GL.PACK_SKIP_ROWS]: 0,\n [GL.UNPACK_ROW_LENGTH]: 0,\n [GL.UNPACK_IMAGE_HEIGHT]: 0,\n [GL.UNPACK_SKIP_PIXELS]: 0,\n [GL.UNPACK_SKIP_ROWS]: 0,\n [GL.UNPACK_SKIP_IMAGES]: 0\n};\n\n// SETTER TABLES - ENABLES SETTING ANY PARAMETER WITH A COMMON API\n\nconst enable = (gl: WebGL2RenderingContext, value: unknown, key: GL) =>\n value ? gl.enable(key) : gl.disable(key);\nconst hint = (gl: WebGL2RenderingContext, value: GL, key: GL) => gl.hint(key, value);\nconst pixelStorei = (gl: WebGL2RenderingContext, value: number | boolean, key: GL) =>\n gl.pixelStorei(key, value);\n\nconst bindFramebuffer = (gl: WebGL2RenderingContext, value: unknown, key: GL) => {\n const target = key === GL.FRAMEBUFFER_BINDING ? GL.DRAW_FRAMEBUFFER : GL.READ_FRAMEBUFFER;\n return gl.bindFramebuffer(target, value as WebGLFramebuffer);\n};\n\nconst bindBuffer = (gl: WebGL2RenderingContext, value: unknown, key: GL) => {\n const bindingMap: Partial> = {\n [GL.ARRAY_BUFFER_BINDING]: GL.ARRAY_BUFFER,\n [GL.COPY_READ_BUFFER_BINDING]: GL.COPY_READ_BUFFER,\n [GL.COPY_WRITE_BUFFER_BINDING]: GL.COPY_WRITE_BUFFER,\n [GL.PIXEL_PACK_BUFFER_BINDING]: GL.PIXEL_PACK_BUFFER,\n [GL.PIXEL_UNPACK_BUFFER_BINDING]: GL.PIXEL_UNPACK_BUFFER\n };\n const glTarget = bindingMap[key];\n\n gl.bindBuffer(glTarget as number, value as WebGLBuffer | null);\n};\n\n// Utility\nfunction isArray(array: unknown): boolean {\n return Array.isArray(array) || (ArrayBuffer.isView(array) && !(array instanceof DataView));\n}\n\n// Map from WebGL parameter names to corresponding WebGL setter functions\n// WegGL constants are read by parameter names, but set by function names\n// NOTE: When value type is a string, it will be handled by 'GL_COMPOSITE_PARAMETER_SETTERS'\nexport const GL_PARAMETER_SETTERS = {\n [GL.BLEND]: enable,\n [GL.BLEND_COLOR]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.blendColor(...value),\n [GL.BLEND_EQUATION_RGB]: 'blendEquation',\n [GL.BLEND_EQUATION_ALPHA]: 'blendEquation',\n [GL.BLEND_SRC_RGB]: 'blendFunc',\n [GL.BLEND_DST_RGB]: 'blendFunc',\n [GL.BLEND_SRC_ALPHA]: 'blendFunc',\n [GL.BLEND_DST_ALPHA]: 'blendFunc',\n [GL.COLOR_CLEAR_VALUE]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.clearColor(...value),\n [GL.COLOR_WRITEMASK]: (gl: WebGL2RenderingContext, value: [boolean, boolean, boolean, boolean]) =>\n gl.colorMask(...value),\n [GL.CULL_FACE]: enable,\n [GL.CULL_FACE_MODE]: (gl: WebGL2RenderingContext, value) => gl.cullFace(value),\n [GL.DEPTH_TEST]: enable,\n [GL.DEPTH_CLEAR_VALUE]: (gl: WebGL2RenderingContext, value) => gl.clearDepth(value),\n [GL.DEPTH_FUNC]: (gl: WebGL2RenderingContext, value) => gl.depthFunc(value),\n [GL.DEPTH_RANGE]: (gl: WebGL2RenderingContext, value: [number, number]) =>\n gl.depthRange(...value),\n [GL.DEPTH_WRITEMASK]: (gl: WebGL2RenderingContext, value) => gl.depthMask(value),\n [GL.DITHER]: enable,\n [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: hint,\n\n [GL.CURRENT_PROGRAM]: (gl: WebGL2RenderingContext, value) => gl.useProgram(value),\n [GL.RENDERBUFFER_BINDING]: (gl: WebGL2RenderingContext, value) =>\n gl.bindRenderbuffer(GL.RENDERBUFFER, value),\n [GL.TRANSFORM_FEEDBACK_BINDING]: (gl: WebGL2RenderingContext, value) =>\n gl.bindTransformFeedback?.(GL.TRANSFORM_FEEDBACK, value),\n [GL.VERTEX_ARRAY_BINDING]: (gl: WebGL2RenderingContext, value) => gl.bindVertexArray(value),\n // NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.\n [GL.FRAMEBUFFER_BINDING]: bindFramebuffer,\n [GL.READ_FRAMEBUFFER_BINDING]: bindFramebuffer,\n\n // Buffers\n [GL.ARRAY_BUFFER_BINDING]: bindBuffer,\n [GL.COPY_READ_BUFFER_BINDING]: bindBuffer,\n [GL.COPY_WRITE_BUFFER_BINDING]: bindBuffer,\n [GL.PIXEL_PACK_BUFFER_BINDING]: bindBuffer,\n [GL.PIXEL_UNPACK_BUFFER_BINDING]: bindBuffer,\n\n [GL.FRONT_FACE]: (gl: WebGL2RenderingContext, value) => gl.frontFace(value),\n [GL.GENERATE_MIPMAP_HINT]: hint,\n [GL.LINE_WIDTH]: (gl: WebGL2RenderingContext, value) => gl.lineWidth(value),\n [GL.POLYGON_OFFSET_FILL]: enable,\n [GL.POLYGON_OFFSET_FACTOR]: 'polygonOffset',\n [GL.POLYGON_OFFSET_UNITS]: 'polygonOffset',\n [GL.RASTERIZER_DISCARD]: enable,\n [GL.SAMPLE_ALPHA_TO_COVERAGE]: enable,\n [GL.SAMPLE_COVERAGE]: enable,\n [GL.SAMPLE_COVERAGE_VALUE]: 'sampleCoverage',\n [GL.SAMPLE_COVERAGE_INVERT]: 'sampleCoverage',\n [GL.SCISSOR_TEST]: enable,\n [GL.SCISSOR_BOX]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.scissor(...value),\n [GL.STENCIL_TEST]: enable,\n [GL.STENCIL_CLEAR_VALUE]: (gl: WebGL2RenderingContext, value) => gl.clearStencil(value),\n [GL.STENCIL_WRITEMASK]: (gl: WebGL2RenderingContext, value) =>\n gl.stencilMaskSeparate(GL.FRONT, value),\n [GL.STENCIL_BACK_WRITEMASK]: (gl: WebGL2RenderingContext, value) =>\n gl.stencilMaskSeparate(GL.BACK, value),\n [GL.STENCIL_FUNC]: 'stencilFuncFront',\n [GL.STENCIL_REF]: 'stencilFuncFront',\n [GL.STENCIL_VALUE_MASK]: 'stencilFuncFront',\n [GL.STENCIL_BACK_FUNC]: 'stencilFuncBack',\n [GL.STENCIL_BACK_REF]: 'stencilFuncBack',\n [GL.STENCIL_BACK_VALUE_MASK]: 'stencilFuncBack',\n [GL.STENCIL_FAIL]: 'stencilOpFront',\n [GL.STENCIL_PASS_DEPTH_FAIL]: 'stencilOpFront',\n [GL.STENCIL_PASS_DEPTH_PASS]: 'stencilOpFront',\n [GL.STENCIL_BACK_FAIL]: 'stencilOpBack',\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]: 'stencilOpBack',\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]: 'stencilOpBack',\n [GL.VIEWPORT]: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.viewport(...value),\n\n // WEBGL2 EXTENSIONS\n\n // EXT_depth_clamp https://registry.khronos.org/webgl/extensions/EXT_depth_clamp/\n\n [GL.DEPTH_CLAMP_EXT]: enable,\n\n // WEBGL_provoking_vertex https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/\n\n // [GL.PROVOKING_VERTEX_WEBL]: TODO - extension function needed\n\n // WEBGL_polygon_mode https://registry.khronos.org/webgl/extensions/WEBGL_polygon_mode/\n\n // POLYGON_MODE_WEBGL TODO - extension function needed\n [GL.POLYGON_OFFSET_LINE_WEBGL]: enable,\n\n // WEBGL_clip_cull_distance https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/\n\n [GL.CLIP_DISTANCE0_WEBGL]: enable,\n [GL.CLIP_DISTANCE1_WEBGL]: enable,\n [GL.CLIP_DISTANCE2_WEBGL]: enable,\n [GL.CLIP_DISTANCE3_WEBGL]: enable,\n [GL.CLIP_DISTANCE4_WEBGL]: enable,\n [GL.CLIP_DISTANCE5_WEBGL]: enable,\n [GL.CLIP_DISTANCE6_WEBGL]: enable,\n [GL.CLIP_DISTANCE7_WEBGL]: enable,\n\n // PIXEL PACK/UNPACK MODES\n [GL.PACK_ALIGNMENT]: pixelStorei,\n [GL.UNPACK_ALIGNMENT]: pixelStorei,\n [GL.UNPACK_FLIP_Y_WEBGL]: pixelStorei,\n [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]: pixelStorei,\n [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]: pixelStorei,\n [GL.PACK_ROW_LENGTH]: pixelStorei,\n [GL.PACK_SKIP_PIXELS]: pixelStorei,\n [GL.PACK_SKIP_ROWS]: pixelStorei,\n [GL.UNPACK_ROW_LENGTH]: pixelStorei,\n [GL.UNPACK_IMAGE_HEIGHT]: pixelStorei,\n [GL.UNPACK_SKIP_PIXELS]: pixelStorei,\n [GL.UNPACK_SKIP_ROWS]: pixelStorei,\n [GL.UNPACK_SKIP_IMAGES]: pixelStorei,\n\n // Function-style setters\n framebuffer: (gl: WebGL2RenderingContext, framebuffer) => {\n // accepts 1) a WebGLFramebuffer 2) null (default framebuffer), or 3) luma.gl Framebuffer class\n // framebuffer is null when restoring to default framebuffer, otherwise use the WebGL handle.\n const handle = framebuffer && 'handle' in framebuffer ? framebuffer.handle : framebuffer;\n return gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n },\n blend: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.BLEND) : gl.disable(GL.BLEND),\n blendColor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.blendColor(...value),\n blendEquation: (gl: WebGL2RenderingContext, args: number | [number, number]) => {\n const separateModes = typeof args === 'number' ? ([args, args] as [number, number]) : args;\n gl.blendEquationSeparate(...separateModes);\n },\n blendFunc: (\n gl: WebGL2RenderingContext,\n args: [number, number] | [number, number, number, number]\n ) => {\n const separateFuncs =\n args?.length === 2 ? ([...args, ...args] as [number, number, number, number]) : args;\n gl.blendFuncSeparate(...separateFuncs);\n },\n\n clearColor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.clearColor(...value),\n clearDepth: (gl: WebGL2RenderingContext, value) => gl.clearDepth(value),\n clearStencil: (gl: WebGL2RenderingContext, value) => gl.clearStencil(value),\n\n colorMask: (gl: WebGL2RenderingContext, value: [boolean, boolean, boolean, boolean]) =>\n gl.colorMask(...value),\n\n cull: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.CULL_FACE) : gl.disable(GL.CULL_FACE),\n cullFace: (gl: WebGL2RenderingContext, value) => gl.cullFace(value),\n\n depthTest: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.DEPTH_TEST) : gl.disable(GL.DEPTH_TEST),\n depthFunc: (gl: WebGL2RenderingContext, value) => gl.depthFunc(value),\n depthMask: (gl: WebGL2RenderingContext, value) => gl.depthMask(value),\n depthRange: (gl: WebGL2RenderingContext, value: [number, number]) => gl.depthRange(...value),\n\n dither: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.DITHER) : gl.disable(GL.DITHER),\n\n derivativeHint: (gl: WebGL2RenderingContext, value) => {\n // gl1: 'OES_standard_derivatives'\n gl.hint(GL.FRAGMENT_SHADER_DERIVATIVE_HINT, value);\n },\n\n frontFace: (gl: WebGL2RenderingContext, value) => gl.frontFace(value),\n\n mipmapHint: (gl: WebGL2RenderingContext, value) => gl.hint(GL.GENERATE_MIPMAP_HINT, value),\n\n lineWidth: (gl: WebGL2RenderingContext, value) => gl.lineWidth(value),\n\n polygonOffsetFill: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.POLYGON_OFFSET_FILL) : gl.disable(GL.POLYGON_OFFSET_FILL),\n polygonOffset: (gl: WebGL2RenderingContext, value: [number, number]) =>\n gl.polygonOffset(...value),\n\n sampleCoverage: (gl: WebGL2RenderingContext, value: [number, boolean?]) =>\n gl.sampleCoverage(value[0], value[1] || false),\n\n scissorTest: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.SCISSOR_TEST) : gl.disable(GL.SCISSOR_TEST),\n scissor: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.scissor(...value),\n\n stencilTest: (gl: WebGL2RenderingContext, value) =>\n value ? gl.enable(GL.STENCIL_TEST) : gl.disable(GL.STENCIL_TEST),\n stencilMask: (gl: WebGL2RenderingContext, value) => {\n value = isArray(value) ? value : [value, value];\n const [mask, backMask] = value;\n gl.stencilMaskSeparate(GL.FRONT, mask);\n gl.stencilMaskSeparate(GL.BACK, backMask);\n },\n stencilFunc: (gl: WebGL2RenderingContext, args) => {\n args = isArray(args) && args.length === 3 ? [...args, ...args] : args;\n const [func, ref, mask, backFunc, backRef, backMask] = args;\n gl.stencilFuncSeparate(GL.FRONT, func, ref, mask);\n gl.stencilFuncSeparate(GL.BACK, backFunc, backRef, backMask);\n },\n stencilOp: (gl: WebGL2RenderingContext, args) => {\n args = isArray(args) && args.length === 3 ? [...args, ...args] : args;\n const [sfail, dpfail, dppass, backSfail, backDpfail, backDppass] = args;\n gl.stencilOpSeparate(GL.FRONT, sfail, dpfail, dppass);\n gl.stencilOpSeparate(GL.BACK, backSfail, backDpfail, backDppass);\n },\n\n viewport: (gl: WebGL2RenderingContext, value: [number, number, number, number]) =>\n gl.viewport(...value)\n};\n\nfunction getValue(glEnum, values, cache) {\n return values[glEnum] !== undefined ? values[glEnum] : cache[glEnum];\n}\n\n// COMPOSITE_WEBGL_PARAMETER_\nexport const GL_COMPOSITE_PARAMETER_SETTERS = {\n blendEquation: (gl: WebGL2RenderingContext, values, cache) =>\n gl.blendEquationSeparate(\n getValue(GL.BLEND_EQUATION_RGB, values, cache),\n getValue(GL.BLEND_EQUATION_ALPHA, values, cache)\n ),\n blendFunc: (gl: WebGL2RenderingContext, values, cache) =>\n gl.blendFuncSeparate(\n getValue(GL.BLEND_SRC_RGB, values, cache),\n getValue(GL.BLEND_DST_RGB, values, cache),\n getValue(GL.BLEND_SRC_ALPHA, values, cache),\n getValue(GL.BLEND_DST_ALPHA, values, cache)\n ),\n polygonOffset: (gl: WebGL2RenderingContext, values, cache) =>\n gl.polygonOffset(\n getValue(GL.POLYGON_OFFSET_FACTOR, values, cache),\n getValue(GL.POLYGON_OFFSET_UNITS, values, cache)\n ),\n sampleCoverage: (gl: WebGL2RenderingContext, values, cache) =>\n gl.sampleCoverage(\n getValue(GL.SAMPLE_COVERAGE_VALUE, values, cache),\n getValue(GL.SAMPLE_COVERAGE_INVERT, values, cache)\n ),\n stencilFuncFront: (gl: WebGL2RenderingContext, values, cache) =>\n gl.stencilFuncSeparate(\n GL.FRONT,\n getValue(GL.STENCIL_FUNC, values, cache),\n getValue(GL.STENCIL_REF, values, cache),\n getValue(GL.STENCIL_VALUE_MASK, values, cache)\n ),\n stencilFuncBack: (gl: WebGL2RenderingContext, values, cache) =>\n gl.stencilFuncSeparate(\n GL.BACK,\n getValue(GL.STENCIL_BACK_FUNC, values, cache),\n getValue(GL.STENCIL_BACK_REF, values, cache),\n getValue(GL.STENCIL_BACK_VALUE_MASK, values, cache)\n ),\n stencilOpFront: (gl: WebGL2RenderingContext, values, cache) =>\n gl.stencilOpSeparate(\n GL.FRONT,\n getValue(GL.STENCIL_FAIL, values, cache),\n getValue(GL.STENCIL_PASS_DEPTH_FAIL, values, cache),\n getValue(GL.STENCIL_PASS_DEPTH_PASS, values, cache)\n ),\n stencilOpBack: (gl: WebGL2RenderingContext, values, cache) =>\n gl.stencilOpSeparate(\n GL.BACK,\n getValue(GL.STENCIL_BACK_FAIL, values, cache),\n getValue(GL.STENCIL_BACK_PASS_DEPTH_FAIL, values, cache),\n getValue(GL.STENCIL_BACK_PASS_DEPTH_PASS, values, cache)\n )\n};\n\ntype UpdateFunc = (params: Record) => void;\n\n// Setter functions intercepted for cache updates\nexport const GL_HOOKED_SETTERS = {\n // GENERIC SETTERS\n\n enable: (update: UpdateFunc, capability: GL) =>\n update({\n [capability]: true\n }),\n disable: (update: UpdateFunc, capability: GL) =>\n update({\n [capability]: false\n }),\n pixelStorei: (update: UpdateFunc, pname: GL, value) =>\n update({\n [pname]: value\n }),\n hint: (update: UpdateFunc, pname: GL, value: GL) =>\n update({\n [pname]: value\n }),\n\n // SPECIFIC SETTERS\n useProgram: (update: UpdateFunc, value) =>\n update({\n [GL.CURRENT_PROGRAM]: value\n }),\n bindRenderbuffer: (update: UpdateFunc, target, value) =>\n update({\n [GL.RENDERBUFFER_BINDING]: value\n }),\n bindTransformFeedback: (update: UpdateFunc, target, value) =>\n update({\n [GL.TRANSFORM_FEEDBACK_BINDING]: value\n }),\n bindVertexArray: (update: UpdateFunc, value) =>\n update({\n [GL.VERTEX_ARRAY_BINDING]: value\n }),\n\n bindFramebuffer: (update: UpdateFunc, target, framebuffer) => {\n switch (target) {\n case GL.FRAMEBUFFER:\n return update({\n [GL.DRAW_FRAMEBUFFER_BINDING]: framebuffer,\n [GL.READ_FRAMEBUFFER_BINDING]: framebuffer\n });\n case GL.DRAW_FRAMEBUFFER:\n return update({[GL.DRAW_FRAMEBUFFER_BINDING]: framebuffer});\n case GL.READ_FRAMEBUFFER:\n return update({[GL.READ_FRAMEBUFFER_BINDING]: framebuffer});\n default:\n return null;\n }\n },\n bindBuffer: (update: UpdateFunc, target, buffer) => {\n const pname = {\n [GL.ARRAY_BUFFER]: [GL.ARRAY_BUFFER_BINDING],\n [GL.COPY_READ_BUFFER]: [GL.COPY_READ_BUFFER_BINDING],\n [GL.COPY_WRITE_BUFFER]: [GL.COPY_WRITE_BUFFER_BINDING],\n [GL.PIXEL_PACK_BUFFER]: [GL.PIXEL_PACK_BUFFER_BINDING],\n [GL.PIXEL_UNPACK_BUFFER]: [GL.PIXEL_UNPACK_BUFFER_BINDING]\n }[target];\n\n if (pname) {\n return update({[pname]: buffer});\n }\n // targets that should not be cached\n return {valueChanged: true};\n },\n\n blendColor: (update: UpdateFunc, r: number, g: number, b: number, a: number) =>\n update({\n [GL.BLEND_COLOR]: new Float32Array([r, g, b, a])\n }),\n\n blendEquation: (update: UpdateFunc, mode) =>\n update({\n [GL.BLEND_EQUATION_RGB]: mode,\n [GL.BLEND_EQUATION_ALPHA]: mode\n }),\n\n blendEquationSeparate: (update: UpdateFunc, modeRGB, modeAlpha) =>\n update({\n [GL.BLEND_EQUATION_RGB]: modeRGB,\n [GL.BLEND_EQUATION_ALPHA]: modeAlpha\n }),\n\n blendFunc: (update: UpdateFunc, src, dst) =>\n update({\n [GL.BLEND_SRC_RGB]: src,\n [GL.BLEND_DST_RGB]: dst,\n [GL.BLEND_SRC_ALPHA]: src,\n [GL.BLEND_DST_ALPHA]: dst\n }),\n\n blendFuncSeparate: (update: UpdateFunc, srcRGB, dstRGB, srcAlpha, dstAlpha) =>\n update({\n [GL.BLEND_SRC_RGB]: srcRGB,\n [GL.BLEND_DST_RGB]: dstRGB,\n [GL.BLEND_SRC_ALPHA]: srcAlpha,\n [GL.BLEND_DST_ALPHA]: dstAlpha\n }),\n\n clearColor: (update: UpdateFunc, r: number, g: number, b: number, a: number) =>\n update({\n [GL.COLOR_CLEAR_VALUE]: new Float32Array([r, g, b, a])\n }),\n\n clearDepth: (update: UpdateFunc, depth: number) =>\n update({\n [GL.DEPTH_CLEAR_VALUE]: depth\n }),\n\n clearStencil: (update: UpdateFunc, s: number) =>\n update({\n [GL.STENCIL_CLEAR_VALUE]: s\n }),\n\n colorMask: (update: UpdateFunc, r: number, g: number, b: number, a: number) =>\n update({\n [GL.COLOR_WRITEMASK]: [r, g, b, a]\n }),\n\n cullFace: (update: UpdateFunc, mode) =>\n update({\n [GL.CULL_FACE_MODE]: mode\n }),\n\n depthFunc: (update: UpdateFunc, func) =>\n update({\n [GL.DEPTH_FUNC]: func\n }),\n\n depthRange: (update: UpdateFunc, zNear: number, zFar: number) =>\n update({\n [GL.DEPTH_RANGE]: new Float32Array([zNear, zFar])\n }),\n\n depthMask: (update: UpdateFunc, mask: number) =>\n update({\n [GL.DEPTH_WRITEMASK]: mask\n }),\n\n frontFace: (update: UpdateFunc, face) =>\n update({\n [GL.FRONT_FACE]: face\n }),\n\n lineWidth: (update: UpdateFunc, width) =>\n update({\n [GL.LINE_WIDTH]: width\n }),\n\n polygonOffset: (update: UpdateFunc, factor, units) =>\n update({\n [GL.POLYGON_OFFSET_FACTOR]: factor,\n [GL.POLYGON_OFFSET_UNITS]: units\n }),\n\n sampleCoverage: (update: UpdateFunc, value, invert) =>\n update({\n [GL.SAMPLE_COVERAGE_VALUE]: value,\n [GL.SAMPLE_COVERAGE_INVERT]: invert\n }),\n\n scissor: (update: UpdateFunc, x, y, width, height) =>\n update({\n [GL.SCISSOR_BOX]: new Int32Array([x, y, width, height])\n }),\n\n stencilMask: (update: UpdateFunc, mask) =>\n update({\n [GL.STENCIL_WRITEMASK]: mask,\n [GL.STENCIL_BACK_WRITEMASK]: mask\n }),\n\n stencilMaskSeparate: (update: UpdateFunc, face, mask) =>\n update({\n [face === GL.FRONT ? GL.STENCIL_WRITEMASK : GL.STENCIL_BACK_WRITEMASK]: mask\n }),\n\n stencilFunc: (update: UpdateFunc, func, ref, mask) =>\n update({\n [GL.STENCIL_FUNC]: func,\n [GL.STENCIL_REF]: ref,\n [GL.STENCIL_VALUE_MASK]: mask,\n [GL.STENCIL_BACK_FUNC]: func,\n [GL.STENCIL_BACK_REF]: ref,\n [GL.STENCIL_BACK_VALUE_MASK]: mask\n }),\n\n stencilFuncSeparate: (update: UpdateFunc, face, func, ref, mask) =>\n update({\n [face === GL.FRONT ? GL.STENCIL_FUNC : GL.STENCIL_BACK_FUNC]: func,\n [face === GL.FRONT ? GL.STENCIL_REF : GL.STENCIL_BACK_REF]: ref,\n [face === GL.FRONT ? GL.STENCIL_VALUE_MASK : GL.STENCIL_BACK_VALUE_MASK]: mask\n }),\n\n stencilOp: (update: UpdateFunc, fail, zfail, zpass) =>\n update({\n [GL.STENCIL_FAIL]: fail,\n [GL.STENCIL_PASS_DEPTH_FAIL]: zfail,\n [GL.STENCIL_PASS_DEPTH_PASS]: zpass,\n [GL.STENCIL_BACK_FAIL]: fail,\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]: zfail,\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]: zpass\n }),\n\n stencilOpSeparate: (update: UpdateFunc, face, fail, zfail, zpass) =>\n update({\n [face === GL.FRONT ? GL.STENCIL_FAIL : GL.STENCIL_BACK_FAIL]: fail,\n [face === GL.FRONT ? GL.STENCIL_PASS_DEPTH_FAIL : GL.STENCIL_BACK_PASS_DEPTH_FAIL]: zfail,\n [face === GL.FRONT ? GL.STENCIL_PASS_DEPTH_PASS : GL.STENCIL_BACK_PASS_DEPTH_PASS]: zpass\n }),\n\n viewport: (update: UpdateFunc, x, y, width, height) =>\n update({\n [GL.VIEWPORT]: [x, y, width, height]\n })\n};\n\n// GETTER TABLE - FOR READING OUT AN ENTIRE CONTEXT\n\nconst isEnabled = (gl: WebGL2RenderingContext, key) => gl.isEnabled(key);\n\n// Exceptions for any keys that cannot be queried by gl.getParameters\nexport const GL_PARAMETER_GETTERS = {\n [GL.BLEND]: isEnabled,\n [GL.CULL_FACE]: isEnabled,\n [GL.DEPTH_TEST]: isEnabled,\n [GL.DITHER]: isEnabled,\n [GL.POLYGON_OFFSET_FILL]: isEnabled,\n [GL.SAMPLE_ALPHA_TO_COVERAGE]: isEnabled,\n [GL.SAMPLE_COVERAGE]: isEnabled,\n [GL.SCISSOR_TEST]: isEnabled,\n [GL.STENCIL_TEST]: isEnabled,\n [GL.RASTERIZER_DISCARD]: isEnabled\n};\n\nexport const NON_CACHE_PARAMETERS = new Set([\n // setter not intercepted\n GL.ACTIVE_TEXTURE,\n GL.TRANSFORM_FEEDBACK_ACTIVE,\n GL.TRANSFORM_FEEDBACK_PAUSED,\n\n // setters bindBufferRange/bindBufferBase cannot be pruned based on cache\n GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,\n GL.UNIFORM_BUFFER_BINDING,\n\n // states depending on VERTEX_ARRAY_BINDING\n GL.ELEMENT_ARRAY_BUFFER_BINDING,\n // states depending on READ_FRAMEBUFFER_BINDING\n GL.IMPLEMENTATION_COLOR_READ_FORMAT,\n GL.IMPLEMENTATION_COLOR_READ_TYPE,\n // states depending on FRAMEBUFFER_BINDING\n GL.READ_BUFFER,\n GL.DRAW_BUFFER0,\n GL.DRAW_BUFFER1,\n GL.DRAW_BUFFER2,\n GL.DRAW_BUFFER3,\n GL.DRAW_BUFFER4,\n GL.DRAW_BUFFER5,\n GL.DRAW_BUFFER6,\n GL.DRAW_BUFFER7,\n GL.DRAW_BUFFER8,\n GL.DRAW_BUFFER9,\n GL.DRAW_BUFFER10,\n GL.DRAW_BUFFER11,\n GL.DRAW_BUFFER12,\n GL.DRAW_BUFFER13,\n GL.DRAW_BUFFER14,\n GL.DRAW_BUFFER15,\n // states depending on ACTIVE_TEXTURE\n GL.SAMPLER_BINDING,\n GL.TEXTURE_BINDING_2D,\n GL.TEXTURE_BINDING_2D_ARRAY,\n GL.TEXTURE_BINDING_3D,\n GL.TEXTURE_BINDING_CUBE_MAP\n]);\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Provides a unified API for getting and setting any WebGL parameter\n// Also knows default values of all parameters, enabling fast cache initialization\n// Provides base functionality for the state caching.\nimport type {GLParameters} from '@luma.gl/constants';\nimport {\n GL_PARAMETER_DEFAULTS,\n GL_PARAMETER_SETTERS,\n GL_COMPOSITE_PARAMETER_SETTERS,\n GL_PARAMETER_GETTERS\n} from './webgl-parameter-tables';\n\nexport type {GLParameters};\n\n/**\n * Sets any GL parameter regardless of function (gl.blendMode, ...)\n *\n * @note requires a `cache` object to be set on the context (gl.state.cache)\n * This object is used to fill in any missing values for composite setter functions\n */\nexport function setGLParameters(gl: WebGL2RenderingContext, parameters: GLParameters): void {\n if (isObjectEmpty(parameters)) {\n return;\n }\n\n const compositeSetters = {};\n\n // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)\n\n for (const key in parameters) {\n const glConstant = Number(key);\n const setter = GL_PARAMETER_SETTERS[key];\n if (setter) {\n // Composite setters should only be called once, so save them\n if (typeof setter === 'string') {\n compositeSetters[setter] = true;\n } else {\n // if (gl[glConstant] !== undefined) {\n // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...\n // TODO - deep equal on values? only call setter if value has changed?\n // NOTE - the setter will automatically update this.state\n setter(gl, parameters[key], glConstant);\n }\n }\n }\n\n // HANDLE COMPOSITE SETTERS\n\n // NOTE: any non-provided values needed by composite setters are filled in from state cache\n // The cache parameter is automatically retrieved from the context\n // This depends on `trackContextState`, which is technically a \"circular\" dependency.\n // But it is too inconvenient to always require a cache parameter here.\n // This is the ONLY external dependency in this module/\n // @ts-expect-error\n const cache = gl.state && gl.state.cache;\n if (cache) {\n for (const key in compositeSetters) {\n // TODO - avoid calling composite setters if values have not changed.\n const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];\n // Note - if `trackContextState` has been called,\n // the setter will automatically update this.state.cache\n compositeSetter(gl, parameters, cache);\n }\n }\n\n // Add a log for the else case?\n}\n\n/**\n * Reads the entire WebGL state from a context\n\n // default to querying all parameters\n\n * @returns - a newly created map, with values keyed by GL parameters\n *\n * @note Copies the state from a context (gl.getParameter should not be overriden)\n * Reads the entire WebGL state from a context\n *\n * @note This can generates a huge amount of synchronous driver roundtrips and should be\n * considered a very slow operation, to be used only if/when a context already manipulated\n * by external code needs to be synchronized for the first time\n */\nexport function getGLParameters(\n gl: WebGL2RenderingContext,\n parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS\n): GLParameters {\n // support both arrays of parameters and objects (keys represent parameters)\n\n if (typeof parameters === 'number') {\n // single GL enum\n const key = parameters;\n const getter = GL_PARAMETER_GETTERS[key];\n return getter ? getter(gl, key) : gl.getParameter(key);\n }\n\n const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);\n\n const state = {};\n for (const key of parameterKeys) {\n const getter = GL_PARAMETER_GETTERS[key];\n state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));\n }\n return state;\n}\n\n/**\n * Reset all parameters to a (almost) pure context state\n * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,\n * NOT the canvas size dimensions, so they will have to be properly set after\n * calling this function.\n */\nexport function resetGLParameters(gl: WebGL2RenderingContext): void {\n setGLParameters(gl, GL_PARAMETER_DEFAULTS);\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/** deeply compare two arrays */\nexport function deepArrayEqual(x: any, y: any): boolean {\n if (x === y) {\n return true;\n }\n const isArrayX = Array.isArray(x) || ArrayBuffer.isView(x);\n const isArrayY = Array.isArray(y) || ArrayBuffer.isView(y);\n // @ts-expect-error TODO fix\n if (isArrayX && isArrayY && x.length === y.length) {\n // @ts-expect-error TODO fix\n for (let i = 0; i < x.length; ++i) {\n if (x[i] !== y[i]) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {setGLParameters, getGLParameters} from '../parameters/unified-parameter-api';\nimport {deepArrayEqual} from './deep-array-equal';\nimport {\n GL_PARAMETER_DEFAULTS,\n GL_HOOKED_SETTERS,\n NON_CACHE_PARAMETERS\n} from '../parameters/webgl-parameter-tables';\n\n// HELPER CLASS - WebGLStateTracker\n\n/**\n * Support for listening to context state changes and intercepting state queries\n * NOTE: this system does not handle buffer bindings\n */\nexport class WebGLStateTracker {\n static get(gl: WebGL2RenderingContext): WebGLStateTracker {\n // @ts-expect-error\n return gl.state as WebGLStateTracker;\n }\n\n gl: WebGL2RenderingContext;\n program: unknown = null;\n stateStack: object[] = [];\n enable = true;\n cache: Record = null!;\n log;\n\n protected initialized = false;\n\n constructor(\n gl: WebGL2RenderingContext,\n props?: {\n log; // Logging function, called when gl parameter change calls are actually issued\n }\n ) {\n this.gl = gl;\n this.log = props?.log || (() => {});\n\n this._updateCache = this._updateCache.bind(this);\n Object.seal(this);\n }\n\n push(values = {}) {\n this.stateStack.push({});\n }\n\n pop() {\n // assert(this.stateStack.length > 0);\n // Use the saved values in the state stack to restore parameters\n const oldValues = this.stateStack[this.stateStack.length - 1];\n setGLParameters(this.gl, oldValues);\n // Don't pop until we have reset parameters (to make sure other \"stack frames\" are not affected)\n this.stateStack.pop();\n }\n\n /**\n * Initialize WebGL state caching on a context\n * can be called multiple times to enable/disable\n *\n * @note After calling this function, context state will be cached\n * .push() and .pop() will be available for saving,\n * temporarily modifying, and then restoring state.\n */\n trackState(gl: WebGL2RenderingContext, options?: {copyState?: boolean}): void {\n this.cache = options.copyState ? getGLParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);\n\n if (this.initialized) {\n throw new Error('WebGLStateTracker');\n }\n this.initialized = true;\n\n // @ts-expect-error\n this.gl.state = this;\n\n installProgramSpy(gl);\n\n // intercept all setter functions in the table\n for (const key in GL_HOOKED_SETTERS) {\n const setter = GL_HOOKED_SETTERS[key];\n installSetterSpy(gl, key, setter);\n }\n\n // intercept all getter functions in the table\n installGetterOverride(gl, 'getParameter');\n installGetterOverride(gl, 'isEnabled');\n }\n\n /**\n // interceptor for context set functions - update our cache and our stack\n // values (Object) - the key values for this setter\n * @param values\n * @returns\n */\n _updateCache(values: {[key: number | string]: any}) {\n let valueChanged = false;\n let oldValue; // = undefined\n\n const oldValues: {[key: number | string]: any} | null =\n this.stateStack.length > 0 ? this.stateStack[this.stateStack.length - 1] : null;\n\n for (const key in values) {\n // assert(key !== undefined);\n const value = values[key];\n const cached = this.cache[key];\n // Check that value hasn't already been shadowed\n if (!deepArrayEqual(value, cached)) {\n valueChanged = true;\n oldValue = cached;\n\n // First, save current value being shadowed\n // If a state stack frame is active, save the current parameter values for pop\n // but first check that value hasn't already been shadowed and saved\n if (oldValues && !(key in oldValues)) {\n oldValues[key] = cached;\n }\n\n // Save current value being shadowed\n this.cache[key] = value;\n }\n }\n\n return {valueChanged, oldValue};\n }\n}\n\n// HELPER FUNCTIONS - INSTALL GET/SET INTERCEPTORS (SPYS) ON THE CONTEXT\n\n/**\n// Overrides a WebGL2RenderingContext state \"getter\" function\n// to return values directly from cache\n * @param gl\n * @param functionName\n */\nfunction installGetterOverride(gl: WebGL2RenderingContext, functionName: string) {\n // Get the original function from the WebGL2RenderingContext\n const originalGetterFunc = gl[functionName].bind(gl);\n\n // Wrap it with a spy so that we can update our state cache when it gets called\n gl[functionName] = function get(pname) {\n if (pname === undefined || NON_CACHE_PARAMETERS.has(pname)) {\n // Invalid or blacklisted parameter, do not cache\n return originalGetterFunc(pname);\n }\n\n const glState = WebGLStateTracker.get(gl);\n if (!(pname in glState.cache)) {\n // WebGL limits are not prepopulated in the cache, call the original getter when first queried.\n glState.cache[pname] = originalGetterFunc(pname);\n }\n\n // Optionally call the original function to do a \"hard\" query from the WebGL2RenderingContext\n return glState.enable\n ? // Call the getter the params so that it can e.g. serve from a cache\n glState.cache[pname]\n : // Optionally call the original function to do a \"hard\" query from the WebGL2RenderingContext\n originalGetterFunc(pname);\n };\n\n // Set the name of this anonymous function to help in debugging and profiling\n Object.defineProperty(gl[functionName], 'name', {\n value: `${functionName}-from-cache`,\n configurable: false\n });\n}\n\n/**\n// Overrides a WebGL2RenderingContext state \"setter\" function\n// to call a setter spy before the actual setter. Allows us to keep a cache\n// updated with a copy of the WebGL context state.\n * @param gl\n * @param functionName\n * @param setter\n * @returns\n */\nfunction installSetterSpy(gl: WebGL2RenderingContext, functionName: string, setter: Function) {\n // Get the original function from the WebGL2RenderingContext\n if (!gl[functionName]) {\n // TODO - remove?\n // This could happen if we try to intercept WebGL2 method on a WebGL1 context\n return;\n }\n\n const originalSetterFunc = gl[functionName].bind(gl);\n\n // Wrap it with a spy so that we can update our state cache when it gets called\n gl[functionName] = function set(...params) {\n // Update the value\n // Call the setter with the state cache and the params so that it can store the parameters\n const glState = WebGLStateTracker.get(gl);\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const {valueChanged, oldValue} = setter(glState._updateCache, ...params);\n\n // Call the original WebGL2RenderingContext func to make sure the context actually gets updated\n if (valueChanged) {\n originalSetterFunc(...params);\n }\n\n // Note: if the original function fails to set the value, our state cache will be bad\n // No solution for this at the moment, but assuming that this is unlikely to be a real problem\n // We could call the setter after the originalSetterFunc. Concern is that this would\n // cause different behavior in debug mode, where originalSetterFunc can throw exceptions\n\n return oldValue;\n };\n\n // Set the name of this anonymous function to help in debugging and profiling\n Object.defineProperty(gl[functionName], 'name', {\n value: `${functionName}-to-cache`,\n configurable: false\n });\n}\n\nfunction installProgramSpy(gl: WebGL2RenderingContext): void {\n const originalUseProgram = gl.useProgram.bind(gl);\n\n gl.useProgram = function useProgramLuma(handle) {\n const glState = WebGLStateTracker.get(gl);\n if (glState.program !== handle) {\n originalUseProgram(handle);\n glState.program = handle;\n }\n };\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * ContextProps\n * @param onContextLost\n * @param onContextRestored *\n */\ntype ContextProps = {\n /** Called when a context is lost */\n onContextLost: (event: Event) => void;\n /** Called when a context is restored */\n onContextRestored: (event: Event) => void;\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n * @param canvas A canvas element or offscreen canvas\n */\nexport function createBrowserContext(\n canvas: HTMLCanvasElement | OffscreenCanvas,\n props: ContextProps,\n webglContextAttributes: WebGLContextAttributes\n): WebGL2RenderingContext {\n // Try to extract any extra information about why context creation failed\n let errorMessage = '';\n // const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);\n\n // Avoid multiple listeners?\n // canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n // canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const webglProps: WebGLContextAttributes = {\n preserveDrawingBuffer: true,\n // failIfMajorPerformanceCaveat: true,\n ...webglContextAttributes\n };\n\n // Create the desired context\n let gl: WebGL2RenderingContext | null = null;\n\n // Create a webgl2 context\n gl ||= canvas.getContext('webgl2', webglProps);\n if (webglProps.failIfMajorPerformanceCaveat) {\n errorMessage ||=\n 'Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.';\n }\n\n // Creation failed with failIfMajorPerformanceCaveat - Try a Software GPU\n if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {\n webglProps.failIfMajorPerformanceCaveat = false;\n gl = canvas.getContext('webgl2', webglProps);\n // @ts-expect-error\n gl.luma ||= {};\n // @ts-expect-error\n gl.luma.softwareRenderer = true;\n }\n\n if (!gl) {\n gl = canvas.getContext('webgl', {}) as WebGL2RenderingContext;\n if (gl) {\n gl = null;\n errorMessage ||= 'Your browser only supports WebGL1';\n }\n }\n\n if (!gl) {\n errorMessage ||= 'Your browser does not support WebGL';\n throw new Error(`Failed to create WebGL context: ${errorMessage}`);\n }\n\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost, onContextRestored} = props;\n canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);\n canvas.addEventListener(\n 'webglcontextrestored',\n (event: Event) => onContextRestored(event),\n false\n );\n\n // @ts-expect-error\n gl.luma ||= {};\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {DeviceInfo} from '@luma.gl/core';\nimport {GL, GLExtensions} from '@luma.gl/constants';\nimport {getWebGLExtension} from '../../context/helpers/webgl-extensions';\n\n/** @returns strings identifying the GPU vendor and driver. */\nexport function getDeviceInfo(gl: WebGL2RenderingContext, extensions: GLExtensions): DeviceInfo {\n // \"Masked\" info is always available, but don't contain much useful information\n const vendorMasked = gl.getParameter(GL.VENDOR);\n const rendererMasked = gl.getParameter(GL.RENDERER);\n\n // If we are lucky, unmasked info is available\n // https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_renderer_info/\n getWebGLExtension(gl, 'WEBGL_debug_renderer_info', extensions);\n const ext = extensions.WEBGL_debug_renderer_info;\n const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : GL.VENDOR);\n const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : GL.RENDERER);\n const vendor = vendorUnmasked || vendorMasked;\n const renderer = rendererUnmasked || rendererMasked;\n\n // Driver version\n const version = gl.getParameter(GL.VERSION) as string;\n\n // \"Sniff\" the GPU type and backend from the info. This works best if unmasked info is available.\n const gpu = identifyGPUVendor(vendor, renderer);\n const gpuBackend = identifyGPUBackend(vendor, renderer);\n const gpuType = identifyGPUType(vendor, renderer);\n\n // Determine GLSL version\n // For now, skip parsing of the long version string, just use context type below to deduce version\n // const version = gl.getParameter(GL.SHADING_LANGUAGE_VERSION) as string;\n // const shadingLanguageVersion = parseGLSLVersion(version);\n const shadingLanguage = 'glsl';\n const shadingLanguageVersion = 300;\n\n return {\n type: 'webgl',\n gpu,\n gpuType,\n gpuBackend,\n vendor,\n renderer,\n version,\n shadingLanguage,\n shadingLanguageVersion\n };\n}\n\n/** \"Sniff\" the GPU type from the info. This works best if unmasked info is available. */\nfunction identifyGPUVendor(\n vendor: string,\n renderer: string\n): 'nvidia' | 'intel' | 'apple' | 'amd' | 'software' | 'unknown' {\n if (/NVIDIA/i.exec(vendor) || /NVIDIA/i.exec(renderer)) {\n return 'nvidia';\n }\n if (/INTEL/i.exec(vendor) || /INTEL/i.exec(renderer)) {\n return 'intel';\n }\n if (/Apple/i.exec(vendor) || /Apple/i.exec(renderer)) {\n return 'apple';\n }\n if (\n /AMD/i.exec(vendor) ||\n /AMD/i.exec(renderer) ||\n /ATI/i.exec(vendor) ||\n /ATI/i.exec(renderer)\n ) {\n return 'amd';\n }\n if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {\n return 'software';\n }\n\n return 'unknown';\n}\n\n/** \"Sniff\" the GPU backend from the info. This works best if unmasked info is available. */\nfunction identifyGPUBackend(vendor: string, renderer: string): 'opengl' | 'metal' | 'unknown' {\n if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {\n return 'metal';\n }\n if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {\n return 'opengl';\n }\n return 'unknown';\n}\n\nfunction identifyGPUType(\n vendor: string,\n renderer: string\n): 'discrete' | 'integrated' | 'cpu' | 'unknown' {\n if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {\n return 'cpu';\n }\n\n const gpuVendor = identifyGPUVendor(vendor, renderer);\n switch (gpuVendor) {\n case 'intel':\n return 'integrated';\n case 'software':\n return 'cpu';\n case 'unknown':\n return 'unknown';\n default:\n return 'discrete';\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GLExtensions} from '@luma.gl/constants';\n\n/** Ensure extensions are only requested once */\nexport function getWebGLExtension(\n gl: WebGL2RenderingContext,\n name: string,\n extensions: GLExtensions\n): unknown {\n if (extensions[name] === undefined) {\n extensions[name] = gl.getExtension(name) || null;\n }\n return extensions[name];\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Feature detection for WebGL\n// Provides a function that enables simple checking of which WebGL features are\n\nimport {DeviceFeature, DeviceFeatures} from '@luma.gl/core';\nimport {GLExtensions} from '@luma.gl/constants';\nimport {getWebGLExtension} from '../../context/helpers/webgl-extensions';\nimport {\n isTextureFeature,\n checkTextureFeature,\n TEXTURE_FEATURES\n} from '../converters/webgl-texture-table';\n\n/**\n * Defines luma.gl \"feature\" names and semantics\n * when value is 'string' it is the name of the extension that enables this feature\n */\nconst WEBGL_FEATURES: Partial> = {\n // optional WebGPU features\n 'depth-clip-control': 'EXT_depth_clamp', // TODO these seem subtly different\n // 'timestamp-query' // GPUQueryType \"timestamp-query\"\n // \"indirect-first-instance\"\n // Textures are handled by getTextureFeatures()\n // 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'\n\n // optional WebGL features\n 'timer-query-webgl': 'EXT_disjoint_timer_query_webgl2',\n 'compilation-status-async-webgl': 'KHR_parallel_shader_compile',\n 'polygon-mode-webgl': 'WEBGL_polygon_mode',\n 'provoking-vertex-webgl': 'WEBGL_provoking_vertex',\n 'shader-clip-cull-distance-webgl': 'WEBGL_clip_cull_distance',\n 'shader-noperspective-interpolation-webgl': 'NV_shader_noperspective_interpolation',\n 'shader-conservative-depth-webgl': 'EXT_conservative_depth'\n\n // Textures are handled by getTextureFeatures()\n};\n\n/**\n * WebGL extensions exposed as luma.gl features\n * To minimize GL log noise and improve performance, this class ensures that\n * - WebGL extensions are not queried until the corresponding feature is checked.\n * - WebGL extensions are only queried once.\n */\nexport class WebGLDeviceFeatures extends DeviceFeatures {\n protected gl: WebGL2RenderingContext;\n protected extensions: GLExtensions;\n protected testedFeatures = new Set();\n\n constructor(\n gl: WebGL2RenderingContext,\n extensions: GLExtensions,\n disabledFeatures: Partial>\n ) {\n super([], disabledFeatures);\n this.gl = gl;\n this.extensions = extensions;\n // TODO - is this really needed?\n // Enable EXT_float_blend first: https://developer.mozilla.org/en-US/docs/Web/API/EXT_float_blend\n getWebGLExtension(gl, 'EXT_color_buffer_float', extensions);\n }\n\n *[Symbol.iterator](): IterableIterator {\n const features = this.getFeatures();\n for (const feature of features) {\n if (this.has(feature)) {\n yield feature;\n }\n }\n return [];\n }\n\n override has(feature: DeviceFeature): boolean {\n if (this.disabledFeatures?.[feature]) {\n return false;\n }\n\n // We have already tested this feature\n if (!this.testedFeatures.has(feature)) {\n this.testedFeatures.add(feature);\n\n // Check the feature once\n if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {\n this.features.add(feature);\n }\n\n if (this.getWebGLFeature(feature)) {\n this.features.add(feature);\n }\n }\n return this.features.has(feature);\n }\n\n // FOR DEVICE\n\n initializeFeatures() {\n // Initialize all features by checking them.\n // Except WEBGL_polygon_mode since Chrome logs ugly console warnings\n const features = this.getFeatures().filter(feature => feature !== 'polygon-mode-webgl');\n for (const feature of features) {\n this.has(feature);\n }\n }\n\n // IMPLEMENTATION\n\n getFeatures() {\n return [...Object.keys(WEBGL_FEATURES), ...Object.keys(TEXTURE_FEATURES)] as DeviceFeature[];\n }\n\n /** Extract all WebGL features */\n protected getWebGLFeature(feature: DeviceFeature): boolean {\n const featureInfo = WEBGL_FEATURES[feature];\n // string value requires checking the corresponding WebGL extension\n const isSupported =\n typeof featureInfo === 'string'\n ? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions))\n : Boolean(featureInfo);\n\n return isSupported;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n DeviceFeature,\n TextureFormat,\n TextureFormatCapabilities,\n DeviceTextureFormatCapabilities\n} from '@luma.gl/core';\nimport {decodeTextureFormat} from '@luma.gl/core';\nimport {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/constants';\nimport {getWebGLExtension} from '../../context/helpers/webgl-extensions';\nimport {getGLFromVertexType} from './vertex-formats';\n\n/* eslint-disable camelcase */\n\n// TEXTURE FEATURES\n\n// Define local webgl extension strings to optimize minification\nconst X_S3TC = 'WEBGL_compressed_texture_s3tc'; // BC1, BC2, BC3\nconst X_S3TC_SRGB = 'WEBGL_compressed_texture_s3tc_srgb'; // BC1, BC2, BC3\nconst X_RGTC = 'EXT_texture_compression_rgtc'; // BC4, BC5\nconst X_BPTC = 'EXT_texture_compression_bptc'; // BC6, BC7\nconst X_ETC2 = 'WEBGL_compressed_texture_etc'; // Renamed from 'WEBGL_compressed_texture_es3'\nconst X_ASTC = 'WEBGL_compressed_texture_astc';\nconst X_ETC1 = 'WEBGL_compressed_texture_etc1';\nconst X_PVRTC = 'WEBGL_compressed_texture_pvrtc';\nconst X_ATC = 'WEBGL_compressed_texture_atc';\n\n// Define local webgl extension strings to optimize minification\nconst EXT_texture_norm16 = 'EXT_texture_norm16';\nconst EXT_render_snorm = 'EXT_render_snorm';\nconst EXT_color_buffer_float = 'EXT_color_buffer_float';\n\n// prettier-ignore\nexport const TEXTURE_FEATURES: Partial> = {\n 'float32-renderable-webgl': ['EXT_color_buffer_float'],\n 'float16-renderable-webgl': ['EXT_color_buffer_half_float'],\n 'rgb9e5ufloat-renderable-webgl': ['WEBGL_render_shared_exponent'],\n 'snorm8-renderable-webgl': [EXT_render_snorm],\n 'norm16-renderable-webgl': [EXT_texture_norm16],\n 'snorm16-renderable-webgl': [EXT_texture_norm16, EXT_render_snorm],\n\n 'float32-filterable': ['OES_texture_float_linear'],\n 'float16-filterable-webgl': ['OES_texture_half_float_linear'],\n 'texture-filterable-anisotropic-webgl': ['EXT_texture_filter_anisotropic'],\n\n 'texture-blend-float-webgl': ['EXT_float_blend'],\n\n 'texture-compression-bc': [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],\n // 'texture-compression-bc3-srgb-webgl': [X_S3TC_SRGB],\n // 'texture-compression-bc3-webgl': [X_S3TC],\n 'texture-compression-bc5-webgl': [X_RGTC],\n 'texture-compression-bc7-webgl': [X_BPTC],\n 'texture-compression-etc2': [X_ETC2],\n 'texture-compression-astc': [X_ASTC],\n 'texture-compression-etc1-webgl': [X_ETC1],\n 'texture-compression-pvrtc-webgl': [X_PVRTC],\n 'texture-compression-atc-webgl': [X_ATC]\n};\n\nexport function isTextureFeature(feature: DeviceFeature): boolean {\n return feature in TEXTURE_FEATURES;\n}\n\n/** Checks a texture feature (for Device.features). Mainly compressed texture support */\nexport function checkTextureFeature(\n gl: WebGL2RenderingContext,\n feature: DeviceFeature,\n extensions: GLExtensions\n): boolean {\n const textureExtensions = TEXTURE_FEATURES[feature] || [];\n return textureExtensions.every(extension => getWebGLExtension(gl, extension, extensions));\n}\n\n// TEXTURE FORMATS\n\n/** Map a format to webgl and constants */\ntype WebGLFormatInfo = {\n gl?: GL;\n /** compressed */\n x?: string;\n types?: GLPixelType[];\n dataFormat?: GLTexelDataFormat;\n /** if depthTexture is set this is a depth/stencil format that can be set to a texture */\n depthTexture?: boolean;\n /** @deprecated can this format be used with renderbuffers */\n rb?: boolean;\n};\n\n// TABLES\n\n/**\n * Texture format data -\n * Exported but can change without notice\n */\n// prettier-ignore\nexport const WEBGL_TEXTURE_FORMATS: Record = {\n // 8-bit formats\n 'r8unorm': {gl: GL.R8, rb: true},\n 'r8snorm': {gl: GL.R8_SNORM},\n 'r8uint': {gl: GL.R8UI, rb: true},\n 'r8sint': {gl: GL.R8I, rb: true},\n\n // 16-bit formats\n 'rg8unorm': {gl: GL.RG8, rb: true},\n 'rg8snorm': {gl: GL.RG8_SNORM},\n 'rg8uint': {gl: GL.RG8UI, rb: true},\n 'rg8sint': {gl: GL.RG8I, rb: true},\n\n 'r16uint': {gl: GL.R16UI, rb: true},\n 'r16sint': {gl: GL.R16I, rb: true},\n 'r16float': {gl: GL.R16F, rb: true},\n 'r16unorm-webgl': {gl: GL.R16_EXT, rb: true},\n 'r16snorm-webgl': {gl: GL.R16_SNORM_EXT},\n\n // Packed 16-bit formats\n 'rgba4unorm-webgl': {gl: GL.RGBA4, rb: true},\n 'rgb565unorm-webgl': {gl: GL.RGB565, rb: true},\n 'rgb5a1unorm-webgl': {gl: GL.RGB5_A1, rb: true},\n\n // 24-bit formats\n 'rgb8unorm-webgl': {gl: GL.RGB8},\n 'rgb8snorm-webgl': {gl: GL.RGB8_SNORM},\n\n // 32-bit formats \n 'rgba8unorm': {gl: GL.RGBA8},\n 'rgba8unorm-srgb': {gl: GL.SRGB8_ALPHA8},\n 'rgba8snorm': {gl: GL.RGBA8_SNORM},\n 'rgba8uint': {gl: GL.RGBA8UI},\n 'rgba8sint': {gl: GL.RGBA8I},\n // reverse colors, webgpu only\n 'bgra8unorm': {},\n 'bgra8unorm-srgb': {},\n\n 'rg16uint': {gl: GL.RG16UI},\n 'rg16sint': {gl: GL.RG16I},\n 'rg16float': {gl: GL.RG16F, rb: true},\n 'rg16unorm-webgl': {gl: GL.RG16_EXT},\n 'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT},\n\n 'r32uint': {gl: GL.R32UI, rb: true},\n 'r32sint': {gl: GL.R32I, rb: true},\n 'r32float': {gl: GL.R32F},\n\n // Packed 32-bit formats\n 'rgb9e5ufloat': {gl: GL.RGB9_E5}, // , filter: true},\n 'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, rb: true},\n 'rgb10a2unorm': {gl: GL.RGB10_A2, rb: true},\n 'rgb10a2uint-webgl': {gl: GL.RGB10_A2UI, rb: true},\n\n // 48-bit formats\n 'rgb16unorm-webgl': {gl: GL.RGB16_EXT}, // rgb not renderable\n 'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT}, // rgb not renderable\n\n // 64-bit formats\n 'rg32uint': {gl: GL.RG32UI, rb: true},\n 'rg32sint': {gl: GL.RG32I, rb: true},\n 'rg32float': {gl: GL.RG32F, rb: true},\n 'rgba16uint': {gl: GL.RGBA16UI, rb: true},\n 'rgba16sint': {gl: GL.RGBA16I, rb: true},\n 'rgba16float': {gl: GL.RGBA16F},\n 'rgba16unorm-webgl': {gl: GL.RGBA16_EXT, rb: true},\n 'rgba16snorm-webgl': {gl: GL.RGBA16_SNORM_EXT},\n\n // 96-bit formats (deprecated!)\n 'rgb32float-webgl': {gl: GL.RGB32F, x: EXT_color_buffer_float, dataFormat: GL.RGB, types: [GL.FLOAT]},\n \n // 128-bit formats\n 'rgba32uint': {gl: GL.RGBA32UI, rb: true},\n 'rgba32sint': {gl: GL.RGBA32I, rb: true},\n 'rgba32float': {gl: GL.RGBA32F, rb: true},\n\n // Depth and stencil formats\n 'stencil8': {gl: GL.STENCIL_INDEX8, rb: true}, // 8 stencil bits\n\n 'depth16unorm': {gl: GL.DEPTH_COMPONENT16, dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_SHORT], rb: true}, // 16 depth bits\n 'depth24plus': {gl: GL.DEPTH_COMPONENT24, dataFormat: GL.DEPTH_COMPONENT, types: [GL.UNSIGNED_INT]},\n 'depth32float': {gl: GL.DEPTH_COMPONENT32F, dataFormat: GL.DEPTH_COMPONENT, types: [GL.FLOAT], rb: true},\n\n // The depth component of the \"depth24plus\" and \"depth24plus-stencil8\" formats may be implemented as either a 24-bit depth value or a \"depth32float\" value.\n 'depth24plus-stencil8': {gl: GL.DEPTH24_STENCIL8, rb: true, depthTexture: true, dataFormat: GL.DEPTH_STENCIL, types: [GL.UNSIGNED_INT_24_8]},\n // \"depth32float-stencil8\" feature - TODO below is render buffer only?\n 'depth32float-stencil8': {gl: GL.DEPTH32F_STENCIL8, dataFormat: GL.DEPTH_STENCIL, types: [GL.FLOAT_32_UNSIGNED_INT_24_8_REV], rb: true},\n\n // BC compressed formats: check device.features.has(\"texture-compression-bc\");\n\n 'bc1-rgb-unorm-webgl': {gl: GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC},\n 'bc1-rgb-unorm-srgb-webgl': {gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB},\n\n 'bc1-rgba-unorm': {gl: GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, x: X_S3TC},\n 'bc1-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB},\n 'bc2-rgba-unorm': {gl: GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, x: X_S3TC},\n 'bc2-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, x: X_S3TC_SRGB},\n 'bc3-rgba-unorm': {gl: GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, x: X_S3TC},\n 'bc3-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, x: X_S3TC_SRGB},\n 'bc4-r-unorm': {gl: GL.COMPRESSED_RED_RGTC1_EXT, x: X_RGTC},\n 'bc4-r-snorm': {gl: GL.COMPRESSED_SIGNED_RED_RGTC1_EXT, x: X_RGTC},\n 'bc5-rg-unorm': {gl: GL.COMPRESSED_RED_GREEN_RGTC2_EXT, x: X_RGTC},\n 'bc5-rg-snorm': {gl: GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, x: X_RGTC},\n 'bc6h-rgb-ufloat': {gl: GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, x: X_BPTC},\n 'bc6h-rgb-float': {gl: GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, x: X_BPTC},\n 'bc7-rgba-unorm': {gl: GL.COMPRESSED_RGBA_BPTC_UNORM_EXT, x: X_BPTC},\n 'bc7-rgba-unorm-srgb': {gl: GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, x: X_BPTC},\n\n // WEBGL_compressed_texture_etc: device.features.has(\"texture-compression-etc2\")\n // Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression\n\n 'etc2-rgb8unorm': {gl: GL.COMPRESSED_RGB8_ETC2},\n 'etc2-rgb8unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ETC2},\n 'etc2-rgb8a1unorm': {gl: GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2},\n 'etc2-rgb8a1unorm-srgb': {gl: GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2},\n 'etc2-rgba8unorm': {gl: GL.COMPRESSED_RGBA8_ETC2_EAC},\n 'etc2-rgba8unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC},\n\n 'eac-r11unorm': {gl: GL.COMPRESSED_R11_EAC},\n 'eac-r11snorm': {gl: GL.COMPRESSED_SIGNED_R11_EAC},\n 'eac-rg11unorm': {gl: GL.COMPRESSED_RG11_EAC},\n 'eac-rg11snorm': {gl: GL.COMPRESSED_SIGNED_RG11_EAC},\n\n // X_ASTC compressed formats: device.features.has(\"texture-compression-astc\")\n\n 'astc-4x4-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_4x4_KHR},\n 'astc-4x4-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR},\n 'astc-5x4-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_5x4_KHR},\n 'astc-5x4-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR},\n 'astc-5x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_5x5_KHR},\n 'astc-5x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR},\n 'astc-6x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_6x5_KHR},\n 'astc-6x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR},\n 'astc-6x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_6x6_KHR},\n 'astc-6x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR},\n 'astc-8x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x5_KHR},\n 'astc-8x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR},\n 'astc-8x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x6_KHR},\n 'astc-8x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR},\n 'astc-8x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_8x8_KHR},\n 'astc-8x8-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR},\n 'astc-10x5-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR},\n 'astc-10x5-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR},\n 'astc-10x6-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x6_KHR},\n 'astc-10x6-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR},\n 'astc-10x8-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x8_KHR},\n 'astc-10x8-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR},\n 'astc-10x10-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_10x10_KHR},\n 'astc-10x10-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR},\n 'astc-12x10-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_12x10_KHR},\n 'astc-12x10-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR},\n 'astc-12x12-unorm': {gl: GL.COMPRESSED_RGBA_ASTC_12x12_KHR},\n 'astc-12x12-unorm-srgb': {gl: GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR},\n\n // WEBGL_compressed_texture_pvrtc\n\n 'pvrtc-rgb4unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},\n 'pvrtc-rgba4unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},\n 'pvrtc-rbg2unorm-webgl': {gl: GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG},\n 'pvrtc-rgba2unorm-webgl': {gl: GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG},\n\n // WEBGL_compressed_texture_etc1\n\n 'etc1-rbg-unorm-webgl': {gl: GL.COMPRESSED_RGB_ETC1_WEBGL},\n\n // WEBGL_compressed_texture_atc\n\n 'atc-rgb-unorm-webgl': {gl: GL.COMPRESSED_RGB_ATC_WEBGL},\n 'atc-rgba-unorm-webgl': {gl: GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL},\n 'atc-rgbai-unorm-webgl': {gl: GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL}\n};\n\n// FUNCTIONS\n\n/** Checks if a texture format is supported */\nexport function isWebGLTextureFormatCapabilitiesed(\n gl: WebGL2RenderingContext,\n format: TextureFormat,\n extensions: GLExtensions\n): boolean {\n const webglTextureInfo = WEBGL_TEXTURE_FORMATS[format];\n // Check that we have a GL constant\n if (!webglTextureInfo?.gl) {\n return false;\n }\n\n // Check extensions\n const extension = webglTextureInfo.x;\n if (extension) {\n return Boolean(getWebGLExtension(gl, extension, extensions));\n }\n return true;\n}\n\n/** Checks if a texture format is supported, renderable, filterable etc */\nexport function getTextureFormatCapabilitiesWebGL(\n gl: WebGL2RenderingContext,\n formatSupport: TextureFormatCapabilities,\n extensions: GLExtensions\n): DeviceTextureFormatCapabilities {\n let supported = formatSupport.create;\n const webglFormatInfo = WEBGL_TEXTURE_FORMATS[formatSupport.format];\n\n // Support Check that we have a GL constant\n if (webglFormatInfo?.gl === undefined) {\n supported = false;\n }\n\n if (webglFormatInfo?.x) {\n supported = supported && Boolean(getWebGLExtension(gl, webglFormatInfo.x, extensions));\n }\n\n return {\n format: formatSupport.format,\n // @ts-ignore\n create: supported && formatSupport.create,\n // @ts-ignore\n render: supported && formatSupport.render,\n // @ts-ignore\n filter: supported && formatSupport.filter,\n // @ts-ignore\n blend: supported && formatSupport.blend,\n // @ts-ignore\n store: supported && formatSupport.store\n };\n}\n\n/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */\nexport function getTextureFormatWebGL(format: TextureFormat): {\n internalFormat: GL;\n format: GLTexelDataFormat;\n type: GLPixelType;\n compressed: boolean;\n} {\n const formatData = WEBGL_TEXTURE_FORMATS[format];\n const webglFormat = convertTextureFormatToGL(format);\n const decoded = decodeTextureFormat(format);\n return {\n internalFormat: webglFormat,\n format:\n formatData?.dataFormat ||\n getWebGLPixelDataFormat(decoded.channels, decoded.integer, decoded.normalized, webglFormat),\n // depth formats don't have a type\n type: decoded.dataType\n ? getGLFromVertexType(decoded.dataType)\n : formatData?.types?.[0] || GL.UNSIGNED_BYTE,\n compressed: decoded.compressed || false\n };\n}\n\nexport function getDepthStencilAttachmentWebGL(\n format: TextureFormat\n): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT {\n const formatInfo = decodeTextureFormat(format);\n switch (formatInfo.attachment) {\n case 'depth':\n return GL.DEPTH_ATTACHMENT;\n case 'stencil':\n return GL.STENCIL_ATTACHMENT;\n case 'depth-stencil':\n return GL.DEPTH_STENCIL_ATTACHMENT;\n default:\n throw new Error(`Not a depth stencil format: ${format}`);\n }\n}\n\n/** TODO - VERY roundabout legacy way of calculating bytes per pixel */\nexport function getTextureFormatBytesPerPixel(format: TextureFormat): number {\n const formatInfo = decodeTextureFormat(format);\n return formatInfo.bytesPerPixel;\n}\n\n// DATA TYPE HELPERS\n\nexport function getWebGLPixelDataFormat(\n channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra',\n integer: boolean,\n normalized: boolean,\n format: GL\n): GLTexelDataFormat {\n // WebGL1 formats use same internalFormat\n if (format === GL.RGBA || format === GL.RGB) {\n return format;\n }\n // prettier-ignore\n switch (channels) {\n case 'r': return integer && !normalized ? GL.RED_INTEGER : GL.RED;\n case 'rg': return integer && !normalized ? GL.RG_INTEGER : GL.RG;\n case 'rgb': return integer && !normalized ? GL.RGB_INTEGER : GL.RGB;\n case 'rgba': return integer && !normalized ? GL.RGBA_INTEGER : GL.RGBA;\n case 'bgra': throw new Error('bgra pixels not supported by WebGL');\n default: return GL.RGBA;\n }\n}\n\n/**\n * Map WebGPU style texture format strings to GL constants\n */\nfunction convertTextureFormatToGL(format: TextureFormat): GL | undefined {\n const formatInfo = WEBGL_TEXTURE_FORMATS[format];\n const webglFormat = formatInfo?.gl;\n if (webglFormat === undefined) {\n throw new Error(`Unsupported texture format ${format}`);\n }\n return webglFormat;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GL} from '@luma.gl/constants';\nimport {VertexFormat, VertexType} from '@luma.gl/core';\n\ntype GLDataType =\n | GL.UNSIGNED_BYTE\n | GL.BYTE\n | GL.UNSIGNED_SHORT\n | GL.SHORT\n | GL.UNSIGNED_INT\n | GL.INT\n | GL.HALF_FLOAT\n | GL.FLOAT;\n\n/** Get vertex format from GL constants */\nexport function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 | 4): VertexFormat {\n const base = getVertexTypeFromGL(type);\n // prettier-ignore\n switch (components) {\n // @ts-expect-error TODO deal with lack of formats\n case 1: return base;\n case 2: return `${base}x2`;\n // @ts-expect-error TODO deal with lack of formats\n case 3: return `${base}x3`;\n case 4: return `${base}x4`;\n }\n // @ts-ignore unreachable\n throw new Error(String(components));\n}\n\n/** Get data type from GL constants */\nexport function getVertexTypeFromGL(type: GLDataType, normalized = false): VertexType {\n // prettier-ignore\n switch (type) {\n // WebGPU does not support normalized 32 bit integer attributes\n case GL.INT: return normalized ? 'sint32' : 'sint32';\n case GL.UNSIGNED_INT: return normalized ? 'uint32' : 'uint32';\n case GL.SHORT: return normalized ? 'sint16' : 'unorm16';\n case GL.UNSIGNED_SHORT: return normalized ? 'uint16' : 'unorm16';\n case GL.BYTE: return normalized ? 'sint8' : 'snorm16';\n case GL.UNSIGNED_BYTE: return normalized ? 'uint8' : 'unorm8';\n case GL.FLOAT: return 'float32';\n case GL.HALF_FLOAT: return 'float16';\n }\n // @ts-ignore unreachable\n throw new Error(String(type));\n}\n\nexport function getGLFromVertexType(\n dataType: VertexType\n):\n | GL.UNSIGNED_BYTE\n | GL.BYTE\n | GL.UNSIGNED_SHORT\n | GL.SHORT\n | GL.UNSIGNED_INT\n | GL.INT\n | GL.HALF_FLOAT\n | GL.FLOAT {\n // prettier-ignore\n switch (dataType) {\n case 'uint8': return GL.UNSIGNED_BYTE;\n case 'sint8': return GL.BYTE;\n case 'unorm8': return GL.UNSIGNED_BYTE;\n case 'snorm8': return GL.BYTE;\n case 'uint16': return GL.UNSIGNED_SHORT;\n case 'sint16': return GL.SHORT;\n case 'unorm16': return GL.UNSIGNED_SHORT;\n case 'snorm16': return GL.SHORT;\n case 'uint32': return GL.UNSIGNED_INT;\n case 'sint32': return GL.INT;\n // WebGPU does not support normalized 32 bit integer attributes\n // case 'unorm32': return GL.UNSIGNED_INT;\n // case 'snorm32': return GL.INT;\n case 'float16': return GL.HALF_FLOAT;\n case 'float32': return GL.FLOAT;\n }\n // @ts-ignore unreachable\n throw new Error(String(dataType));\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {DeviceLimits} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\n// prettier-ignore\nexport class WebGLDeviceLimits extends DeviceLimits {\n get maxTextureDimension1D() { return 0; } // WebGL does not support 1D textures\n get maxTextureDimension2D() { return this.getParameter(GL.MAX_TEXTURE_SIZE); }\n get maxTextureDimension3D() { return this.getParameter(GL.MAX_3D_TEXTURE_SIZE); }\n get maxTextureArrayLayers() { return this.getParameter(GL.MAX_ARRAY_TEXTURE_LAYERS); }\n get maxBindGroups() { return 0; }\n get maxDynamicUniformBuffersPerPipelineLayout() { return 0; } // TBD\n get maxDynamicStorageBuffersPerPipelineLayout() { return 0; } // TBD\n get maxSampledTexturesPerShaderStage() { return this.getParameter(GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS); } // ) TBD\n get maxSamplersPerShaderStage() { return this.getParameter(GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS); }\n get maxStorageBuffersPerShaderStage() { return 0; } // TBD\n get maxStorageTexturesPerShaderStage() { return 0; } // TBD\n get maxUniformBuffersPerShaderStage() { return this.getParameter(GL.MAX_UNIFORM_BUFFER_BINDINGS); }\n get maxUniformBufferBindingSize() { return this.getParameter(GL.MAX_UNIFORM_BLOCK_SIZE); }\n get maxStorageBufferBindingSize() { return 0; }\n get minUniformBufferOffsetAlignment() { return this.getParameter(GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT); }\n get minStorageBufferOffsetAlignment() { return 0; } \n get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284\n get maxVertexAttributes() { return this.getParameter(GL.MAX_VERTEX_ATTRIBS); }\n get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU\n get maxInterStageShaderComponents() { return this.getParameter(GL.MAX_VARYING_COMPONENTS); }\n get maxComputeWorkgroupStorageSize() { return 0; } // WebGL does not support compute shaders\n get maxComputeInvocationsPerWorkgroup() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupSizeX() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupSizeY() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupSizeZ() { return 0; } // WebGL does not support compute shaders\n get maxComputeWorkgroupsPerDimension() { return 0;} // WebGL does not support compute shaders\n\n // PRIVATE\n\n protected gl: WebGL2RenderingContext;\n protected limits: Partial> = {};\n\n constructor(gl: WebGL2RenderingContext) {\n super();\n this.gl = gl;\n }\n\n protected getParameter(parameter: GL): number {\n if (this.limits[parameter] === undefined) {\n this.limits[parameter] = this.gl.getParameter(parameter);\n }\n return this.limits[parameter] || 0;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CanvasContextProps, TextureFormat} from '@luma.gl/core';\nimport {CanvasContext} from '@luma.gl/core';\nimport {WebGLDevice} from './webgl-device';\nimport {WEBGLFramebuffer} from './resources/webgl-framebuffer';\n\n/**\n * A WebGL Canvas Context which manages the canvas and handles drawing buffer resizing etc\n */\nexport class WebGLCanvasContext extends CanvasContext {\n readonly device: WebGLDevice;\n readonly format: TextureFormat = 'rgba8unorm';\n readonly depthStencilFormat: TextureFormat = 'depth24plus';\n\n presentationSize: [number, number];\n private _framebuffer: WEBGLFramebuffer | null = null;\n\n get [Symbol.toStringTag](): string {\n return 'WebGLCanvasContext';\n }\n\n constructor(device: WebGLDevice, props: CanvasContextProps) {\n // Note: Base class creates / looks up the canvas (unless under Node.js)\n super(props);\n this.device = device;\n this.presentationSize = [-1, -1];\n this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);\n this.update();\n }\n\n getCurrentFramebuffer(): WEBGLFramebuffer {\n this.update();\n // Setting handle to null returns a reference to the default framebuffer\n this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, {handle: null});\n return this._framebuffer;\n }\n\n /** Resizes and updates render targets if necessary */\n update() {\n const size = this.getPixelSize();\n const sizeChanged =\n size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];\n if (sizeChanged) {\n this.presentationSize = size;\n this.resize();\n }\n }\n\n /**\n * Resize the canvas' drawing buffer.\n *\n * Can match the canvas CSS size, and optionally also consider devicePixelRatio\n * Can be called every frame\n *\n * Regardless of size, the drawing buffer will always be scaled to the viewport, but\n * for best visual results, usually set to either:\n * canvas CSS width x canvas CSS height\n * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio\n * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n */\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n if (!this.device.gl) return;\n\n // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n }\n\n commit() {\n // gl.commit was ultimately removed from the WebGL standard??\n // if (this.offScreen && this.gl.commit) {\n // // @ts-expect-error gl.commit is not officially part of WebGL2RenderingContext\n // this.gl.commit();\n // }\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {FramebufferProps} from '@luma.gl/core';\nimport {Framebuffer} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLTextureView} from './webgl-texture-view';\nimport {getDepthStencilAttachmentWebGL} from '../converters/webgl-texture-table';\n\nexport type Attachment = WEBGLTextureView | WEBGLTexture; // | WEBGLRenderbuffer;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGL2RenderingContext;\n handle: WebGLFramebuffer;\n\n colorAttachments: WEBGLTextureView[] = [];\n depthStencilAttachment: WEBGLTextureView | null = null;\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n this.updateAttachments();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n protected updateAttachments(): void {\n /** Attach from a map of attachments */\n // @ts-expect-error native bindFramebuffer is overridden by our state tracker\n const prevHandle: WebGLFramebuffer | null = this.gl.bindFramebuffer(\n GL.FRAMEBUFFER,\n this.handle\n );\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n if (attachment) {\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n this._attachTextureView(attachmentPoint, attachment);\n }\n }\n\n if (this.depthStencilAttachment) {\n const attachmentPoint = getDepthStencilAttachmentWebGL(\n this.depthStencilAttachment.props.format\n );\n this._attachTextureView(attachmentPoint, this.depthStencilAttachment);\n }\n\n /** Check the status */\n if (this.device.props.debug) {\n const status = this.gl.checkFramebufferStatus(GL.FRAMEBUFFER) as GL;\n if (status !== GL.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle);\n }\n\n // PRIVATE\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n // protected override createDepthStencilTexture(format: TextureFormat): Texture {\n // // return new WEBGLRenderbuffer(this.device, {\n // return new WEBGLTexture(this.device, {\n // id: `${this.id}-depth-stencil`,\n // format,\n // width: this.width,\n // height: this.height,\n // mipmaps: false\n // });\n // }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel\n */\n protected _attachTextureView(attachment: GL, textureView: WEBGLTextureView): void {\n const {gl} = this.device;\n const {texture} = textureView;\n const level = textureView.props.baseMipLevel;\n const layer = textureView.props.baseArrayLayer;\n\n gl.bindTexture(texture.glTarget, texture.handle);\n\n switch (texture.glTarget) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n gl.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.handle, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n throw new Error('Illegal texture type');\n }\n\n gl.bindTexture(texture.glTarget, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < (GL.TEXTURE_CUBE_MAP_POSITIVE_X as number)\n ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X\n : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n\n/**\n * Attachment resize is expected to be a noop if size is same\n *\nprotected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n colorAttachment.texture.clone({width, height});\n }\n if (this.depthStencilAttachment) {\n this.depthStencilAttachment.texture.resize({width, height});\n }\n return this;\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {log} from '@luma.gl/core';\nimport {loadScript} from '../../utils/load-script';\n\nimport type {Spector} from './spector-types';\n\n/** Spector debug initialization options */\ntype SpectorProps = {\n /** Whether spector.js is enabled */\n debugSpectorJS?: boolean;\n /** URL to load spector script from. Typically a CDN URL */\n debugSpectorJSUrl?: string;\n /** Canvas to monitor */\n gl?: WebGL2RenderingContext;\n};\n\nconst LOG_LEVEL = 1;\n\nlet spector: Spector = null;\nlet initialized: boolean = false;\n\ndeclare global {\n // @ts-ignore\n // eslint-disable-next-line no-var\n var SPECTOR: Spector;\n}\n\nexport const DEFAULT_SPECTOR_PROPS: Required = {\n debugSpectorJS: log.get('debug-spectorjs'),\n // https://github.com/BabylonJS/Spector.js#basic-usage\n // https://forum.babylonjs.com/t/spectorcdn-is-temporarily-off/48241\n // spectorUrl: 'https://spectorcdn.babylonjs.com/spector.bundle.js';\n debugSpectorJSUrl: 'https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js',\n gl: undefined!\n};\n\n/** Loads spector from CDN if not already installed */\nexport async function loadSpectorJS(props: {debugSpectorJSUrl?: string}): Promise {\n if (!globalThis.SPECTOR) {\n try {\n await loadScript(props.debugSpectorJSUrl || DEFAULT_SPECTOR_PROPS.debugSpectorJSUrl);\n } catch (error) {\n log.warn(String(error));\n }\n }\n}\n\nexport function initializeSpectorJS(props: SpectorProps): Spector | null {\n props = {...DEFAULT_SPECTOR_PROPS, ...props};\n if (!props.debugSpectorJS) {\n return null;\n }\n\n if (!spector && globalThis.SPECTOR && !globalThis.luma?.spector) {\n log.probe(LOG_LEVEL, 'SPECTOR found and initialized. Start with `luma.spector.displayUI()`')();\n const {Spector: SpectorJS} = globalThis.SPECTOR as any;\n spector = new SpectorJS();\n if (globalThis.luma) {\n (globalThis.luma as any).spector = spector;\n }\n }\n\n if (!spector) {\n return null;\n }\n\n if (!initialized) {\n initialized = true;\n\n // enables recording some extra information merged in the capture like texture memory sizes and formats\n spector.spyCanvases();\n // A callback when results are ready\n spector?.onCaptureStarted.add((capture: unknown) =>\n log.info('Spector capture started:', capture)()\n );\n spector?.onCapture.add((capture: unknown) => {\n log.info('Spector capture complete:', capture)();\n // Use undocumented Spector API to open the UI with our capture\n // See https://github.com/BabylonJS/Spector.js/blob/767ad1195a25b85a85c381f400eb50a979239eca/src/spector.ts#L124\n spector?.getResultUI();\n // @ts-expect-error private\n spector?.resultView.display();\n // @ts-expect-error private\n spector?.resultView.addCapture(capture);\n });\n }\n\n if (props.gl) {\n // capture startup\n const gl = props.gl;\n // @ts-expect-error\n const device = gl.device;\n spector?.startCapture(props.gl, 500); // 500 commands\n // @ts-expect-error\n gl.device = device;\n\n new Promise(resolve => setTimeout(resolve, 2000)).then(_ => {\n log.info('Spector capture stopped after 2 seconds')();\n spector?.stopCapture();\n // spector?.displayUI();\n });\n }\n\n return spector;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * Load a script (identified by an url). When the url returns, the\n * content of this file is added into a new script element, attached to the DOM (body element)\n * @param scriptUrl defines the url of the script to laod\n * @param scriptId defines the id of the script element\n */\nexport async function loadScript(scriptUrl: string, scriptId?: string): Promise {\n const head = document.getElementsByTagName('head')[0];\n if (!head) {\n throw new Error('loadScript');\n }\n\n const script = document.createElement('script');\n script.setAttribute('type', 'text/javascript');\n script.setAttribute('src', scriptUrl);\n if (scriptId) {\n script.id = scriptId;\n }\n\n return new Promise((resolve, reject) => {\n script.onload = resolve;\n script.onerror = error =>\n reject(new Error(`Unable to load script '${scriptUrl}': ${error as string}`));\n head.appendChild(script);\n });\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {log} from '@luma.gl/core';\n// Rename constant to prevent inlining. We need the full set of constants for generating debug strings.\nimport {GL as GLEnum} from '@luma.gl/constants';\nimport {isBrowser} from '@probe.gl/env';\nimport {loadScript} from '../../utils/load-script';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debugWebGL?: boolean;\n traceWebGL?: boolean;\n};\n\ntype ContextData = {\n realContext?: WebGL2RenderingContext;\n debugContext?: WebGL2RenderingContext;\n};\n\n// Helper to get shared context data\nfunction getWebGLContextData(gl: any): ContextData {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed\n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise {\n if (isBrowser() && !globalThis.WebGLDebugUtils) {\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(\n gl: WebGL2RenderingContext,\n props: DebugContextProps = {}\n): WebGL2RenderingContext {\n return props.debugWebGL || props.traceWebGL ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGL2RenderingContext): WebGL2RenderingContext {\n const data = getWebGLContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(\n gl: WebGL2RenderingContext,\n props: DebugContextProps\n): WebGL2RenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getWebGLContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GLEnum, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GLEnum) {\n if (!(key in glDebug) && typeof GLEnum[key] === 'number') {\n glDebug[key] = GLEnum[key];\n }\n }\n\n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => (arg === undefined ? 'undefined' : arg));\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => (arg === undefined ? 'undefined' : arg));\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const message = `${errorMessage} in gl.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n // throw new Error(message);\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(\n props: DebugContextProps,\n functionName: string,\n functionArgs: any[]\n): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n if (props.traceWebGL) {\n log.log(1, functionString)();\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n debugger; // eslint-disable-line\n // throw new Error(`Undefined argument: ${functionString}`);\n }\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst uidCounters: Record = {};\n\n/**\n * Returns a UID.\n * @param id= - Identifier base name\n * @return uid\n **/\nexport function uid(id: string = 'id'): string {\n uidCounters[id] = uidCounters[id] || 1;\n const count = uidCounters[id]++;\n return `${id}-${count}`;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {BufferProps} from '@luma.gl/core';\nimport {Buffer} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\n\n/** WebGL Buffer interface */\nexport class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGL2RenderingContext;\n readonly handle: WebGLBuffer;\n\n /** Target in OpenGL defines the type of buffer */\n readonly glTarget: GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER;\n /** Usage is a hint on how frequently the buffer will be updates */\n readonly glUsage: GL.STATIC_DRAW | GL.DYNAMIC_DRAW;\n /** Index type is needed when issuing draw calls, so we pre-compute it */\n readonly glIndexType: GL.UNSIGNED_SHORT | GL.UNSIGNED_INT = GL.UNSIGNED_SHORT;\n\n /** Number of bytes allocated on the GPU for this buffer */\n byteLength: number;\n /** Number of bytes used */\n bytesUsed: number;\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n\n const handle = typeof props === 'object' ? props.handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // - In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // - In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n this.glTarget = getWebGLTarget(this.props.usage);\n this.glUsage = getWebGLUsage(this.props.usage);\n this.glIndexType = this.props.indexType === 'uint32' ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n }\n\n // PRIVATE METHODS\n\n /** Allocate a new buffer and initialize to contents of typed array */\n _initWithData(\n data: ArrayBuffer | ArrayBufferView,\n byteOffset: number = 0,\n byteLength: number = data.byteLength + byteOffset\n ): void {\n // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n const glTarget = this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, byteLength, this.glUsage);\n this.gl.bufferSubData(glTarget, byteOffset, data);\n this.gl.bindBuffer(glTarget, null);\n\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this._setDebugData(data, byteOffset, byteLength);\n this.trackAllocatedMemory(byteLength);\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n // assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n // const glTarget = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n const glTarget = this.glTarget;\n\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this._setDebugData(null, 0, byteLength);\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const glTarget = GL.COPY_WRITE_BUFFER;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.gl.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, byteOffset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n this._setDebugData(data, byteOffset, data.byteLength);\n }\n\n /** Asynchronously read data from the buffer */\n override async readAsync(byteOffset = 0, byteLength?: number): Promise {\n return this.readSyncWebGL(byteOffset, byteLength);\n }\n\n /** Synchronously read data from the buffer. WebGL only. */\n override readSyncWebGL(byteOffset = 0, byteLength?: number): Uint8Array {\n byteLength = byteLength ?? this.byteLength - byteOffset;\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // Update local `data` if offsets are 0\n this._setDebugData(data, byteOffset, byteLength);\n\n return data;\n }\n}\n\n/**\n * Returns a WebGL buffer target\n *\n * @param usage\n * static MAP_READ = 0x01;\n * static MAP_WRITE = 0x02;\n * static COPY_SRC = 0x0004;\n * static COPY_DST = 0x0008;\n * static INDEX = 0x0010;\n * static VERTEX = 0x0020;\n * static UNIFORM = 0x0040;\n * static STORAGE = 0x0080;\n * static INDIRECT = 0x0100;\n * static QUERY_RESOLVE = 0x0200;\n *\n * @returns WebGL buffer targe\n *\n * Buffer bind points in WebGL2\n * gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n * gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n * gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n * gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n * gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n */\nfunction getWebGLTarget(\n usage: number\n): GL.ARRAY_BUFFER | GL.ELEMENT_ARRAY_BUFFER | GL.UNIFORM_BUFFER {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, we can use GL.COPY_WRITE_BUFFER to avoid locking the type\n return GL.ARRAY_BUFFER;\n}\n\n/** @todo usage is not passed correctly */\nfunction getWebGLUsage(usage: number): GL.STATIC_DRAW | GL.DYNAMIC_DRAW {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.STATIC_DRAW;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Shader, ShaderProps, CompilerMessage, log} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {parseShaderCompilerLog} from '../helpers/parse-shader-compiler-log';\nimport {WebGLDevice} from '../webgl-device';\n\n/**\n * An immutable compiled shader program that execute portions of the GPU Pipeline\n */\nexport class WEBGLShader extends Shader {\n readonly device: WebGLDevice;\n readonly handle: WebGLShader;\n\n constructor(device: WebGLDevice, props: ShaderProps) {\n super(device, props);\n this.device = device;\n switch (this.props.stage) {\n case 'vertex':\n this.handle = this.props.handle || this.device.gl.createShader(GL.VERTEX_SHADER);\n break;\n case 'fragment':\n this.handle = this.props.handle || this.device.gl.createShader(GL.FRAGMENT_SHADER);\n break;\n default:\n throw new Error(this.props.stage);\n }\n this._compile(this.source);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.device.gl.deleteShader(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n get asyncCompilationStatus(): Promise<'pending' | 'success' | 'error'> {\n return this._waitForCompilationComplete().then(() => this.compilationStatus);\n }\n\n override async getCompilationInfo(): Promise {\n await this._waitForCompilationComplete();\n return this.getCompilationInfoSync();\n }\n\n override getCompilationInfoSync(): readonly CompilerMessage[] {\n const shaderLog = this.device.gl.getShaderInfoLog(this.handle);\n return shaderLog ? parseShaderCompilerLog(shaderLog) : [];\n }\n\n override getTranslatedSource(): string | null {\n const extensions = this.device.getExtension('WEBGL_debug_shaders');\n const ext = extensions.WEBGL_debug_shaders;\n return ext?.getTranslatedShaderSource(this.handle) || null;\n }\n\n // PRIVATE METHODS\n\n /** Compile a shader and get compilation status */\n protected async _compile(source: string): Promise {\n source = source.startsWith('#version ') ? source : `#version 300 es\\n${source}`;\n\n const {gl} = this.device;\n gl.shaderSource(this.handle, source);\n gl.compileShader(this.handle);\n\n // For performance reasons, avoid checking shader compilation errors on production\n if (!this.device.props.debug) {\n this.compilationStatus = 'pending';\n return;\n }\n\n // Sync case - slower, but advantage is that it throws in the constructor, making break on error more useful\n if (!this.device.features.has('compilation-status-async-webgl')) {\n this._getCompilationStatus();\n // The `Shader` base class will determine if debug window should be opened based on this.compilationStatus\n this.debugShader();\n if (this.compilationStatus === 'error') {\n throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);\n }\n return;\n }\n\n // async case\n log.once(1, 'Shader compilation is asynchronous')();\n await this._waitForCompilationComplete();\n log.info(2, `Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)();\n this._getCompilationStatus();\n\n // The `Shader` base class will determine if debug window should be opened based on this.compilationStatus\n this.debugShader();\n }\n\n /** Use KHR_parallel_shader_compile extension if available */\n protected async _waitForCompilationComplete(): Promise {\n const waitMs = async (ms: number) => await new Promise(resolve => setTimeout(resolve, ms));\n const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)\n\n // If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking\n if (!this.device.features.has('compilation-status-async-webgl')) {\n await waitMs(DELAY_MS);\n return;\n }\n\n const {gl} = this.device;\n for (;;) {\n const complete = gl.getShaderParameter(this.handle, GL.COMPLETION_STATUS_KHR);\n if (complete) {\n return;\n }\n await waitMs(DELAY_MS);\n }\n }\n\n /**\n * Get the shader compilation status\n * TODO - Load log even when no error reported, to catch warnings?\n * https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings\n */\n protected _getCompilationStatus() {\n this.compilationStatus = this.device.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS)\n ? 'success'\n : 'error';\n }\n}\n\n// TODO - Original code from luma.gl v8 - keep until new debug functionality has matured\n// if (!compilationSuccess) {\n// const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];\n// const messages = parsedLog.filter(message => message.type === 'error');\n// const formattedLog = formatCompilerLog(messages, source, {showSourceCode: 'all', html: true});\n// const shaderDescription = `${this.stage} shader ${shaderName}`;\n// log.error(`GLSL compilation errors in ${shaderDescription}\\n${formattedLog}`)();\n// displayShaderLog(parsedLog, source, shaderName);\n// }\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CompilerMessage} from '@luma.gl/core';\n\n/**\n * Parse a WebGL-format GLSL compilation log into an array of WebGPU style message records.\n * This follows documented WebGL conventions for compilation logs.\n * Based on https://github.com/wwwtyro/gl-format-compiler-error (public domain)\n */\nexport function parseShaderCompilerLog(errLog: string): readonly CompilerMessage[] {\n // Parse the error - note: browser and driver dependent\n const lines = errLog.split(/\\r?\\n/);\n\n const messages: CompilerMessage[] = [];\n\n for (const line of lines) {\n if (line.length <= 1) {\n continue; // eslint-disable-line no-continue\n }\n\n const segments: string[] = line.split(':');\n\n // Check for messages with no line information `ERROR: unsupported shader version`\n if (segments.length === 2) {\n const [messageType, message] = segments;\n messages.push({\n message: message.trim(),\n type: getMessageType(messageType),\n lineNum: 0,\n linePos: 0\n });\n continue; // eslint-disable-line no-continue\n }\n\n const [messageType, linePosition, lineNumber, ...rest] = segments;\n\n let lineNum = parseInt(lineNumber, 10);\n if (isNaN(lineNum)) {\n lineNum = 0;\n }\n\n let linePos = parseInt(linePosition, 10);\n if (isNaN(linePos)) {\n linePos = 0;\n }\n\n messages.push({\n message: rest.join(':').trim(),\n type: getMessageType(messageType),\n lineNum,\n linePos // TODO\n });\n }\n\n return messages;\n}\n\n/** Ensure supported type */\nfunction getMessageType(messageType: string): 'warning' | 'error' | 'info' {\n const MESSAGE_TYPES = ['warning', 'error', 'info'];\n const lowerCaseType = messageType.toLowerCase();\n return (MESSAGE_TYPES.includes(lowerCaseType) ? lowerCaseType : 'info') as\n | 'warning'\n | 'error'\n | 'info';\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Sampler, SamplerProps} from '@luma.gl/core';\nimport {GL, GLSamplerParameters} from '@luma.gl/constants';\nimport {convertSamplerParametersToWebGL} from '../converters/sampler-parameters';\nimport type {WebGLDevice} from '../webgl-device';\n\n/**\n * Sampler object -\n * so that they can be set directly on the texture\n * https://github.com/WebGLSamples/WebGL2Samples/blob/master/samples/sampler_object.html\n */\nexport class WEBGLSampler extends Sampler {\n readonly device: WebGLDevice;\n readonly handle: WebGLSampler;\n readonly parameters: GLSamplerParameters;\n\n constructor(device: WebGLDevice, props: SamplerProps) {\n super(device, props);\n this.device = device;\n this.parameters = convertSamplerParametersToWebGL(props);\n this.handle = this.handle || this.device.gl.createSampler();\n this._setSamplerParameters(this.parameters);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.device.gl.deleteSampler(this.handle);\n // @ts-expect-error read-only/undefined\n this.handle = undefined;\n }\n }\n\n override toString(): string {\n return `Sampler(${this.id},${JSON.stringify(this.props)})`;\n }\n\n /** Set sampler parameters on the sampler */\n private _setSamplerParameters(parameters: GLSamplerParameters): void {\n for (const [pname, value] of Object.entries(parameters)) {\n // Apparently there are integer/float conversion issues requires two parameter setting functions in JavaScript.\n // For now, pick the float version for parameters specified as GLfloat.\n const param = Number(pname) as GL.TEXTURE_MIN_LOD | GL.TEXTURE_MAX_LOD;\n switch (param) {\n case GL.TEXTURE_MIN_LOD:\n case GL.TEXTURE_MAX_LOD:\n this.device.gl.samplerParameterf(this.handle, param, value);\n break;\n default:\n this.device.gl.samplerParameteri(this.handle, param, value);\n break;\n }\n }\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// SAMPLER FILTERS\nimport {SamplerProps} from '@luma.gl/core';\nimport {GL, GLSamplerParameters} from '@luma.gl/constants';\nimport {convertCompareFunction} from './device-parameters';\n\n/**\n * Convert WebGPU-style sampler props to WebGL\n * @param props\n * @returns\n */\nexport function convertSamplerParametersToWebGL(props: SamplerProps): GLSamplerParameters {\n const params: GLSamplerParameters = {};\n if (props.addressModeU) {\n params[GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);\n }\n if (props.addressModeV) {\n params[GL.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);\n }\n if (props.addressModeW) {\n params[GL.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);\n }\n if (props.magFilter) {\n params[GL.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);\n }\n if (props.minFilter || props.mipmapFilter) {\n // TODO - arbitrary choice of linear?\n params[GL.TEXTURE_MIN_FILTER] = convertMinFilterMode(\n props.minFilter || 'linear',\n props.mipmapFilter\n );\n }\n if (props.lodMinClamp !== undefined) {\n params[GL.TEXTURE_MIN_LOD] = props.lodMinClamp;\n }\n if (props.lodMaxClamp !== undefined) {\n params[GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;\n }\n if (props.type === 'comparison-sampler') {\n // Setting prop.compare turns this into a comparison sampler\n params[GL.TEXTURE_COMPARE_MODE] = GL.COMPARE_REF_TO_TEXTURE;\n }\n if (props.compare) {\n params[GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction('compare', props.compare);\n }\n // Note depends on WebGL extension\n if (props.maxAnisotropy) {\n params[GL.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;\n }\n return params;\n}\n\n// HELPERS\n\n/** Convert address more */\nfunction convertAddressMode(\n addressMode: 'clamp-to-edge' | 'repeat' | 'mirror-repeat'\n): GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT {\n switch (addressMode) {\n case 'clamp-to-edge':\n return GL.CLAMP_TO_EDGE;\n case 'repeat':\n return GL.REPEAT;\n case 'mirror-repeat':\n return GL.MIRRORED_REPEAT;\n }\n}\n\nfunction convertMaxFilterMode(maxFilter: 'nearest' | 'linear'): GL.NEAREST | GL.LINEAR {\n switch (maxFilter) {\n case 'nearest':\n return GL.NEAREST;\n case 'linear':\n return GL.LINEAR;\n }\n}\n\n/**\n * WebGPU has separate min filter and mipmap filter,\n * WebGL is combined and effectively offers 6 options\n */\nfunction convertMinFilterMode(\n minFilter: 'nearest' | 'linear',\n mipmapFilter: 'none' | 'nearest' | 'linear' = 'none'\n):\n | GL.NEAREST\n | GL.LINEAR\n | GL.NEAREST_MIPMAP_NEAREST\n | GL.LINEAR_MIPMAP_NEAREST\n | GL.NEAREST_MIPMAP_LINEAR\n | GL.LINEAR_MIPMAP_LINEAR {\n if (!mipmapFilter) {\n return convertMaxFilterMode(minFilter);\n }\n switch (mipmapFilter) {\n case 'none':\n return convertMaxFilterMode(minFilter);\n case 'nearest':\n return minFilter === 'nearest' ? GL.NEAREST_MIPMAP_NEAREST : GL.NEAREST_MIPMAP_LINEAR;\n case 'linear':\n return minFilter === 'nearest' ? GL.LINEAR_MIPMAP_NEAREST : GL.LINEAR_MIPMAP_LINEAR;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CompareFunction, StencilOperation, BlendOperation, BlendFactor} from '@luma.gl/core';\nimport {Device, log, Parameters, PolygonMode, ProvokingVertex} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport type {\n GLBlendEquation,\n GLBlendFunction,\n GLFunction,\n GLParameters,\n GLPolygonMode,\n GLProvokingVertex,\n GLStencilOp\n} from '@luma.gl/constants';\nimport {setGLParameters} from '../../context/parameters/unified-parameter-api';\nimport {WebGLDevice} from '../webgl-device';\n\n/* eslint-disable no-unused-expressions */ // For expression ? gl.enable() : gl.disable()\n\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withDeviceAndGLParameters(\n device: Device,\n parameters: Parameters,\n glParameters: GLParameters,\n func: (_?: Device) => T\n): T {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n const webglDevice = device as WebGLDevice;\n webglDevice.pushState();\n try {\n setDeviceParameters(device, parameters);\n setGLParameters(webglDevice.gl, glParameters);\n return func(device);\n } finally {\n webglDevice.popState();\n }\n}\n\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n * @deprecated use withDeviceParameters instead\n */\nexport function withGLParameters(\n device: Device,\n parameters: GLParameters,\n func: (_?: Device) => T\n): T {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n const webglDevice = device as WebGLDevice;\n webglDevice.pushState();\n try {\n setGLParameters(webglDevice.gl, parameters);\n return func(device);\n } finally {\n webglDevice.popState();\n }\n}\n\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withDeviceParameters(\n device: Device,\n parameters: Parameters,\n func: (_?: Device) => T\n): T {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(device);\n }\n\n // Wrap in a try-catch to ensure that parameters are restored on exceptions'\n const webglDevice = device as WebGLDevice;\n webglDevice.pushState();\n try {\n setDeviceParameters(device, parameters);\n return func(device);\n } finally {\n webglDevice.popState();\n }\n}\n\n/** Set WebGPU Style Parameters */\nexport function setDeviceParameters(device: Device, parameters: Parameters) {\n const webglDevice = device as WebGLDevice;\n const {gl} = webglDevice;\n\n // RASTERIZATION SETTINGS\n if (parameters.cullMode) {\n switch (parameters.cullMode) {\n case 'none':\n gl.disable(GL.CULL_FACE);\n break;\n case 'front':\n gl.enable(GL.CULL_FACE);\n gl.cullFace(GL.FRONT);\n break;\n case 'back':\n gl.enable(GL.CULL_FACE);\n gl.cullFace(GL.BACK);\n break;\n }\n }\n\n if (parameters.frontFace) {\n gl.frontFace(\n map('frontFace', parameters.frontFace, {\n ccw: GL.CCW,\n cw: GL.CW\n })\n );\n }\n\n if (parameters.unclippedDepth) {\n if (device.features.has('depth-clip-control')) {\n // EXT_depth_clamp\n gl.enable(GL.DEPTH_CLAMP_EXT);\n }\n }\n\n if (parameters.depthBias !== undefined) {\n gl.enable(GL.POLYGON_OFFSET_FILL);\n gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);\n }\n\n // depthBiasSlopeScale: {\n // // Handled by depthBias\n // },\n\n // WEBGL EXTENSIONS\n\n if (parameters.provokingVertex) {\n if (device.features.has('provoking-vertex-webgl')) {\n const extensions = webglDevice.getExtension('WEBGL_provoking_vertex');\n const ext = extensions.WEBGL_provoking_vertex;\n\n const vertex = map(\n 'provokingVertex',\n parameters.provokingVertex,\n {\n first: GL.FIRST_VERTEX_CONVENTION_WEBGL,\n last: GL.LAST_VERTEX_CONVENTION_WEBGL\n }\n );\n ext?.provokingVertexWEBGL(vertex);\n }\n }\n\n if (parameters.polygonMode || parameters.polygonOffsetLine) {\n if (device.features.has('polygon-mode-webgl')) {\n if (parameters.polygonMode) {\n const extensions = webglDevice.getExtension('WEBGL_polygon_mode');\n const ext = extensions.WEBGL_polygon_mode;\n const mode = map('polygonMode', parameters.polygonMode, {\n fill: GL.FILL_WEBGL,\n line: GL.LINE_WEBGL\n });\n ext?.polygonModeWEBGL(GL.FRONT, mode);\n ext?.polygonModeWEBGL(GL.BACK, mode);\n }\n\n if (parameters.polygonOffsetLine) {\n gl.enable(GL.POLYGON_OFFSET_LINE_WEBGL);\n }\n }\n }\n\n if (device.features.has('shader-clip-cull-distance-webgl')) {\n if (parameters.clipDistance0) {\n gl.enable(GL.CLIP_DISTANCE0_WEBGL);\n }\n if (parameters.clipDistance1) {\n gl.enable(GL.CLIP_DISTANCE1_WEBGL);\n }\n if (parameters.clipDistance2) {\n gl.enable(GL.CLIP_DISTANCE2_WEBGL);\n }\n if (parameters.clipDistance3) {\n gl.enable(GL.CLIP_DISTANCE3_WEBGL);\n }\n if (parameters.clipDistance4) {\n gl.enable(GL.CLIP_DISTANCE4_WEBGL);\n }\n if (parameters.clipDistance5) {\n gl.enable(GL.CLIP_DISTANCE5_WEBGL);\n }\n if (parameters.clipDistance6) {\n gl.enable(GL.CLIP_DISTANCE6_WEBGL);\n }\n if (parameters.clipDistance7) {\n gl.enable(GL.CLIP_DISTANCE7_WEBGL);\n }\n }\n\n // DEPTH STENCIL\n\n if (parameters.depthWriteEnabled !== undefined) {\n gl.depthMask(mapBoolean('depthWriteEnabled', parameters.depthWriteEnabled));\n }\n\n if (parameters.depthCompare) {\n parameters.depthCompare !== 'always' ? gl.enable(GL.DEPTH_TEST) : gl.disable(GL.DEPTH_TEST);\n gl.depthFunc(convertCompareFunction('depthCompare', parameters.depthCompare));\n }\n\n if (parameters.stencilWriteMask) {\n const mask = parameters.stencilWriteMask;\n gl.stencilMaskSeparate(GL.FRONT, mask);\n gl.stencilMaskSeparate(GL.BACK, mask);\n }\n\n if (parameters.stencilReadMask) {\n // stencilReadMask is handle inside stencil***Compare.\n log.warn('stencilReadMask not supported under WebGL');\n }\n\n if (parameters.stencilCompare) {\n const mask = parameters.stencilReadMask || 0xffffffff;\n const glValue = convertCompareFunction('depthCompare', parameters.stencilCompare);\n // TODO - ensure back doesn't overwrite\n parameters.stencilCompare !== 'always'\n ? gl.enable(GL.STENCIL_TEST)\n : gl.disable(GL.STENCIL_TEST);\n gl.stencilFuncSeparate(GL.FRONT, glValue, 0, mask);\n gl.stencilFuncSeparate(GL.BACK, glValue, 0, mask);\n }\n\n if (\n parameters.stencilPassOperation &&\n parameters.stencilFailOperation &&\n parameters.stencilDepthFailOperation\n ) {\n const dppass = convertStencilOperation('stencilPassOperation', parameters.stencilPassOperation);\n const sfail = convertStencilOperation('stencilFailOperation', parameters.stencilFailOperation);\n const dpfail = convertStencilOperation(\n 'stencilDepthFailOperation',\n parameters.stencilDepthFailOperation\n );\n gl.stencilOpSeparate(GL.FRONT, sfail, dpfail, dppass);\n gl.stencilOpSeparate(GL.BACK, sfail, dpfail, dppass);\n }\n\n // stencilDepthFailOperation() {\n // // handled by stencilPassOperation\n // },\n\n // stencilFailOperation() {\n // // handled by stencilPassOperation\n // },\n\n // COLOR STATE\n switch (parameters.blend) {\n case true:\n gl.enable(GL.BLEND);\n break;\n case false:\n gl.disable(GL.BLEND);\n break;\n default:\n // leave WebGL blend state unchanged if `parameters.blend` is not set\n }\n\n if (parameters.blendColorOperation || parameters.blendAlphaOperation) {\n const colorEquation = convertBlendOperationToEquation(\n 'blendColorOperation',\n parameters.blendColorOperation || 'add'\n );\n const alphaEquation = convertBlendOperationToEquation(\n 'blendAlphaOperation',\n parameters.blendAlphaOperation || 'add'\n );\n gl.blendEquationSeparate(colorEquation, alphaEquation);\n\n const colorSrcFactor = convertBlendFactorToFunction(\n 'blendColorSrcFactor',\n parameters.blendColorSrcFactor || 'one'\n );\n const colorDstFactor = convertBlendFactorToFunction(\n 'blendColorDstFactor',\n parameters.blendColorDstFactor || 'zero'\n );\n const alphaSrcFactor = convertBlendFactorToFunction(\n 'blendAlphaSrcFactor',\n parameters.blendAlphaSrcFactor || 'one'\n );\n const alphaDstFactor = convertBlendFactorToFunction(\n 'blendAlphaDstFactor',\n parameters.blendAlphaDstFactor || 'zero'\n );\n gl.blendFuncSeparate(colorSrcFactor, colorDstFactor, alphaSrcFactor, alphaDstFactor);\n }\n}\n\n/*\n rasterizationState: {\n cullMode: \"back\",\n },\n\n depthStencilState: {\n depthWriteEnabled: true,\n depthCompare: \"less\",\n format: \"depth24plus-stencil8\",\n },\n\n colorStates: [\n {\n format: \"bgra8unorm\",\n // colorBlend.srcFactor = wgpu::BlendFactor::SrcAlpha;\n // colorBlend.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;\n // alphaBlend.srcFactor = wgpu::BlendFactor::SrcAlpha;\n // alphaBlend.dstFactor = wgpu::BlendFactor::OneMinusSrcAlpha;\n },\n ],\n });\n*/\n\nexport function convertCompareFunction(parameter: string, value: CompareFunction): GLFunction {\n return map(parameter, value, {\n never: GL.NEVER,\n less: GL.LESS,\n equal: GL.EQUAL,\n 'less-equal': GL.LEQUAL,\n greater: GL.GREATER,\n 'not-equal': GL.NOTEQUAL,\n 'greater-equal': GL.GEQUAL,\n always: GL.ALWAYS\n });\n}\n\nexport function convertToCompareFunction(parameter: string, value: GLFunction): CompareFunction {\n return map(parameter, value, {\n [GL.NEVER]: 'never',\n [GL.LESS]: 'less',\n [GL.EQUAL]: 'equal',\n [GL.LEQUAL]: 'less-equal',\n [GL.GREATER]: 'greater',\n [GL.NOTEQUAL]: 'not-equal',\n [GL.GEQUAL]: 'greater-equal',\n [GL.ALWAYS]: 'always'\n });\n}\n\nfunction convertStencilOperation(parameter: string, value: StencilOperation): GL {\n return map(parameter, value, {\n keep: GL.KEEP,\n zero: GL.ZERO,\n replace: GL.REPLACE,\n invert: GL.INVERT,\n 'increment-clamp': GL.INCR,\n 'decrement-clamp': GL.DECR,\n 'increment-wrap': GL.INCR_WRAP,\n 'decrement-wrap': GL.DECR_WRAP\n });\n}\n\nfunction convertBlendOperationToEquation(\n parameter: string,\n value: BlendOperation\n): GLBlendEquation {\n return map(parameter, value, {\n add: GL.FUNC_ADD,\n subtract: GL.FUNC_SUBTRACT,\n 'reverse-subtract': GL.FUNC_REVERSE_SUBTRACT,\n min: GL.MIN,\n max: GL.MAX\n });\n}\n\nfunction convertBlendFactorToFunction(parameter: string, value: BlendFactor): GLBlendFunction {\n return map(parameter, value, {\n one: GL.ONE,\n zero: GL.ZERO,\n 'src-color': GL.SRC_COLOR,\n 'one-minus-src-color': GL.ONE_MINUS_SRC_COLOR,\n 'dst-color': GL.DST_COLOR,\n 'one-minus-dst-color': GL.ONE_MINUS_DST_COLOR,\n 'src-alpha': GL.SRC_ALPHA,\n 'one-minus-src-alpha': GL.ONE_MINUS_SRC_ALPHA,\n 'dst-alpha': GL.DST_ALPHA,\n 'one-minus-dst-alpha': GL.ONE_MINUS_DST_ALPHA,\n 'src-alpha-saturated': GL.SRC_ALPHA_SATURATE,\n 'constant-color': GL.CONSTANT_COLOR,\n 'one-minus-constant-color': GL.ONE_MINUS_CONSTANT_COLOR,\n 'constant-alpha': GL.CONSTANT_ALPHA,\n 'one-minus-constant-alpha': GL.ONE_MINUS_CONSTANT_ALPHA\n });\n}\n\nfunction message(parameter: string, value: any): string {\n return `Illegal parameter ${value} for ${parameter}`;\n}\n\nfunction map(parameter: string, value: K, valueMap: Record): V {\n if (!(value in valueMap)) {\n throw new Error(message(parameter, value));\n }\n return valueMap[value];\n}\n\nfunction mapBoolean(parameter: string, value: boolean): boolean {\n return value;\n}\n\n/** Returns true if given object is empty, false otherwise. */\nfunction isObjectEmpty(obj: object): boolean {\n let isEmpty = true;\n // @ts-ignore key is unused\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const key in obj) {\n isEmpty = false;\n break;\n }\n return isEmpty;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n Device,\n TextureProps,\n TextureViewProps,\n Sampler,\n SamplerProps,\n SamplerParameters,\n TextureCubeFace,\n ExternalImage,\n Texture1DData,\n Texture2DData,\n Texture3DData,\n TextureCubeData,\n TextureArrayData,\n TextureCubeArrayData\n} from '@luma.gl/core';\nimport {Texture, log} from '@luma.gl/core';\nimport {\n GL,\n GLPixelType,\n GLSamplerParameters,\n GLTexelDataFormat,\n GLTextureTarget\n} from '@luma.gl/constants';\nimport {getTextureFormatWebGL} from '../converters/webgl-texture-table';\nimport {convertSamplerParametersToWebGL} from '../converters/sampler-parameters';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLSampler} from './webgl-sampler';\nimport {WEBGLTextureView} from './webgl-texture-view';\n\nimport {\n initializeTextureStorage,\n // clearMipLevel,\n copyExternalImageToMipLevel,\n copyCPUDataToMipLevel,\n // copyGPUBufferToMipLevel,\n getWebGLTextureTarget\n} from '../helpers/webgl-texture-utils';\n\n/**\n * WebGL... the texture API from hell... hopefully made simpler\n */\nexport class WEBGLTexture extends Texture {\n // readonly MAX_ATTRIBUTES: number;\n readonly device: WebGLDevice;\n readonly gl: WebGL2RenderingContext;\n handle: WebGLTexture;\n\n sampler: WEBGLSampler = undefined; // TODO - currently unused in WebGL. Create dummy sampler?\n view: WEBGLTextureView = undefined; // TODO - currently unused in WebGL. Create dummy view?\n\n mipmaps: boolean;\n\n // Texture type\n /** Whether the internal format is compressed */\n compressed: boolean;\n\n /**\n * The WebGL target corresponding to the texture type\n * @note `target` cannot be modified by bind:\n * textures are special because when you first bind them to a target,\n * When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture.\n * And it will always be a 2D texture; this state cannot be changed ever.\n * A texture that was first bound as a GL_TEXTURE_2D, must always be bound as a GL_TEXTURE_2D;\n * attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error\n */\n glTarget: GLTextureTarget;\n /** The WebGL format - essentially channel structure */\n glFormat: GLTexelDataFormat;\n /** The WebGL data format - the type of each channel */\n glType: GLPixelType;\n /** The WebGL constant corresponding to the WebGPU style constant in format */\n glInternalFormat: GL;\n\n // state\n /** Texture binding slot - TODO - move to texture view? */\n textureUnit: number = 0;\n\n constructor(device: Device, props: TextureProps) {\n super(device, props);\n\n // Texture base class strips out the data prop, so we need to add it back in\n const propsWithData = {...this.props};\n propsWithData.data = props.data;\n\n this.device = device as WebGLDevice;\n this.gl = this.device.gl;\n\n // Note: In WebGL the texture target defines the type of texture on first bind.\n this.glTarget = getWebGLTextureTarget(this.props.dimension);\n\n // The target format of this texture\n const formatInfo = getTextureFormatWebGL(this.props.format);\n this.glInternalFormat = formatInfo.internalFormat;\n this.glFormat = formatInfo.format;\n this.glType = formatInfo.type;\n this.compressed = formatInfo.compressed;\n this.mipmaps = Boolean(this.props.mipmaps);\n\n this._initialize(propsWithData);\n\n Object.seal(this);\n }\n\n /** Initialize texture with supplied props */\n // eslint-disable-next-line max-statements\n _initialize(propsWithData: TextureProps): void {\n this.handle = this.props.handle || this.gl.createTexture();\n this.device.setSpectorMetadata(this.handle, {...this.props, data: propsWithData.data});\n\n let {width, height} = propsWithData;\n\n if (!width || !height) {\n const textureSize = Texture.getTextureDataSize(propsWithData.data);\n width = textureSize?.width || 1;\n height = textureSize?.height || 1;\n }\n\n // Store opts for accessors\n this.width = width;\n this.height = height;\n this.depth = propsWithData.depth;\n\n // Set texture sampler parameters\n this.setSampler(propsWithData.sampler);\n // @ts-ignore TODO - fix types\n this.view = new WEBGLTextureView(this.device, {...this.props, texture: this});\n\n this.bind();\n initializeTextureStorage(this.gl, this.mipLevels, this);\n\n if (propsWithData.data) {\n // prettier-ignore\n switch (propsWithData.dimension) {\n case '1d': this.setTexture1DData(propsWithData.data); break;\n case '2d': this.setTexture2DData(propsWithData.data); break;\n case '3d': this.setTexture3DData(propsWithData.data); break;\n case 'cube': this.setTextureCubeData(propsWithData.data); break;\n case '2d-array': this.setTextureArrayData(propsWithData.data); break;\n case 'cube-array': this.setTextureCubeArrayData(propsWithData.data); break;\n // @ts-expect-error\n default: throw new Error(propsWithData.dimension);\n }\n }\n\n if (this.mipmaps) {\n this.generateMipmap();\n }\n }\n\n override destroy(): void {\n if (this.handle) {\n this.gl.deleteTexture(this.handle);\n this.removeStats();\n this.trackDeallocatedMemory('Texture');\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n createView(props: TextureViewProps): WEBGLTextureView {\n return new WEBGLTextureView(this.device, {...props, texture: this});\n }\n\n setSampler(sampler: Sampler | SamplerProps = {}): void {\n let samplerProps: SamplerParameters;\n if (sampler instanceof WEBGLSampler) {\n this.sampler = sampler;\n samplerProps = sampler.props;\n } else {\n this.sampler = new WEBGLSampler(this.device, sampler);\n samplerProps = sampler as SamplerProps;\n }\n\n const parameters = convertSamplerParametersToWebGL(samplerProps);\n this._setSamplerParameters(parameters);\n }\n\n // Call to regenerate mipmaps after modifying texture(s)\n generateMipmap(options?: {force?: boolean}): void {\n const isFilterableAndRenderable =\n this.device.isTextureFormatRenderable(this.props.format) &&\n this.device.isTextureFormatFilterable(this.props.format);\n if (!isFilterableAndRenderable) {\n log.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)();\n if (!options?.force) {\n return;\n }\n }\n\n try {\n this.gl.bindTexture(this.glTarget, this.handle);\n this.gl.generateMipmap(this.glTarget);\n } catch (error) {\n log.warn(`Error generating mipmap for ${this}: ${(error as Error).message}`)();\n } finally {\n this.gl.bindTexture(this.glTarget, null);\n }\n }\n\n // Image Data Setters\n copyExternalImage(options: {\n image: ExternalImage;\n sourceX?: number;\n sourceY?: number;\n width?: number;\n height?: number;\n depth?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n flipY?: boolean;\n }): {width: number; height: number} {\n const size = Texture.getExternalImageSize(options.image);\n const opts = {...Texture.defaultCopyExternalImageOptions, ...size, ...options};\n\n const {image, depth, mipLevel, x, y, z, flipY} = opts;\n let {width, height} = opts;\n const {dimension, glTarget, glFormat, glInternalFormat, glType} = this;\n\n // WebGL will error if we try to copy outside the bounds of the texture\n width = Math.min(width, this.width - x);\n height = Math.min(height, this.height - y);\n\n if (options.sourceX || options.sourceY) {\n // requires copyTexSubImage2D from a framebuffer'\n throw new Error('WebGL does not support sourceX/sourceY)');\n }\n\n copyExternalImageToMipLevel(this.device.gl, this.handle, image, {\n dimension,\n mipLevel,\n x,\n y,\n z,\n width,\n height,\n depth,\n glFormat,\n glInternalFormat,\n glType,\n glTarget,\n flipY\n });\n\n return {width: opts.width, height: opts.height};\n }\n\n setTexture1DData(data: Texture1DData): void {\n throw new Error('setTexture1DData not supported in WebGL.');\n }\n\n /** Set a simple texture */\n setTexture2DData(lodData: Texture2DData, depth = 0): void {\n this.bind();\n\n const lodArray = Texture.normalizeTextureData(lodData, this);\n\n // If the user provides multiple LODs, then automatic mipmap\n // generation generateMipmap() should be disabled to avoid overwriting them.\n if (lodArray.length > 1 && this.props.mipmaps !== false) {\n log.warn(`Texture ${this.id} mipmap and multiple LODs.`)();\n }\n\n for (let lodLevel = 0; lodLevel < lodArray.length; lodLevel++) {\n const imageData = lodArray[lodLevel];\n this._setMipLevel(depth, lodLevel, imageData);\n }\n\n this.unbind();\n }\n\n /**\n * Sets a 3D texture\n * @param data\n */\n setTexture3DData(data: Texture3DData): void {\n if (this.props.dimension !== '3d') {\n throw new Error(this.id);\n }\n if (ArrayBuffer.isView(data)) {\n this.bind();\n copyCPUDataToMipLevel(this.device.gl, data, this);\n this.unbind();\n }\n }\n\n /**\n * Set a Texture Cube Data\n * @todo - could support TextureCubeArray with depth\n * @param data\n * @param index\n */\n setTextureCubeData(data: TextureCubeData, depth: number = 0): void {\n if (this.props.dimension !== 'cube') {\n throw new Error(this.id);\n }\n for (const face of Texture.CubeFaces) {\n this.setTextureCubeFaceData(data[face], face);\n }\n }\n\n /**\n * Sets an entire texture array\n * @param data\n */\n setTextureArrayData(data: TextureArrayData): void {\n if (this.props.dimension !== '2d-array') {\n throw new Error(this.id);\n }\n throw new Error('setTextureArrayData not implemented.');\n }\n\n /**\n * Sets an entire texture cube array\n * @param data\n */\n setTextureCubeArrayData(data: TextureCubeArrayData): void {\n throw new Error('setTextureCubeArrayData not supported in WebGL2.');\n }\n\n setTextureCubeFaceData(lodData: Texture2DData, face: TextureCubeFace, depth: number = 0): void {\n // assert(this.props.dimension === 'cube');\n\n // If the user provides multiple LODs, then automatic mipmap\n // generation generateMipmap() should be disabled to avoid overwriting them.\n if (Array.isArray(lodData) && lodData.length > 1 && this.props.mipmaps !== false) {\n log.warn(`${this.id} has mipmap and multiple LODs.`)();\n }\n\n const faceDepth = Texture.CubeFaces.indexOf(face);\n\n this.setTexture2DData(lodData, faceDepth);\n }\n\n // DEPRECATED METHODS\n\n /** Update external texture (video frame or canvas) @deprecated Use ExternalTexture */\n update(): void {\n throw new Error('Texture.update() not implemented. Use ExternalTexture');\n }\n\n // INTERNAL METHODS\n\n /** @todo update this method to accept LODs */\n setImageDataForFace(options): void {\n const {\n face,\n width,\n height,\n pixels,\n data,\n format = GL.RGBA,\n type = GL.UNSIGNED_BYTE\n // generateMipmap = false // TODO\n } = options;\n\n const {gl} = this;\n\n const imageData = pixels || data;\n\n this.bind();\n if (imageData instanceof Promise) {\n imageData.then(resolvedImageData =>\n this.setImageDataForFace(\n Object.assign({}, options, {\n face,\n data: resolvedImageData,\n pixels: resolvedImageData\n })\n )\n );\n } else if (this.width || this.height) {\n gl.texImage2D(face, 0, format, width, height, 0 /* border*/, format, type, imageData);\n } else {\n gl.texImage2D(face, 0, format, format, type, imageData);\n }\n }\n\n _getImageDataMap(faceData: Record): Record {\n for (let i = 0; i < Texture.CubeFaces.length; ++i) {\n const faceName = Texture.CubeFaces[i];\n if (faceData[faceName]) {\n faceData[GL.TEXTURE_CUBE_MAP_POSITIVE_X + i] = faceData[faceName];\n delete faceData[faceName];\n }\n }\n return faceData;\n }\n\n // RESOURCE METHODS\n\n /**\n * Sets sampler parameters on texture\n */\n _setSamplerParameters(parameters: GLSamplerParameters): void {\n log.log(1, `${this.id} sampler parameters`, this.device.getGLKeys(parameters))();\n\n this.gl.bindTexture(this.glTarget, this.handle);\n for (const [pname, pvalue] of Object.entries(parameters)) {\n const param = Number(pname) as keyof GLSamplerParameters;\n const value = pvalue;\n\n // Apparently integer/float issues require two different texture parameter setting functions in JavaScript.\n // For now, pick the float version for parameters specified as GLfloat.\n switch (param) {\n case GL.TEXTURE_MIN_LOD:\n case GL.TEXTURE_MAX_LOD:\n this.gl.texParameterf(this.glTarget, param, value);\n break;\n\n case GL.TEXTURE_MIN_FILTER:\n this.gl.texParameteri(this.glTarget, param, value);\n break;\n\n case GL.TEXTURE_WRAP_S:\n case GL.TEXTURE_WRAP_T:\n this.gl.texParameteri(this.glTarget, param, value);\n break;\n case GL.TEXTURE_MAX_ANISOTROPY_EXT:\n // We have to query feature before using it\n if (this.device.features.has('texture-filterable-anisotropic-webgl')) {\n this.gl.texParameteri(this.glTarget, param, value);\n }\n break;\n default:\n this.gl.texParameteri(this.glTarget, param, value);\n break;\n }\n }\n\n this.gl.bindTexture(this.glTarget, null);\n }\n\n // INTERNAL SETTERS\n\n /**\n * Copy a region of data from a CPU memory buffer into this texture.\n * @todo - GLUnpackParameters parameters\n */\n protected _setMipLevel(\n depth: number,\n mipLevel: number,\n textureData: Texture2DData,\n glTarget: GL = this.glTarget\n ) {\n // if (!textureData) {\n // clearMipLevel(this.device.gl, {...this, depth, level});\n // return;\n // }\n\n if (Texture.isExternalImage(textureData)) {\n copyExternalImageToMipLevel(this.device.gl, this.handle, textureData, {\n ...this,\n depth,\n mipLevel,\n glTarget,\n flipY: this.props.flipY\n });\n return;\n }\n\n // @ts-expect-error\n if (Texture.isTextureLevelData(textureData)) {\n copyCPUDataToMipLevel(this.device.gl, textureData.data, {\n ...this,\n depth,\n mipLevel,\n glTarget\n });\n return;\n }\n\n throw new Error('Texture: invalid image data');\n }\n // HELPERS\n\n getActiveUnit(): number {\n return this.gl.getParameter(GL.ACTIVE_TEXTURE) - GL.TEXTURE0;\n }\n\n bind(textureUnit?: number): number {\n const {gl} = this;\n\n if (textureUnit !== undefined) {\n this.textureUnit = textureUnit;\n gl.activeTexture(gl.TEXTURE0 + textureUnit);\n }\n\n gl.bindTexture(this.glTarget, this.handle);\n return textureUnit;\n }\n\n unbind(textureUnit?: number): number | undefined {\n const {gl} = this;\n\n if (textureUnit !== undefined) {\n this.textureUnit = textureUnit;\n gl.activeTexture(gl.TEXTURE0 + textureUnit);\n }\n\n gl.bindTexture(this.glTarget, null);\n return textureUnit;\n }\n}\n\n// TODO - Remove when texture refactor is complete\n\n/*\nsetCubeMapData(options: {\n width: number;\n height: number;\n data: Record | Record;\n format?: any;\n type?: any;\n /** @deprecated Use .data *\n pixels: any;\n}): void {\n const {gl} = this;\n\n const {width, height, pixels, data, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = options;\n\n // pixel data (imageDataMap) is an Object from Face to Image or Promise.\n // For example:\n // {\n // GL.TEXTURE_CUBE_MAP_POSITIVE_X : Image-or-Promise,\n // GL.TEXTURE_CUBE_MAP_NEGATIVE_X : Image-or-Promise,\n // ... }\n // To provide multiple level-of-details (LODs) this can be Face to Array\n // of Image or Promise, like this\n // {\n // GL.TEXTURE_CUBE_MAP_POSITIVE_X : [Image-or-Promise-LOD-0, Image-or-Promise-LOD-1],\n // GL.TEXTURE_CUBE_MAP_NEGATIVE_X : [Image-or-Promise-LOD-0, Image-or-Promise-LOD-1],\n // ... }\n\n const imageDataMap = this._getImageDataMap(pixels || data);\n\n const resolvedFaces = WEBGLTexture.FACES.map(face => {\n const facePixels = imageDataMap[face];\n return Array.isArray(facePixels) ? facePixels : [facePixels];\n });\n this.bind();\n\n WEBGLTexture.FACES.forEach((face, index) => {\n if (resolvedFaces[index].length > 1 && this.props.mipmaps !== false) {\n // If the user provides multiple LODs, then automatic mipmap\n // generation generateMipmap() should be disabled to avoid overwritting them.\n log.warn(`${this.id} has mipmap and multiple LODs.`)();\n }\n resolvedFaces[index].forEach((image, lodLevel) => {\n // TODO: adjust width & height for LOD!\n if (width && height) {\n gl.texImage2D(face, lodLevel, format, width, height, 0 /* border*, format, type, image);\n } else {\n gl.texImage2D(face, lodLevel, format, format, type, image);\n }\n });\n });\n\n this.unbind();\n}\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, TextureViewProps} from '@luma.gl/core';\n// import {decodeTextureFormat} from '@luma.gl/core';\nimport {TextureView, Texture} from '@luma.gl/core';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\n\nexport class WEBGLTextureView extends TextureView {\n readonly device: WebGLDevice;\n readonly gl: WebGL2RenderingContext;\n readonly handle: null; // Does not have a WebGL representation\n readonly texture: WEBGLTexture;\n\n constructor(device: Device, props: TextureViewProps & {texture: WEBGLTexture}) {\n super(device, {...Texture.defaultProps, ...props});\n\n this.device = device as WebGLDevice;\n this.gl = this.device.gl;\n this.handle = null;\n this.texture = props.texture;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n//\n// WebGL... the texture API from hell... hopefully made simpler\n//\n\nimport {TypedArray} from '@math.gl/types';\nimport type {ExternalImage} from '@luma.gl/core';\nimport {Buffer, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';\nimport {\n GL,\n GLTextureTarget,\n GLTextureCubeMapTarget,\n GLTexelDataFormat,\n GLPixelType,\n GLDataType\n} from '@luma.gl/constants';\n\nimport {WEBGLFramebuffer} from '../resources/webgl-framebuffer';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\nimport {glFormatToComponents, glTypeToBytes} from './format-utils';\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\nimport {WEBGLTexture} from '../resources/webgl-texture';\nimport {withGLParameters} from '../../context/state-tracker/with-parameters';\n\n/** A \"border\" parameter is required in many WebGL texture APIs, but must always be 0... */\nconst BORDER = 0;\n\n/**\n * Options for setting data into a texture\n */\nexport type WebGLSetTextureOptions = {\n dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n height: number;\n width: number;\n depth: number;\n mipLevel?: number;\n glTarget: GLTextureTarget;\n glInternalFormat: GL;\n glFormat: GLTexelDataFormat;\n glType: GLPixelType;\n compressed?: boolean;\n byteOffset?: number;\n byteLength?: number;\n};\n\n/**\n * Options for copying an image or data into a texture\n *\n * @param {GLenum} format - internal format of image data.\n * @param {GLenum} type\n * - format of array (autodetect from type) or\n * - (WEBGL2) format of buffer or ArrayBufferView\n * @param {GLenum} dataFormat - format of image data.\n * @param {Number} offset - (WEBGL2) offset from start of buffer\n * @parameters - temporary settings to be applied, can be used to supply pixel store settings.\n */\nexport type WebGLCopyTextureOptions = {\n dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n /** mip level to be updated */\n mipLevel?: number;\n /** width of the sub image to be updated */\n width: number;\n /** height of the sub image to be updated */\n height: number;\n /** depth of texture to be updated */\n depth?: number;\n /** xOffset from where texture to be updated */\n x?: number;\n /** yOffset from where texture to be updated */\n y?: number;\n /** yOffset from where texture to be updated */\n z?: number;\n\n glTarget: GLTextureTarget;\n glInternalFormat: GL;\n glFormat: GL;\n glType: GL;\n compressed?: boolean;\n byteOffset?: number;\n byteLength?: number;\n};\n\n/**\n * Initializes a texture memory space\n * Clear all the textures and mip levels of a two-dimensional or array texture at the same time.\n * On some implementations faster than repeatedly setting levels\n *\n * @note From WebGL 2 spec section 3.7.6:\n * @see https://registry.khronos.org/webgl/specs/latest/2.0/\n * - The image contents are set as if a buffer of sufficient size initialized to 0 would be passed to each level's texImage2D/3D\n * - texStorage2D should be considered a preferred alternative to texImage2D. It may have lower memory costs than texImage2D in some implementations.\n * - Once texStorage*D has been called, the texture is immutable and can only be updated with texSubImage*(), not texImage()\n */\nexport function initializeTextureStorage(\n gl: WebGL2RenderingContext,\n levels: number,\n options: WebGLSetTextureOptions\n): void {\n const {dimension, width, height, depth = 0} = options;\n const {glInternalFormat} = options;\n const glTarget = options.glTarget; // getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n switch (dimension) {\n case '2d-array':\n case '3d':\n gl.texStorage3D(glTarget, levels, glInternalFormat, width, height, depth);\n break;\n\n default:\n gl.texStorage2D(glTarget, levels, glInternalFormat, width, height);\n }\n}\n\n/**\n * Copy a region of compressed data from a GPU memory buffer into this texture.\n */\nexport function copyExternalImageToMipLevel(\n gl: WebGL2RenderingContext,\n handle: WebGLTexture,\n image: ExternalImage,\n options: WebGLCopyTextureOptions & {flipY?: boolean}\n): void {\n const {width, height} = options;\n const {dimension, depth = 0, mipLevel = 0} = options;\n const {x = 0, y = 0, z = 0} = options;\n const {glFormat, glType} = options;\n\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n const glParameters = options.flipY ? {[GL.UNPACK_FLIP_Y_WEBGL]: true} : {};\n withGLParameters(gl, glParameters, () => {\n switch (dimension) {\n case '2d-array':\n case '3d':\n gl.bindTexture(glTarget, handle);\n // prettier-ignore\n gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, image);\n gl.bindTexture(glTarget, null);\n break;\n\n case '2d':\n case 'cube':\n gl.bindTexture(glTarget, handle);\n // prettier-ignore\n gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, image);\n gl.bindTexture(glTarget, null);\n break;\n\n default:\n throw new Error(dimension);\n }\n });\n}\n\n/**\n * Copy a region of data from a CPU memory buffer into this texture.\n */\nexport function copyCPUDataToMipLevel(\n gl: WebGL2RenderingContext,\n typedArray: TypedArray,\n options: WebGLCopyTextureOptions\n): void {\n const {dimension, width, height, depth = 0, mipLevel = 0, byteOffset = 0} = options;\n const {x = 0, y = 0, z = 0} = options;\n const {glFormat, glType, compressed} = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n // gl.bindTexture(glTarget, null);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, typedArray, byteOffset); // , byteLength\n } else {\n // prettier-ignore\n gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, typedArray, byteOffset); // , byteLength\n }\n break;\n\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, typedArray, byteOffset); // , byteLength\n } else {\n // prettier-ignore\n gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, glType, typedArray, byteOffset); // , byteLength\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n}\n\n/**\n * Copy a region of compressed data from a GPU memory buffer into this texture.\n */\nexport function copyGPUBufferToMipLevel(\n gl: WebGL2RenderingContext,\n webglBuffer: WebGLBuffer,\n byteLength: number,\n options: WebGLCopyTextureOptions\n): void {\n const {dimension, width, height, depth = 0, mipLevel = 0, byteOffset = 0} = options;\n const {x = 0, y = 0, z = 0} = options;\n const {glFormat, glType, compressed} = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, webglBuffer);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n // 3 dimensional textures requires 3D texture functions\n if (compressed) {\n // TODO enable extension?\n // prettier-ignore\n gl.compressedTexSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, byteLength, byteOffset);\n } else {\n // prettier-ignore\n gl.texSubImage3D(glTarget, mipLevel, x, y, z, width, height, depth, glFormat, glType, byteOffset);\n }\n break;\n\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexSubImage2D(glTarget, mipLevel, x, y, width, height, glFormat, byteLength, byteOffset);\n } else {\n // prettier-ignore\n gl.texSubImage2D(glTarget, mipLevel, x, y, width, height, BORDER, glFormat, byteOffset);\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n}\n\n// INTERNAL HELPERS\n\n/** Convert a WebGPU style texture constant to a WebGL style texture constant */\nexport function getWebGLTextureTarget(\n dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d'\n): GLTextureTarget {\n // prettier-ignore\n switch (dimension) {\n case '1d': break; // not supported in any WebGL version\n case '2d': return GL.TEXTURE_2D; // supported in WebGL1\n case '3d': return GL.TEXTURE_3D; // supported in WebGL2\n case 'cube': return GL.TEXTURE_CUBE_MAP; // supported in WebGL1\n case '2d-array': return GL.TEXTURE_2D_ARRAY; // supported in WebGL2\n case 'cube-array': break; // not supported in any WebGL version\n }\n throw new Error(dimension);\n}\n\n/**\n * In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.\n * @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.\n * @returns glTarget unchanged, if dimension !== 'cube'.\n */\nexport function getWebGLCubeFaceTarget(\n glTarget: GLTextureTarget,\n dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n level: number\n): GLTextureTarget | GLTextureCubeMapTarget {\n return dimension === 'cube' ? GL.TEXTURE_CUBE_MAP_POSITIVE_X + level : glTarget;\n}\n\n// texImage methods\n\n/**\n * Clear a texture mip level.\n * Wrapper for the messy WebGL texture API\n *\nexport function clearMipLevel(gl: WebGL2RenderingContext, options: WebGLSetTextureOptions): void {\n const {dimension, width, height, depth = 0, mipLevel = 0} = options;\n const {glInternalFormat, glFormat, glType, compressed} = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);\n } else {\n // prettier-ignore\n gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);\n }\n break;\n\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);\n } else {\n // prettier-ignore\n gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n}\n */\n\n/**\n * Set a texture mip level to the contents of an external image.\n * Wrapper for the messy WebGL texture API\n * @note Corresponds to WebGPU device.queue.copyExternalImageToTexture()\n *\nexport function setMipLevelFromExternalImage(\n gl: WebGL2RenderingContext,\n image: ExternalImage,\n options: WebGLSetTextureOptions\n): void {\n const {dimension, width, height, depth = 0, level = 0} = options;\n const {glInternalFormat, glType} = options;\n\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n // TODO - we can't change texture width (due to WebGPU limitations) -\n // and the width/heigh of an external image is implicit, so why do we need to extract it?\n // So what width height do we supply? The image size or the texture size?\n // const {width, height} = Texture.getExternalImageSize(image);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n // prettier-ignore\n gl.texImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, glInternalFormat, glType, image);\n break;\n\n case '2d':\n case 'cube':\n // prettier-ignore\n gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glInternalFormat, glType, image);\n break;\n\n default:\n throw new Error(dimension);\n }\n}\n\n/**\n * Set a texture mip level from CPU memory\n * Wrapper for the messy WebGL texture API\n * @note Not available (directly) in WebGPU\n *\nexport function setMipLevelFromTypedArray(\n gl: WebGL2RenderingContext,\n data: TypedArray,\n parameters: {},\n options: {\n dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n height: number;\n width: number;\n depth?: number;\n level?: number;\n offset?: number;\n glTarget: GLTextureTarget;\n glInternalFormat: GL;\n glFormat: GL;\n glType: GL;\n compressed?: boolean;\n }\n): void {\n const {dimension, width, height, depth = 0, level = 0, offset = 0} = options;\n const {glInternalFormat, glFormat, glType, compressed} = options;\n\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n withGLParameters(gl, parameters, () => {\n switch (dimension) {\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, data);\n } else {\n // prettier-ignore\n gl.texImage3D( glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, data);\n }\n break;\n\n case '2d':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, data);\n } else {\n // prettier-ignore\n gl.texImage2D( glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, data, offset);\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n });\n}\n\n/**\n * Set a texture level from CPU memory\n * @note Not available (directly) in WebGPU\n _setMipLevelFromTypedArray(\n depth: number,\n level: number,\n data: TextureLevelData,\n offset = 0,\n parameters\n ): void {\n withGLParameters(this.gl, parameters, () => {\n switch (this.props.dimension) {\n case '2d-array':\n case '3d':\n if (this.compressed) {\n // prettier-ignore\n this.device.gl.compressedTexImage3D(this.glTarget, level, this.glInternalFormat, data.width, data.height, depth, BORDER, data.data);\n } else {\n // prettier-ignore\n this.gl.texImage3D( this.glTarget, level, this.glInternalFormat, this.width, this.height, depth, BORDER, this.glFormat, this.glType, data.data);\n }\n break;\n\n case '2d':\n if (this.compressed) {\n // prettier-ignore\n this.device.gl.compressedTexImage2D(this.glTarget, level, this.glInternalFormat, data.width, data.height, BORDER, data.data);\n } else {\n // prettier-ignore\n this.device.gl.texImage2D( this.glTarget, level, this.glInternalFormat, this.width, this.height, BORDER, this.glFormat, this.glType, data.data, offset);\n }\n break;\n\n default:\n throw new Error(this.props.dimension);\n }\n });\n }\n\n * Set a texture level from a GPU buffer\n *\nexport function setMipLevelFromGPUBuffer(\n gl: WebGL2RenderingContext,\n buffer: Buffer,\n options: WebGLSetTextureOptions\n): void {\n const {dimension, width, height, depth = 0, level = 0, byteOffset = 0} = options;\n const {glInternalFormat, glFormat, glType, compressed} = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n const webglBuffer = buffer as WEBGLBuffer;\n const imageSize = buffer.byteLength;\n\n // In WebGL the source buffer is not a parameter. Instead it needs to be bound to a special bind point\n gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, webglBuffer.handle);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, imageSize, byteOffset);\n } else {\n // prettier-ignore\n gl.texImage3D(glTarget, level, glInternalFormat, width, height, depth, BORDER, glFormat, glType, byteOffset);\n }\n break;\n\n case '2d':\n if (compressed) {\n // prettier-ignore\n gl.compressedTexImage2D(glTarget, level, glInternalFormat, width, height, BORDER, imageSize, byteOffset);\n } else {\n // prettier-ignore\n gl.texImage2D(glTarget, level, glInternalFormat, width, height, BORDER, glFormat, glType, byteOffset);\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n\n gl.bindBuffer(GL.PIXEL_UNPACK_BUFFER, null);\n}\n*/\nexport type ReadPixelsToArrayOptions = {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceDepth?: number;\n sourceType?: number;\n};\n\nexport type ReadPixelsToBufferOptions = {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n};\n\n/**\n * Copies data from a type or a Texture object into ArrayBuffer object.\n * App can provide targetPixelArray or have it auto allocated by this method\n * newly allocated by this method unless provided by app.\n * @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read\n * @note Slow requires roundtrip to GPU\n *\n * @param source\n * @param options\n * @returns pixel array,\n */\nexport function readPixelsToArray(\n source: Framebuffer | Texture,\n options?: ReadPixelsToArrayOptions\n): Uint8Array | Uint16Array | Float32Array {\n const {\n sourceX = 0,\n sourceY = 0,\n sourceAttachment = 0 // TODO - support gl.readBuffer\n } = options || {};\n let {\n target = null,\n // following parameters are auto deduced if not provided\n sourceWidth,\n sourceHeight,\n sourceDepth,\n sourceFormat,\n sourceType\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n // assert(framebuffer);\n const {gl, handle} = framebuffer;\n\n sourceWidth ||= framebuffer.width;\n sourceHeight ||= framebuffer.height;\n\n const texture = framebuffer.colorAttachments[sourceAttachment]?.texture;\n if (!texture) {\n throw new Error(`Invalid framebuffer attachment ${sourceAttachment}`);\n }\n sourceDepth = texture?.depth || 1;\n\n sourceFormat ||= texture?.glFormat || GL.RGBA;\n // Deduce the type from color attachment if not provided.\n sourceType ||= texture?.glType || GL.UNSIGNED_BYTE;\n\n // Deduce type and allocated pixelArray if needed\n target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight, sourceDepth);\n\n // Pixel array available, if necessary, deduce type from it.\n sourceType = sourceType || getGLTypeFromTypedArray(target);\n\n // Note: luma.gl overrides bindFramebuffer so that we can reliably restore the previous framebuffer (this is the only function for which we do that)\n const prevHandle = gl.bindFramebuffer(\n GL.FRAMEBUFFER,\n handle\n ) as unknown as WebGLFramebuffer | null;\n\n // Select the color attachment to read from\n gl.readBuffer(gl.COLOR_ATTACHMENT0 + sourceAttachment);\n\n // There is a lot of hedging in the WebGL2 spec about what formats are guaranteed to be readable\n // (It should always be possible to read RGBA/UNSIGNED_BYTE, but most other combinations are not guaranteed)\n // Querying is possible but expensive:\n // const {device} = framebuffer;\n // texture.glReadFormat ||= gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);\n // texture.glReadType ||= gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);\n // console.log('params', device.getGLKey(texture.glReadFormat), device.getGLKey(texture.glReadType));\n\n gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);\n gl.readBuffer(gl.COLOR_ATTACHMENT0);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n\n return target;\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.\n * @deprecated Use CommandEncoder\n * @param source\n * @param options\n */\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: ReadPixelsToBufferOptions\n): WEBGLBuffer {\n const {\n target,\n sourceX = 0,\n sourceY = 0,\n sourceFormat = GL.RGBA,\n targetByteOffset = 0\n } = options || {};\n // following parameters are auto deduced if not provided\n let {sourceWidth, sourceHeight, sourceType} = options || {};\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n // assert(framebuffer);\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const webglFramebuffer = framebuffer;\n\n // deduce type if not available.\n sourceType = sourceType || GL.UNSIGNED_BYTE;\n\n let webglBufferTarget = target as unknown as WEBGLBuffer | undefined;\n if (!webglBufferTarget) {\n // Create new buffer with enough size\n const components = glFormatToComponents(sourceFormat);\n const byteCount = glTypeToBytes(sourceType);\n const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;\n webglBufferTarget = webglFramebuffer.device.createBuffer({byteLength});\n }\n\n // TODO(donmccurdy): Do we have tests to confirm this is working?\n const commandEncoder = source.device.createCommandEncoder();\n commandEncoder.copyTextureToBuffer({\n sourceTexture: source as Texture,\n width: sourceWidth,\n height: sourceHeight,\n origin: [sourceX, sourceY],\n destinationBuffer: webglBufferTarget,\n byteOffset: targetByteOffset\n });\n commandEncoder.destroy();\n\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n\n return webglBufferTarget;\n}\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n * @deprecated Use CommandEncoder\n */\n// eslint-disable-next-line complexity, max-statements\nexport function copyToTexture(\n sourceTexture: Framebuffer | Texture,\n destinationTexture: Texture | GL,\n options?: {\n sourceX?: number;\n sourceY?: number;\n\n targetX?: number;\n targetY?: number;\n targetZ?: number;\n targetMipmaplevel?: number;\n targetInternalFormat?: number;\n\n width?: number; // defaults to target width\n height?: number; // defaults to target height\n }\n): Texture {\n const {\n sourceX = 0,\n sourceY = 0,\n // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMipmaplevel = 0,\n targetInternalFormat = GL.RGBA\n } = options || {};\n let {\n targetX,\n targetY,\n targetZ,\n width, // defaults to target width\n height // defaults to target height\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(sourceTexture);\n // assert(framebuffer);\n const webglFramebuffer = framebuffer;\n const {device, handle} = webglFramebuffer;\n const isSubCopy =\n typeof targetX !== 'undefined' ||\n typeof targetY !== 'undefined' ||\n typeof targetZ !== 'undefined';\n targetX = targetX || 0;\n targetY = targetY || 0;\n targetZ = targetZ || 0;\n const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n // assert(target);\n let texture: WEBGLTexture | null = null;\n let textureTarget: GL;\n if (destinationTexture instanceof WEBGLTexture) {\n texture = destinationTexture;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture?.bind(0);\n // @ts-ignore\n textureTarget = texture.target;\n } else {\n // @ts-ignore\n textureTarget = target;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n targetMipmaplevel,\n targetInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n switch (textureTarget) {\n case GL.TEXTURE_2D:\n case GL.TEXTURE_CUBE_MAP:\n device.gl.copyTexSubImage2D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n device.gl.copyTexSubImage3D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n targetZ,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n default:\n }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n deleteFramebuffer: boolean;\n} {\n if (!(source instanceof Framebuffer)) {\n return {framebuffer: toFramebuffer(source), deleteFramebuffer: true};\n }\n return {framebuffer: source as WEBGLFramebuffer, deleteFramebuffer: false};\n}\n\n/**\n * Wraps a given texture into a framebuffer object, that can be further used\n * to read data from the texture object.\n */\nexport function toFramebuffer(texture: Texture, props?: FramebufferProps): WEBGLFramebuffer {\n const {device, width, height, id} = texture;\n const framebuffer = device.createFramebuffer({\n ...props,\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [texture]\n });\n return framebuffer as WEBGLFramebuffer;\n}\n\n// eslint-disable-next-line max-params\nfunction getPixelArray(\n pixelArray,\n glType: GLDataType | GLPixelType,\n glFormat: GL,\n width: number,\n height: number,\n depth?: number\n): Uint8Array | Uint16Array | Float32Array {\n if (pixelArray) {\n return pixelArray;\n }\n // const formatInfo = decodeTextureFormat(format);\n // Allocate pixel array if not already available, using supplied type\n glType ||= GL.UNSIGNED_BYTE;\n const ArrayType = getTypedArrayFromGLType(glType, {clamped: false});\n const components = glFormatToComponents(glFormat);\n // TODO - check for composite type (components = 1).\n return new ArrayType(width * height * components) as Uint8Array | Uint16Array | Float32Array;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TypedArray, TypedArrayConstructor} from '@math.gl/types';\nimport {GL, GLDataType, GLPixelType} from '@luma.gl/constants';\n\nconst ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';\n\n/**\n * Converts TYPED ARRAYS to corresponding GL constant\n * Used to auto deduce gl parameter types\n * @deprecated Use getDataTypeFromTypedArray\n * @param arrayOrType\n * @returns\n */\nexport function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType {\n // If typed array, look up constructor\n const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;\n switch (type) {\n case Float32Array:\n return GL.FLOAT;\n case Uint16Array:\n return GL.UNSIGNED_SHORT;\n case Uint32Array:\n return GL.UNSIGNED_INT;\n case Uint8Array:\n return GL.UNSIGNED_BYTE;\n case Uint8ClampedArray:\n return GL.UNSIGNED_BYTE;\n case Int8Array:\n return GL.BYTE;\n case Int16Array:\n return GL.SHORT;\n case Int32Array:\n return GL.INT;\n default:\n throw new Error(ERR_TYPE_DEDUCTION);\n }\n}\n\n/**\n * Converts GL constant to corresponding TYPED ARRAY\n * Used to auto deduce gl parameter types\n * @deprecated Use getTypedArrayFromDataType\n * @param glType\n * @param param1\n * @returns\n */\n// eslint-disable-next-line complexity\nexport function getTypedArrayFromGLType(\n glType: GLDataType | GLPixelType,\n options?: {\n clamped?: boolean;\n }\n): TypedArrayConstructor {\n const {clamped = true} = options || {};\n // Sorted in some order of likelihood to reduce amount of comparisons\n switch (glType) {\n case GL.FLOAT:\n return Float32Array;\n case GL.UNSIGNED_SHORT:\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return Uint16Array;\n case GL.UNSIGNED_INT:\n return Uint32Array;\n case GL.UNSIGNED_BYTE:\n return clamped ? Uint8ClampedArray : Uint8Array;\n case GL.BYTE:\n return Int8Array;\n case GL.SHORT:\n return Int16Array;\n case GL.INT:\n return Int32Array;\n default:\n throw new Error('Failed to deduce typed array type from GL constant');\n }\n}\n\n/**\n * Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)\n * https: *stackoverflow.com/questions/41969562/\n * how-can-i-flip-the-result-of-webglrenderingcontext-readpixels\n * @param param0\n */\nexport function flipRows(options: {\n data: TypedArray;\n width: number;\n height: number;\n bytesPerPixel?: number;\n temp?: Uint8Array;\n}): void {\n const {data, width, height, bytesPerPixel = 4, temp} = options;\n const bytesPerRow = width * bytesPerPixel;\n\n // make a temp buffer to hold one row\n const tempBuffer = temp || new Uint8Array(bytesPerRow);\n for (let y = 0; y < height / 2; ++y) {\n const topOffset = y * bytesPerRow;\n const bottomOffset = (height - y - 1) * bytesPerRow;\n // make copy of a row on the top half\n tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));\n // copy a row from the bottom half to the top\n data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);\n // copy the copy of the top half row to the bottom half\n data.set(tempBuffer, bottomOffset);\n }\n}\n\nexport function scalePixels(options: {data: TypedArray; width: number; height: number}): {\n data: Uint8Array;\n width: number;\n height: number;\n} {\n const {data, width, height} = options;\n const newWidth = Math.round(width / 2);\n const newHeight = Math.round(height / 2);\n const newData = new Uint8Array(newWidth * newHeight * 4);\n for (let y = 0; y < newHeight; y++) {\n for (let x = 0; x < newWidth; x++) {\n for (let c = 0; c < 4; c++) {\n newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];\n }\n }\n }\n return {data: newData, width: newWidth, height: newHeight};\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GL} from '@luma.gl/constants';\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format) {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n case GL.RED_INTEGER:\n return 1;\n case GL.RG32I:\n case GL.RG32UI:\n case GL.RG32F:\n case GL.RG_INTEGER:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB_INTEGER:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA_INTEGER:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n return 0;\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type) {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n return 0;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GLParameters, setGLParameters} from '../parameters/unified-parameter-api';\nimport {WebGLStateTracker} from './webgl-state-tracker';\n\n/**\n * Execute a function with a set of temporary WebGL parameter overrides\n * - Saves current \"global\" WebGL context settings\n * - Sets the supplies WebGL context parameters,\n * - Executes supplied function\n * - Restores parameters\n * - Returns the return value of the supplied function\n */\nexport function withGLParameters(\n gl: WebGL2RenderingContext,\n parameters: GLParameters & {nocatch?: boolean},\n func: any\n): any {\n if (isObjectEmpty(parameters)) {\n // Avoid setting state if no parameters provided. Just call and return\n return func(gl);\n }\n\n const {nocatch = true} = parameters;\n\n const webglState = WebGLStateTracker.get(gl);\n webglState.push();\n setGLParameters(gl, parameters);\n\n // Setup is done, call the function\n let value;\n\n if (nocatch) {\n // Avoid try catch to minimize stack size impact for safe execution paths\n value = func(gl);\n webglState.pop();\n } else {\n // Wrap in a try-catch to ensure that parameters are restored on exceptions\n try {\n value = func(gl);\n } finally {\n webglState.pop();\n }\n }\n\n return value;\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore - dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {NumericArray, NumberArray4} from '@math.gl/types';\nimport {RenderPass, RenderPassProps, RenderPassParameters} from '@luma.gl/core';\nimport {WebGLDevice} from '../webgl-device';\nimport {GL, GLParameters} from '@luma.gl/constants';\nimport {withGLParameters} from '../../context/state-tracker/with-parameters';\nimport {setGLParameters} from '../../context/parameters/unified-parameter-api';\nimport {WEBGLQuerySet} from './webgl-query-set';\n\nconst COLOR_CHANNELS = [0x1, 0x2, 0x4, 0x8]; // GPUColorWrite RED, GREEN, BLUE, ALPHA\n\nexport class WEBGLRenderPass extends RenderPass {\n readonly device: WebGLDevice;\n\n /** Parameters that should be applied before each draw call */\n glParameters: GLParameters;\n\n constructor(device: WebGLDevice, props: RenderPassProps) {\n super(device, props);\n this.device = device;\n\n // If no viewport is provided, apply reasonably defaults\n let viewport;\n if (!props?.parameters?.viewport) {\n if (props?.framebuffer) {\n // Set the viewport to the size of the framebuffer\n const {width, height} = props.framebuffer;\n viewport = [0, 0, width, height];\n } else {\n // Instead of using our own book-keeping, we can just read the values from the WebGL context\n const [width, height] = device.getCanvasContext().getDrawingBufferSize();\n viewport = [0, 0, width, height];\n }\n }\n\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.device.pushState();\n this.setParameters({viewport, ...this.props.parameters});\n\n // Specify mapping of draw buffer locations to color attachments\n if (this.props.framebuffer) {\n const drawBuffers = this.props.framebuffer.colorAttachments.map(\n (_, i) => GL.COLOR_ATTACHMENT0 + i\n );\n this.device.gl.drawBuffers(drawBuffers);\n } else {\n this.device.gl.drawBuffers([GL.BACK]);\n }\n\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n\n end(): void {\n this.device.popState();\n // should add commands to CommandEncoder.\n }\n\n pushDebugGroup(groupLabel: string): void {}\n popDebugGroup(): void {}\n insertDebugMarker(markerLabel: string): void {}\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable): void;\n\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters: RenderPassParameters = {}): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n // Framebuffers are specified using parameters in WebGL\n glParameters.framebuffer = this.props.framebuffer || null;\n\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n\n glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;\n\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n // WebGPU viewports are 6 coordinates (X, Y, Z)\n if (parameters.viewport.length >= 6) {\n glParameters.viewport = parameters.viewport.slice(0, 4) as NumberArray4;\n glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];\n } else {\n // WebGL viewports are 4 coordinates (X, Y)\n glParameters.viewport = parameters.viewport as NumberArray4;\n }\n }\n if (parameters.scissorRect) {\n glParameters.scissorTest = true;\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n parameters[GL.STENCIL_REF] = parameters.stencilReference;\n }\n\n if (parameters.colorMask) {\n glParameters.colorMask = COLOR_CHANNELS.map(channel =>\n Boolean(channel & parameters.colorMask)\n );\n }\n\n this.glParameters = glParameters;\n\n setGLParameters(this.device.gl, glParameters);\n }\n\n beginOcclusionQuery(queryIndex: number): void {\n const webglQuerySet = this.props.occlusionQuerySet as WEBGLQuerySet;\n webglQuerySet?.beginOcclusionQuery();\n }\n\n override endOcclusionQuery(): void {\n const webglQuerySet = this.props.occlusionQuerySet as WEBGLQuerySet;\n webglQuerySet?.endOcclusionQuery();\n }\n\n // PRIVATE\n\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n protected clear(): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n let clearMask = 0;\n\n if (this.props.clearColors) {\n this.props.clearColors.forEach((color, drawBufferIndex) => {\n if (color) {\n this.clearColorBuffer(drawBufferIndex, color);\n }\n });\n }\n\n if (this.props.clearColor !== false && this.props.clearColors === undefined) {\n clearMask |= GL.COLOR_BUFFER_BIT;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= GL.DEPTH_BUFFER_BIT;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= GL.STENCIL_BUFFER_BIT;\n glParameters.clearStencil = this.props.clearStencil;\n }\n\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withGLParameters(this.device.gl, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n }\n }\n\n /**\n * WebGL2 - clear a specific color buffer\n */\n protected clearColorBuffer(drawBuffer: number = 0, value: NumericArray = [0, 0, 0, 0]) {\n withGLParameters(this.device.gl, {framebuffer: this.props.framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int8Array:\n case Int16Array:\n case Int32Array:\n this.device.gl.clearBufferiv(GL.COLOR, drawBuffer, value);\n break;\n case Uint8Array:\n case Uint8ClampedArray:\n case Uint16Array:\n case Uint32Array:\n this.device.gl.clearBufferuiv(GL.COLOR, drawBuffer, value);\n break;\n case Float32Array:\n this.device.gl.clearBufferfv(GL.COLOR, drawBuffer, value);\n break;\n default:\n throw new Error('clearColorBuffer: color must be typed array');\n }\n });\n }\n\n /*\n clearDepthStencil() {\n case GL.DEPTH:\n this.device.gl.clearBufferfv(GL.DEPTH, 0, [value]);\n break;\n\n case GL_STENCIL:\n this.device.gl.clearBufferiv(GL.STENCIL, 0, [value]);\n break;\n\n case GL.DEPTH_STENCIL:\n const [depth, stencil] = value;\n this.device.gl.clearBufferfi(GL.DEPTH_STENCIL, 0, depth, stencil);\n break;\n\n default:\n assert(false, ERR_ARGUMENTS);\n }\n });\n */\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n RenderPipelineProps,\n RenderPipelineParameters,\n PrimitiveTopology,\n ShaderLayout,\n UniformValue,\n Binding,\n RenderPass,\n VertexArray\n} from '@luma.gl/core';\nimport {RenderPipeline, log} from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {getShaderLayoutFromGLSL} from '../helpers/get-shader-layout';\nimport {withDeviceAndGLParameters} from '../converters/device-parameters';\nimport {setUniform} from '../helpers/set-uniform';\nimport {splitUniformsAndBindings} from '../../utils/split-uniforms-and-bindings';\n// import {copyUniform, checkUniformValues} from '../../classes/uniforms';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLShader} from './webgl-shader';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLTextureView} from './webgl-texture-view';\nimport {WEBGLRenderPass} from './webgl-render-pass';\nimport {WEBGLTransformFeedback} from './webgl-transform-feedback';\nimport {getGLDrawMode} from '../helpers/webgl-topology-utils';\n\nconst LOG_PROGRAM_PERF_PRIORITY = 4;\n\n/** Creates a new render pipeline */\nexport class WEBGLRenderPipeline extends RenderPipeline {\n /** The WebGL device that created this render pipeline */\n device: WebGLDevice;\n /** Handle to underlying WebGL program */\n handle: WebGLProgram;\n /** vertex shader */\n vs: WEBGLShader;\n /** fragment shader */\n fs: WEBGLShader;\n /** The layout extracted from shader by WebGL introspection APIs */\n introspectedLayout: ShaderLayout;\n\n /** Uniforms set on this model */\n uniforms: Record = {};\n /** Bindings set on this model */\n bindings: Record = {};\n /** WebGL varyings */\n varyings: string[] | null = null;\n\n _uniformCount: number = 0;\n _uniformSetters: Record = {}; // TODO are these used?\n\n constructor(device: WebGLDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.gl.createProgram();\n this.device.setSpectorMetadata(this.handle, {id: this.props.id});\n\n // Create shaders if needed\n this.vs = props.vs as WEBGLShader;\n this.fs = props.fs as WEBGLShader;\n // assert(this.vs.stage === 'vertex');\n // assert(this.fs.stage === 'fragment');\n\n // Setup varyings if supplied\n // @ts-expect-error WebGL only\n const {varyings, bufferMode = GL.SEPARATE_ATTRIBS} = props;\n if (varyings && varyings.length > 0) {\n this.varyings = varyings;\n this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);\n }\n\n this._linkShaders();\n\n log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();\n this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);\n log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();\n\n // Merge provided layout with introspected layout\n this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.device.gl.deleteProgram(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n /**\n * Bindings include: textures, samplers and uniform buffers\n * @todo needed for portable model\n */\n setBindings(bindings: Record, options?: {disableWarnings?: boolean}): void {\n // if (log.priority >= 2) {\n // checkUniformValues(uniforms, this.id, this._uniformSetters);\n // }\n\n for (const [name, value] of Object.entries(bindings)) {\n // Accept both `xyz` and `xyzUniforms` as valid names for `xyzUniforms` uniform block\n // This convention allows shaders to name uniform blocks as `uniform appUniforms {} app;`\n // and reference them as `app` from both GLSL and JS.\n // TODO - this is rather hacky - we could also remap the name directly in the shader layout.\n const binding =\n this.shaderLayout.bindings.find(binding_ => binding_.name === name) ||\n this.shaderLayout.bindings.find(binding_ => binding_.name === `${name}Uniforms`);\n\n if (!binding) {\n const validBindings = this.shaderLayout.bindings\n .map(binding_ => `\"${binding_.name}\"`)\n .join(', ');\n if (!options?.disableWarnings) {\n log.warn(\n `No binding \"${name}\" in render pipeline \"${this.id}\", expected one of ${validBindings}`,\n value\n )();\n }\n continue; // eslint-disable-line no-continue\n }\n if (!value) {\n log.warn(`Unsetting binding \"${name}\" in render pipeline \"${this.id}\"`)();\n }\n switch (binding.type) {\n case 'uniform':\n // @ts-expect-error\n if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {\n throw new Error('buffer value');\n }\n break;\n case 'texture':\n if (\n !(\n value instanceof WEBGLTextureView ||\n value instanceof WEBGLTexture ||\n value instanceof WEBGLFramebuffer\n )\n ) {\n throw new Error('texture value');\n }\n break;\n case 'sampler':\n log.warn(`Ignoring sampler ${name}`)();\n break;\n default:\n throw new Error(binding.type);\n }\n\n this.bindings[name] = value;\n }\n }\n\n /** @todo needed for portable model\n * @note The WebGL API is offers many ways to draw things\n * This function unifies those ways into a single call using common parameters with sane defaults\n */\n draw(options: {\n renderPass: RenderPass;\n parameters?: RenderPipelineParameters;\n topology?: PrimitiveTopology;\n vertexArray: VertexArray;\n isInstanced?: boolean;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n transformFeedback?: WEBGLTransformFeedback;\n }): boolean {\n const {\n renderPass,\n parameters = this.props.parameters,\n topology = this.props.topology,\n vertexArray,\n vertexCount,\n // indexCount,\n instanceCount,\n isInstanced = false,\n firstVertex = 0,\n // firstIndex,\n // firstInstance,\n // baseVertex,\n transformFeedback\n } = options;\n\n const glDrawMode = getGLDrawMode(topology);\n const isIndexed: boolean = Boolean(vertexArray.indexBuffer);\n const glIndexType = (vertexArray.indexBuffer as WEBGLBuffer)?.glIndexType;\n // Note that we sometimes get called with 0 instances\n\n // If we are using async linking, we need to wait until linking completes\n if (this.linkStatus !== 'success') {\n log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();\n return false;\n }\n\n // Avoid WebGL draw call when not rendering any data or values are incomplete\n // Note: async textures set as uniforms might still be loading.\n // Now that all uniforms have been updated, check if any texture\n // in the uniforms is not yet initialized, then we don't draw\n if (!this._areTexturesRenderable()) {\n log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();\n // Note: false means that the app needs to redraw the pipeline again.\n return false;\n }\n\n // (isInstanced && instanceCount === 0)\n // if (vertexCount === 0) {\n // log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();\n // Note: false means that the app needs to redraw the pipeline again.\n // return true;\n // }\n\n this.device.gl.useProgram(this.handle);\n\n // Note: Rebinds constant attributes before each draw call\n vertexArray.bindBeforeRender(renderPass);\n\n if (transformFeedback) {\n transformFeedback.begin(this.props.topology);\n }\n\n // We have to apply bindings before every draw call since other draw calls will overwrite\n this._applyBindings();\n this._applyUniforms();\n\n const webglRenderPass = renderPass as WEBGLRenderPass;\n\n withDeviceAndGLParameters(this.device, parameters, webglRenderPass.glParameters, () => {\n if (isIndexed && isInstanced) {\n this.device.gl.drawElementsInstanced(\n glDrawMode,\n vertexCount || 0, // indexCount?\n glIndexType,\n firstVertex,\n instanceCount || 0\n );\n // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {\n // this.device.gldrawRangeElements(glDrawMode, start, end, vertexCount, glIndexType, offset);\n } else if (isIndexed) {\n this.device.gl.drawElements(glDrawMode, vertexCount || 0, glIndexType, firstVertex); // indexCount?\n } else if (isInstanced) {\n this.device.gl.drawArraysInstanced(\n glDrawMode,\n firstVertex,\n vertexCount || 0,\n instanceCount || 0\n );\n } else {\n this.device.gl.drawArrays(glDrawMode, firstVertex, vertexCount || 0);\n }\n\n if (transformFeedback) {\n transformFeedback.end();\n }\n });\n\n vertexArray.unbindAfterRender(renderPass);\n\n return true;\n }\n\n // DEPRECATED METHODS\n\n override setUniformsWebGL(uniforms: Record) {\n const {bindings} = splitUniformsAndBindings(uniforms);\n Object.keys(bindings).forEach(name => {\n log.warn(\n `Unsupported value \"${JSON.stringify(\n bindings[name]\n )}\" used in setUniforms() for key ${name}. Use setBindings() instead?`\n )();\n });\n // TODO - check against layout\n Object.assign(this.uniforms, uniforms);\n }\n\n // PRIVATE METHODS\n\n // setAttributes(attributes: Record): void {}\n // setBindings(bindings: Record): void {}\n\n protected async _linkShaders() {\n const {gl} = this.device;\n gl.attachShader(this.handle, this.vs.handle);\n gl.attachShader(this.handle, this.fs.handle);\n log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n gl.linkProgram(this.handle);\n log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n\n // TODO Avoid checking program linking error in production\n if (log.level === 0) {\n // return;\n }\n\n if (!this.device.features.has('compilation-status-async-webgl')) {\n const status = this._getLinkStatus();\n this._reportLinkStatus(status);\n return;\n }\n\n // async case\n log.once(1, 'RenderPipeline linking is asynchronous')();\n await this._waitForLinkComplete();\n log.info(2, `RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();\n const status = this._getLinkStatus();\n this._reportLinkStatus(status);\n }\n\n /** Report link status. First, check for shader compilation failures if linking fails */\n async _reportLinkStatus(status: 'success' | 'linking' | 'validation'): Promise {\n switch (status) {\n case 'success':\n return;\n\n default:\n // First check for shader compilation failures if linking fails\n switch (this.vs.compilationStatus) {\n case 'error':\n this.vs.debugShader();\n throw new Error(`Error during compilation of shader ${this.vs.id}`);\n case 'pending':\n this.vs.asyncCompilationStatus.then(() => this.vs.debugShader());\n break;\n case 'success':\n break;\n }\n\n switch (this.fs?.compilationStatus) {\n case 'error':\n this.fs.debugShader();\n throw new Error(`Error during compilation of shader ${this.fs.id}`);\n case 'pending':\n this.fs.asyncCompilationStatus.then(() => this.fs.debugShader());\n break;\n case 'success':\n break;\n }\n\n const linkErrorLog = this.device.gl.getProgramInfoLog(this.handle);\n throw new Error(`Error during ${status}: ${linkErrorLog}`);\n }\n }\n\n /**\n * Get the shader compilation status\n * TODO - Load log even when no error reported, to catch warnings?\n * https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings\n */\n _getLinkStatus(): 'success' | 'linking' | 'validation' {\n const {gl} = this.device;\n const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);\n if (!linked) {\n this.linkStatus = 'error';\n return 'linking';\n }\n\n gl.validateProgram(this.handle);\n const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);\n if (!validated) {\n this.linkStatus = 'error';\n return 'validation';\n }\n\n this.linkStatus = 'success';\n return 'success';\n }\n\n /** Use KHR_parallel_shader_compile extension if available */\n async _waitForLinkComplete(): Promise {\n const waitMs = async (ms: number) => await new Promise(resolve => setTimeout(resolve, ms));\n const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)\n\n // If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking\n if (!this.device.features.has('compilation-status-async-webgl')) {\n await waitMs(DELAY_MS);\n return;\n }\n\n const {gl} = this.device;\n for (;;) {\n const complete = gl.getProgramParameter(this.handle, GL.COMPLETION_STATUS_KHR);\n if (complete) {\n return;\n }\n await waitMs(DELAY_MS);\n }\n }\n\n /**\n * Checks if all texture-values uniforms are renderable (i.e. loaded)\n * Update a texture if needed (e.g. from video)\n * Note: This is currently done before every draw call\n */\n _areTexturesRenderable() {\n let texturesRenderable = true;\n\n for (const bindingInfo of this.shaderLayout.bindings) {\n if (\n !this.bindings[bindingInfo.name] &&\n !this.bindings[bindingInfo.name.replace(/Uniforms$/, '')]\n ) {\n log.warn(`Binding ${bindingInfo.name} not found in ${this.id}`)();\n texturesRenderable = false;\n }\n }\n\n // TODO - remove this should be handled by ExternalTexture\n // for (const [, texture] of Object.entries(this.bindings)) {\n // if (texture instanceof WEBGLTexture) {\n // texture.update();\n // }\n // }\n\n return texturesRenderable;\n }\n\n /** Apply any bindings (before each draw call) */\n _applyBindings() {\n // If we are using async linking, we need to wait until linking completes\n if (this.linkStatus !== 'success') {\n return;\n }\n\n const {gl} = this.device;\n gl.useProgram(this.handle);\n\n let textureUnit = 0;\n let uniformBufferIndex = 0;\n for (const binding of this.shaderLayout.bindings) {\n // Accept both `xyz` and `xyzUniforms` as valid names for `xyzUniforms` uniform block\n const value =\n this.bindings[binding.name] || this.bindings[binding.name.replace(/Uniforms$/, '')];\n if (!value) {\n throw new Error(`No value for binding ${binding.name} in ${this.id}`);\n }\n switch (binding.type) {\n case 'uniform':\n // Set buffer\n const {name} = binding;\n const location = gl.getUniformBlockIndex(this.handle, name);\n if ((location as GL) === GL.INVALID_INDEX) {\n throw new Error(`Invalid uniform block name ${name}`);\n }\n gl.uniformBlockBinding(this.handle, uniformBufferIndex, location);\n // console.debug(binding, location);\n if (value instanceof WEBGLBuffer) {\n gl.bindBufferBase(GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);\n } else {\n gl.bindBufferRange(\n GL.UNIFORM_BUFFER,\n uniformBufferIndex,\n // @ts-expect-error\n value.buffer.handle,\n // @ts-expect-error\n value.offset || 0,\n // @ts-expect-error\n value.size || value.buffer.byteLength - value.offset\n );\n }\n uniformBufferIndex += 1;\n break;\n\n case 'texture':\n if (\n !(\n value instanceof WEBGLTextureView ||\n value instanceof WEBGLTexture ||\n value instanceof WEBGLFramebuffer\n )\n ) {\n throw new Error('texture');\n }\n let texture: WEBGLTexture;\n if (value instanceof WEBGLTextureView) {\n texture = value.texture;\n } else if (value instanceof WEBGLTexture) {\n texture = value;\n } else if (\n value instanceof WEBGLFramebuffer &&\n value.colorAttachments[0] instanceof WEBGLTextureView\n ) {\n log.warn(\n 'Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead'\n )();\n texture = value.colorAttachments[0].texture;\n } else {\n throw new Error('No texture');\n }\n\n gl.activeTexture(GL.TEXTURE0 + textureUnit);\n gl.bindTexture(texture.glTarget, texture.handle);\n // gl.bindSampler(textureUnit, sampler.handle);\n textureUnit += 1;\n break;\n\n case 'sampler':\n // ignore\n break;\n\n case 'storage':\n case 'read-only-storage':\n throw new Error(`binding type '${binding.type}' not supported in WebGL`);\n }\n }\n }\n\n /**\n * Due to program sharing, uniforms need to be reset before every draw call\n * (though caching will avoid redundant WebGL calls)\n */\n _applyUniforms() {\n for (const uniformLayout of this.shaderLayout.uniforms || []) {\n const {name, location, type, textureUnit} = uniformLayout;\n const value = this.uniforms[name] ?? textureUnit;\n if (value !== undefined) {\n setUniform(this.device.gl, location, type, value);\n }\n }\n }\n}\n\n/**\n * Merges an provided shader layout into a base shader layout\n * In WebGL, this allows the auto generated shader layout to be overridden by the application\n * Typically to change the format of the vertex attributes (from float32x4 to uint8x4 etc).\n * @todo Drop this? Aren't all use cases covered by mergeBufferLayout()?\n */\nfunction mergeShaderLayout(baseLayout: ShaderLayout, overrideLayout: ShaderLayout): ShaderLayout {\n // Deep clone the base layout\n const mergedLayout: ShaderLayout = {\n ...baseLayout,\n attributes: baseLayout.attributes.map(attribute => ({...attribute}))\n };\n // Merge the attributes\n for (const attribute of overrideLayout?.attributes || []) {\n const baseAttribute = mergedLayout.attributes.find(attr => attr.name === attribute.name);\n if (!baseAttribute) {\n log.warn(`shader layout attribute ${attribute.name} not present in shader`);\n } else {\n baseAttribute.type = attribute.type || baseAttribute.type;\n baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;\n }\n }\n return mergedLayout;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n ShaderLayout,\n UniformBinding,\n UniformBlockBinding,\n AttributeDeclaration,\n VaryingBinding\n} from '@luma.gl/core';\n\nimport {GL} from '@luma.gl/constants';\nimport {decodeGLUniformType, decodeGLAttributeType, isSamplerUniform} from './decode-webgl-types';\n\n/**\n * Extract metadata describing binding information for a program's shaders\n * Note: `linkProgram()` needs to have been called\n * (although linking does not need to have been successful).\n */\nexport function getShaderLayoutFromGLSL(\n gl: WebGL2RenderingContext,\n program: WebGLProgram\n): ShaderLayout {\n const shaderLayout: ShaderLayout = {\n attributes: [],\n bindings: []\n };\n\n shaderLayout.attributes = readAttributeDeclarations(gl, program);\n\n // Uniform blocks\n const uniformBlocks: UniformBlockBinding[] = readUniformBlocks(gl, program);\n for (const uniformBlock of uniformBlocks) {\n const uniforms = uniformBlock.uniforms.map(uniform => ({\n name: uniform.name,\n format: uniform.format,\n byteOffset: uniform.byteOffset,\n byteStride: uniform.byteStride,\n arrayLength: uniform.arrayLength\n }));\n shaderLayout.bindings.push({\n type: 'uniform',\n name: uniformBlock.name,\n group: 0,\n location: uniformBlock.location,\n visibility: (uniformBlock.vertex ? 0x1 : 0) & (uniformBlock.fragment ? 0x2 : 0),\n minBindingSize: uniformBlock.byteLength,\n uniforms\n });\n }\n\n const uniforms: UniformBinding[] = readUniformBindings(gl, program);\n let textureUnit = 0;\n for (const uniform of uniforms) {\n if (isSamplerUniform(uniform.type)) {\n const {viewDimension, sampleType} = getSamplerInfo(uniform.type);\n shaderLayout.bindings.push({\n type: 'texture',\n name: uniform.name,\n group: 0,\n location: textureUnit,\n viewDimension,\n sampleType\n });\n\n // @ts-expect-error\n uniform.textureUnit = textureUnit;\n textureUnit += 1;\n }\n }\n\n if (uniforms.length) {\n shaderLayout.uniforms = uniforms;\n }\n\n // Varyings\n const varyings: VaryingBinding[] = readVaryings(gl, program);\n // Note - samplers are always in unform bindings, even if uniform blocks are used\n if (varyings?.length) {\n shaderLayout.varyings = varyings;\n }\n\n return shaderLayout;\n}\n\n// HELPERS\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readAttributeDeclarations(\n gl: WebGL2RenderingContext,\n program: WebGLProgram\n): AttributeDeclaration[] {\n const attributes: AttributeDeclaration[] = [];\n\n const count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);\n\n for (let index = 0; index < count; index++) {\n const activeInfo = gl.getActiveAttrib(program, index);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType /* , size*/} = activeInfo;\n const location = gl.getAttribLocation(program, name);\n // Add only user provided attributes, for built-in attributes like `gl_InstanceID` location will be < 0\n if (location >= 0) {\n const {attributeType} = decodeGLAttributeType(compositeType);\n\n // Whether an attribute is instanced is essentially fixed by the structure of the shader code,\n // so it is arguably a static property of the shader.\n // There is no hint in the shader declarations\n // Heuristic: Any attribute name containing the word \"instance\" will be assumed to be instanced\n const stepMode = /instance/i.test(name) ? 'instance' : 'vertex';\n\n attributes.push({\n name,\n location,\n stepMode,\n type: attributeType\n // size - for arrays, size is the number of elements in the array\n });\n }\n }\n\n // Sort by declaration order\n attributes.sort((a: AttributeDeclaration, b: AttributeDeclaration) => a.location - b.location);\n return attributes;\n}\n\n/**\n * Extract info about all transform feedback varyings\n *\n * linkProgram needs to have been called, although linking does not need to have been successful\n */\nfunction readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): VaryingBinding[] {\n const varyings: VaryingBinding[] = [];\n\n const count = gl.getProgramParameter(program, GL.TRANSFORM_FEEDBACK_VARYINGS);\n for (let location = 0; location < count; location++) {\n const activeInfo = gl.getTransformFeedbackVarying(program, location);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name, type: compositeType, size} = activeInfo;\n const {glType, components} = decodeGLUniformType(compositeType);\n const varying = {location, name, type: glType, size: size * components}; // Base values\n varyings.push(varying);\n }\n\n varyings.sort((a, b) => a.location - b.location);\n return varyings;\n}\n\n/**\n * Extract info about all uniforms\n *\n * Query uniform locations and build name to setter map.\n */\nfunction readUniformBindings(gl: WebGL2RenderingContext, program: WebGLProgram): UniformBinding[] {\n const uniforms: UniformBinding[] = [];\n\n const uniformCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORMS);\n for (let i = 0; i < uniformCount; i++) {\n const activeInfo = gl.getActiveUniform(program, i);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n const {name: rawName, size, type} = activeInfo;\n const {name, isArray} = parseUniformName(rawName);\n let webglLocation = gl.getUniformLocation(program, name);\n const uniformInfo = {\n // WebGL locations are uniquely typed but just numbers\n location: webglLocation as number,\n name,\n size,\n type,\n isArray\n };\n uniforms.push(uniformInfo);\n\n // Array (e.g. matrix) uniforms can occupy several 4x4 byte banks\n if (uniformInfo.size > 1) {\n for (let j = 0; j < uniformInfo.size; j++) {\n const elementName = `${name}[${j}]`;\n\n webglLocation = gl.getUniformLocation(program, elementName);\n\n const arrayElementUniformInfo = {\n ...uniformInfo,\n name: elementName,\n location: webglLocation as number\n };\n\n uniforms.push(arrayElementUniformInfo);\n }\n }\n }\n return uniforms;\n}\n\n/**\n * Extract info about all \"active\" uniform blocks\n * @note In WebGL, \"active\" just means that unused (inactive) blocks may have been optimized away during linking)\n */\nfunction readUniformBlocks(\n gl: WebGL2RenderingContext,\n program: WebGLProgram\n): UniformBlockBinding[] {\n const getBlockParameter = (blockIndex: number, pname: GL): any =>\n gl.getActiveUniformBlockParameter(program, blockIndex, pname);\n\n const uniformBlocks: UniformBlockBinding[] = [];\n\n const blockCount = gl.getProgramParameter(program, GL.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {\n const blockInfo: UniformBlockBinding = {\n name: gl.getActiveUniformBlockName(program, blockIndex) || '',\n location: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_BINDING),\n byteLength: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_DATA_SIZE),\n vertex: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n fragment: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n uniformCount: getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n uniforms: [] as any[]\n };\n\n const uniformIndices =\n (getBlockParameter(blockIndex, GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) as number[]) || [];\n\n const uniformType = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_TYPE); // Array of GLenum indicating the types of the uniforms.\n const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_SIZE); // Array of GLuint indicating the sizes of the uniforms.\n // const uniformBlockIndex = gl.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_BLOCK_INDEX\n // ); // Array of GLint indicating the block indices of the uniforms.\n const uniformOffset = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_OFFSET); // Array of GLint indicating the uniform buffer offsets.\n const uniformStride = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_ARRAY_STRIDE); // Array of GLint indicating the strides between the elements.\n // const uniformMatrixStride = gl.getActiveUniforms(\n // program,\n // uniformIndices,\n // GL.UNIFORM_MATRIX_STRIDE\n // ); // Array of GLint indicating the strides between columns of a column-major matrix or a row-major matrix.\n // const uniformRowMajor = gl.getActiveUniforms(program, uniformIndices, GL.UNIFORM_IS_ROW_MAJOR);\n for (let i = 0; i < blockInfo.uniformCount; ++i) {\n const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);\n if (!activeInfo) {\n throw new Error('activeInfo');\n }\n\n blockInfo.uniforms.push({\n name: activeInfo.name,\n format: decodeGLUniformType(uniformType[i]).format,\n type: uniformType[i],\n arrayLength: uniformArrayLength[i],\n byteOffset: uniformOffset[i],\n byteStride: uniformStride[i]\n // matrixStride: uniformStride[i],\n // rowMajor: uniformRowMajor[i]\n });\n }\n\n uniformBlocks.push(blockInfo);\n }\n\n uniformBlocks.sort((a, b) => a.location - b.location);\n return uniformBlocks;\n}\n\n/**\n * TOOD - compare with a above, confirm copy, then delete\n const bindings: Binding[] = [];\n const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORM_BLOCKS);\n for (let blockIndex = 0; blockIndex < count; blockIndex++) {\n const vertex = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),\n const fragment = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),\n const visibility = (vertex) + (fragment);\n const binding: BufferBinding = {\n location: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_BINDING),\n // name: gl.getActiveUniformBlockName(program, blockIndex),\n type: 'uniform',\n visibility,\n minBindingSize: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE),\n // uniformCount: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORMS),\n // uniformIndices: gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),\n }\n bindings.push(binding);\n }\n*/\n\nconst SAMPLER_UNIFORMS_GL_TO_GPU: Record<\n number,\n [\n '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint'\n ]\n> = {\n [GL.SAMPLER_2D]: ['2d', 'float'],\n [GL.SAMPLER_CUBE]: ['cube', 'float'],\n [GL.SAMPLER_3D]: ['3d', 'float'],\n [GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],\n [GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],\n [GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],\n [GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],\n [GL.INT_SAMPLER_2D]: ['2d', 'sint'],\n [GL.INT_SAMPLER_3D]: ['3d', 'sint'],\n [GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],\n [GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],\n [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']\n};\n\ntype SamplerInfo = {\n viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';\n sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';\n};\n\nfunction getSamplerInfo(type: GL): SamplerInfo {\n const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];\n if (!sampler) {\n throw new Error('sampler');\n }\n const [viewDimension, sampleType] = sampler;\n return {viewDimension, sampleType};\n}\n\n// HELPERS\n\nfunction parseUniformName(name: string): {name: string; length: number; isArray: boolean} {\n // Shortcut to avoid redundant or bad matches\n if (name[name.length - 1] !== ']') {\n return {\n name,\n length: 1,\n isArray: false\n };\n }\n\n // if array name then clean the array brackets\n const UNIFORM_NAME_REGEXP = /([^[]*)(\\[[0-9]+\\])?/;\n const matches = UNIFORM_NAME_REGEXP.exec(name);\n if (!matches || matches.length < 2) {\n throw new Error(`Failed to parse GLSL uniform name ${name}`);\n }\n\n return {\n name: matches[1],\n length: matches[2] ? 1 : 0,\n isArray: Boolean(matches[2])\n };\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ShaderUniformType, ShaderAttributeType, VertexFormat} from '@luma.gl/core';\nimport {GL, GLUniformType, GLSamplerType, GLCompositeType, GLDataType} from '@luma.gl/constants';\n\n/** Check is uniform is of sampler type */\nexport function isSamplerUniform(type: GLUniformType): boolean {\n return SAMPLER_TYPES.includes(type as GLSamplerType);\n}\n\nconst SAMPLER_TYPES: GLSamplerType[] = [\n GL.SAMPLER_2D,\n GL.SAMPLER_CUBE,\n GL.SAMPLER_3D,\n GL.SAMPLER_2D_SHADOW,\n GL.SAMPLER_2D_ARRAY,\n GL.SAMPLER_2D_ARRAY_SHADOW,\n GL.SAMPLER_CUBE_SHADOW,\n GL.INT_SAMPLER_2D,\n GL.INT_SAMPLER_3D,\n GL.INT_SAMPLER_CUBE,\n GL.INT_SAMPLER_2D_ARRAY,\n GL.UNSIGNED_INT_SAMPLER_2D,\n GL.UNSIGNED_INT_SAMPLER_3D,\n GL.UNSIGNED_INT_SAMPLER_CUBE,\n GL.UNSIGNED_INT_SAMPLER_2D_ARRAY\n];\n\n// Composite types table\nconst COMPOSITE_GL_TYPES: Record<\n GLCompositeType,\n [GLDataType, number, string, ShaderUniformType, VertexFormat?]\n> = {\n [GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],\n [GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2', 'float32x2'],\n [GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3', 'float32x3'],\n [GL.FLOAT_VEC4]: [GL.FLOAT, 4, 'vec4', 'vec4', 'float32x4'],\n\n [GL.INT]: [GL.INT, 1, 'int', 'i32', 'sint32'],\n [GL.INT_VEC2]: [GL.INT, 2, 'ivec2', 'vec2', 'sint32x2'],\n [GL.INT_VEC3]: [GL.INT, 3, 'ivec3', 'vec3', 'sint32x3'],\n [GL.INT_VEC4]: [GL.INT, 4, 'ivec4', 'vec4', 'sint32x4'],\n\n [GL.UNSIGNED_INT]: [GL.UNSIGNED_INT, 1, 'uint', 'u32', 'uint32'],\n [GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, 'uvec2', 'vec2', 'uint32x2'],\n [GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, 'uvec3', 'vec3', 'uint32x3'],\n [GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, 'uvec4', 'vec4', 'uint32x4'],\n\n [GL.BOOL]: [GL.FLOAT, 1, 'bool', 'f32', 'float32'],\n [GL.BOOL_VEC2]: [GL.FLOAT, 2, 'bvec2', 'vec2', 'float32x2'],\n [GL.BOOL_VEC3]: [GL.FLOAT, 3, 'bvec3', 'vec3', 'float32x3'],\n [GL.BOOL_VEC4]: [GL.FLOAT, 4, 'bvec4', 'vec4', 'float32x4'],\n\n // TODO - are sizes/components below correct?\n [GL.FLOAT_MAT2]: [GL.FLOAT, 8, 'mat2', 'mat2x2'], // 4\n [GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, 'mat2x3', 'mat2x3'], // 6\n [GL.FLOAT_MAT2x4]: [GL.FLOAT, 8, 'mat2x4', 'mat2x4'], // 8\n\n [GL.FLOAT_MAT3x2]: [GL.FLOAT, 12, 'mat3x2', 'mat3x2'], // 6\n [GL.FLOAT_MAT3]: [GL.FLOAT, 12, 'mat3', 'mat3x3'], // 9\n [GL.FLOAT_MAT3x4]: [GL.FLOAT, 12, 'mat3x4', 'mat3x4'], // 12\n\n [GL.FLOAT_MAT4x2]: [GL.FLOAT, 16, 'mat4x2', 'mat4x2'], // 8\n [GL.FLOAT_MAT4x3]: [GL.FLOAT, 16, 'mat4x3', 'mat4x3'], // 12\n [GL.FLOAT_MAT4]: [GL.FLOAT, 16, 'mat4', 'mat4x4'] // 16\n};\n\n/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */\nexport function decodeGLUniformType(glUniformType: GL): {\n format: ShaderUniformType;\n components: number;\n glType: GLDataType;\n} {\n const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];\n if (!typeAndSize) {\n throw new Error('uniform');\n }\n const [glType, components, , format] = typeAndSize;\n return {format, components, glType};\n}\n\n/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */\nexport function decodeGLAttributeType(glAttributeType: GL): {\n attributeType: ShaderAttributeType;\n vertexFormat: VertexFormat;\n components: number;\n // glType: GLDataType;\n} {\n const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];\n if (!typeAndSize) {\n throw new Error('attribute');\n }\n const [, components, , shaderType, vertexFormat] = typeAndSize;\n // TODO sanity - if (shaderType.startsWith('mat' ...))\n const attributeType = shaderType as unknown as ShaderAttributeType;\n return {attributeType, vertexFormat, components}; // , glType};\n}\n\n/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */\nexport function decomposeCompositeGLDataType(\n compositeGLDataType: GLCompositeType\n): {type: GLDataType; components: number} | null {\n const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];\n if (!typeAndSize) {\n return null;\n }\n const [type, components] = typeAndSize;\n return {type, components};\n}\n\nexport function getCompositeGLDataType(\n type: GL,\n components\n): {glType: GLDataType; name: string} | null {\n switch (type) {\n case GL.BYTE:\n case GL.UNSIGNED_BYTE:\n case GL.SHORT:\n case GL.UNSIGNED_SHORT:\n type = GL.FLOAT;\n break;\n default:\n }\n\n for (const glType in COMPOSITE_GL_TYPES) {\n const [compType, compComponents, name] = COMPOSITE_GL_TYPES[glType];\n if (compType === type && compComponents === components) {\n return {glType: Number(glType), name};\n }\n }\n return null;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable */\n\n// Uniforms\nimport type {UniformValue} from '@luma.gl/core';\nimport {GL, GLCompositeType, GLSamplerType} from '@luma.gl/constants';\n\n/** Set a raw uniform (without type conversion and caching) */\n/* eslint-disable max-len */\nexport function setUniform(\n gl: WebGL2RenderingContext,\n location: WebGLUniformLocation,\n type: GLCompositeType | GLSamplerType,\n value: UniformValue\n): void {\n const gl2 = gl as WebGL2RenderingContext;\n\n // Prepare the value for WebGL setters\n let uniformValue = value;\n if (uniformValue === true) {\n uniformValue = 1;\n }\n if (uniformValue === false) {\n uniformValue = 0;\n }\n const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;\n\n // prettier-ignore\n switch (type) {\n case GL.SAMPLER_2D:\n case GL.SAMPLER_CUBE:\n case GL.SAMPLER_3D:\n case GL.SAMPLER_2D_SHADOW:\n case GL.SAMPLER_2D_ARRAY:\n case GL.SAMPLER_2D_ARRAY_SHADOW:\n case GL.SAMPLER_CUBE_SHADOW:\n case GL.INT_SAMPLER_2D:\n case GL.INT_SAMPLER_3D:\n case GL.INT_SAMPLER_CUBE:\n case GL.INT_SAMPLER_2D_ARRAY:\n case GL.UNSIGNED_INT_SAMPLER_2D:\n case GL.UNSIGNED_INT_SAMPLER_3D:\n case GL.UNSIGNED_INT_SAMPLER_CUBE:\n case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:\n if (typeof value !== 'number') {\n throw new Error('samplers must be set to integers');\n }\n return gl.uniform1i(location, value);\n\n case GL.FLOAT: return gl.uniform1fv(location, arrayValue);\n case GL.FLOAT_VEC2: return gl.uniform2fv(location, arrayValue);\n case GL.FLOAT_VEC3: return gl.uniform3fv(location, arrayValue);\n case GL.FLOAT_VEC4: return gl.uniform4fv(location, arrayValue);\n\n case GL.INT: return gl.uniform1iv(location, arrayValue);\n case GL.INT_VEC2: return gl.uniform2iv(location, arrayValue);\n case GL.INT_VEC3: return gl.uniform3iv(location, arrayValue);\n case GL.INT_VEC4: return gl.uniform4iv(location, arrayValue);\n\n case GL.BOOL: return gl.uniform1iv(location, arrayValue);\n case GL.BOOL_VEC2: return gl.uniform2iv(location, arrayValue);\n case GL.BOOL_VEC3: return gl.uniform3iv(location, arrayValue);\n case GL.BOOL_VEC4: return gl.uniform4iv(location, arrayValue);\n\n // WEBGL2 - unsigned integers\n case GL.UNSIGNED_INT: return gl2.uniform1uiv(location, arrayValue, 1);\n case GL.UNSIGNED_INT_VEC2: return gl2.uniform2uiv(location, arrayValue, 2);\n case GL.UNSIGNED_INT_VEC3: return gl2.uniform3uiv(location, arrayValue, 3);\n case GL.UNSIGNED_INT_VEC4: return gl2.uniform4uiv(location, arrayValue, 4);\n\n // WebGL2 - quadratic matrices\n // false: don't transpose the matrix\n case GL.FLOAT_MAT2: return gl.uniformMatrix2fv(location, false, arrayValue);\n case GL.FLOAT_MAT3: return gl.uniformMatrix3fv(location, false, arrayValue);\n case GL.FLOAT_MAT4: return gl.uniformMatrix4fv(location, false, arrayValue);\n\n // WebGL2 - rectangular matrices\n case GL.FLOAT_MAT2x3: return gl2.uniformMatrix2x3fv(location, false, arrayValue);\n case GL.FLOAT_MAT2x4: return gl2.uniformMatrix2x4fv(location, false, arrayValue);\n case GL.FLOAT_MAT3x2: return gl2.uniformMatrix3x2fv(location, false, arrayValue);\n case GL.FLOAT_MAT3x4: return gl2.uniformMatrix3x4fv(location, false, arrayValue);\n case GL.FLOAT_MAT4x2: return gl2.uniformMatrix4x2fv(location, false, arrayValue);\n case GL.FLOAT_MAT4x3: return gl2.uniformMatrix4x3fv(location, false, arrayValue);\n }\n\n throw new Error('Illegal uniform');\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {UniformValue, Binding} from '@luma.gl/core';\nimport {isNumericArray} from '@math.gl/types';\n\nexport function isUniformValue(value: unknown): value is UniformValue {\n return isNumericArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';\n}\n\ntype UniformsAndBindings = {\n bindings: Record;\n uniforms: Record;\n};\n\nexport function splitUniformsAndBindings(\n uniforms: Record\n): UniformsAndBindings {\n const result: UniformsAndBindings = {bindings: {}, uniforms: {}};\n Object.keys(uniforms).forEach(name => {\n const uniform = uniforms[name];\n if (isUniformValue(uniform)) {\n result.uniforms[name] = uniform;\n } else {\n result.bindings[name] = uniform;\n }\n });\n\n return result;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {GL, GLPrimitiveTopology, GLPrimitive} from '@luma.gl/constants';\nimport {PrimitiveTopology} from '@luma.gl/core';\n\n// Counts the number of complete primitives given a number of vertices and a drawMode\nexport function getPrimitiveDrawMode(drawMode: GLPrimitiveTopology): GLPrimitive {\n switch (drawMode) {\n case GL.POINTS:\n return GL.POINTS;\n case GL.LINES:\n return GL.LINES;\n case GL.LINE_STRIP:\n return GL.LINES;\n case GL.LINE_LOOP:\n return GL.LINES;\n case GL.TRIANGLES:\n return GL.TRIANGLES;\n case GL.TRIANGLE_STRIP:\n return GL.TRIANGLES;\n case GL.TRIANGLE_FAN:\n return GL.TRIANGLES;\n default:\n throw new Error('drawMode');\n }\n}\n\n// Counts the number of complete \"primitives\" given a number of vertices and a drawMode\nexport function getPrimitiveCount(options: {\n drawMode: GLPrimitiveTopology;\n vertexCount: number;\n}): number {\n const {drawMode, vertexCount} = options;\n switch (drawMode) {\n case GL.POINTS:\n case GL.LINE_LOOP:\n return vertexCount;\n case GL.LINES:\n return vertexCount / 2;\n case GL.LINE_STRIP:\n return vertexCount - 1;\n case GL.TRIANGLES:\n return vertexCount / 3;\n case GL.TRIANGLE_STRIP:\n case GL.TRIANGLE_FAN:\n return vertexCount - 2;\n default:\n throw new Error('drawMode');\n }\n}\n\n// Counts the number of vertices after splitting the vertex stream into separate \"primitives\"\nexport function getVertexCount(options: {\n drawMode: GLPrimitiveTopology;\n vertexCount: number;\n}): number {\n const {drawMode, vertexCount} = options;\n const primitiveCount = getPrimitiveCount({drawMode, vertexCount});\n switch (getPrimitiveDrawMode(drawMode)) {\n case GL.POINTS:\n return primitiveCount;\n case GL.LINES:\n return primitiveCount * 2;\n case GL.TRIANGLES:\n return primitiveCount * 3;\n default:\n throw new Error('drawMode');\n }\n}\n\n/** Get the primitive type for draw */\nexport function getGLDrawMode(\n topology: PrimitiveTopology\n):\n | GL.POINTS\n | GL.LINES\n | GL.LINE_STRIP\n | GL.LINE_LOOP\n | GL.TRIANGLES\n | GL.TRIANGLE_STRIP\n | GL.TRIANGLE_FAN {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINE_STRIP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n default: throw new Error(topology);\n }\n}\n\n/** Get the primitive type for transform feedback */\nexport function getGLPrimitive(topology: PrimitiveTopology): GL.POINTS | GL.LINES | GL.TRIANGLES {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {CommandEncoder, CommandEncoderProps} from '@luma.gl/core';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions,\n // ClearTextureOptions,\n // ReadTextureOptions,\n QuerySet,\n Buffer\n} from '@luma.gl/core';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(device, props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n // clearTexture(options: ClearTextureOptions): void {\n // this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n // }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n override resolveQuerySet(\n querySet: QuerySet,\n destination: Buffer,\n options?: {\n firstQuery?: number;\n queryCount?: number;\n destinationOffset?: number;\n }\n ): void {}\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n // ClearTextureOptions,\n // ReadTextureOptions\n} from '@luma.gl/core';\nimport {CommandBuffer, Texture, Framebuffer} from '@luma.gl/core';\nimport {\n GL,\n GLTextureTarget,\n GLTextureCubeMapTarget\n // GLTexelDataFormat,\n // GLPixelType,\n // GLDataType\n} from '@luma.gl/constants';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\nimport {getTextureFormatWebGL} from '../converters/webgl-texture-table';\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype ClearTextureCommand = {\n name: 'clear-texture';\n options: {}; // ClearTextureOptions;\n};\n\ntype ReadTextureCommand = {\n name: 'read-texture';\n options: {}; // ReadTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand\n | ClearTextureCommand\n | ReadTextureCommand;\n\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device: WebGLDevice;\n commands: Command[] = [];\n\n constructor(device: WebGLDevice) {\n super(device, {});\n this.device = device;\n }\n\n submitCommands(commands: Command[] = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n // case 'clear-texture':\n // _clearTexture(this.device, command.options);\n // break;\n default:\n throw new Error(command.name);\n }\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = options.sourceBuffer as WEBGLBuffer;\n const destination = options.destinationBuffer as WEBGLBuffer;\n\n // {In WebGL2 we can p}erform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n device.gl.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n device.gl.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n device.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n device.gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n}\n\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {\n throw new Error('Not implemented');\n}\n\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {\n const {\n /** Texture to copy to/from. */\n sourceTexture,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all',\n\n /** Width to copy */\n width = options.sourceTexture.width,\n /** Height to copy */\n height = options.sourceTexture.height,\n depthOrArrayLayers = 0,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Destination buffer */\n destinationBuffer,\n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0,\n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow,\n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage\n } = options;\n\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('aspect not supported in WebGL');\n }\n\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== 0 || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const {framebuffer, destroyFramebuffer} = getFramebuffer(sourceTexture);\n let prevHandle: WebGLFramebuffer | null | undefined;\n try {\n const webglBuffer = destinationBuffer as WEBGLBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n const sourceParams = getTextureFormatWebGL(\n framebuffer.colorAttachments[0].texture.props.format\n );\n const sourceFormat = sourceParams.format;\n const sourceType = sourceParams.type;\n\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n\n device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);\n // @ts-expect-error native bindFramebuffer is overridden by our state tracker\n prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n\n device.gl.readPixels(\n origin[0],\n origin[1],\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n byteOffset\n );\n } finally {\n device.gl.bindBuffer(GL.PIXEL_PACK_BUFFER, null);\n // prevHandle may be unassigned if the try block failed before binding\n if (prevHandle !== undefined) {\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle);\n }\n\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {\n const {\n /** Texture to copy to/from. */\n sourceTexture,\n /** Mip-map level of the texture to copy to (Default 0) */\n destinationMipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */\n origin = [0, 0],\n\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */\n destinationOrigin = [0, 0],\n\n /** Texture to copy to/from. */\n destinationTexture\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n } = options;\n\n let {\n width = options.destinationTexture.width,\n height = options.destinationTexture.height\n // depthOrArrayLayers = 0\n } = options;\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(sourceTexture);\n const [sourceX, sourceY] = origin;\n const [destinationX, destinationY, destinationZ] = destinationOrigin;\n\n // @ts-expect-error native bindFramebuffer is overridden by our state tracker\n const prevHandle: WebGLFramebuffer | null = device.gl.bindFramebuffer(\n GL.FRAMEBUFFER,\n framebuffer.handle\n );\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n\n let texture: WEBGLTexture = null;\n let textureTarget: GL;\n if (destinationTexture instanceof WEBGLTexture) {\n texture = destinationTexture;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.glTarget;\n } else {\n throw new Error('invalid destination');\n }\n\n switch (textureTarget) {\n case GL.TEXTURE_2D:\n case GL.TEXTURE_CUBE_MAP:\n device.gl.copyTexSubImage2D(\n textureTarget,\n destinationMipLevel,\n destinationX,\n destinationY,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n device.gl.copyTexSubImage3D(\n textureTarget,\n destinationMipLevel,\n destinationX,\n destinationY,\n destinationZ,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n default:\n }\n\n if (texture) {\n texture.unbind();\n }\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n}\n\n/** Clear one mip level of a texture *\nfunction _clearTexture(device: WebGLDevice, options: ClearTextureOptions) {\n const BORDER = 0;\n const {dimension, width, height, depth = 0, mipLevel = 0} = options;\n const {glInternalFormat, glFormat, glType, compressed} = options;\n const glTarget = getWebGLCubeFaceTarget(options.glTarget, dimension, depth);\n\n switch (dimension) {\n case '2d-array':\n case '3d':\n if (compressed) {\n // prettier-ignore\n device.gl.compressedTexImage3D(glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, null);\n } else {\n // prettier-ignore\n device.gl.texImage3D( glTarget, mipLevel, glInternalFormat, width, height, depth, BORDER, glFormat, glType, null);\n }\n break;\n\n case '2d':\n case 'cube':\n if (compressed) {\n // prettier-ignore\n device.gl.compressedTexImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, null);\n } else {\n // prettier-ignore\n device.gl.texImage2D(glTarget, mipLevel, glInternalFormat, width, height, BORDER, glFormat, glType, null);\n }\n break;\n\n default:\n throw new Error(dimension);\n }\n}\n */\n\n// function _readTexture(device: WebGLDevice, options: CopyTextureToBufferOptions) {}\n\n// HELPERS\n\n/**\n * In WebGL, cube maps specify faces by overriding target instead of using the depth parameter.\n * @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels.\n * @returns glTarget unchanged, if dimension !== 'cube'.\n */\nexport function getWebGLCubeFaceTarget(\n glTarget: GLTextureTarget,\n dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',\n level: number\n): GLTextureTarget | GLTextureCubeMapTarget {\n return dimension === 'cube' ? GL.TEXTURE_CUBE_MAP_POSITIVE_X + level : glTarget;\n}\n\n/** Wrap a texture in a framebuffer so that we can use WebGL APIs that work on framebuffers */\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n destroyFramebuffer: boolean;\n} {\n if (source instanceof Texture) {\n const {width, height, id} = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n }) as unknown as WEBGLFramebuffer;\n\n return {framebuffer, destroyFramebuffer: true};\n }\n return {framebuffer: source as unknown as WEBGLFramebuffer, destroyFramebuffer: false};\n}\n\n/**\n * Returns number of components in a specific readPixels WebGL format\n * @todo use shadertypes utils instead?\n */\nexport function glFormatToComponents(format): 1 | 2 | 3 | 4 {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n\n/**\n * Return byte count for given readPixels WebGL type\n * @todo use shadertypes utils instead?\n */\nexport function glTypeToBytes(type: GL): 1 | 2 | 4 {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray, NumericArray} from '@math.gl/types';\nimport type {Device, Buffer, VertexArrayProps} from '@luma.gl/core';\nimport {VertexArray, getScratchArray} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nimport {getGLFromVertexType} from '../converters/vertex-formats';\nimport {fillArray} from '../../utils/fill-array';\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArray extends VertexArray {\n override get [Symbol.toStringTag](): string {\n return 'VertexArray';\n }\n\n readonly device: WebGLDevice;\n readonly handle: WebGLVertexArrayObject;\n\n /** Attribute 0 buffer constant */\n private buffer: WEBGLBuffer | null = null;\n private bufferValue = null;\n\n /** * Attribute 0 can not be disable on most desktop OpenGL based browsers */\n static isConstantAttributeZeroSupported(device: Device): boolean {\n return getBrowser() === 'Chrome';\n }\n\n // Create a VertexArray\n constructor(device: WebGLDevice, props: VertexArrayProps) {\n super(device, props);\n this.device = device;\n this.handle = this.device.gl.createVertexArray()!;\n }\n\n override destroy(): void {\n super.destroy();\n if (this.buffer) {\n this.buffer?.destroy();\n }\n if (this.handle) {\n this.device.gl.deleteVertexArray(this.handle);\n // @ts-expect-error read-only/undefined\n this.handle = undefined!;\n }\n\n // Auto-delete elements?\n // return [this.elements];\n }\n\n /**\n // Set (bind/unbind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER or null. Constants not supported\n *\n * @param elementBuffer\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n const buffer = indexBuffer as WEBGLBuffer;\n // Explicitly allow `null` to support clearing the index buffer\n if (buffer && buffer.glTarget !== GL.ELEMENT_ARRAY_BUFFER) {\n throw new Error('Use .setBuffer()');\n }\n // In WebGL The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject\n this.device.gl.bindVertexArray(this.handle);\n this.device.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, buffer ? buffer.handle : null);\n\n this.indexBuffer = buffer;\n\n // Unbind to prevent unintended changes to the VAO.\n this.device.gl.bindVertexArray(null);\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, attributeBuffer: Buffer): void {\n const buffer = attributeBuffer as WEBGLBuffer;\n // Sanity check target\n if (buffer.glTarget === GL.ELEMENT_ARRAY_BUFFER) {\n throw new Error('Use .setIndexBuffer()');\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = this._getAccessor(location);\n\n this.device.gl.bindVertexArray(this.handle);\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n this.device.gl.bindBuffer(GL.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n this.device.gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n // Clear binding - keeping it may cause [.WebGL-0x12804417100]\n // GL_INVALID_OPERATION: A transform feedback buffer that would be written to is also bound to a non-transform-feedback target\n this.device.gl.bindBuffer(GL.ARRAY_BUFFER, null);\n\n // Mark as non-constant\n this.device.gl.enableVertexAttribArray(location);\n // Set the step mode 0=vertex, 1=instance\n this.device.gl.vertexAttribDivisor(location, divisor || 0);\n\n this.attributes[location] = buffer;\n\n // Unbind to prevent unintended changes to the VAO.\n this.device.gl.bindVertexArray(null);\n }\n\n /** Set a location in vertex attributes array to a constant value, disables the location */\n override setConstantWebGL(location: number, value: TypedArray): void {\n this._enable(location, false);\n this.attributes[location] = value;\n }\n\n override bindBeforeRender(): void {\n this.device.gl.bindVertexArray(this.handle);\n this._applyConstantAttributes();\n }\n\n override unbindAfterRender(): void {\n // Unbind to prevent unintended changes to the VAO.\n this.device.gl.bindVertexArray(null);\n }\n\n // Internal methods\n\n /**\n * Constant attributes need to be reset before every draw call\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @note Constant attributes are only supported in WebGL, not in WebGPU\n */\n protected _applyConstantAttributes(): void {\n for (let location = 0; location < this.maxVertexAttributes; ++location) {\n const constant = this.attributes[location];\n // A typed array means this is a constant\n if (ArrayBuffer.isView(constant)) {\n this.device.setConstantAttributeWebGL(location, constant);\n }\n }\n }\n\n /**\n * Set a location in vertex attributes array to a buffer, enables the location, sets divisor\n * @note requires vertex array to be bound\n */\n // protected _setAttributeLayout(location: number): void {\n // const {size, type, stride, offset, normalized, integer, divisor} = this._getAccessor(location);\n\n // // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n // if (integer) {\n // this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);\n // } else {\n // // Attaches ARRAY_BUFFER with specified buffer format to location\n // this.device.gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n // }\n // this.device.gl.vertexAttribDivisor(location, divisor || 0);\n // }\n\n /** Get an accessor from the */\n protected _getAccessor(location: number) {\n const attributeInfo = this.attributeInfos[location];\n if (!attributeInfo) {\n throw new Error(`Unknown attribute location ${location}`);\n }\n const glType = getGLFromVertexType(attributeInfo.bufferDataType);\n return {\n size: attributeInfo.bufferComponents,\n type: glType,\n stride: attributeInfo.byteStride,\n offset: attributeInfo.byteOffset,\n normalized: attributeInfo.normalized,\n // it is the shader attribute declaration, not the vertex memory format,\n // that determines if the data in the buffer will be treated as integers.\n //\n // Also note that WebGL supports assigning non-normalized integer data to floating point attributes,\n // but as far as we can tell, WebGPU does not.\n integer: attributeInfo.integer,\n divisor: attributeInfo.stepMode === 'instance' ? 1 : 0\n };\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n protected _enable(location: number, enable = true): void {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = WEBGLVertexArray.isConstantAttributeZeroSupported(this.device);\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.device.gl.bindVertexArray(this.handle);\n if (enable) {\n this.device.gl.enableVertexAttribArray(location);\n } else {\n this.device.gl.disableVertexAttribArray(location);\n }\n this.device.gl.bindVertexArray(null);\n }\n }\n\n /**\n * Provide a means to create a buffer that is equivalent to a constant.\n * NOTE: Desktop OpenGL cannot disable attribute 0.\n * https://stackoverflow.com/questions/20305231/webgl-warning-attribute-0-is-disabled-\n * this-has-significant-performance-penalty\n */\n getConstantBuffer(elementCount: number, value: TypedArray): Buffer {\n // Create buffer only when needed, and reuse it (avoids inflating buffer creation statistics)\n\n const constantValue = normalizeConstantArrayValue(value);\n\n const byteLength = constantValue.byteLength * elementCount;\n const length = constantValue.length * elementCount;\n\n if (this.buffer && byteLength !== this.buffer.byteLength) {\n throw new Error(\n `Buffer size is immutable, byte length ${byteLength} !== ${this.buffer.byteLength}.`\n );\n }\n let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || this.device.createBuffer({byteLength});\n\n // Reallocate and update contents if needed\n updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);\n\n if (updateNeeded) {\n // Create a typed array that is big enough, and fill it with the required data\n const typedArray = getScratchArray(value.constructor, length);\n fillArray({target: typedArray, source: constantValue, start: 0, count: length});\n this.buffer.write(typedArray);\n this.bufferValue = value;\n }\n\n return this.buffer;\n }\n}\n\n// HELPER FUNCTIONS\n\n/**\n * TODO - convert Arrays based on known type? (read type from accessor, don't assume Float32Array)\n * TODO - handle single values for size 1 attributes?\n */\nfunction normalizeConstantArrayValue(arrayValue: NumericArray) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n\n/**\n *\n */\nfunction compareConstantArrayValues(v1: NumericArray, v2: NumericArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {NumericArray} from '@math.gl/types';\n\n// Uses copyWithin to significantly speed up typed array value filling\nexport function fillArray(options: {\n target: NumericArray;\n source: NumericArray;\n start?: number;\n count?: number;\n}): NumericArray {\n const {target, source, start = 0, count = 1} = options;\n const length = source.length;\n const total = count * length;\n let copied = 0;\n for (let i = start; copied < length; copied++) {\n target[i++] = source[copied];\n }\n\n while (copied < total) {\n // If we have copied less than half, copy everything we got\n // else copy remaining in one operation\n if (copied < total - copied) {\n target.copyWithin(start + copied, start, start + copied);\n copied *= 2;\n } else {\n target.copyWithin(start + copied, start, start + total - copied);\n copied = total;\n }\n }\n\n return options.target;\n}\n", "import type {PrimitiveTopology, ShaderLayout, TransformFeedbackProps} from '@luma.gl/core';\nimport {log, TransformFeedback, Buffer, BufferRange} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from '../../index';\nimport {getGLPrimitive} from '../helpers/webgl-topology-utils';\n\nexport class WEBGLTransformFeedback extends TransformFeedback {\n readonly device: WebGLDevice;\n readonly gl: WebGL2RenderingContext;\n readonly handle: WebGLTransformFeedback;\n\n /**\n * NOTE: The Model already has this information while drawing, but\n * TransformFeedback currently needs it internally, to look up\n * varying information outside of a draw() call.\n */\n readonly layout: ShaderLayout;\n buffers: Record = {};\n unusedBuffers: Record = {};\n /**\n * Allows us to avoid a Chrome bug where a buffer that is already bound to a\n * different target cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.\n * This a major workaround, see: https://github.com/KhronosGroup/WebGL/issues/2346\n */\n bindOnUse = true;\n private _bound: boolean = false;\n\n constructor(device: WebGLDevice, props: TransformFeedbackProps) {\n super(device, props);\n\n this.device = device;\n this.gl = device.gl;\n this.handle = this.props.handle || this.gl.createTransformFeedback();\n this.layout = this.props.layout;\n\n if (props.buffers) {\n this.setBuffers(props.buffers);\n }\n\n Object.seal(this);\n }\n\n override destroy(): void {\n this.gl.deleteTransformFeedback(this.handle);\n super.destroy();\n }\n\n begin(topology: PrimitiveTopology = 'point-list'): void {\n this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, this.handle);\n if (this.bindOnUse) {\n this._bindBuffers();\n }\n this.gl.beginTransformFeedback(getGLPrimitive(topology));\n }\n\n end(): void {\n this.gl.endTransformFeedback();\n if (this.bindOnUse) {\n this._unbindBuffers();\n }\n this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, null);\n }\n\n // SUBCLASS\n\n setBuffers(buffers: Record): void {\n this.buffers = {};\n this.unusedBuffers = {};\n\n this.bind(() => {\n for (const bufferName in buffers) {\n this.setBuffer(bufferName, buffers[bufferName]);\n }\n });\n }\n\n setBuffer(locationOrName: string | number, bufferOrRange: Buffer | BufferRange): void {\n const location = this._getVaryingIndex(locationOrName);\n const {buffer, byteLength, byteOffset} = this._getBufferRange(bufferOrRange);\n\n if (location < 0) {\n this.unusedBuffers[locationOrName] = buffer;\n log.warn(`${this.id} unusedBuffers varying buffer ${locationOrName}`)();\n return;\n }\n\n this.buffers[location] = {buffer, byteLength, byteOffset};\n\n // Need to avoid chrome bug where buffer that is already bound to a different target\n // cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.\n if (!this.bindOnUse) {\n this._bindBuffer(location, buffer, byteOffset, byteLength);\n }\n }\n\n getBuffer(locationOrName: string | number): Buffer | BufferRange | null {\n if (isIndex(locationOrName)) {\n return this.buffers[locationOrName] || null;\n }\n const location = this._getVaryingIndex(locationOrName);\n return location >= 0 ? this.buffers[location] : null;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, funcOrHandle);\n return this;\n }\n\n let value: unknown;\n\n if (!this._bound) {\n this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, this.handle);\n this._bound = true;\n value = funcOrHandle();\n this._bound = false;\n this.gl.bindTransformFeedback(GL.TRANSFORM_FEEDBACK, null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n // PRIVATE METHODS\n\n /** Extract offsets for bindBufferRange */\n protected _getBufferRange(\n bufferOrRange: Buffer | {buffer: Buffer; byteOffset?: number; byteLength?: number}\n ): Required {\n if (bufferOrRange instanceof WEBGLBuffer) {\n return {buffer: bufferOrRange, byteOffset: 0, byteLength: bufferOrRange.byteLength};\n }\n\n // To use bindBufferRange either offset or size must be specified.\n // @ts-expect-error Must be a BufferRange.\n const {buffer, byteOffset = 0, byteLength = bufferOrRange.buffer.byteLength} = bufferOrRange;\n return {buffer, byteOffset, byteLength};\n }\n\n protected _getVaryingIndex(locationOrName: string | number): number {\n if (isIndex(locationOrName)) {\n return Number(locationOrName);\n }\n\n for (const varying of this.layout.varyings) {\n if (locationOrName === varying.name) {\n return varying.location;\n }\n }\n\n return -1;\n }\n\n /**\n * Need to avoid chrome bug where buffer that is already bound to a different target\n * cannot be bound to 'TRANSFORM_FEEDBACK_BUFFER' target.\n */\n protected _bindBuffers(): void {\n for (const bufferIndex in this.buffers) {\n const {buffer, byteLength, byteOffset} = this._getBufferRange(this.buffers[bufferIndex]);\n this._bindBuffer(Number(bufferIndex), buffer, byteOffset, byteLength);\n }\n }\n\n protected _unbindBuffers(): void {\n for (const bufferIndex in this.buffers) {\n this.gl.bindBufferBase(GL.TRANSFORM_FEEDBACK_BUFFER, Number(bufferIndex), null);\n }\n }\n\n protected _bindBuffer(index: number, buffer: Buffer, byteOffset = 0, byteLength?: number): void {\n const handle = buffer && (buffer as WEBGLBuffer).handle;\n if (!handle || byteLength === undefined) {\n this.gl.bindBufferBase(GL.TRANSFORM_FEEDBACK_BUFFER, index, handle);\n } else {\n this.gl.bindBufferRange(GL.TRANSFORM_FEEDBACK_BUFFER, index, handle, byteOffset, byteLength);\n }\n }\n}\n\n/**\n * Returns true if the given value is an integer, or a string that\n * trivially converts to an integer (only numeric characters).\n */\nfunction isIndex(value: string | number): boolean {\n if (typeof value === 'number') {\n return Number.isInteger(value);\n }\n return /^\\d+$/.test(value);\n}\n", "// WebGL2 Query (also handles disjoint timer extensions)\nimport {QuerySet, QuerySetProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\n\n/**\n * Asynchronous queries for different kinds of information\n */\nexport class WEBGLQuerySet extends QuerySet {\n device: WebGLDevice;\n handle: WebGLQuery;\n\n target: number | null = null;\n _queryPending = false;\n _pollingPromise: Promise | null = null;\n\n override get [Symbol.toStringTag](): string {\n return 'Query';\n }\n\n // Create a query class\n constructor(device: WebGLDevice, props: QuerySetProps) {\n super(device, props);\n this.device = device;\n\n if (props.count > 1) {\n throw new Error('WebGL QuerySet can only have one value');\n }\n\n this.handle = this.device.gl.createQuery();\n Object.seal(this);\n }\n\n override destroy() {\n this.device.gl.deleteQuery(this.handle);\n }\n\n // FOR RENDER PASS AND COMMAND ENCODER\n\n /**\n * Shortcut for timer query (dependent on extension in both WebGL1 and 2)\n * Measures GPU time delta between this call and a matching `end` call in the\n * GPU instruction stream.\n */\n beginTimestampQuery(): void {\n return this._begin(GL.TIME_ELAPSED_EXT);\n }\n\n endTimestampQuery(): void {\n this._end();\n }\n\n // Shortcut for occlusion queries\n beginOcclusionQuery(options?: {conservative?: boolean}): void {\n return this._begin(\n options?.conservative ? GL.ANY_SAMPLES_PASSED_CONSERVATIVE : GL.ANY_SAMPLES_PASSED\n );\n }\n\n endOcclusionQuery() {\n this._end();\n }\n\n // Shortcut for transformFeedbackQuery\n beginTransformFeedbackQuery(): void {\n return this._begin(GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);\n }\n\n endTransformFeedbackQuery(): void {\n this._end();\n }\n\n async resolveQuery(): Promise {\n const value = await this.pollQuery();\n return [value];\n }\n\n // PRIVATE METHODS\n\n /**\n * Due to OpenGL API limitations, after calling `begin()` on one Query\n * instance, `end()` must be called on that same instance before\n * calling `begin()` on another query. While there can be multiple\n * outstanding queries representing disjoint `begin()`/`end()` intervals.\n * It is not possible to interleave or overlap `begin` and `end` calls.\n */\n protected _begin(target: number): void {\n // Don't start a new query if one is already active.\n if (this._queryPending) {\n return;\n }\n\n this.target = target;\n this.device.gl.beginQuery(this.target, this.handle);\n\n return;\n }\n\n // ends the current query\n protected _end(): void {\n // Can't end a new query if the last one hasn't been resolved.\n if (this._queryPending) {\n return;\n }\n\n if (this.target) {\n this.device.gl.endQuery(this.target);\n this.target = null;\n this._queryPending = true;\n }\n return;\n }\n\n // Returns true if the query result is available\n isResultAvailable(): boolean {\n if (!this._queryPending) {\n return false;\n }\n\n const resultAvailable = this.device.gl.getQueryParameter(\n this.handle,\n GL.QUERY_RESULT_AVAILABLE\n );\n if (resultAvailable) {\n this._queryPending = false;\n }\n return resultAvailable;\n }\n\n // Timing query is disjoint, i.e. results are invalid\n isTimerDisjoint(): boolean {\n return this.device.gl.getParameter(GL.GPU_DISJOINT_EXT);\n }\n\n // Returns query result.\n getResult(): any {\n return this.device.gl.getQueryParameter(this.handle, GL.QUERY_RESULT);\n }\n\n // Returns the query result, converted to milliseconds to match JavaScript conventions.\n getTimerMilliseconds() {\n return this.getResult() / 1e6;\n }\n\n // Polls the query\n pollQuery(limit: number = Number.POSITIVE_INFINITY): Promise {\n if (this._pollingPromise) {\n return this._pollingPromise;\n }\n\n let counter = 0;\n\n this._pollingPromise = new Promise((resolve, reject) => {\n const poll = () => {\n if (this.isResultAvailable()) {\n resolve(this.getResult());\n this._pollingPromise = null;\n } else if (counter++ > limit) {\n reject('Timed out');\n this._pollingPromise = null;\n } else {\n requestAnimationFrame(poll);\n }\n };\n\n requestAnimationFrame(poll);\n });\n\n return this._pollingPromise;\n }\n}\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Goal is to make WebGL2 contexts look like WebGL1\n// @note Partly inspired by with some older code from the `regl` library\n\n/* eslint-disable camelcase */\n\nimport {GL} from '@luma.gl/constants';\n\n// webgl1 extensions natively supported by webgl2\nconst WEBGL1_STATIC_EXTENSIONS = {\n WEBGL_depth_texture: {\n UNSIGNED_INT_24_8_WEBGL: GL.UNSIGNED_INT_24_8\n } as const satisfies WEBGL_depth_texture,\n OES_element_index_uint: {} as const satisfies OES_element_index_uint,\n OES_texture_float: {} as const satisfies OES_texture_float,\n OES_texture_half_float: {\n // @ts-expect-error different numbers?\n HALF_FLOAT_OES: GL.HALF_FLOAT\n } as const satisfies OES_texture_half_float,\n EXT_color_buffer_float: {} as const satisfies EXT_color_buffer_float,\n OES_standard_derivatives: {\n FRAGMENT_SHADER_DERIVATIVE_HINT_OES: GL.FRAGMENT_SHADER_DERIVATIVE_HINT\n } as const satisfies OES_standard_derivatives,\n EXT_frag_depth: {} as const satisfies EXT_frag_depth,\n EXT_blend_minmax: {\n MIN_EXT: GL.MIN,\n MAX_EXT: GL.MAX\n } as const satisfies EXT_blend_minmax,\n EXT_shader_texture_lod: {} as const satisfies EXT_shader_texture_lod\n};\n\nconst getWEBGL_draw_buffers = (gl: WebGL2RenderingContext) =>\n ({\n drawBuffersWEBGL(buffers: number[]) {\n return gl.drawBuffers(buffers);\n },\n COLOR_ATTACHMENT0_WEBGL: GL.COLOR_ATTACHMENT0,\n COLOR_ATTACHMENT1_WEBGL: GL.COLOR_ATTACHMENT1,\n COLOR_ATTACHMENT2_WEBGL: GL.COLOR_ATTACHMENT2,\n COLOR_ATTACHMENT3_WEBGL: GL.COLOR_ATTACHMENT3\n }) as const satisfies Partial; // - too many fields\n\nconst getOES_vertex_array_object = (gl: WebGL2RenderingContext) =>\n ({\n VERTEX_ARRAY_BINDING_OES: GL.VERTEX_ARRAY_BINDING,\n createVertexArrayOES() {\n return gl.createVertexArray();\n },\n deleteVertexArrayOES(vertexArray: WebGLVertexArrayObject): void {\n return gl.deleteVertexArray(vertexArray);\n },\n isVertexArrayOES(vertexArray: WebGLVertexArrayObject): boolean {\n return gl.isVertexArray(vertexArray);\n },\n bindVertexArrayOES(vertexArray: WebGLVertexArrayObject): void {\n return gl.bindVertexArray(vertexArray);\n }\n }) as const satisfies OES_vertex_array_object;\n\nconst getANGLE_instanced_arrays = (gl: WebGL2RenderingContext) =>\n ({\n VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: 0x88fe,\n drawArraysInstancedANGLE(...args) {\n return gl.drawArraysInstanced(...args);\n },\n drawElementsInstancedANGLE(...args) {\n return gl.drawElementsInstanced(...args);\n },\n vertexAttribDivisorANGLE(...args) {\n return gl.vertexAttribDivisor(...args);\n }\n }) as const satisfies ANGLE_instanced_arrays;\n\n/**\n * Make browser return WebGL2 contexts even if WebGL1 contexts are requested\n * @param enforce\n * @returns\n */\nexport function enforceWebGL2(enforce: boolean = true): void {\n const prototype = HTMLCanvasElement.prototype as any;\n if (!enforce && prototype.originalGetContext) {\n // Reset the original getContext function\n prototype.getContext = prototype.originalGetContext;\n prototype.originalGetContext = undefined;\n return;\n }\n\n // Store the original getContext function\n prototype.originalGetContext = prototype.getContext;\n\n // Override the getContext function\n prototype.getContext = function (contextId: string, options?: WebGLContextAttributes) {\n // Attempt to force WebGL2 for all WebGL1 contexts\n if (contextId === 'webgl' || contextId === 'experimental-webgl') {\n const context = this.originalGetContext('webgl2', options) as WebGL2RenderingContext;\n // Work around test mocking\n if (context instanceof HTMLElement) {\n polyfillWebGL1Extensions(context);\n }\n return context;\n }\n // For any other type, return the original context\n return this.originalGetContext(contextId, options);\n };\n}\n\n/** Install WebGL1-only extensions on WebGL2 contexts */\nexport function polyfillWebGL1Extensions(gl: WebGL2RenderingContext): void {\n // Enable, to support float and half-float textures\n gl.getExtension('EXT_color_buffer_float');\n\n // WebGL1 extensions implemented using WebGL2 APIs\n const boundExtensions = {\n ...WEBGL1_STATIC_EXTENSIONS,\n WEBGL_disjoint_timer_query: gl.getExtension('EXT_disjoint_timer_query_webgl2'),\n WEBGL_draw_buffers: getWEBGL_draw_buffers(gl),\n OES_vertex_array_object: getOES_vertex_array_object(gl),\n ANGLE_instanced_arrays: getANGLE_instanced_arrays(gl)\n };\n\n // Override gl.getExtension\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalGetExtension = gl.getExtension;\n gl.getExtension = function (extensionName: string) {\n const ext = originalGetExtension.call(gl, extensionName);\n if (ext) {\n return ext;\n }\n\n // Injected extensions\n if (extensionName in boundExtensions) {\n return boundExtensions[extensionName];\n }\n\n return null;\n };\n\n // Override gl.getSupportedExtensions\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalGetSupportedExtensions = gl.getSupportedExtensions;\n gl.getSupportedExtensions = function (): string[] | null {\n const extensions = originalGetSupportedExtensions.apply(gl) || [];\n return extensions?.concat(Object.keys(boundExtensions));\n };\n}\n\n// Update unsized WebGL1 formats to sized WebGL2 formats\n// todo move to texture format file\n// export function getInternalFormat(gl: WebGL2RenderingContext, format: GL, type: GL): GL {\n// // webgl2 texture formats\n// // https://webgl2fundamentals.org/webgl/lessons/webgl-data-textures.html\n// switch (format) {\n// case GL.DEPTH_COMPONENT:\n// return GL.DEPTH_COMPONENT24;\n// case GL.DEPTH_STENCIL:\n// return GL.DEPTH24_STENCIL8;\n// case GL.RGBA:\n// return type === GL.HALF_FLOAT ? GL.RGBA16F : GL.RGBA32F;\n// case GL.RGB:\n// return type === GL.HALF_FLOAT ? GL.RGB16F : GL.RGB32F;\n// default:\n// return format;\n// }\n// }\n\n/*\n// texture type to update on the fly\nexport function getTextureType(gl: WebGL2RenderingContext, type: GL): GL {\n if (type === HALF_FLOAT_OES) {\n return GL.HALF_FLOAT;\n }\n return type;\n}\n\n // And texImage2D to convert the internalFormat to webgl2.\n const webgl2 = this;\n const origTexImage = gl.texImage2D;\n gl.texImage2D = function (target, miplevel, iformat, a, typeFor6, c, d, typeFor9, f) {\n if (arguments.length == 6) {\n var ifmt = webgl2.getInternalFormat(gl, iformat, typeFor6);\n origTexImage.apply(gl, [target, miplevel, ifmt, a, webgl.getTextureType(gl, typeFor6), c]);\n } else {\n // arguments.length == 9\n var ifmt = webgl2.getInternalFormat(gl, iformat, typeFor9);\n origTexImage.apply(gl, [\n target,\n miplevel,\n ifmt,\n a,\n typeFor6,\n c,\n d,\n webgl2.getTextureType(gl, typeFor9),\n f\n ]);\n }\n };\n};\n*/\n", "// luma.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Buffer, log} from '@luma.gl/core';\nimport {GL, GLDataType, GLPixelType} from '@luma.gl/constants';\nimport {TypedArrayConstructor} from '@math.gl/types';\n\n/**\n * Attribute descriptor object\n * @deprecated Use ShaderLayout\n */\nexport interface AccessorObject {\n buffer?: Buffer;\n // format: VertexFormat;\n offset?: number;\n // can now be described with single WebGPU-style `format` string\n\n //\n stride?: number;\n\n /** @deprecated - Use accessor.stepMode */\n divisor?: number;\n\n /** @deprecated - Infer from format */\n type?: number;\n /** @deprecated - Infer from format */\n size?: number;\n /** @deprecated - Infer from format */\n normalized?: boolean;\n /** @deprecated - Infer from format */\n integer?: boolean;\n\n /** @deprecated */\n index?: number;\n}\n\nconst DEFAULT_ACCESSOR_VALUES = {\n offset: 0,\n stride: 0,\n type: GL.FLOAT,\n size: 1,\n divisor: 0,\n normalized: false,\n integer: false\n};\n\nexport class Accessor implements AccessorObject {\n offset?: number;\n stride?: number;\n type?: number;\n size?: number;\n divisor?: number;\n normalized?: boolean;\n integer?: boolean;\n\n buffer?: Buffer;\n index?: number;\n\n static getBytesPerElement(accessor: Accessor | AccessorObject): number {\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT;\n }\n\n static getBytesPerVertex(accessor: AccessorObject): number {\n // assert(accessor.size);\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT * accessor.size;\n }\n\n // Combines (merges) a list of accessors. On top of default values\n // Usually [programAccessor, bufferAccessor, appAccessor]\n // All props will be set in the returned object.\n // TODO check for conflicts between values in the supplied accessors\n static resolve(...accessors: AccessorObject[]): Accessor {\n return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]); // Default values\n }\n\n constructor(...accessors: AccessorObject[]) {\n log.warn('Accessor will be removed in next minor release');\n accessors.forEach(accessor => this._assign(accessor)); // Merge in sequence\n Object.freeze(this);\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n\n // ACCESSORS\n\n // TODO - remove>\n get BYTES_PER_ELEMENT(): number {\n return Accessor.getBytesPerElement(this);\n }\n\n get BYTES_PER_VERTEX(): number {\n return Accessor.getBytesPerVertex(this);\n }\n\n // PRIVATE\n\n // eslint-disable-next-line complexity, max-statements\n _assign(props: AccessorObject = {}): this {\n if (props.type !== undefined) {\n this.type = props.type;\n\n // Auto-deduce integer type?\n if ((props.type as GL) === GL.INT || (props.type as GL) === GL.UNSIGNED_INT) {\n this.integer = true;\n }\n }\n if (props.size !== undefined) {\n this.size = props.size;\n }\n if (props.offset !== undefined) {\n this.offset = props.offset;\n }\n if (props.stride !== undefined) {\n this.stride = props.stride;\n }\n // @ts-expect-error\n if (props.normalize !== undefined) {\n // @ts-expect-error\n this.normalized = props.normalize;\n }\n if (props.normalized !== undefined) {\n this.normalized = props.normalized;\n }\n if (props.integer !== undefined) {\n this.integer = props.integer;\n }\n\n // INSTANCE DIVISOR\n if (props.divisor !== undefined) {\n this.divisor = props.divisor;\n }\n\n // Buffer is optional\n if (props.buffer !== undefined) {\n this.buffer = props.buffer;\n }\n\n // The binding index (for binding e.g. Transform feedbacks and Uniform buffers)\n // TODO - should this be part of accessor?\n if (props.index !== undefined) {\n if (typeof props.index === 'boolean') {\n this.index = props.index ? 1 : 0;\n } else {\n this.index = props.index;\n }\n }\n\n // DEPRECATED\n // @ts-expect-error\n if (props.instanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.instanced ? 1 : 0;\n }\n // @ts-expect-error\n if (props.isInstanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.isInstanced ? 1 : 0;\n }\n\n if (this.offset === undefined) delete this.offset;\n if (this.stride === undefined) delete this.stride;\n if (this.type === undefined) delete this.type;\n if (this.size === undefined) delete this.size;\n if (this.divisor === undefined) delete this.divisor;\n if (this.normalized === undefined) delete this.normalized;\n if (this.integer === undefined) delete this.integer;\n\n if (this.buffer === undefined) delete this.buffer;\n if (this.index === undefined) delete this.index;\n\n return this;\n }\n}\n\n/**\n * Converts GL constant to corresponding TYPED ARRAY\n * Used to auto deduce gl parameter types\n * @deprecated Use getTypedArrayFromDataType\n * @param glType\n * @param param1\n * @returns\n */\n// eslint-disable-next-line complexity\nfunction getTypedArrayFromGLType(\n glType: GLDataType | GLPixelType,\n options?: {\n clamped?: boolean;\n }\n): TypedArrayConstructor {\n const {clamped = true} = options || {};\n // Sorted in some order of likelihood to reduce amount of comparisons\n switch (glType) {\n case GL.FLOAT:\n return Float32Array;\n case GL.UNSIGNED_SHORT:\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return Uint16Array;\n case GL.UNSIGNED_INT:\n return Uint32Array;\n case GL.UNSIGNED_BYTE:\n return clamped ? Uint8ClampedArray : Uint8Array;\n case GL.BYTE:\n return Int8Array;\n case GL.SHORT:\n return Int16Array;\n case GL.INT:\n return Int32Array;\n default:\n throw new Error('Failed to deduce typed array type from GL constant');\n }\n}\n\n// TEST EXPORTS\nexport {DEFAULT_ACCESSOR_VALUES};\n"], "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,IAAAA,gBAAgD;;;ACgChD,IAAAC,gBAAyC;;;AC/BzC,uBAA+B;AAMxB,IAAM,wBAAsC;EACjD,CAAA,IAAA,GAAY;EACZ,CAAA,KAAA,GAAkB,IAAI,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;EAC/C,CAAA,KAAA,GAAuB;EACvB,CAAA,KAAA,GAAyB;EACzB,CAAA,KAAA,GAAkB;EAClB,CAAA,KAAA,GAAkB;EAClB,CAAA,KAAA,GAAoB;EACpB,CAAA,KAAA,GAAoB;EACpB,CAAA,IAAA,GAAwB,IAAI,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;;EACrD,CAAA,IAAA,GAAsB,CAAC,MAAM,MAAM,MAAM,IAAI;EAC7C,CAAA,IAAA,GAAgB;EAChB,CAAA,IAAA,GAAmB;EACnB,CAAA,IAAA,GAAiB;EACjB,CAAA,IAAA,GAAwB;EACxB,CAAA,IAAA,GAAe;EACf,CAAA,IAA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C7B,UAAI,OAAO,MAAM,UAAU,WAAW;AACpC,aAAK,QAAQ,MAAM,QAAQ,IAAI;MACjC,OAAO;AACL,aAAK,QAAQ,MAAM;MACrB;IACF;AAIA,QAAI,MAAM,cAAc,QAAW;AAEjC,WAAK,UAAU,MAAM,YAAY,IAAI;IACvC;AAEA,QAAI,MAAM,gBAAgB,QAAW;AAEnC,WAAK,UAAU,MAAM,cAAc,IAAI;IACzC;AAEA,QAAI,KAAK,WAAW;AAAW,aAAO,KAAK;AAC3C,QAAI,KAAK,WAAW;AAAW,aAAO,KAAK;AAC3C,QAAI,KAAK,SAAS;AAAW,aAAO,KAAK;AACzC,QAAI,KAAK,SAAS;AAAW,aAAO,KAAK;AACzC,QAAI,KAAK,YAAY;AAAW,aAAO,KAAK;AAC5C,QAAI,KAAK,eAAe;AAAW,aAAO,KAAK;AAC/C,QAAI,KAAK,YAAY;AAAW,aAAO,KAAK;AAE5C,QAAI,KAAK,WAAW;AAAW,aAAO,KAAK;AAC3C,QAAI,KAAK,UAAU;AAAW,aAAO,KAAK;AAE1C,WAAO;EACT;;AAYF,SAASA,yBACP,QACA,SAEC;AAED,QAAM,EAAC,UAAU,KAAI,IAAI,WAAW,CAAA;AAEpC,UAAQ,QAAQ;IACd,KAAA;AACE,aAAO;IACT,KAAA;IACA,KAAA;IACA,KAAA;IACA,KAAA;AACE,aAAO;IACT,KAAA;AACE,aAAO;IACT,KAAA;AACE,aAAO,UAAU,oBAAoB;IACvC,KAAA;AACE,aAAO;IACT,KAAA;AACE,aAAO;IACT,KAAA;AACE,aAAO;IACT;AACE,YAAM,IAAI,MAAM,oDAAoD;EACxE;AACF;", "names": ["import_core", "import_core", "target", "import_constants", "import_core", "import_constants", "import_constants", "import_core", "import_constants", "import_core", "import_core", "import_constants", "import_core", "import_core", "import_constants", "GLEnum", "message", "import_core", "import_constants", "import_core", "import_constants", "messageType", "message", "import_core", "import_constants", "import_constants", "import_core", "import_constants", "isObjectEmpty", "isObjectEmpty", "isObjectEmpty", "import_core", "import_constants", "import_core", "import_core", "import_constants", "import_constants", "import_constants", "isObjectEmpty", "target", "import_core", "import_constants", "import_core", "import_constants", "import_constants", "import_constants", "uniforms", "isArray", "import_constants", "import_constants", "status", "import_core", "import_core", "import_constants", "getFramebuffer", "getFramebuffer", "import_core", "import_constants", "import_env", "target", "enable", "import_core", "import_constants", "import_core", "import_constants", "target", "_a", "compareConstantArrayValues", "import_constants", "LOG_LEVEL", "enable", "message", "import_core", "import_constants", "getTypedArrayFromGLType"] }