@luma.gl/webgl 9.0.0-alpha.33 → 9.0.0-alpha.34
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/dist/adapter/converters/device-parameters.js +1 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.js +3 -3
- package/dist/adapter/converters/shader-formats.js.map +1 -1
- package/dist/adapter/converters/texture-formats.js +3 -3
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +3 -3
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +1 -1
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +2 -2
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +1 -1
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +3 -4
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +7 -8
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +2 -3
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +10 -11
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +3 -4
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +2 -3
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +6 -7
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +2 -3
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +31 -32
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +4 -5
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +7 -8
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +19 -20
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +4 -5
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.js +25 -24
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.js +9 -10
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/buffer-with-accessor.js +1 -2
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/classic/copy-and-blit.js +1 -1
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/context/context/create-browser-context.js +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +5 -5
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +8 -9
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/dist.dev.js +57 -30
- package/dist/index.cjs +2 -2
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/resources/webgl-render-pipeline.ts +2 -2
|
@@ -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","
|
|
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":["import {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":"AAAA,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,I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,uBAAuB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { assert, checkProps } from '@luma.gl/core';
|
|
3
2
|
import { GL } from '@luma.gl/constants';
|
|
4
3
|
import { assertWebGL2Context } from "../context/context/webgl-checks.js";
|
|
@@ -48,7 +47,7 @@ export class BufferWithAccessor extends WEBGLBuffer {
|
|
|
48
47
|
constructor(device) {
|
|
49
48
|
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
50
49
|
super(WebGLDevice.attach(device), getWEBGLBufferProps(props));
|
|
51
|
-
|
|
50
|
+
this.accessor = void 0;
|
|
52
51
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
53
52
|
if (this.props.data) {
|
|
54
53
|
const type = getGLTypeFromTypedArray(this.props.data);
|
|
@@ -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","_defineProperty","setAccessor","Object","assign","accessor","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,uBAAuB,EAAEC,uBAAuB;AAAA,SAEhDC,WAAW;AAAA,SACXC,WAAW;AAEnB,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,MAAMC,gBAAgB,GAAG;EACvBC,MAAM,EAAE,iBAAiB;EACzBC,MAAM,EAAE,iBAAiB;EACzBC,IAAI,EAAE,eAAe;EACrBC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAE,kBAAkB;EAC3BC,UAAU,EAAE,qBAAqB;EACjCC,OAAO,EAAE,kBAAkB;EAC3BC,SAAS,EAAE,kBAAkB;EAC7BC,WAAW,EAAE;AACf,CAAC;AAGD,MAAMC,sBAAsB,GAAG;EAC7BC,YAAY,EAAE,CAAC,CAAC;EAChBC,aAAa,EAAE;IACbC,KAAK,EAAE;EACT,CAAC;EAEDC,eAAe,EAAEd;AACnB,CAAC;AAGD,MAAMe,qBAAqB,GAAG;EAE5BJ,YAAY,EAAEX;AAChB,CAAC;AAED,SAASgB,mBAAmBA,CAACC,KAAyD,EAAe;EAEnG,IAAIC,WAAW,CAACC,MAAM,CAACF,KAAK,CAAC,EAAE;IAC7B,OAAO;MAACG,IAAI,EAAEH;IAAK,CAAC;EACtB,CAAC,MAGI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAO;MAACI,UAAU,EAAEJ;IAAM,CAAC;EAC7B;EAEAA,K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,CAAC,IAAIrC,QAAQ,CAAC,IAAI,CAACwC,QAAQ,EAAE;QAAC/B,IAAI,EAAER,uBAAuB,CAACyB,IAAI;MAAC,CAAC,CAAC,CAAC;IACtF;EACF;EAIA6F,YAAYA,CAACC,KAAS,EAAO;IAC3B,IAAI,CAACtD,EAAE,CAACG,UAAU,CAAC,IAAI,CAACJ,QAAQ,EAAE,IAAI,CAACK,MAAM,CAAC;IAC9C,MAAMmD,KAAK,GAAG,IAAI,CAACvD,EAAE,CAACwD,kBAAkB,CAAC,IAAI,CAACzD,QAAQ,EAAEuD,KAAK,CAAC;IAC9D,IAAI,CAACtD,EAAE,CAACG,UAAU,CAAC,IAAI,CAACJ,QAAQ,EAAE,IAAI,CAAC;IACvC,OAAOwD,KAAK;EACd;EAIA,IAAIhH,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAAC+B,QAAQ,CAAC/B,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\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,uBAAuB,EAAEC,uBAAuB;AAAA,SAEhDC,WAAW;AAAA,SACXC,WAAW;AAEnB,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,MAAMC,gBAAgB,GAAG;EACvBC,MAAM,EAAE,iBAAiB;EACzBC,MAAM,EAAE,iBAAiB;EACzBC,IAAI,EAAE,eAAe;EACrBC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAE,kBAAkB;EAC3BC,UAAU,EAAE,qBAAqB;EACjCC,OAAO,EAAE,kBAAkB;EAC3BC,SAAS,EAAE,kBAAkB;EAC7BC,WAAW,EAAE;AACf,CAAC;AAGD,MAAMC,sBAAsB,GAAG;EAC7BC,YAAY,EAAE,CAAC,CAAC;EAChBC,aAAa,EAAE;IACbC,KAAK,EAAE;EACT,CAAC;EAEDC,eAAe,EAAEd;AACnB,CAAC;AAGD,MAAMe,qBAAqB,GAAG;EAE5BJ,YAAY,EAAEX;AAChB,CAAC;AAED,SAASgB,mBAAmBA,CAACC,KAAyD,EAAe;EAEnG,IAAIC,WAAW,CAACC,MAAM,CAACF,KAAK,CAAC,EAAE;IAC7B,OAAO;MAACG,IAAI,EAAEH;IAAK,CAAC;EACtB,CAAC,MAGI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAO;MAACI,UAAU,EAAEJ;IAAM,CAAC;EAC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E;MACvB,IAAI,CAAC4B,WAAW,CAAC,IAAIrC,QAAQ,CAAC,IAAI,CAACoC,QAAQ,EAAE;QAAC3B,IAAI,EAAER,uBAAuB,CAACyB,IAAI;MAAC,CAAC,CAAC,CAAC;IACtF;EACF;EAIA4F,YAAYA,CAACC,KAAS,EAAO;IAC3B,IAAI,CAACtD,EAAE,CAACG,UAAU,CAAC,IAAI,CAACJ,QAAQ,EAAE,IAAI,CAACK,MAAM,CAAC;IAC9C,MAAMmD,KAAK,GAAG,IAAI,CAACvD,EAAE,CAACwD,kBAAkB,CAAC,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"}
|
|
@@ -181,7 +181,7 @@ export function toFramebuffer(texture, props) {
|
|
|
181
181
|
} = texture;
|
|
182
182
|
const framebuffer = device.createFramebuffer({
|
|
183
183
|
...props,
|
|
184
|
-
id:
|
|
184
|
+
id: `framebuffer-for-${id}`,
|
|
185
185
|
width,
|
|
186
186
|
height,
|
|
187
187
|
colorAttachments: [texture]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-and-blit.js","names":["assert","Texture","Framebuffer","GL","BufferWithAccessor","Buffer","withParameters","getGLTypeFromTypedArray","getTypedArrayFromGLType","glFormatToComponents","glTypeToBytes","readPixelsToArray","source","options","sourceX","sourceY","sourceFormat","RGBA","sourceAttachment","COLOR_ATTACHMENT0","target","sourceWidth","sourceHeight","sourceType","framebuffer","deleteFramebuffer","getFramebuffer","gl","handle","width","height","FRONT","attachment","colorAttachments","type","getPixelArray","prevHandle","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","readPixelsToBuffer","targetByteOffset","webglFramebuffer","gl2","device","assertWebGL2","UNSIGNED_BYTE","components","byteCount","byteLength","accessor","size","bind","glTarget","PIXEL_PACK_BUFFER","unbind","copyToTexture","targetMipmaplevel","targetInternalFormat","targetX","targetY","targetZ","isSubCopy","texture","textureTarget","Number","isFinite","copyTexImage2D","TEXTURE_2D","TEXTURE_CUBE_MAP","copyTexSubImage2D","TEXTURE_2D_ARRAY","TEXTURE_3D","copyTexSubImage3D","toFramebuffer","props","id","createFramebuffer","concat","pixelArray","format","ArrayType","clamped"],"sources":["../../src/classic/copy-and-blit.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {assert, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {BufferWithAccessor as Buffer} from './buffer-with-accessor';\nimport {WEBGLTexture} from '../adapter/resources/webgl-texture';\nimport {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';\nimport {withParameters} from '../context/state-tracker/with-parameters';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\nimport {glFormatToComponents, glTypeToBytes} from './format-utils';\n\n/**\n * Copies data from a type or a Texture object into ArrayBuffer object.\n * App can provide targetPixelArray or have it auto allocated by this method\n * newly allocated by this method unless provided by app.\n * @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read\n * @note Slow requires roundtrip to GPU\n *\n * @param source\n * @param options\n * @returns pixel array,\n */\nexport function readPixelsToArray(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Uint8Array | Uint16Array | Float32Array {\n const {sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA} = options || {};\n let {\n sourceAttachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n target = null,\n // following parameters are auto deduced if not provided\n sourceWidth,\n sourceHeight,\n sourceType\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const {gl, handle} = framebuffer as WEBGLFramebuffer;\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // TODO - Set and unset gl.readBuffer\n if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {\n sourceAttachment = GL.FRONT;\n }\n\n const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;\n // assert(attachments[sourceAttachment]);\n\n // Deduce the type from color attachment if not provided.\n sourceType = sourceType || (framebuffer.colorAttachments[attachment] as WEBGLTexture).type;\n\n // Deduce type and allocated pixelArray if needed\n target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);\n\n // Pixel array available, if necessary, deduce type from it.\n sourceType = sourceType || getGLTypeFromTypedArray(target);\n\n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return target;\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.\n * @deprecated Use CommandEncoder\n * @param source\n * @param options\n */\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer {\n const {sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, targetByteOffset = 0} = options || {};\n // following parameters are auto deduced if not provided\n let {target, sourceWidth, sourceHeight, sourceType} = options || {};\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const gl2 = webglFramebuffer.device.assertWebGL2();\n\n // deduce type if not available.\n sourceType = sourceType || (target ? target.type : GL.UNSIGNED_BYTE);\n\n if (!target) {\n // Create new buffer with enough size\n const components = glFormatToComponents(sourceFormat);\n const byteCount = glTypeToBytes(sourceType);\n const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;\n target = new Buffer(gl2, {byteLength, accessor: {type: sourceType, size: components}});\n }\n\n target.bind({glTarget: GL.PIXEL_PACK_BUFFER});\n withParameters(gl2, {framebuffer}, () => {\n gl2.readPixels(\n sourceX,\n sourceY,\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n targetByteOffset\n );\n });\n target.unbind({glTarget: GL.PIXEL_PACK_BUFFER});\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n\n return target;\n}\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n * @deprecated Use CommandEncoder\n */\n// eslint-disable-next-line complexity, max-statements\nexport function copyToTexture(\n source: Framebuffer | Texture,\n target: Texture | GL,\n options?: {\n sourceX?: number;\n sourceY?: number;\n\n targetX?: number;\n targetY?: number;\n targetZ?: number;\n targetMipmaplevel?: number;\n targetInternalFormat?: number;\n\n width?: number; // defaults to target width\n height?: number; // defaults to target height\n }\n): Texture {\n const {\n sourceX = 0,\n sourceY = 0,\n // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMipmaplevel = 0,\n targetInternalFormat = GL.RGBA\n } = options || {};\n let {\n targetX,\n targetY,\n targetZ,\n width, // defaults to target width\n height // defaults to target height\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const {device, handle} = webglFramebuffer;\n const isSubCopy =\n typeof targetX !== 'undefined' ||\n typeof targetY !== 'undefined' ||\n typeof targetZ !== 'undefined';\n targetX = targetX || 0;\n targetY = targetY || 0;\n targetZ = targetZ || 0;\n const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n assert(target);\n let texture = null;\n let textureTarget: GL;\n if (target instanceof Texture) {\n texture = target;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.target;\n } else {\n textureTarget = target;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n targetMipmaplevel,\n targetInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n switch (textureTarget) {\n case GL.TEXTURE_2D:\n case GL.TEXTURE_CUBE_MAP:\n device.gl.copyTexSubImage2D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n device.assertWebGL2();\n device.gl2.copyTexSubImage3D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n targetZ,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n default:\n }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: Framebuffer;\n deleteFramebuffer: boolean;\n} {\n if (!(source instanceof Framebuffer)) {\n return {framebuffer: toFramebuffer(source), deleteFramebuffer: true};\n }\n return {framebuffer: source, deleteFramebuffer: false};\n}\n\n/**\n * Wraps a given texture into a framebuffer object, that can be further used\n * to read data from the texture object.\n */\nexport function toFramebuffer(texture: Texture, props?: FramebufferProps): Framebuffer {\n const {device, width, height, id} = texture;\n const framebuffer = device.createFramebuffer({\n ...props,\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [\n texture\n ]\n }\n );\n return framebuffer;\n}\n\nfunction getPixelArray(\n pixelArray,\n type,\n format,\n width: number,\n height: number\n): Uint8Array | Uint16Array | Float32Array {\n if (pixelArray) {\n return pixelArray;\n }\n // Allocate pixel array if not already available, using supplied type\n type = type || GL.UNSIGNED_BYTE;\n const ArrayType = getTypedArrayFromGLType(type, {clamped: false});\n const components = glFormatToComponents(format);\n // TODO - check for composite type (components = 1).\n return new ArrayType(width * height * components) as Uint8Array | Uint16Array | Float32Array;\n}\n"],"mappings":"AACA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,WAAW,QAAyB,eAAe;AAC5E,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,kBAAkB,IAAIC,MAAM;AAAA,SAG5BC,cAAc;AAAA,SACdC,uBAAuB,EAAEC,uBAAuB;AAAA,SAChDC,oBAAoB,EAAEC,aAAa;AAa3C,OAAO,SAASC,iBAAiBA,CAC/BC,MAA6B,EAC7BC,OAUC,EACwC;EACzC,MAAM;IAACC,OAAO,GAAG,CAAC;IAAEC,OAAO,GAAG,CAAC;IAAEC,YAAY,GAAGb,EAAE,CAACc;EAAI,CAAC,GAAGJ,OAAO,IAAI,CAAC,CAAC;EACxE,IAAI;IACFK,gBAAgB,GAAGf,EAAE,CAACgB,iBAAiB;IACvCC,MAAM,GAAG,IAAI;IAEbC,WAAW;IACXC,YAAY;IACZC;EACF,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EAEjB,MAAM;IAACW,WAAW;IAAEC;EAAiB,CAAC,GAAGC,cAAc,CAACd,MAAM,CAAC;EAC/DZ,MAAM,CAACwB,WAAW,CAAC;EACnB,MAAM;IAACG,EAAE;IAAEC;EAAM,CAAC,GAAGJ,WAA+B;EACpDH,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,CAAC;EACvB;EACA,OAAOwB,OAAO;AAChB;AAEA,SAAStC,cAAcA,CAACd,MAA6B,EAGnD;EACA,IAAI,EAAEA,MAAM,YAAYV,WAAW,CAAC,EAAE;IACpC,OAAO;MAACsB,WAAW,EAAEmD,aAAa,CAAC/D,MAAM,CAAC;MAAEa,iBAAiB,EAAE;IAAI,CAAC;EACtE;EACA,OAAO;IAACD,WAAW,EAAEZ,MAAM;IAAEa,iBAAiB,EAAE;EAAK,CAAC;AACxD;AAMA,OAAO,SAASkD,aAAaA,CAACX,OAAgB,EAAEY,KAAwB,EAAe;EACrF,MAAM;IAAC/B,MAAM;IAAEhB,KAAK;IAAEC,MAAM;IAAE+C;EAAE,CAAC,GAAGb,OAAO;EAC3C,MAAMxC,WAAW,GAAGqB,MAAM,CAACiC,iBAAiB,CAAC;IAC3C,GAAGF,KAAK;IACRC,EAAE,qBAAAE,MAAA,CAAqBF,EAAE,CAAE;IAC3BhD,KAAK;IACLC,MAAM;IACNG,gBAAgB,EAAE,CAChB+B,OAAO;EAEX,CACA,CAAC;EACD,OAAOxC,WAAW;AACpB;AAEA,SAASW,aAAaA,CACpB6C,UAAU,EACV9C,IAAI,EACJ+C,MAAM,EACNpD,KAAa,EACbC,MAAc,EAC2B;EACzC,IAAIkD,UAAU,EAAE;IACd,OAAOA,UAAU;EACnB;EAEA9C,IAAI,GAAGA,IAAI,IAAI/B,EAAE,CAAC4C,aAAa;EAC/B,MAAMmC,SAAS,GAAG1E,uBAAuB,CAAC0B,IAAI,EAAE;IAACiD,OAAO,EAAE;EAAK,CAAC,CAAC;EACjE,MAAMnC,UAAU,GAAGvC,oBAAoB,CAACwE,MAAM,CAAC;EAE/C,OAAO,IAAIC,SAAS,CAACrD,KAAK,GAAGC,MAAM,GAAGkB,UAAU,CAAC;AACnD"}
|
|
1
|
+
{"version":3,"file":"copy-and-blit.js","names":["assert","Texture","Framebuffer","GL","BufferWithAccessor","Buffer","withParameters","getGLTypeFromTypedArray","getTypedArrayFromGLType","glFormatToComponents","glTypeToBytes","readPixelsToArray","source","options","sourceX","sourceY","sourceFormat","RGBA","sourceAttachment","COLOR_ATTACHMENT0","target","sourceWidth","sourceHeight","sourceType","framebuffer","deleteFramebuffer","getFramebuffer","gl","handle","width","height","FRONT","attachment","colorAttachments","type","getPixelArray","prevHandle","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","readPixelsToBuffer","targetByteOffset","webglFramebuffer","gl2","device","assertWebGL2","UNSIGNED_BYTE","components","byteCount","byteLength","accessor","size","bind","glTarget","PIXEL_PACK_BUFFER","unbind","copyToTexture","targetMipmaplevel","targetInternalFormat","targetX","targetY","targetZ","isSubCopy","texture","textureTarget","Number","isFinite","copyTexImage2D","TEXTURE_2D","TEXTURE_CUBE_MAP","copyTexSubImage2D","TEXTURE_2D_ARRAY","TEXTURE_3D","copyTexSubImage3D","toFramebuffer","props","id","createFramebuffer","pixelArray","format","ArrayType","clamped"],"sources":["../../src/classic/copy-and-blit.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {assert, Texture, Framebuffer, FramebufferProps} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\n\nimport {BufferWithAccessor as Buffer} from './buffer-with-accessor';\nimport {WEBGLTexture} from '../adapter/resources/webgl-texture';\nimport {WEBGLFramebuffer} from '../adapter/resources/webgl-framebuffer';\nimport {withParameters} from '../context/state-tracker/with-parameters';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\nimport {glFormatToComponents, glTypeToBytes} from './format-utils';\n\n/**\n * Copies data from a type or a Texture object into ArrayBuffer object.\n * App can provide targetPixelArray or have it auto allocated by this method\n * newly allocated by this method unless provided by app.\n * @deprecated Use CommandEncoder.copyTextureToBuffer and Buffer.read\n * @note Slow requires roundtrip to GPU\n *\n * @param source\n * @param options\n * @returns pixel array,\n */\nexport function readPixelsToArray(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Uint8Array | Uint16Array | Float32Array {\n const {sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA} = options || {};\n let {\n sourceAttachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n target = null,\n // following parameters are auto deduced if not provided\n sourceWidth,\n sourceHeight,\n sourceType\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const {gl, handle} = framebuffer as WEBGLFramebuffer;\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // TODO - Set and unset gl.readBuffer\n if (sourceAttachment === GL.COLOR_ATTACHMENT0 && handle === null) {\n sourceAttachment = GL.FRONT;\n }\n\n const attachment = sourceAttachment - GL.COLOR_ATTACHMENT0;\n // assert(attachments[sourceAttachment]);\n\n // Deduce the type from color attachment if not provided.\n sourceType = sourceType || (framebuffer.colorAttachments[attachment] as WEBGLTexture).type;\n\n // Deduce type and allocated pixelArray if needed\n target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);\n\n // Pixel array available, if necessary, deduce type from it.\n sourceType = sourceType || getGLTypeFromTypedArray(target);\n\n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return target;\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.\n * @deprecated Use CommandEncoder\n * @param source\n * @param options\n */\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer {\n const {sourceX = 0, sourceY = 0, sourceFormat = GL.RGBA, targetByteOffset = 0} = options || {};\n // following parameters are auto deduced if not provided\n let {target, sourceWidth, sourceHeight, sourceType} = options || {};\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n sourceWidth = sourceWidth || framebuffer.width;\n sourceHeight = sourceHeight || framebuffer.height;\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const gl2 = webglFramebuffer.device.assertWebGL2();\n\n // deduce type if not available.\n sourceType = sourceType || (target ? target.type : GL.UNSIGNED_BYTE);\n\n if (!target) {\n // Create new buffer with enough size\n const components = glFormatToComponents(sourceFormat);\n const byteCount = glTypeToBytes(sourceType);\n const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;\n target = new Buffer(gl2, {byteLength, accessor: {type: sourceType, size: components}});\n }\n\n target.bind({glTarget: GL.PIXEL_PACK_BUFFER});\n withParameters(gl2, {framebuffer}, () => {\n gl2.readPixels(\n sourceX,\n sourceY,\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n targetByteOffset\n );\n });\n target.unbind({glTarget: GL.PIXEL_PACK_BUFFER});\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n\n return target;\n}\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n * @deprecated Use CommandEncoder\n */\n// eslint-disable-next-line complexity, max-statements\nexport function copyToTexture(\n source: Framebuffer | Texture,\n target: Texture | GL,\n options?: {\n sourceX?: number;\n sourceY?: number;\n\n targetX?: number;\n targetY?: number;\n targetZ?: number;\n targetMipmaplevel?: number;\n targetInternalFormat?: number;\n\n width?: number; // defaults to target width\n height?: number; // defaults to target height\n }\n): Texture {\n const {\n sourceX = 0,\n sourceY = 0,\n // attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer\n targetMipmaplevel = 0,\n targetInternalFormat = GL.RGBA\n } = options || {};\n let {\n targetX,\n targetY,\n targetZ,\n width, // defaults to target width\n height // defaults to target height\n } = options || {};\n\n const {framebuffer, deleteFramebuffer} = getFramebuffer(source);\n assert(framebuffer);\n const webglFramebuffer = framebuffer as WEBGLFramebuffer;\n const {device, handle} = webglFramebuffer;\n const isSubCopy =\n typeof targetX !== 'undefined' ||\n typeof targetY !== 'undefined' ||\n typeof targetZ !== 'undefined';\n targetX = targetX || 0;\n targetY = targetY || 0;\n targetZ = targetZ || 0;\n const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n assert(target);\n let texture = null;\n let textureTarget: GL;\n if (target instanceof Texture) {\n texture = target;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.target;\n } else {\n textureTarget = target;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n targetMipmaplevel,\n targetInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n switch (textureTarget) {\n case GL.TEXTURE_2D:\n case GL.TEXTURE_CUBE_MAP:\n device.gl.copyTexSubImage2D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n device.assertWebGL2();\n device.gl2.copyTexSubImage3D(\n textureTarget,\n targetMipmaplevel,\n targetX,\n targetY,\n targetZ,\n sourceX,\n sourceY,\n width,\n height\n );\n break;\n default:\n }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (deleteFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: Framebuffer;\n deleteFramebuffer: boolean;\n} {\n if (!(source instanceof Framebuffer)) {\n return {framebuffer: toFramebuffer(source), deleteFramebuffer: true};\n }\n return {framebuffer: source, deleteFramebuffer: false};\n}\n\n/**\n * Wraps a given texture into a framebuffer object, that can be further used\n * to read data from the texture object.\n */\nexport function toFramebuffer(texture: Texture, props?: FramebufferProps): Framebuffer {\n const {device, width, height, id} = texture;\n const framebuffer = device.createFramebuffer({\n ...props,\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [\n texture\n ]\n }\n );\n return framebuffer;\n}\n\nfunction getPixelArray(\n pixelArray,\n type,\n format,\n width: number,\n height: number\n): Uint8Array | Uint16Array | Float32Array {\n if (pixelArray) {\n return pixelArray;\n }\n // Allocate pixel array if not already available, using supplied type\n type = type || GL.UNSIGNED_BYTE;\n const ArrayType = getTypedArrayFromGLType(type, {clamped: false});\n const components = glFormatToComponents(format);\n // TODO - check for composite type (components = 1).\n return new ArrayType(width * height * components) as Uint8Array | Uint16Array | Float32Array;\n}\n"],"mappings":"AACA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,WAAW,QAAyB,eAAe;AAC5E,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,kBAAkB,IAAIC,MAAM;AAAA,SAG5BC,cAAc;AAAA,SACdC,uBAAuB,EAAEC,uBAAuB;AAAA,SAChDC,oBAAoB,EAAEC,aAAa;AAa3C,OAAO,SAASC,iBAAiBA,CAC/BC,MAA6B,EAC7BC,OAUC,EACwC;EACzC,MAAM;IAACC,OAAO,GAAG,CAAC;IAAEC,OAAO,GAAG,CAAC;IAAEC,YAAY,GAAGb,EAAE,CAACc;EAAI,CAAC,GAAGJ,OAAO,IAAI,CAAC,CAAC;EACxE,IAAI;IACFK,gBAAgB,GAAGf,EAAE,CAACgB,iBAAiB;IACvCC,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AAC,CAAC;EACjE,MAAMlC,UAAU,GAAGvC,oBAAoB,CAACuE,MAAM,CAAC;EAE/C,OAAO,IAAIC,SAAS,CAACpD,KAAK,GAAGC,MAAM,GAAGkB,UAAU,CAAC;AACnD"}
|
|
@@ -34,7 +34,7 @@ export function createBrowserContext(canvas, props) {
|
|
|
34
34
|
}
|
|
35
35
|
canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
|
|
36
36
|
if (!gl) {
|
|
37
|
-
throw new Error(
|
|
37
|
+
throw new Error(`Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${errorMessage || 'Unknown error'}`);
|
|
38
38
|
}
|
|
39
39
|
if (props.onContextLost) {
|
|
40
40
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-browser-context.js","names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","
|
|
1
|
+
{"version":3,"file":"create-browser-context.js","names":["DEFAULT_CONTEXT_PROPS","webgl2","webgl1","powerPreference","onContextLost","console","error","onContextRestored","info","createBrowserContext","canvas","props","errorMessage","onCreateError","statusMessage","addEventListener","gl","type","getContext","removeEventListener","Error","event"],"sources":["../../../src/context/context/create-browser-context.ts"],"sourcesContent":["// luma.gl, MIT license\n\n/**\n * ContextProps\n * @param webgl2 Set to false to not create a WebGL2 context (force webgl1)\n * @param webgl1 set to false to not create a WebGL1 context (fail if webgl2 not available)\n * @param onContextLost\n * @param onContextRestored\n *\n * BROWSER CONTEXT PARAMETERS\n * @param debug Instrument context (at the expense of performance).\n * @param alpha Default render target has an alpha buffer.\n * @param depth Default render target has a depth buffer of at least 16 bits.\n * @param stencil Default render target has a stencil buffer of at least 8 bits.\n * @param antialias Boolean that indicates whether or not to perform anti-aliasing.\n * @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n * @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n * @param failIfMajorPerformanceCaveat Do not create if the system performance is low.\n */\ntype ContextProps = {\n type?: 'webgl' | 'webgl1' | 'webgl2' | string;\n webgl1?: boolean;\n webgl2?: boolean;\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n alpha?: boolean; // indicates if the canvas contains an alpha buffer.\n desynchronized?: boolean; // hints the user agent to reduce the latency by desynchronizing the canvas paint cycle from the event loop\n antialias?: boolean; // indicates whether or not to perform anti-aliasing.\n depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.\n failIfMajorPerformanceCaveat?: boolean; // indicates if a context will be created if the system performance is low or if no hardware GPU is available.\n powerPreference?: 'default' | 'high-performance' | 'low-power';\n premultipliedAlpha?: boolean; // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean; // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.\n};\n\nconst DEFAULT_CONTEXT_PROPS: ContextProps = {\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons\n // eslint-disable-next-line no-console\n onContextLost: () => console.error('WebGL context lost'),\n // eslint-disable-next-line no-console\n onContextRestored: () => console.info('WebGL context restored')\n};\n\n/**\n * Create a WebGL context for a canvas\n * Note calling this multiple time on the same canvas does return the same context\n * @param canvas A canvas element or offscreen canvas\n */\nexport function createBrowserContext(\n canvas: HTMLCanvasElement | OffscreenCanvas,\n props: ContextProps\n): WebGLRenderingContext {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n // Create the desired context\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = null;\n\n if (props.type === 'webgl2') {\n props = {...props, webgl1: false};\n }\n if (props.type === 'webgl1') {\n props = {...props, webgl2: false};\n }\n\n // Prefer webgl2 over webgl1 if both are acceptable\n if (!gl && props.webgl2) {\n gl = canvas.getContext('webgl2', props) as WebGL2RenderingContext;\n }\n if (!gl && props.webgl1) {\n gl = canvas.getContext('webgl', props) as WebGLRenderingContext;\n }\n\n // TODO are we removing this listener before giving it a chance to fire?\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n if (!gl) {\n throw new Error(\n `Failed to create ${props.webgl2 && !props.webgl1 ? 'WebGL2' : 'WebGL'} context: ${\n errorMessage || 'Unknown error'\n }`\n );\n }\n\n if (props.onContextLost) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextLost} = props;\n canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);\n }\n if (props.onContextRestored) {\n // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.\n const {onContextRestored} = props;\n canvas.addEventListener(\n 'webglcontextrestored',\n (event: Event) => onContextRestored(event),\n false\n );\n }\n\n return gl;\n}\n\n/* TODO - can we call this asynchronously to catch the error events?\nexport async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGLRenderingContext> {\n props = {...DEFAULT_CONTEXT_PROPS, ...props};\n\n // Try to extract any extra information about why context creation failed\n let errorMessage = null;\n const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);\n canvas.addEventListener('webglcontextcreationerror', onCreateError, false);\n\n const gl = createBrowserContext(canvas, props);\n\n // Give the listener a chance to fire\n await new Promise(resolve => setTimeout(resolve, 0));\n\n canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);\n\n return gl;\n}\n*/\n"],"mappings":"AAmCA,MAAMA,qBAAmC,GAAG;EAC1CC,MAAM,EAAE,IAAI;EACZC,MAAM,EAAE,IAAI;EACZC,eAAe,EAAE,kBAAkB;EAEnC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,OAAQ,aACrEU,YAAY,IAAI,eACjB,EACH,CAAC;EACH;EAEA,IAAID,KAAK,CAACP,aAAa,EAAE;IAEvB,MAAM;MAACA;IAAa,CAAC,GAAGO,KAAK;IAC7BD,MAAM,CAACK,gBAAgB,CAAC,kBAAkB,EAAGM,KAAY,IAAKjB,aAAa,CAACiB,KAAK,CAAC,EAAE,KAAK,CAAC;EAC5F;EACA,IAAIV,KAAK,CAACJ,iBAAiB,EAAE;IAE3B,MAAM;MAACA;IAAiB,CAAC,GAAGI,KAAK;IACjCD,MAAM,CAACK,gBAAgB,CACrB,sBAAsB,EACrBM,KAAY,IAAKd,iBAAiB,CAACc,KAAK,CAAC,EAC1C,KACF,CAAC;EACH;EAEA,OAAOL,EAAE;AACX"}
|
|
@@ -55,15 +55,15 @@ function getDebugContext(gl, props) {
|
|
|
55
55
|
function getFunctionString(functionName, functionArgs) {
|
|
56
56
|
functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);
|
|
57
57
|
let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);
|
|
58
|
-
args =
|
|
59
|
-
return
|
|
58
|
+
args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;
|
|
59
|
+
return `gl.${functionName}(${args})`;
|
|
60
60
|
}
|
|
61
61
|
function onGLError(props, err, functionName, args) {
|
|
62
62
|
args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);
|
|
63
63
|
const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);
|
|
64
64
|
const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);
|
|
65
65
|
const glName = props.webgl2 ? 'gl2' : 'gl1';
|
|
66
|
-
const message =
|
|
66
|
+
const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;
|
|
67
67
|
log.error(message)();
|
|
68
68
|
debugger;
|
|
69
69
|
if (props.throwOnError) {
|
|
@@ -87,9 +87,9 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
87
87
|
if (arg === undefined) {
|
|
88
88
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
89
89
|
if (props.throwOnError) {
|
|
90
|
-
throw new Error(
|
|
90
|
+
throw new Error(`Undefined argument: ${functionString}`);
|
|
91
91
|
} else {
|
|
92
|
-
log.error(
|
|
92
|
+
log.error(`Undefined argument: ${functionString}`)();
|
|
93
93
|
debugger;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-developer-tools.js","names":["log","loadScript","GL","isBrowser","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","arguments","length","undefined","debug","getDebugContext","getRealContext","data","realContext","warn","debugContext","init","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","args","glFunctionArgsToString","concat","slice","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {isBrowser} from '@probe.gl/env'\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\n// const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n// debug: true,\n// throwOnError: false,\n// break: [],\n// webgl2: false,\n// }\n\ntype ContextData = {\n realContext?: WebGLRenderingContext;\n debugContext?: WebGLRenderingContext;\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any): ContextData {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (isBrowser() && !globalThis.WebGLDebugUtils) {\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n // If array of breakpoint strings supplied, check if any of them is contained in current GL function\n if (props.break && props.break.length > 0) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint = props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"mappings":"AACA,SAAQA,GAAG,EAAEC,UAAU,QAAO,eAAe;AAC7C,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,SAAS,QAAO,eAAe;AAEvC,MAAMC,mBAAmB,GAAG,8CAA8C;AAsB1E,SAASC,cAAcA,CAACC,EAAO,EAAe;EAC5CA,EAAE,CAACC,IAAI,GAAGD,EAAE,CAACC,IAAI,IAAI,CAAC,CAAC;EACvB,OAAOD,EAAE,CAACC,IAAI;AAChB;AAaA,OAAO,eAAeC,uBAAuBA,CAAA,EAAkB;EAC7D,IAAIL,SAAS,CAAC,CAAC,IAAI,CAACM,UAAU,CAACC,eAAe,EAAE;IAC9CD,UAAU,CAACE,MAAM,GAAGF,UAAU,CAACE,MAAM,IAAIF,UAAU;IAEnDA,UAAU,CAACE,MAAM,CAACC,MAAM,GAAG,CAAC,CAAC;IAC7B,MAAMX,UAAU,CAACG,mBAAmB,CAAC;EACvC;AACF;AAIA,OAAO,SAASS,gBAAgBA,CAACP,EAAyB,EAA+D;EAAA,IAA7DQ,KAAwB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEvF,IAAI,CAACT,EAAE,EAAE;IACP,OAAO,IAAI;EACb;EAEA,OAAOQ,KAAK,CAACI,KAAK,GAAGC,eAAe,CAACb,EAAE,EAAEQ,KAAK,CAAC,GAAGM,cAAc,CAACd,EAAE,CAAC;AACtE;AAGA,SAASc,cAAcA,CAACd,EAAyB,EAAyB;EACxE,MAAMe,IAAI,GAAGhB,cAAc,CAACC,EAAE,CAAC;EAE/B,OAAOe,IAAI,CAACC,WAAW,GAAGD,IAAI,CAACC,WAAW,GAAGhB,EAAE;AACjD;AAGA,SAASa,eAAeA,CAACb,EAAyB,E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AACF;AAGA,SAASvB,gBAAgBA,CAACf,KAAwB,EAAEuB,YAAoB,EAAEC,YAAmB,EAAQ;EACnG,IAAIkB,cAAsB,GAAG,EAAE;EAC/B,IAAIxD,GAAG,CAACyD,KAAK,IAAI,CAAC,EAAE;IAClBD,cAAc,GAAGpB,iBAAiB,CAACC,YAAY,EAAEC,YAAY,CAAC;IAC9DtC,GAAG,CAACA,GAAG,CAAC,CAAC,EAAEwD,cAAc,CAAC,CAAC,CAAC;EAC9B;EAGA,IAAI1C,KAAK,CAAC4C,KAAK,IAAI5C,KAAK,CAAC4C,KAAK,CAAC1C,MAAM,GAAG,CAAC,EAAE;IACzCwC,cAAc,GAAGA,cAAc,IAAIpB,iBAAiB,CAACC,YAAY,EAAEC,YAAY,CAAC;IAChF,MAAMqB,YAAY,GAAG7C,KAAK,CAAC4C,KAAK,CAACE,KAAK,CAAEC,OAAe,IAAKL,cAAc,CAACM,OAAO,CAACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACnG,IAAIF,YAAY,EAAE;MAChB;IACF;EACF;EAEA,KAAK,MAAMjB,GAAG,IAAIJ,YAAY,EAAE;IAC9B,IAAII,GAAG,KAAKzB,SAAS,EAAE;MACrBuC,cAAc,GAAGA,cAAc,IAAIpB,iBAAiB,CAACC,YAAY,EAAEC,YAAY,CAAC;MAChF,IAAIxB,KAAK,CAACwC,YAAY,EAAE;QACtB,MAAM,IAAIC,KAAK,wBAAAV,MAAA,CAAwBW,cAAc,CAAE,CAAC;MAC1D,CAAC,MAAM;QACLxD,GAAG,CAACqD,KAAK,wBAAAR,MAAA,CAAwBW,cAAc,CAAE,CAAC,CAAC,CAAC;QACpD;MACF;IACF;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"webgl-developer-tools.js","names":["log","loadScript","GL","isBrowser","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","arguments","length","undefined","debug","getDebugContext","getRealContext","data","realContext","warn","debugContext","init","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","args","glFunctionArgsToString","slice","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {isBrowser} from '@probe.gl/env'\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\n// const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n// debug: true,\n// throwOnError: false,\n// break: [],\n// webgl2: false,\n// }\n\ntype ContextData = {\n realContext?: WebGLRenderingContext;\n debugContext?: WebGLRenderingContext;\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any): ContextData {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (isBrowser() && !globalThis.WebGLDebugUtils) {\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n // If array of breakpoint strings supplied, check if any of them is contained in current GL function\n if (props.break && props.break.length > 0) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint = props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"mappings":"AACA,SAAQA,GAAG,EAAEC,UAAU,QAAO,eAAe;AAC7C,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,SAAS,QAAO,eAAe;AAEvC,MAAMC,mBAAmB,GAAG,8CAA8C;AAsB1E,SAASC,cAAcA,CAACC,EAAO,EAAe;EAC5CA,EAAE,CAACC,IAAI,GAAGD,EAAE,CAACC,IAAI,IAAI,CAAC,CAAC;EACvB,OAAOD,EAAE,CAACC,IAAI;AAChB;AAaA,OAAO,eAAeC,uBAAuBA,CAAA,EAAkB;EAC7D,IAAIL,SAAS,C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M,OAAO,CAACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACnG,IAAIF,YAAY,EAAE;MAChB;IACF;EACF;EAEA,KAAK,MAAMhB,GAAG,IAAIJ,YAAY,EAAE;IAC9B,IAAII,GAAG,KAAKzB,SAAS,EAAE;MACrBsC,cAAc,GAAGA,cAAc,IAAInB,iBAAiB,CAACC,YAAY,EAAEC,YAAY,CAAC;MAChF,IAAIxB,KAAK,CAACuC,YAAY,EAAE;QACtB,MAAM,IAAIC,KAAK,CAAE,uBAAsBC,cAAe,EAAC,CAAC;MAC1D,CAAC,MAAM;QACLvD,GAAG,CAACoD,KAAK,CAAE,uBAAsBG,cAAe,EAAC,CAAC,CAAC,CAAC;QACpD;MACF;IACF;EACF;AACF"}
|
|
@@ -52,7 +52,7 @@ function polyfillExtension(gl, _ref) {
|
|
|
52
52
|
} = meta;
|
|
53
53
|
const ext = gl.getExtension(extension);
|
|
54
54
|
for (const key of Object.keys(defaults)) {
|
|
55
|
-
const extKey =
|
|
55
|
+
const extKey = `${key}${suffix}`;
|
|
56
56
|
let polyfill = null;
|
|
57
57
|
if (key === 'meta') {} else if (typeof gl[key] === 'function') {} else if (ext && typeof ext[extKey] === 'function') {
|
|
58
58
|
polyfill = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill-context.js","names":["assert","polyfillVertexArrayObject","WEBGL2_CONTEXT_POLYFILLS","WEBGL2_CONTEXT_OVERRIDES","getContextData","polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","_ref","defaults","meta","suffix","ext","key","keys","extKey","
|
|
1
|
+
{"version":3,"file":"polyfill-context.js","names":["assert","polyfillVertexArrayObject","WEBGL2_CONTEXT_POLYFILLS","WEBGL2_CONTEXT_OVERRIDES","getContextData","polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","_ref","defaults","meta","suffix","ext","key","keys","extKey","polyfill","arguments","bind","_ref2","forEach","originalFunc"],"sources":["../../../src/context/polyfill/polyfill-context.ts"],"sourcesContent":["// WebGL1/WebGL2 extension polyfill support\n//\n// Provides a function that creates polyfills for WebGL2 functions based\n// on available extensions and installs them on a supplied target (could be\n// the WebGLContext or its prototype, or a separate object).\n//\n// This is intended to be a stand-alone file with minimal dependencies,\n// easy to reuse or repurpose in other projects.\n\nimport {assert} from '@luma.gl/core';\nimport {polyfillVertexArrayObject} from './polyfill-vertex-array-object';\n\nimport {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';\nimport {getContextData} from './context-data';\n\n/**\n * Registers extensions, polyfills or mock functions for extensions in the polyfills list\n */\nexport function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {\n const contextState = getContextData(gl);\n\n if (!contextState._polyfilled) {\n polyfillVertexArrayObject(gl);\n initializeExtensions(gl);\n installPolyfills(gl, WEBGL2_CONTEXT_POLYFILLS);\n installOverrides(gl, {target: contextState, target2: gl});\n contextState._polyfilled = true;\n }\n\n // Note - only supports a subset of WebGL2\n return gl as WebGL2RenderingContext;\n}\n\nfunction initializeExtensions(gl: WebGLRenderingContext): void {\n const contextState = getContextData(gl);\n // `getSupportedExtensions` can return null when context is lost.\n const EXTENSIONS = gl.getSupportedExtensions() || [];\n for (const extensionName of EXTENSIONS) {\n const extension = gl.getExtension(extensionName);\n contextState._extensions[extensionName] = extension;\n }\n}\n\nfunction installPolyfills(gl: WebGLRenderingContext, polyfills): void {\n const contextState = getContextData(gl);\n for (const extension of Object.getOwnPropertyNames(polyfills)) {\n if (extension !== 'overrides') {\n polyfillExtension(gl, {extension, target: contextState, target2: gl});\n }\n }\n}\n\n/** Polyfills a single WebGL extension into the `target` object */\nfunction polyfillExtension(gl: WebGLRenderingContext, {extension, target, target2}): void {\n const defaults = WEBGL2_CONTEXT_POLYFILLS[extension];\n assert(defaults);\n\n const {meta = {}} = defaults;\n const {suffix = ''} = meta;\n\n const ext = gl.getExtension(extension);\n\n for (const key of Object.keys(defaults)) {\n const extKey = `${key}${suffix}`;\n\n let polyfill: Function | null = null;\n if (key === 'meta') {\n // ignore\n } else if (typeof gl[key] === 'function') {\n // WebGL2 implementation is already\n } else if (ext && typeof ext[extKey] === 'function') {\n // pick extension implementation,if available\n polyfill = (...args) => ext[extKey](...args);\n } else if (typeof defaults[key] === 'function') {\n // pick the mock implementation, if no implementation was detected\n polyfill = defaults[key].bind(target);\n }\n\n if (polyfill) {\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n }\n}\n\n/** Install simple overrides (mostly get* functions) */\nfunction installOverrides(gl: WebGLRenderingContext, {target, target2}) {\n Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {\n if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {\n // install an override, if no implementation was detected\n const originalFunc = gl[key] ? gl[key].bind(gl) : () => {};\n const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl, originalFunc);\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n });\n}\n"],"mappings":"AASA,SAAQA,MAAM,QAAO,eAAe;AAAC,SAC7BC,yBAAyB;AAAA,SAEzBC,wBAAwB,EAAEC,wBAAwB;AAAA,SAClDC,cAAc;AAKtB,OAAO,SAASC,eAAeA,CAACC,EAAyB,EAA0B;EACjF,MAAMC,YAAY,GAAGH,cAAc,CAACE,EAAE,CAAC;EAEvC,IAAI,CAACC,YAAY,CAACC,WAAW,EAAE;IAC7BP,yBAAyB,CAACK,EAAE,CAAC;IAC7BG,oBAAoB,CAACH,EAAE,CAAC;IACxBI,gBAAgB,CAACJ,EAAE,EAAEJ,wBAAwB,CAAC;IAC9CS,gBAAgB,CAACL,EAAE,EAAE;MAACM,MAAM,EAAEL,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CAAC,IAAI,EAAE5B,EAAE,EAAE+B,YAAY,CAAC;MAC3EzB,MAAM,CAACiB,GAAG,CAAC,GAAGG,QAAQ;MACtBnB,OAAO,CAACgB,GAAG,CAAC,GAAGG,QAAQ;IACzB;EACF,CAAC,CAAC;AACJ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import { assert } from '@luma.gl/core';
|
|
3
2
|
import { GL_PARAMETER_DEFAULTS, GL_HOOKED_SETTERS, NON_CACHE_PARAMETERS } from "../parameters/webgl-parameter-tables.js";
|
|
4
3
|
import { setParameters, getParameters } from "../parameters/unified-parameter-api.js";
|
|
@@ -9,12 +8,12 @@ class GLState {
|
|
|
9
8
|
copyState = false,
|
|
10
9
|
log = () => {}
|
|
11
10
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
this.gl = void 0;
|
|
12
|
+
this.program = null;
|
|
13
|
+
this.stateStack = [];
|
|
14
|
+
this.enable = true;
|
|
15
|
+
this.cache = void 0;
|
|
16
|
+
this.log = void 0;
|
|
18
17
|
this.gl = gl;
|
|
19
18
|
this.cache = copyState ? getParameters(gl) : Object.assign({}, GL_PARAMETER_DEFAULTS);
|
|
20
19
|
this.log = log;
|
|
@@ -107,7 +106,7 @@ function installGetterOverride(gl, functionName) {
|
|
|
107
106
|
return glState.enable ? glState.cache[pname] : originalGetterFunc(pname);
|
|
108
107
|
};
|
|
109
108
|
Object.defineProperty(gl[functionName], 'name', {
|
|
110
|
-
value:
|
|
109
|
+
value: `${functionName}-from-cache`,
|
|
111
110
|
configurable: false
|
|
112
111
|
});
|
|
113
112
|
}
|
|
@@ -131,7 +130,7 @@ function installSetterSpy(gl, functionName, setter) {
|
|
|
131
130
|
return oldValue;
|
|
132
131
|
};
|
|
133
132
|
Object.defineProperty(gl[functionName], 'name', {
|
|
134
|
-
value:
|
|
133
|
+
value: `${functionName}-to-cache`,
|
|
135
134
|
configurable: false
|
|
136
135
|
});
|
|
137
136
|
}
|