@luma.gl/webgl 9.0.0-alpha.39 → 9.0.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +1 -1
- package/dist/adapter/device-helpers/is-old-ie.js.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -1
- package/dist/adapter/helpers/get-shader-info.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-info.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +12 -3
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -1
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js.map +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js.map +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/context/create-headless-context.d.ts.map +1 -1
- package/dist/context/context/create-headless-context.js.map +1 -1
- package/dist/context/context/webgl-checks.d.ts.map +1 -1
- package/dist/context/context/webgl-checks.js.map +1 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/context-data.d.ts.map +1 -1
- package/dist/context/polyfill/context-data.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +11 -3
- package/dist/index.cjs +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +18 -18
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +3 -0
- package/src/adapter/converters/sampler-parameters.ts +3 -0
- package/src/adapter/converters/shader-formats.ts +3 -0
- package/src/adapter/converters/texture-formats.ts +3 -0
- package/src/adapter/converters/vertex-formats.ts +3 -0
- package/src/adapter/device-helpers/device-features.ts +3 -0
- package/src/adapter/device-helpers/device-limits.ts +2 -0
- package/src/adapter/device-helpers/get-device-info.ts +3 -0
- package/src/adapter/device-helpers/is-old-ie.ts +3 -0
- package/src/adapter/helpers/decode-webgl-types.ts +3 -0
- package/src/adapter/helpers/get-shader-info.ts +1 -0
- package/src/adapter/helpers/get-shader-layout.ts +1 -0
- package/src/adapter/helpers/parse-shader-compiler-log.ts +2 -0
- package/src/adapter/helpers/set-uniform.ts +3 -0
- package/src/adapter/helpers/webgl-topology-utils.ts +3 -0
- package/src/adapter/objects/constants-to-keys.ts +3 -0
- package/src/adapter/objects/webgl-renderbuffer.ts +3 -0
- package/src/adapter/objects/webgl-resource.ts +2 -0
- package/src/adapter/resources/webgl-buffer.ts +3 -0
- package/src/adapter/resources/webgl-command-buffer.ts +1 -0
- package/src/adapter/resources/webgl-command-encoder.ts +3 -0
- package/src/adapter/resources/webgl-external-texture.ts +3 -0
- package/src/adapter/resources/webgl-framebuffer.ts +1 -0
- package/src/adapter/resources/webgl-render-pass.ts +3 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +15 -3
- package/src/adapter/resources/webgl-sampler.ts +1 -0
- package/src/adapter/resources/webgl-shader.ts +2 -0
- package/src/adapter/resources/webgl-texture.ts +2 -0
- package/src/adapter/resources/webgl-vertex-array.ts +1 -0
- package/src/adapter/webgl-canvas-context.ts +2 -0
- package/src/adapter/webgl-device.ts +2 -0
- package/src/classic/accessor.ts +3 -0
- package/src/classic/buffer-with-accessor.ts +1 -0
- package/src/classic/clear.ts +3 -0
- package/src/classic/copy-and-blit.ts +2 -0
- package/src/classic/format-utils.ts +3 -0
- package/src/classic/typed-array-utils.ts +1 -0
- package/src/context/context/create-browser-context.ts +1 -0
- package/src/context/context/create-headless-context.ts +3 -0
- package/src/context/context/webgl-checks.ts +2 -0
- package/src/context/debug/spector.ts +2 -0
- package/src/context/debug/webgl-developer-tools.ts +2 -0
- package/src/context/parameters/unified-parameter-api.ts +3 -0
- package/src/context/parameters/webgl-parameter-tables.ts +3 -0
- package/src/context/polyfill/context-data.ts +3 -0
- package/src/context/polyfill/get-parameter-polyfill.ts +3 -0
- package/src/context/polyfill/polyfill-context.ts +3 -0
- package/src/context/polyfill/polyfill-table.ts +3 -0
- package/src/context/polyfill/polyfill-vertex-array-object.ts +3 -0
- package/src/context/state-tracker/deep-array-equal.ts +2 -0
- package/src/context/state-tracker/track-context-state.ts +3 -0
- package/src/context/state-tracker/with-parameters.ts +3 -0
- package/src/index.ts +3 -0
- package/src/types.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array.js","names":["VertexArray","getScratchArray","fillArray","GL","getBrowser","getGLFromVertexType","_Symbol$toStringTag","Symbol","toStringTag","WEBGLVertexArray","isConstantAttributeZeroSupported","device","info","type","constructor","props","handle","buffer","bufferValue","init","gl2","createVertexArray","destroy","_this$buffer","deleteVertexArray","undefined","setIndexBuffer","indexBuffer","glTarget","ELEMENT_ARRAY_BUFFER","Error","bindVertexArray","bindBuffer","setBuffer","location","attributeBuffer","size","stride","offset","normalized","integer","divisor","_getAccessor","gl","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","attributes","setConstant","value","_enable","bindBeforeRender","webglBuffer","_applyConstantAttributes","unbindAfterRender","maxVertexAttributes","constant","ArrayBuffer","isView","setConstantAttribute","attributeInfo","attributeInfos","glType","bufferDataType","bufferComponents","byteStride","byteOffset","stepMode","enable","arguments","length","canDisableAttributeZero","canDisableAttribute","Number","disableVertexAttribArray","getConstantBuffer","elementCount","constantValue","normalizeConstantArrayValue","byteLength","updateNeeded","createBuffer","reallocate","compareConstantArrayValues","typedArray","target","source","start","count","subData","arrayValue","Array","isArray","Float32Array","v1","v2","i"],"sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, Buffer, VertexArrayProps, TypedArray, NumberArray} from '@luma.gl/core';\nimport {VertexArray, getScratchArray, fillArray} 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 {BufferWithAccessor} from '../../classic/buffer-with-accessor';\nimport {getGLFromVertexType} from '../converters/vertex-formats';\n// import {AccessorObject} from '../..';\n// import {getGLFromVertexType} from '../converters/vertex-formats';\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: BufferWithAccessor | 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 device.info.type === 'webgl2' || 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.gl2.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.gl2.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) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n * \n * @param elementBuffer \n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n const buffer = indexBuffer as WEBGLBuffer;\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.gl2.bindVertexArray(this.handle);\n // TODO - this initial binding does not seem to take effect? see bindBeforeRender()\n this.device.gl2.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, buffer ? buffer.handle : null);\n // log.log(1, 'VertexArray.setIndexBuffer', indexBuffer)();\n // log.log(1, `Binding vertex array ${this.id}`, buffer?.id)();\n\n this.indexBuffer = buffer;\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.gl2.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.assertWebGL2();\n this.device.gl2.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\n // Mark as non-constant\n this.device.gl.enableVertexAttribArray(location);\n // Set the step mode 0=vertex, 1=instance\n this.device.gl2.vertexAttribDivisor(location, divisor || 0);\n\n this.attributes[location] = buffer;\n }\n\n /** Set a location in vertex attributes array to a constant value, disables the location */\n override setConstant(location: number, value: TypedArray): void {\n this._enable(location, false);\n this.attributes[location] = value;\n }\n\n init = false;\n\n override bindBeforeRender(): void {\n this.device.gl2.bindVertexArray(this.handle);\n // TODO - the initial bind does not seem to take effect. \n if (!this.init) {\n // log.log(1, `Binding vertex array ${this.id}`, this.indexBuffer?.id)();\n const webglBuffer = this.indexBuffer as WEBGLBuffer;\n this.device.gl2.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, webglBuffer?.handle || null);\n this.init = true;\n }\n this._applyConstantAttributes();\n }\n\n override unbindAfterRender(): void {\n // log.log(1, `Unbinding vertex array ${this.id}`)();\n // TODO technically this is not necessary, but we might be interfacing \n // with code that does not use vertex array objects\n this.device.gl2.bindVertexArray(null);\n // this.device.gl2.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 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.setConstantAttribute(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.assertWebGL2();\n // this.device.gl2.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.gl2.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.gl2.bindVertexArray(this.handle);\n if (enable) {\n this.device.gl.enableVertexAttribArray(location);\n } else {\n this.device.gl.disableVertexAttribArray(location);\n }\n this.device.gl2.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 let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || (this.device.createBuffer({byteLength}) as BufferWithAccessor);\n updateNeeded = updateNeeded || this.buffer.reallocate(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.subData(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: NumberArray) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n\n/**\n *\n */\nfunction compareConstantArrayValues(v1: NumberArray, v2: NumberArray): 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"],"mappings":";AAGA,SAAQA,WAAW,EAAEC,eAAe,EAAEC,SAAS,QAAO,eAAe;AACrE,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAMjCC,mBAAmB;AAAAC,mBAAA,GAMXC,MAAM,CAACC,WAAW;AADlC,OAAO,MAAMC,gBAAgB,SAAST,WAAW,CAAC;EAChD,KAAAM,mBAAA,IAA4C;IAC1C,OAAO,aAAa;EACtB;EAUA,OAAOI,gCAAgCA,CAACC,MAAc,EAAW;IAC/D,OAAOA,MAAM,CAAC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EAAE,CAACzB,MAAM,IAAIwB,EAAE,CAACnF,WAAW,KAAKoF,EAAE,CAACpF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIqF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAACxB,MAAM,EAAE,EAAE0B,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array.js","names":["VertexArray","getScratchArray","fillArray","GL","getBrowser","getGLFromVertexType","_Symbol$toStringTag","Symbol","toStringTag","WEBGLVertexArray","isConstantAttributeZeroSupported","device","info","type","constructor","props","handle","buffer","bufferValue","init","gl2","createVertexArray","destroy","_this$buffer","deleteVertexArray","undefined","setIndexBuffer","indexBuffer","glTarget","ELEMENT_ARRAY_BUFFER","Error","bindVertexArray","bindBuffer","setBuffer","location","attributeBuffer","size","stride","offset","normalized","integer","divisor","_getAccessor","gl","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","attributes","setConstant","value","_enable","bindBeforeRender","webglBuffer","_applyConstantAttributes","unbindAfterRender","maxVertexAttributes","constant","ArrayBuffer","isView","setConstantAttribute","attributeInfo","attributeInfos","glType","bufferDataType","bufferComponents","byteStride","byteOffset","stepMode","enable","arguments","length","canDisableAttributeZero","canDisableAttribute","Number","disableVertexAttribArray","getConstantBuffer","elementCount","constantValue","normalizeConstantArrayValue","byteLength","updateNeeded","createBuffer","reallocate","compareConstantArrayValues","typedArray","target","source","start","count","subData","arrayValue","Array","isArray","Float32Array","v1","v2","i"],"sources":["../../../src/adapter/resources/webgl-vertex-array.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Buffer, VertexArrayProps, TypedArray, NumberArray} from '@luma.gl/core';\nimport {VertexArray, getScratchArray, fillArray} 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 {BufferWithAccessor} from '../../classic/buffer-with-accessor';\nimport {getGLFromVertexType} from '../converters/vertex-formats';\n// import {AccessorObject} from '../..';\n// import {getGLFromVertexType} from '../converters/vertex-formats';\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: BufferWithAccessor | 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 device.info.type === 'webgl2' || 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.gl2.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.gl2.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) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n * \n * @param elementBuffer \n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n const buffer = indexBuffer as WEBGLBuffer;\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.gl2.bindVertexArray(this.handle);\n // TODO - this initial binding does not seem to take effect? see bindBeforeRender()\n this.device.gl2.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, buffer ? buffer.handle : null);\n // log.log(1, 'VertexArray.setIndexBuffer', indexBuffer)();\n // log.log(1, `Binding vertex array ${this.id}`, buffer?.id)();\n\n this.indexBuffer = buffer;\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.gl2.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.assertWebGL2();\n this.device.gl2.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\n // Mark as non-constant\n this.device.gl.enableVertexAttribArray(location);\n // Set the step mode 0=vertex, 1=instance\n this.device.gl2.vertexAttribDivisor(location, divisor || 0);\n\n this.attributes[location] = buffer;\n }\n\n /** Set a location in vertex attributes array to a constant value, disables the location */\n override setConstant(location: number, value: TypedArray): void {\n this._enable(location, false);\n this.attributes[location] = value;\n }\n\n init = false;\n\n override bindBeforeRender(): void {\n this.device.gl2.bindVertexArray(this.handle);\n // TODO - the initial bind does not seem to take effect. \n if (!this.init) {\n // log.log(1, `Binding vertex array ${this.id}`, this.indexBuffer?.id)();\n const webglBuffer = this.indexBuffer as WEBGLBuffer;\n this.device.gl2.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, webglBuffer?.handle || null);\n this.init = true;\n }\n this._applyConstantAttributes();\n }\n\n override unbindAfterRender(): void {\n // log.log(1, `Unbinding vertex array ${this.id}`)();\n // TODO technically this is not necessary, but we might be interfacing \n // with code that does not use vertex array objects\n this.device.gl2.bindVertexArray(null);\n // this.device.gl2.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, 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.setConstantAttribute(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.assertWebGL2();\n // this.device.gl2.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.gl2.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.gl2.bindVertexArray(this.handle);\n if (enable) {\n this.device.gl.enableVertexAttribArray(location);\n } else {\n this.device.gl.disableVertexAttribArray(location);\n }\n this.device.gl2.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 let updateNeeded = !this.buffer;\n\n this.buffer = this.buffer || (this.device.createBuffer({byteLength}) as BufferWithAccessor);\n updateNeeded = updateNeeded || this.buffer.reallocate(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.subData(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: NumberArray) {\n if (Array.isArray(arrayValue)) {\n return new Float32Array(arrayValue);\n }\n return arrayValue;\n}\n\n/**\n *\n */\nfunction compareConstantArrayValues(v1: NumberArray, v2: NumberArray): 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"],"mappings":";AAIA,SAAQA,WAAW,EAAEC,eAAe,EAAEC,SAAS,QAAO,eAAe;AACrE,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAMjCC,mBAAmB;AAAAC,mBAAA,GAMXC,MAAM,CAACC,WAAW;AADlC,OAAO,MAAMC,gBAAgB,SAAST,WAAW,CAAC;EAChD,KAAAM,mBAAA,IAA4C;IAC1C,OAAO,aAAa;EACtB;EAUA,OAAOI,gCAAgCA,CAACC,MAAc,EAAW;IAC/D,OAAOA,MAAM,CAACC,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAIT,UAAU,CAAC,CAAC,KAAK,QAAQ;EACnE;EAGAU,WAAWA,CAACH,MAAmB,EAAEI,KAAwB,EAAE;IACzD,KAAK,CAACJ,MAAM,EAAEI,KAAK,CAAC;IAAC,KAddJ,MAAM;IAAA,KACNK,MAAM;IAAA,KAGPC,MAAM,GAA8B,IAAI;IAAA,KACxCC,WAAW,GAAG,IAAI;IAAA,KAuF1BC,IAAI,GAAG,KAAK;IA7EV,IAAI,CAACR,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,MAAM,GAAG,IAAI,CAACL,MAAM,CAACS,GAAG,CAACC,iBAAiB,CAAC,CAAC;EACnD;EAESC,OAAOA,CAAA,EAAS;IACvB,KAAK,CAACA,OAAO,CAAC,CAAC;IACf,IAAI,IAAI,CAACL,MAAM,EAAE;MAAA,IAAAM,YAAA;MACf,CAAAA,YAAA,OAAI,CAACN,MAAM,cAAAM,YAAA,uBAAXA,YAAA,CAAaD,OAAO,CAA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AAM,CAAC;MAC7DvE,SAAS,CAAC;QAACsF,MAAM,EAAED,UAAU;QAAEE,MAAM,EAAET,aAAa;QAAEU,KAAK,EAAE,CAAC;QAAEC,KAAK,EAAElB;MAAM,CAAC,CAAC;MAC/E,IAAI,CAACxD,MAAM,CAAC2E,OAAO,CAACL,UAAU,CAAC;MAC/B,IAAI,CAACrE,WAAW,GAAGkC,KAAK;IAC1B;IAEA,OAAO,IAAI,CAACnC,MAAM;EACpB;AACF;AAQA,SAASgE,2BAA2BA,CAACY,UAAuB,EAAE;EAC5D,IAAIC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,EAAE;IAC7B,OAAO,IAAIG,YAAY,CAACH,UAAU,CAAC;EACrC;EACA,OAAOA,UAAU;AACnB;AAKA,SAASP,0BAA0BA,CAACW,EAAe,EAAEC,EAAe,EAAW;EAC7E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAACxB,MAAM,KAAKyB,EAAE,CAACzB,MAAM,IAAIwB,EAAE,CAACnF,WAAW,KAAKoF,EAAE,CAACpF,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIqF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAACxB,MAAM,EAAE,EAAE0B,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-canvas-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-canvas-context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAE/D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,YAAY,CAAiC;gBAEzC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB;IAS1D,qBAAqB,IAAI,gBAAgB;IAOzC,sDAAsD;IACtD,MAAM;IAQN;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;KAAC,GAAG,IAAI;IAe7F,MAAM;CAOP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-canvas-context.js","names":["CanvasContext","WEBGLFramebuffer","WebGLCanvasContext","constructor","device","props","presentationSize","_framebuffer","_setAutoCreatedCanvasId","id","update","getCurrentFramebuffer","handle","size","getPixelSize","sizeChanged","resize","options","canvas","devicePixelRatio","getDevicePixelRatio","useDevicePixels","setDevicePixelRatio","ext","gl","getExtension","width","height","commit"],"sources":["../../src/adapter/webgl-canvas-context.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {CanvasContextProps} 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 presentationSize: [number, number];\n private _framebuffer: WEBGLFramebuffer | null = null;\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 = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];\n if (sizeChanged) {\n this.presentationSize = size;\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 // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = this.device.gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && 'width' in options && 'height' in options) {\n ext.resize(options.width, options.height);\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 WebGLRenderingContext\n // this.gl.commit();\n // }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-canvas-context.js","names":["CanvasContext","WEBGLFramebuffer","WebGLCanvasContext","constructor","device","props","presentationSize","_framebuffer","_setAutoCreatedCanvasId","id","update","getCurrentFramebuffer","handle","size","getPixelSize","sizeChanged","resize","options","canvas","devicePixelRatio","getDevicePixelRatio","useDevicePixels","setDevicePixelRatio","ext","gl","getExtension","width","height","commit"],"sources":["../../src/adapter/webgl-canvas-context.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {CanvasContextProps} 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 presentationSize: [number, number];\n private _framebuffer: WEBGLFramebuffer | null = null;\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 = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];\n if (sizeChanged) {\n this.presentationSize = size;\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 // Resize browser context .\n if (this.canvas) {\n const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);\n this.setDevicePixelRatio(devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = this.device.gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && 'width' in options && 'height' in options) {\n ext.resize(options.width, options.height);\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 WebGLRenderingContext\n // this.gl.commit();\n // }\n }\n}\n"],"mappings":"AAIA,SAAQA,aAAa,QAAO,eAAe;AAAC,SAEpCC,gBAAgB;AAKxB,OAAO,MAAMC,kBAAkB,SAASF,aAAa,CAAC;EAKpDG,WAAWA,CAACC,MAAmB,EAAEC,KAAyB,EAAE;IAE1D,KAAK,CAACA,KAAK,CAAC;IAAC,KANND,MAAM;IAAA,KACfE,gBAAgB;IAAA,KACRC,YAAY,GAA4B,IAAI;IAKlD,IAAI,CAACH,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,gBAAgB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,IAAI,CAACE,uBAAuB,CAAE,GAAE,IAAI,CAACJ,MAAM,CAACK,EAAG,SAAQ,CAAC;IACxD,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAEAC,qBAAqBA,CAAA,EAAqB;IACxC,IAAI,CAACD,MAAM,CAAC,CAAC;IAEb,IAAI,CAACH,YAAY,GAAG,IAAI,CAACA,YAAY,IAAI,IAAIN,gBAAgB,CAAC,IAAI,CAACG,MAAM,EAAE;MAACQ,MAAM,EAAE;IAAI,CAAC,CAAC;IAC1F,OAAO,IAAI,CAACL,YAAY;EAC1B;EAGAG,MAAMA,CAAA,EAAG;IACP,MAAMG,IAAI,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;IAChC,MAAMC,WAAW,GAAGF,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAACP,gBAAgB,CAAC,CAAC,CAAC,IAAIO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAACP,gBAAgB,CAAC,CAAC,CAAC;IAChG,IAAIS,WAAW,EAAE;MACf,IAAI,CAACT,gBAAgB,GAAGO,IAAI;IAC9B;EACF;EAcAG,MAAMA,CAACC,OAA+E,EAAQ;IAE5F,IAAI,IAAI,CAACC,MAAM,EAAE;MACf,MAAMC,gBAAgB,GAAG,IAAI,CAACC,mBAAmB,CAACH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,eAAe,CAAC;MAC3E,IAAI,CAACC,mBAAmB,CAACH,gBAAgB,EAAEF,OAAO,CAAC;MACnD;IACF;IAGA,MAAMM,GAAG,GAAG,IAAI,CAACnB,MAAM,CAACoB,EAAE,CAACC,YAAY,CAAC,8BAA8B,CAAC;IACvE,IAAIF,GAAG,IAAIN,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAI,QAAQ,IAAIA,OAAO,EAAE;MAC/DM,GAAG,CAACP,MAAM,CAACC,OAAO,CAACS,KAAK,EAAET,OAAO,CAACU,MAAM,CAAC;IAC3C;EACF;EAEAC,MAAMA,CAAA,EAAG,CAMT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAetE,OAAO,EAAkC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAU1D,OAAO,KAAK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":"webgl-device.js","names":["Device","CanvasContext","log","uid","assert","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","BufferWithAccessor","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLVertexArray","LOG_LEVEL","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","arguments","length","undefined","groupCollapsed","canvas","pageLoaded","get","debug","spector","probe","constructor","_props$gl","id","info","canvasContext","handle","lost","_resolveContextLost","renderPass","gl2","isWebGL1","isWebGL2","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_extensions","_polyfilled","_webglLimits","_constants","Promise","resolve","onContextLost","event","_this$_resolveContext","call","reason","message","_version","enable","copyState","_len","args","Array","_key","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","createVertexArray","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","framebuffer","getCurrentFramebuffer","createCommandEncoder","submit","_this$renderPass","end","webglLimits","loseDevice","_this$_resolveContext2","deviceLossTriggered","loseContext","pushState","popState","setSpectorMetadata","__SPECTOR_Metadata","getGLKey","value","number","Number","key","String","setConstantAttribute","location","constant","maxVertexAttributes","fill","currentConstant","compareConstantArrayValues","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","WebGL2RenderingContext","Boolean","isFinite","array","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","v1","v2","i"],"sources":["../../src/adapter/webgl-device.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat,\n VertexArray,\n VertexArrayProps,\n TypedArray\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {\n popContextState,\n pushContextState,\n trackContextState\n} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\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} from '@luma.gl/core';\n\nimport {BufferWithAccessor} from '../classic/buffer-with-accessor';\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';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\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 WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (log.get('debug') || props.debug) {\n await loadWebGLDeveloperTools();\n }\n\n // @ts-expect-error spector not on props\n const {spector} = props;\n if (log.get('spector') || spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.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, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser()\n ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})\n : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\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._getBufferProps(props);\n return new BufferWithAccessor(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 createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n override createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(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('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\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/WebGLRenderingContext/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 // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\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: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\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 ext = this.gl.getExtension('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 pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\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<string, unknown>) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL.<KEY> 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, gl?: WebGLRenderingContext): string {\n // @ts-ignore expect-error depends on settings\n gl = gl || this.gl2 || this.gl;\n const number = Number(value);\n for (const key in gl) {\n // @ts-ignore expect-error depends on settings\n if (gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return String(value);\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 setConstantAttribute(location: number, constant: TypedArray): void {\n this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();\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 assert(false);\n }\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\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\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\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.assertWebGL2();\n device.gl2?.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.assertWebGL2();\n device.gl2?.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 *\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"],"mappings":"AAYA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AACrE,SAAQC,SAAS,QAAO,eAAe;AAAC,SAChCC,eAAe;AAAA,SAErBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB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AiB,EAAQ;EAAA,IAAAK,UAAA;EAC3F/H,MAAM,CAACqE,YAAY,CAAC,CAAC;EACrB,CAAA0D,UAAA,GAAA/H,MAAM,CAACwB,GAAG,cAAAuG,UAAA,uBAAVA,UAAA,CAAYC,gBAAgB,CAACrB,QAAQ,EAAEe,KAAK,CAAC;AAiB/C;AAGA,SAASJ,oBAAoBA,CAACtH,MAAmB,EAAE2G,QAAgB,EAAEe,KAAkB,EAAE;EAAA,IAAAO,WAAA;EACvFjI,MAAM,CAACqE,YAAY,CAAC,CAAC;EACrB,CAAA4D,WAAA,GAAAjI,MAAM,CAACwB,GAAG,cAAAyG,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAACvB,QAAQ,EAAEe,KAAK,CAAC;AAkBhD;AAKA,SAASV,0BAA0BA,CAACmB,EAAc,EAAEC,EAAc,EAAW;EAC3E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAC7H,MAAM,KAAK8H,EAAE,CAAC9H,MAAM,IAAI6H,EAAE,CAACpH,WAAW,KAAKqH,EAAE,CAACrH,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIsH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAC7H,MAAM,EAAE,EAAE+H,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"webgl-device.js","names":["Device","CanvasContext","log","uid","assert","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","BufferWithAccessor","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLVertexArray","LOG_LEVEL","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","arguments","length","undefined","groupCollapsed","canvas","pageLoaded","get","debug","spector","probe","constructor","_props$gl","id","info","canvasContext","handle","lost","_resolveContextLost","renderPass","gl2","isWebGL1","isWebGL2","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_extensions","_polyfilled","_webglLimits","_constants","Promise","resolve","onContextLost","event","_this$_resolveContext","call","reason","message","_version","enable","copyState","_len","args","Array","_key","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","createVertexArray","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","framebuffer","getCurrentFramebuffer","createCommandEncoder","submit","_this$renderPass","end","webglLimits","loseDevice","_this$_resolveContext2","deviceLossTriggered","loseContext","pushState","popState","setSpectorMetadata","__SPECTOR_Metadata","getGLKey","value","number","Number","key","String","setConstantAttribute","location","constant","maxVertexAttributes","fill","currentConstant","compareConstantArrayValues","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","WebGL2RenderingContext","Boolean","isFinite","array","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","v1","v2","i"],"sources":["../../src/adapter/webgl-device.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat,\n VertexArray,\n VertexArrayProps,\n TypedArray\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {\n popContextState,\n pushContextState,\n trackContextState\n} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\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} from '@luma.gl/core';\n\nimport {BufferWithAccessor} from '../classic/buffer-with-accessor';\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';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\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 WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (log.get('debug') || props.debug) {\n await loadWebGLDeveloperTools();\n }\n\n // @ts-expect-error spector not on props\n const {spector} = props;\n if (log.get('spector') || spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.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, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser()\n ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})\n : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\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._getBufferProps(props);\n return new BufferWithAccessor(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 createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n override createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(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('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\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/WebGLRenderingContext/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 // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\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: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\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 ext = this.gl.getExtension('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 pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\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<string, unknown>) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL.<KEY> 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, gl?: WebGLRenderingContext): string {\n // @ts-ignore expect-error depends on settings\n gl = gl || this.gl2 || this.gl;\n const number = Number(value);\n for (const key in gl) {\n // @ts-ignore expect-error depends on settings\n if (gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return String(value);\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 setConstantAttribute(location: number, constant: TypedArray): void {\n this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();\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 assert(false);\n }\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\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\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\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.assertWebGL2();\n device.gl2?.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.assertWebGL2();\n device.gl2?.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 *\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"],"mappings":"AAcA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AACrE,SAAQC,SAAS,QAAO,eAAe;AAAC,SAChCC,eAAe;AAAA,SAErBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB;AAAA,SAEXC,oBAAoB;AAAA,SAE1BC,qBAAqB,EACrBC,sBAAsB;AAAA,SAEhBC,aAAa;AAAA,SACbC,iBAAiB;AAAA,SACjBC,eAAe,EAAEC,cAAc;AAAA,SAC/BC,kBAAkB;AAAA,SAClBC,aAAa,EAAEC,mBAAmB;AAAA,SAClCC,uBAAuB,EAAEC,gBAAgB;AAAA,SAE/CC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,EAAE2G,QAAgB,EAAEe,KAAkB,EAAE;EAAA,IAAAO,WAAA;EACvFjI,MAAM,CAACqE,YAAY,CAAC,CAAC;EACrB,CAAA4D,WAAA,GAAAjI,MAAM,CAACwB,GAAG,cAAAyG,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAACvB,QAAQ,EAAEe,KAAK,CAAC;AAkBhD;AAKA,SAASV,0BAA0BA,CAACmB,EAAc,EAAEC,EAAc,EAAW;EAC3E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAC7H,MAAM,KAAK8H,EAAE,CAAC9H,MAAM,IAAI6H,EAAE,CAACpH,WAAW,KAAKqH,EAAE,CAACrH,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIsH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAC7H,MAAM,EAAE,EAAE+H,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AASF,qBAAa,QAAS,YAAW,cAAc;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAY1D,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ;gBAI5C,GAAG,SAAS,EAAE,cAAc,EAAE;IAK1C,QAAQ,IAAI,MAAM;IAOlB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA6E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.js","names":["assert","checkProps","GL","getTypedArrayFromGLType","DEFAULT_ACCESSOR_VALUES","offset","stride","type","FLOAT","size","divisor","normalized","integer","PROP_CHECKS","deprecatedProps","instanced","isInstanced","Accessor","getBytesPerElement","accessor","ArrayType","BYTES_PER_ELEMENT","getBytesPerVertex","resolve","_len","arguments","length","accessors","Array","_key","constructor","buffer","index","_len2","_key2","forEach","_assign","Object","freeze","toString","JSON","stringify","BYTES_PER_VERTEX","props","undefined","INT","UNSIGNED_INT","normalize"],"sources":["../../src/classic/accessor.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"accessor.js","names":["assert","checkProps","GL","getTypedArrayFromGLType","DEFAULT_ACCESSOR_VALUES","offset","stride","type","FLOAT","size","divisor","normalized","integer","PROP_CHECKS","deprecatedProps","instanced","isInstanced","Accessor","getBytesPerElement","accessor","ArrayType","BYTES_PER_ELEMENT","getBytesPerVertex","resolve","_len","arguments","length","accessors","Array","_key","constructor","buffer","index","_len2","_key2","forEach","_assign","Object","freeze","toString","JSON","stringify","BYTES_PER_VERTEX","props","undefined","INT","UNSIGNED_INT","normalize"],"sources":["../../src/classic/accessor.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {getTypedArrayFromGLType} from './typed-array-utils';\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\nconst PROP_CHECKS = {\n deprecatedProps: {\n instanced: 'divisor',\n isInstanced: 'divisor'\n }\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 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 props = checkProps('Accessor', props, PROP_CHECKS);\n\n if (props.type !== undefined) {\n this.type = props.type;\n\n // Auto-deduce integer type?\n if (props.type === GL.INT || props.type === 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// TEST EXPORTS\nexport {DEFAULT_ACCESSOR_VALUES};\n"],"mappings":"AAGA,SAAQA,MAAM,EAAEC,UAAU,QAA+B,eAAe;AACxE,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,uBAAuB;AAE/B,MAAMC,uBAAuB,GAAG;EAC9BC,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAEL,EAAE,CAACM,KAAK;EACdC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,CAAC;EACVC,UAAU,EAAE,KAAK;EACjBC,OAAO,EAAE;AACX,CAAC;AAED,MAAMC,WAAW,GAAG;EAClBC,eAAe,EAAE;IACfC,SAAS,EAAE,SAAS;IACpBC,WAAW,EAAE;EACf;AACF,CAAC;AAED,OAAO,MAAMC,QAAQ,CAA2B;EAY9C,OAAOC,kBAAkBA,CAACC,QAAmC,EAAU;IAGrE,MAAMC,SAAS,GAAGjB,uBAAuB,CAACgB,QAAQ,CAACZ,IAAI,IAAIL,EAAE,CAACM,KAAK,CAAC;IACpE,OAAOY,SAAS,CAACC,iBAAiB;EACpC;EAEA,OAAOC,iBAAiBA,CAACH,QAAwB,EAAU;IACzDnB,MAAM,CAACmB,QAAQ,CAACV,IAAI,CAAC;IAGrB,MAAMW,SAAS,GAAGjB,uBAAuB,CAACgB,QAAQ,CAACZ,IAAI,IAAIL,EAAE,CAACM,KAAK,CAAC;IACpE,OAAOY,SAAS,CAACC,iBAAiB,GAAGF,QAAQ,CAACV,IAAI;EACpD;EAMA,OAAOc,OAAOA,CAAA,EAA2C;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAvCC,SAAS,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAATF,SAAS,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IA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AAa,EAAE,MAAM;IAQ/C,UAAU,CAAC,IAAI,KAAA;IAQf,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,GAAG;IAQ5B,2CAA2C;IAC3C,IAAI,IAAI,WAEP;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-with-accessor.js","names":["assert","checkProps","GL","assertWebGL2Context","Accessor","getGLTypeFromTypedArray","getTypedArrayFromGLType","WebGLDevice","WEBGLBuffer","DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","BufferWithAccessor","constructor","device","arguments","length","undefined","attach","accessor","setAccessor","Object","assign","seal","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","glUsage","STATIC_DRAW","debugData","_setData","byteOffset","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","subData","options","srcOffset","glTarget","gl","webgl2","COPY_WRITE_BUFFER","bindBuffer","handle","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","_this$gl","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","_this$gl2","bindBufferRange","_this$gl3","bindBufferBase","unbind","isIndexedBuffer","_this$gl4","getDebugData","changed","invalidateDebugData","trackDeallocatedMemory","target","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"sources":["../../src/classic/buffer-with-accessor.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/core';\nimport {assert, checkProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport {Accessor} from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport {WebGLDevice} from '../adapter/webgl-device';\nimport {WEBGLBuffer} from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: BufferWithAccessorProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props };\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props };\n // if (bufferProps.offset) {\n // bufferProps.byteOffset = bufferProps.offset;\n // }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type BufferWithAccessorProps = BufferProps & {\n handle?: WebGLBuffer;\n\n accessor?: AccessorObject;\n\n // target?: number;\n // glUsage?: number;\n // /** @deprecated */\n // index?: number;\n // /** @deprecated */\n // offset?: number;\n // /** @deprecated */\n // size?: number;\n // /** @deprecated */\n // type?: number\n}\n\n/** WebGL Buffer interface */\nexport class BufferWithAccessor extends WEBGLBuffer {\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as BufferWithAccessorProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n // override write(data: TypedArray, byteOffset: number = 0): void {\n // this.subData({data, offset: byteOffset});\n // }\n\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: BufferWithAccessorProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n // @ts-expect-error readonly field\n this.glUsage = props.glUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: BufferWithAccessorProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: BufferWithAccessorProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\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 // @ts-expect-error\n const glTarget = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.glTarget, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, offset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n override getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\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.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {glTarget?: number; index?: any; offset?: number; size?: any}): this {\n const {\n glTarget = this.glTarget, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(glTarget, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(glTarget, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(glTarget, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {glTarget?: any; index?: any}): this {\n const {glTarget = this.glTarget, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(glTarget, index, null);\n } else {\n this.gl.bindBuffer(glTarget, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.glUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\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._getTarget();\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.glTarget, this.handle);\n const value = this.gl.getBufferParameter(this.glTarget, pname);\n this.gl.bindBuffer(this.glTarget, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"mappings":"AAGA,SAAQA,MAAM,EAAEC,UAAU,QAAO,eAAe;AAChD,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAC9BC,mBAAmB;AAAA,SAEnBC,QAAQ;AAAA,SACRC,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IAAI,CAACtD,EAAE,CAACG,UAAU,CAAC,IAAI,CAACJ,QAAQ,EAAE,IAAI,CAAC;IACvC,OAAOwD,KAAK;EACd;EAIA,IAAI/G,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAAC2B,QAAQ,CAAC3B,IAAI;EAC3B;AACF"}
|
|
1
|
+
{"version":3,"file":"buffer-with-accessor.js","names":["assert","checkProps","GL","assertWebGL2Context","Accessor","getGLTypeFromTypedArray","getTypedArrayFromGLType","WebGLDevice","WEBGLBuffer","DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","BufferWithAccessor","constructor","device","arguments","length","undefined","attach","accessor","setAccessor","Object","assign","seal","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","glUsage","STATIC_DRAW","debugData","_setData","byteOffset","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","subData","options","srcOffset","glTarget","gl","webgl2","COPY_WRITE_BUFFER","bindBuffer","handle","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","_this$gl","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","_this$gl2","bindBufferRange","_this$gl3","bindBufferBase","unbind","isIndexedBuffer","_this$gl4","getDebugData","changed","invalidateDebugData","trackDeallocatedMemory","target","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"sources":["../../src/classic/buffer-with-accessor.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/core';\nimport {assert, checkProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport {Accessor} from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport {WebGLDevice} from '../adapter/webgl-device';\nimport {WEBGLBuffer} from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: BufferWithAccessorProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props };\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props };\n // if (bufferProps.offset) {\n // bufferProps.byteOffset = bufferProps.offset;\n // }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type BufferWithAccessorProps = BufferProps & {\n handle?: WebGLBuffer;\n\n accessor?: AccessorObject;\n\n // target?: number;\n // glUsage?: number;\n // /** @deprecated */\n // index?: number;\n // /** @deprecated */\n // offset?: number;\n // /** @deprecated */\n // size?: number;\n // /** @deprecated */\n // type?: number\n}\n\n/** WebGL Buffer interface */\nexport class BufferWithAccessor extends WEBGLBuffer {\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: BufferWithAccessorProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as BufferWithAccessorProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n // override write(data: TypedArray, byteOffset: number = 0): void {\n // this.subData({data, offset: byteOffset});\n // }\n\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: BufferWithAccessorProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n // @ts-expect-error readonly field\n this.glUsage = props.glUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: BufferWithAccessorProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: BufferWithAccessorProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\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 // @ts-expect-error\n const glTarget = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n this.gl.bindBuffer(glTarget, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.glTarget, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(glTarget, offset, data);\n }\n this.gl.bindBuffer(glTarget, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n override getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\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.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {glTarget?: number; index?: any; offset?: number; size?: any}): this {\n const {\n glTarget = this.glTarget, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(glTarget, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(glTarget, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(glTarget, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {glTarget?: any; index?: any}): this {\n const {glTarget = this.glTarget, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = glTarget === GL.UNIFORM_BUFFER || glTarget === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(glTarget, index, null);\n } else {\n this.gl.bindBuffer(glTarget, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.glUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\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._getTarget();\n this.gl.bindBuffer(glTarget, this.handle);\n this.gl.bufferData(glTarget, data, this.glUsage);\n this.gl.bindBuffer(glTarget, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.glTarget;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.glTarget, this.handle);\n const value = this.gl.getBufferParameter(this.glTarget, pname);\n this.gl.bindBuffer(this.glTarget, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"mappings":"AAIA,SAAQA,MAAM,EAAEC,UAAU,QAAO,eAAe;AAChD,SAAQC,EAAE,QAAO,oBAAoB;AAAC,S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,IAAI,CAACzD,QAAQ,EAAEuD,KAAK,CAAC;IAC9D,IAAI,CAACtD,EAAE,CAACG,UAAU,CAAC,IAAI,CAACJ,QAAQ,EAAE,IAAI,CAAC;IACvC,OAAOwD,KAAK;EACd;EAIA,IAAI/G,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAAC2B,QAAQ,CAAC3B,IAAI;EAC3B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/classic/clear.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/classic/clear.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAS,MAAM,eAAe,CAAC;AAiB1D;;;GAGG;AACH,wBAAgB,KAAK,CACnB,EAAE,EAAE,MAAM,GAAG,qBAAqB,EAClC,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAC,GAC7E,IAAI,CAsCN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,GAAG,qBAAqB,EAClC,OAAO,CAAC,EAAE;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAA;CAAC,QAuCnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.js","names":["assert","WebGLDevice","withGLParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","GL_DEPTH","GL_STENCIL","GL_DEPTH_STENCIL","ERR_ARGUMENTS","clear","gl","options","device","attach","framebuffer","color","depth","stencil","parameters","clearFlags","clearColor","clearDepth","clearStencil","clearBuffer","buffer","drawBuffer","value","gl2","constructor","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv","clearBufferfi"],"sources":["../../src/classic/clear.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"clear.js","names":["assert","WebGLDevice","withGLParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","GL_DEPTH","GL_STENCIL","GL_DEPTH_STENCIL","ERR_ARGUMENTS","clear","gl","options","device","attach","framebuffer","color","depth","stencil","parameters","clearFlags","clearColor","clearDepth","clearStencil","clearBuffer","buffer","drawBuffer","value","gl2","constructor","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv","clearBufferfi"],"sources":["../../src/classic/clear.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Device, Framebuffer, assert} from '@luma.gl/core';\nimport {WebGLDevice} from '../adapter/webgl-device';\nimport {withGLParameters} from '../context/state-tracker/with-parameters';\n\n// Should collapse during minification\nconst GL_DEPTH_BUFFER_BIT = 0x00000100;\nconst GL_STENCIL_BUFFER_BIT = 0x00000400;\nconst GL_COLOR_BUFFER_BIT = 0x00004000;\n\nconst GL_COLOR = 0x1800;\nconst GL_DEPTH = 0x1801;\nconst GL_STENCIL = 0x1802;\nconst GL_DEPTH_STENCIL = 0x84f9;\n\n// Should disappear if asserts are removed\nconst ERR_ARGUMENTS = 'clear: bad arguments';\n\n/** \n * Optionally clears depth, color and stencil buffers \n * @deprecated Set clear color when creating a RenderPass.\n */\nexport function clear(\n gl: Device | WebGLRenderingContext,\n options?: {framebuffer?: Framebuffer; color?: any; depth?: any; stencil?: any}\n): void {\n const device = WebGLDevice.attach(gl);\n const {framebuffer = null, color = null, depth = null, stencil = null} = options || {};\n const parameters: any = {};\n\n if (framebuffer) {\n parameters.framebuffer = framebuffer;\n }\n\n let clearFlags = 0;\n\n if (color) {\n clearFlags |= GL_COLOR_BUFFER_BIT;\n if (color !== true) {\n parameters.clearColor = color;\n }\n }\n\n if (depth) {\n clearFlags |= GL_DEPTH_BUFFER_BIT;\n if (depth !== true) {\n parameters.clearDepth = depth;\n }\n }\n\n if (stencil) {\n clearFlags |= GL_STENCIL_BUFFER_BIT;\n if (depth !== true) {\n parameters.clearStencil = depth;\n }\n }\n\n assert(clearFlags !== 0, ERR_ARGUMENTS);\n\n // Temporarily set any clear \"colors\" and call clear\n withGLParameters(device.gl, parameters, () => {\n device.gl.clear(clearFlags);\n });\n}\n\n/** \n * WebGL2 - clear a specific drawing buffer \n * @deprecated Set clear color when creating a RenderPass\n */\nexport function clearBuffer(\n gl: Device | WebGLRenderingContext,\n options?: {framebuffer?: Framebuffer; buffer?: any; drawBuffer?: any; value?: any}\n) {\n const device = WebGLDevice.attach(gl);\n\n const {framebuffer = null, buffer = GL_COLOR, drawBuffer = 0, value = [0, 0, 0, 0]} = options || {};\n withGLParameters(device.gl2, {framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (buffer) {\n case GL_COLOR:\n switch (value.constructor) {\n case Int32Array:\n device.gl2.clearBufferiv(buffer, drawBuffer, value);\n break;\n case Uint32Array:\n device.gl2.clearBufferuiv(buffer, drawBuffer, value);\n break;\n case Float32Array:\n default:\n device.gl2.clearBufferfv(buffer, drawBuffer, value);\n }\n break;\n\n case GL_DEPTH:\n device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);\n break;\n\n case GL_STENCIL:\n device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);\n break;\n\n case GL_DEPTH_STENCIL:\n const [depth, stencil] = value;\n device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);\n break;\n\n default:\n assert(false, ERR_ARGUMENTS);\n }\n });\n}\n"],"mappings":"AAGA,SAA6BA,MAAM,QAAO,eAAe;AAAC,SAClDC,WAAW;AAAA,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