@luma.gl/webgl 9.0.0-alpha.13 → 9.0.0-alpha.14
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/resources/webgl-buffer.js +1 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/classic/buffer.d.ts +0 -1
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js +0 -9
- package/dist/classic/buffer.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +2 -2
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-buffer.js +1 -1
- package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/es5/classic/buffer.js +0 -10
- package/dist/es5/classic/buffer.js.map +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +2 -2
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-buffer.js +1 -1
- package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/esm/classic/buffer.js +0 -9
- package/dist/esm/classic/buffer.js.map +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +2 -2
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
- package/package.json +4 -4
- package/src/adapter/resources/webgl-buffer.ts +2 -2
- package/src/classic/buffer.ts +0 -10
- package/src/context/debug/webgl-developer-tools.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","removeStats","trackDeallocatedMemory","deleteBuffer","destroyed","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","offset","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"mappings":";AACA,SAAQA,MAAR,EAAgBC,MAAhB,QAA6B,cAA7B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAGA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,eAAe,MAAMC,WAAN,SAA0BJ,MAA1B,CAAiC;AAe9CK,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAkB,GAAG,EAA3C,EAA+C;AACxD,UAAMD,MAAN,EAAcC,KAAd;;AADwD;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,uCAN1B,IAM0B;;AAAA;;AAGxD,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,EAAL,GAAU,KAAKF,MAAL,CAAYE,EAAtB;AACA,SAAKC,GAAL,GAAW,KAAKH,MAAL,CAAYG,GAAvB;AAEA,UAAMC,MAAM,GAAG,OAAOH,KAAP,KAAiB,QAAjB,GAA6BA,KAAD,CAAuBG,MAAnD,GAA4DC,SAA3E;AACA,SAAKD,MAAL,GAAcA,MAAM,IAAI,KAAKF,EAAL,CAAQI,YAAR,EAAxB;AAEA,SAAKF,MAAL,CAAYG,kBAAZ,GAAiC,EAAC,GAAG,KAAKN,KAAT;AAAgBO,MAAAA,IAAI,EAAE,OAAO,KAAKP,KAAL,CAAWO;AAAxC,KAAjC;AAMA,SAAKC,MAAL,GAAc,KAAKR,KAAL,CAAWQ,MAAX,IAAqBC,cAAc,CAAC,KAAKT,KAAL,CAAWU,KAAZ,CAAjD;AAEA,SAAKC,UAAL,GAAkB,KAAKX,KAAL,CAAWW,UAAX,IAAyBC,aAA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AIvC,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAACwD,cAAV;AACD;;AAUD,SAAOxD,EAAE,CAACsD,YAAV;AACD;;AAED,SAASrC,aAAT,CAAuBF,KAAvB,EAA0C;AACxC,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAAC0D,YAAV;AACD;;AACD,SAAO1D,EAAE,CAAC0D,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, 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 return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\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 return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","offset","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","ST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ACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAAC0D,YAAV;AACD;;AACD,SAAO1D,EAAE,CAAC0D,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, 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 return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\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 return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
|
package/dist/classic/buffer.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
25
25
|
constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);
|
|
26
26
|
constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);
|
|
27
27
|
constructor(device: Device | WebGLRenderingContext, byteLength: number);
|
|
28
|
-
destroy(): void;
|
|
29
28
|
write(data: TypedArray, byteOffset?: number): void;
|
|
30
29
|
getElementCount(accessor?: AccessorObject): number;
|
|
31
30
|
getVertexCount(accessor?: AccessorObject): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/classic/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAIlC,OAAO,WAAW,MAAM,mCAAmC,CAAC;AAoD5D,6BAA6B;A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
package/dist/classic/buffer.js
CHANGED
|
@@ -72,15 +72,6 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
72
72
|
Object.seal(this);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
destroy() {
|
|
76
|
-
if (this.handle) {
|
|
77
|
-
this.removeStats();
|
|
78
|
-
this.trackDeallocatedMemory();
|
|
79
|
-
this.gl.deleteBuffer(this.handle);
|
|
80
|
-
this.destroyed = true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
75
|
write(data, byteOffset) {
|
|
85
76
|
this.subData({
|
|
86
77
|
data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/classic/buffer.ts"],"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","byteOffset","ClassicBuffer","constructor","device","attach","setAccessor","Object","assign","accessor","seal","destroy","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","write","subData","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","webglUsage","STATIC_DRAW","debugData","_setData","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","unbind","isIndexedBuffer","getDebugData","changed","invalidateDebugData","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"mappings":";AAGA,SAAQA,MAAR,EAAgBC,UAAhB,QAAiC,cAAjC;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,mBAAR,QAAkC,iCAAlC;AAEA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAAQC,uBAAR,EAAiCC,uBAAjC,QAA+D,qBAA/D;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,WAAP,MAAwB,mCAAxB;AAEA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAOvBC,EAAAA,OAAO,EAAE,kBAPc;AAQvBC,EAAAA,SAAS,EAAE,kBARY;AASvBC,EAAAA,WAAW,EAAE;AATU,CAAzB;AAaA,MAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,YAAY,EAAE,EADe;AAE7BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,KAAK,EAAE;AADM,GAFc;AAM7BC,EAAAA,eAAe,EAAEd;AANY,CAA/B;AAUA,MAAMe,qBAAqB,GAAG;AAE5BJ,EAAAA,YAAY,EAAEX;AAFc,CAA9B;;AAKA,SAASgB,mBAAT,CAA6BC,KAA7B,EAAgG;AAE9F,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,CAAJ,EAA+B;AAC7B,WAAO;AAACG,MAAAA,IAAI,EAAEH;AAAP,KAAP;AACD,GAFD,MAKK,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iB,IAAIlC,QAAJ,CAAa,KAAKqC,QAAlB,EAA4B;AAAC5B,QAAAA,IAAI,EAAER,uBAAuB,CAACyB,IAAD;AAA9B,OAA5B,CAAjB;AACD;AACF;;AAID2F,EAAAA,YAAY,CAACC,KAAD,EAAiB;AAC3B,SAAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,KAAK9B,MAArC;AACA,UAAM+E,KAAK,GAAG,KAAK5E,EAAL,CAAQ6E,kBAAR,CAA2B,KAAKlD,MAAhC,EAAwCgD,KAAxC,CAAd;AACA,SAAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,WAAOiD,KAAP;AACD;;AAIO,MAAJ9G,IAAI,GAAG;AACT,WAAO,KAAK4B,QAAL,CAAc5B,IAArB;AACD;;AAxYoD","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\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: ClassicBufferProps | 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 as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\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 default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\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 ClassicBufferProps).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 destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: TypedArray, byteOffset?: number): 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: ClassicBufferProps = {}): 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 this.webglUsage = props.webglUsage || 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.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): 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: ClassicBufferProps) {\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 target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, 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.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, 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?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // 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 (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, 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.webglUsage);\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, webglUsage = this.webglUsage): 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 target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\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.target;\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.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, 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"],"file":"buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/classic/buffer.ts"],"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","byteOffset","ClassicBuffer","constructor","device","attach","setAccessor","Object","assign","accessor","seal","write","subData","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","webglUsage","STATIC_DRAW","debugData","_setData","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","options","srcOffset","length","target","gl","webgl2","COPY_WRITE_BUFFER","bindBuffer","handle","undefined","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","unbind","isIndexedBuffer","getDebugData","changed","invalidateDebugData","trackDeallocatedMemory","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"mappings":";AAGA,SAAQA,MAAR,EAAgBC,UAAhB,QAAiC,cAAjC;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,mBAAR,QAAkC,iCAAlC;AAEA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAAQC,uBAAR,EAAiCC,uBAAjC,QAA+D,qBAA/D;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,WAAP,MAAwB,mCAAxB;AAEA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAOvBC,EAAAA,OAAO,EAAE,kBAPc;AAQvBC,EAAAA,SAAS,EAAE,kBARY;AASvBC,EAAAA,WAAW,EAAE;AATU,CAAzB;AAaA,MAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,YAAY,EAAE,EADe;AAE7BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,KAAK,EAAE;AADM,GAFc;AAM7BC,EAAAA,eAAe,EAAEd;AANY,CAA/B;AAUA,MAAMe,qBAAqB,GAAG;AAE5BJ,EAAAA,YAAY,EAAEX;AAFc,CAA9B;;AAKA,SAASgB,mBAAT,CAA6BC,KAA7B,EAAgG;AAE9F,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,CAAJ,EAA+B;AAC7B,WAAO;AAACG,MAAAA,IAAI,EAAEH;AAAP,KAAP;AACD,GAFD,MAKK,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MAArC;AACA,UAAM+C,KAAK,GAAG,KAAKnD,EAAL,CAAQoD,kBAAR,CAA2B,KAAKrD,MAAhC,EAAwCmD,KAAxC,CAAd;AACA,SAAKlD,EAAL,CAAQG,UAAR,CAAmB,KAAKJ,MAAxB,EAAgC,IAAhC;AACA,WAAOoD,KAAP;AACD;;AAIO,MAAJ1G,IAAI,GAAG;AACT,WAAO,KAAK4B,QAAL,CAAc5B,IAArB;AACD;;AA9XoD","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\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: ClassicBufferProps | 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 as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\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 default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\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 ClassicBufferProps).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): 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: ClassicBufferProps = {}): 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 this.webglUsage = props.webglUsage || 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.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): 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: ClassicBufferProps) {\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 target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, 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.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, 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?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // 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 (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, 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.webglUsage);\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, webglUsage = this.webglUsage): 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 target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\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.target;\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.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, 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"],"file":"buffer.js"}
|
|
@@ -90,9 +90,9 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
90
90
|
log.log(1, functionString)();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if (props.break) {
|
|
93
|
+
if (props.break && props.break.length > 0) {
|
|
94
94
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
95
|
-
const isBreakpoint = props.break
|
|
95
|
+
const isBreakpoint = props.break.every(breakOn => functionString.indexOf(breakOn) !== -1);
|
|
96
96
|
|
|
97
97
|
if (isBreakpoint) {
|
|
98
98
|
debugger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","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","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,cAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;AAYD,OAAO,eAAeC,uBAAf,GAAwD;AAC7D,MAAI,CAACC,UAAU,CAACC,eAAhB,EAAiC;AAE/BD,IAAAA,UAAU,CAACE,MAAX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,EAAkB;AAChB;AACD;AACF;;AAED,OAAK,MAAMlB,GAAX,IAAkBJ,YAAlB,EAAgC;AAC9B,QAAII,GAAG,KAAKC,SAAZ,EAAuB;AACrBc,MAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,UAAIrB,KAAK,CAACsC,YAAV,EAAwB;AACtB,cAAM,IAAIC,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,OAFD,MAEO;AACLrD,QAAAA,GAAG,CAACkD,KAAJ,+BAAiCG,cAAjC;AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\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\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\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 (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\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 (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && 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"],"file":"webgl-developer-tools.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","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","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,cAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;AAYD,OAAO,eAAeC,uBAAf,GAAwD;AAC7D,MAAI,CAACC,UAAU,CAACC,eAAhB,EAAiC;AAE/BD,IAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,IAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AACA,UAAMV,UAAU,CAACE,mBAAD,CAAhB;AACD;AACF;AAID,OAAO,SAASS,gBAAT,CAA0BP,EAA1B,EAAqDQ,KAAwB,GAAG,EAAhF,EAAkH;AAEvH,MAAI,CAACR,EAAL,EAAS;AACP,WAAO,IAAP;AACD;;AAED,SAAOQ,KAAK,CAACC,KAAN,GAAcC,eAAe,CAACV,EAAD,EAAKQ,KAAL,CAA7B,GAA2CG,cAAc,CAACX,EAAD,CAAhE;AACD;;AAGD,SAASW,cAAT,CAAwBX,EAAxB,EAA0E;AACxE,QAAMY,IAAI,GAAGb,cAAc,CAACC,EAAD,CAA3B;AAEA,SAAOY,IAAI,CAACC,WAAL,GAAmBD,IAAI,CAACC,WAAxB,GAAsCb,EAA7C;AACD;;AAGD,SAASU,eAAT,CAAyBV,EAAzB,EAAoDQ,KAApD,EAAqG;AACnG,MAAI,CAACL,UAAU,CAACC,eAAhB,EAAiC;AAC/BT,IAAAA,GAAG,CAACmB,IAAJ,CAAS,wBAAT;AACA,WAAOd,EAAP;AACD;;AAED,QAAMY,IAAI,GAAGb,cAAc,CAACC,EAAD,CAA3B;;A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rB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAAlC;AACAlC,IAAAA,GAAG,CAACA,GAAJ,CAAQ,CAAR,EAAWqD,cAAX;AACD;;AAGD,MAAIxC,KAAK,CAAC0C,KAAN,IAAe1C,KAAK,CAAC0C,KAAN,CAAYZ,MAAZ,GAAqB,CAAxC,EAA2C;AACzCU,IAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;AACA,UAAMsB,YAAY,GAAG3C,KAAK,CAAC0C,KAAN,CAAYE,KAAZ,CAAmBC,OAAD,IAAqBL,cAAc,CAACM,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA5E,CAArB;;AACA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAED,OAAK,MAAMlB,GAAX,IAAkBJ,YAAlB,EAAgC;AAC9B,QAAII,GAAG,KAAKC,SAAZ,EAAuB;AACrBc,MAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,UAAIrB,KAAK,CAACsC,YAAV,EAAwB;AACtB,cAAM,IAAIC,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,OAFD,MAEO;AACLrD,QAAAA,GAAG,CAACkD,KAAJ,+BAAiCG,cAAjC;AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\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\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\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 (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\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"],"file":"webgl-developer-tools.js"}
|
|
@@ -124,7 +124,7 @@ var WEBGLBuffer = function (_Buffer) {
|
|
|
124
124
|
}, {
|
|
125
125
|
key: "destroy",
|
|
126
126
|
value: function destroy() {
|
|
127
|
-
if (this.handle) {
|
|
127
|
+
if (!this.destroyed && this.handle) {
|
|
128
128
|
this.removeStats();
|
|
129
129
|
this.trackDeallocatedMemory();
|
|
130
130
|
this.gl.deleteBuffer(this.handle);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/adapter/resources/webgl-buffer.ts"],"names":["DEBUG_DATA_LENGTH","WEBGLBuffer","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","removeStats","trackDeallocatedMemory","deleteBuffer","destroyed","srcOffset","isWebGL2","GL","COPY_WRITE_BUFFER","assertWebGL2","offset","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","Buffer","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,iBAAiB,GAAG,EAA1B;;IAGqBC,W;;;;;AAenB,uBAAYC,MAAZ,EAA0D;AAAA;;AAAA,QAAzBC,KAAyB,uEAAJ,EAAI;AAAA;AACxD,8BAAMD,MAAN,EAAcC,KAAd;AADwD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4FAN1B,IAM0B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B,EAAwC,IAAxC;AAZF,iDAiBSjC,IAjBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAsBA,gCAAuB;AACrB,WAAKM,SAAL,GAAiB,IAAjB;AACD;;;WAED,2BAAkB;AAChB,aAAO,KAAKL,MAAZ;AAED;;;WAED,0BAAiB;AACf,aAAO,KAAKA,MAAZ;AACA,aAAO,KAAKT,MAAL,CAAYkC,QAAZ,GAAuBC,mBAAGM,gBAA1B,GAA6C,KAAKhC,MAAzD;AACD;;;EAnKsCkC,W;;;;AAiLzC,SAASjC,cAAT,CAAwBC,KAAxB,EAA2C;AACzC,MAAIA,KAAK,GAAGgC,YAAOC,KAAnB,EAA0B;AACxB,WAAOT,mBAAGU,oBAAV;AACD;;AACD,MAAIlC,KAAK,GAAGgC,YAAOG,MAAnB,EAA2B;AACzB,WAAOX,mBAAGY,YAAV;AACD;;AACD,MAAIpC,KAAK,GAAGgC,YAAOK,OAAnB,EAA4B;AAC1B,WAAOb,mBAAGc,cAAV;AACD;;AAUD,SAAOd,mBAAGY,YAAV;AACD;;AAED,SAASlC,aAAT,CAAuBF,KAAvB,EAA0C;AACxC,MAAIA,KAAK,GAAGgC,YAAOC,KAAnB,EAA0B;AACxB,WAAOT,mBAAGe,WAAV;AACD;;AACD,MAAIvC,KAAK,GAAGgC,YAAOG,MAAnB,EAA2B;AACzB,WAAOX,mBAAGe,WAAV;AACD;;AACD,MAAIvC,KAAK,GAAGgC,YAAOK,OAAnB,EAA4B;AAC1B,WAAOb,mBAAGgB,YAAV;AACD;;AACD,SAAOhB,mBAAGgB,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, 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 return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\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 return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/adapter/resources/webgl-buffer.ts"],"names":["DEBUG_DATA_LENGTH","WEBGLBuffer","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","srcOffset","isWebGL2","GL","COPY_WRITE_BUFFER","assertWebGL2","offset","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","Buffer","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,iBAAiB,GAAG,EAA1B;;IAGqBC,W;;;;;AAenB,uBAAYC,MAAZ,EAA0D;AAAA;;AAAA,QAAzBC,KAAyB,uEAAJ,EAAI;AAAA;AACxD,8BAAMD,MAAN,EAAcC,KAAd;AADwD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4FAN1B,IAM0B;AAAA;AAGxD,UAAKD,MAAL,GAAcA,MAAd;AACA,UAAKE,EAAL,GAAU,MAAKF,MAAL,CAAYE,EAAtB;AACA,UAAKC,GAAL,GAAW,MAAKH,MAAL,CAAYG,GAAvB;AAEA,QAAMC,MAAM,GAAG,sBAAOH,KAAP,MAAiB,QAAjB,GAA6BA,KAAD,CAAuBG,MAAnD,GAA4DC,SAA3E;AACA,UAAKD,MAAL,GAAcA,MAAM,IAAI,MAAKF,EAAL,CAAQI,YAAR,EAAxB;AAEA,UAAKF,MAAL,CAAYG,kBAAZ,mCAAqC,MAAKN,KAA1C;AAAiDO,MAAAA,IAAI,wBAAS,MAAKP,KAAL,CAAWO,IAApB;AAArD;AAMA,UAAKC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AGgC,YAAOC,KAAnB,EAA0B;AACxB,WAAOT,mBAAGU,oBAAV;AACD;;AACD,MAAIlC,KAAK,GAAGgC,YAAOG,MAAnB,EAA2B;AACzB,WAAOX,mBAAGY,YAAV;AACD;;AACD,MAAIpC,KAAK,GAAGgC,YAAOK,OAAnB,EAA4B;AAC1B,WAAOb,mBAAGc,cAAV;AACD;;AAUD,SAAOd,mBAAGY,YAAV;AACD;;AAED,SAASlC,aAAT,CAAuBF,KAAvB,EAA0C;AACxC,MAAIA,KAAK,GAAGgC,YAAOC,KAAnB,EAA0B;AACxB,WAAOT,mBAAGe,WAAV;AACD;;AACD,MAAIvC,KAAK,GAAGgC,YAAOG,MAAnB,EAA2B;AACzB,WAAOX,mBAAGe,WAAV;AACD;;AACD,MAAIvC,KAAK,GAAGgC,YAAOK,OAAnB,EAA4B;AAC1B,WAAOb,mBAAGgB,YAAV;AACD;;AACD,SAAOhB,mBAAGgB,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, 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 return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\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 return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
|
|
@@ -118,16 +118,6 @@ var ClassicBuffer = function (_WEBGLBuffer) {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
(0, _createClass2.default)(ClassicBuffer, [{
|
|
121
|
-
key: "destroy",
|
|
122
|
-
value: function destroy() {
|
|
123
|
-
if (this.handle) {
|
|
124
|
-
this.removeStats();
|
|
125
|
-
this.trackDeallocatedMemory();
|
|
126
|
-
this.gl.deleteBuffer(this.handle);
|
|
127
|
-
this.destroyed = true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
121
|
key: "write",
|
|
132
122
|
value: function write(data, byteOffset) {
|
|
133
123
|
this.subData({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classic/buffer.ts"],"names":["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","byteOffset","ClassicBuffer","device","WebGLDevice","attach","setAccessor","Object","assign","accessor","Accessor","seal","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","subData","Math","round","getBytesPerElement","getBytesPerVertex","Number","isFinite","webglUsage","GL","STATIC_DRAW","debugData","_setData","_setByteLength","buffer","bytesUsed","initialize","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","isIndexedBuffer","getData","changed","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getElementCount","pname","value","getBufferParameter","WEBGLBuffer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,EAA1B;AAGA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAO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B6C,mBAAG4B,KAAjD,EAAwD;AAACC,QAAAA,OAAO,EAAE;AAAV,OAAxD,CAAlB;AACA,UAAMsB,mBAAmB,GAAG1B,aAAa,GAAGE,SAAS,CAACyB,iBAAtD;AACA,aAAO,KAAKC,eAAL,KAAyBF,mBAAhC;AACD;;;WAID,oBAAW/E,IAAX,EAAiB;AACf,UAAI,CAAC,KAAKW,QAAL,CAAc5B,IAAnB,EAAyB;AACvB,aAAKyB,WAAL,CAAiB,IAAII,iBAAJ,CAAa,KAAKD,QAAlB,EAA4B;AAAC5B,UAAAA,IAAI,EAAE,8CAAwBiB,IAAxB;AAAP,SAA5B,CAAjB;AACD;AACF;;;WAID,sBAAakF,KAAb,EAA6B;AAC3B,WAAKjE,EAAL,CAAQyB,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,KAAKzB,MAArC;AACA,UAAMqE,KAAK,GAAG,KAAKlE,EAAL,CAAQmE,kBAAR,CAA2B,KAAK7C,MAAhC,EAAwC2C,KAAxC,CAAd;AACA,WAAKjE,EAAL,CAAQyB,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,aAAO4C,KAAP;AACD;;;SAID,eAAW;AACT,aAAO,KAAKxE,QAAL,CAAc5B,IAArB;AACD;;;EAxYwCsG,oB","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\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: ClassicBufferProps | 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 as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\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 default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\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 ClassicBufferProps).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 destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: TypedArray, byteOffset?: number): 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: ClassicBufferProps = {}): 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 this.webglUsage = props.webglUsage || 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.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): 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: ClassicBufferProps) {\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 target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, 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.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, 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?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // 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 (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, 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.webglUsage);\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, webglUsage = this.webglUsage): 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 target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\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.target;\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.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, 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"],"file":"buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/classic/buffer.ts"],"names":["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","byteOffset","ClassicBuffer","device","WebGLDevice","attach","setAccessor","Object","assign","accessor","Accessor","seal","subData","Math","round","getBytesPerElement","getBytesPerVertex","Number","isFinite","webglUsage","GL","STATIC_DRAW","debugData","_setData","_setByteLength","buffer","bytesUsed","initialize","options","srcOffset","length","target","gl","webgl2","COPY_WRITE_BUFFER","bindBuffer","handle","undefined","bufferSubData","_inferType","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","isIndexedBuffer","getData","changed","trackDeallocatedMemory","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getElementCount","pname","value","getBufferParameter","WEBGLBuffer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,EAA1B;AAGA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAOvBC,EAAAA,OAAO,EAAE,kBAPc;AAQvBC,EAAAA,SAAS,EAAE,kBARY;AASvBC,EAAAA,WAAW,EAAE;AATU,CAAzB;AAaA,IAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,YAAY,EAAE,EADe;AAE7BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,KAAK,EAAE;AADM,GAFc;AAM7BC,EAAAA,eAAe,EAAEd;AANY,CAA/B;AAUA,IAAMe,qBAAqB,GAAG;AAE5BJ,EAAAA,YAAY,EAAEX;AAFc,CAA9B;;AAKA,SAASgB,mBAAT,CAA6BC,KAA7B,EAAgG;AAE9F,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,CAAJ,EAA+B;AAC7B,WAAO;AAACG,MAAAA,IAAI,EAAEH;AAAP,KAAP;AACD,GAFD,MAKK,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAClC,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;;EA9XwCmG,oB","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\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: ClassicBufferProps | 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 as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\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 default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\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 ClassicBufferProps).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): 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: ClassicBufferProps = {}): 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 this.webglUsage = props.webglUsage || 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.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): 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: ClassicBufferProps) {\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 target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, 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.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, 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?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // 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 (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, 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.webglUsage);\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, webglUsage = this.webglUsage): 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 target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\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.target;\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.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, 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"],"file":"buffer.js"}
|
|
@@ -153,9 +153,9 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
153
153
|
_api.log.log(1, functionString)();
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
if (props.break) {
|
|
156
|
+
if (props.break && props.break.length > 0) {
|
|
157
157
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
158
|
-
var isBreakpoint = props.break
|
|
158
|
+
var isBreakpoint = props.break.every(function (breakOn) {
|
|
159
159
|
return functionString.indexOf(breakOn) !== -1;
|
|
160
160
|
});
|
|
161
161
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","debug","getDebugContext","getRealContext","data","realContext","log","warn","debugContext","init","GL","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;SAYqBC,uB;;;;;uFAAf;AAAA;AAAA;AAAA;AAAA;AAAA,gBACAC,UAAU,CAACC,eADX;AAAA;AAAA;AAAA;;AAGHD,YAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,YAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AALG;AAAA,mBAMG,qBAAWR,mBAAX,CANH;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAYA,SAASS,gBAAT,CAA0BP,EAA1B,EAAkH;AAAA,MAA7DQ,KAA6D,uEAAlC,EAAkC;;AAEvH,MAAI,CAACR,E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A,YAAIvB,KAAK,CAACwC,YAAV,EAAwB;AACtB,gBAAM,IAAIC,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,SAFD,MAEO;AACLpC,mBAAIiC,KAAJ,+BAAiCG,cAAjC;;AACA;AACD;AACF;AACF;AA1BkG;AAAA;AAAA;AAAA;AAAA;AA2BpG","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\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\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\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 (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\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 (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && 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"],"file":"webgl-developer-tools.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","debug","getDebugContext","getRealContext","data","realContext","log","warn","debugContext","init","GL","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;A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,KAAK,CAAC4C,KAAN,CAAYZ,MAAZ,GAAqB,CAAxC,EAA2C;AACzCU,IAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;AACA,QAAMsB,YAAY,GAAG7C,KAAK,CAAC4C,KAAN,CAAYE,KAAZ,CAAkB,UAACC,OAAD;AAAA,aAAqBL,cAAc,CAACM,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA1D;AAAA,KAAlB,CAArB;;AACA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAdkG,6CAgBjFtB,YAhBiF;AAAA;;AAAA;AAgBnG,wDAAgC;AAAA,UAArBI,GAAqB;;AAC9B,UAAIA,GAAG,KAAKC,SAAZ,EAAuB;AACrBc,QAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,YAAIvB,KAAK,CAACwC,YAAV,EAAwB;AACtB,gBAAM,IAAIC,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,SAFD,MAEO;AACLpC,mBAAIiC,KAAJ,+BAAiCG,cAAjC;;AACA;AACD;AACF;AACF;AA1BkG;AAAA;AAAA;AAAA;AAAA;AA2BpG","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\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\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\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 (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\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"],"file":"webgl-developer-tools.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/adapter/resources/webgl-buffer.ts"],"names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","removeStats","trackDeallocatedMemory","deleteBuffer","destroyed","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","offset","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"mappings":";AACA,SAAQA,MAAR,EAAgBC,MAAhB,QAA6B,cAA7B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAGA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,eAAe,MAAMC,WAAN,SAA0BJ,MAA1B,CAAiC;AAe9CK,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAkB,GAAG,EAA3C,EAA+C;AACxD,UAAMD,MAAN,EAAcC,KAAd;;AADwD;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,uCAN1B,IAM0B;;AAAA;;AAGxD,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,EAAL,GAAU,KAAKF,MAAL,CAAYE,EAAtB;AACA,SAAKC,GAAL,GAAW,KAAKH,MAAL,CAAYG,GAAvB;AAEA,UAAMC,MAAM,GAAG,OAAOH,KAAP,KAAiB,QAAjB,GAA6BA,KAAD,CAAuBG,MAA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,EAAAA,cAAc,GAAG;AACf,WAAO,KAAKrC,MAAZ;AACA,WAAO,KAAKT,MAAL,CAAYoC,QAAZ,GAAuBxC,EAAE,CAAC+C,gBAA1B,GAA6C,KAAKlC,MAAzD;AACD;;AAnK6C;;AAiLhD,SAASC,cAAT,CAAwBC,KAAxB,EAA2C;AACzC,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACoD,oBAAV;AACD;;AACD,MAAIrC,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACsD,YAAV;AACD;;AACD,MAAIvC,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAACwD,cAAV;AACD;;AAUD,SAAOxD,EAAE,CAACsD,YAAV;AACD;;AAED,SAASrC,aAAT,CAAuBF,KAAvB,EAA0C;AACxC,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAAC0D,YAAV;AACD;;AACD,SAAO1D,EAAE,CAAC0D,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, 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 return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\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 return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/adapter/resources/webgl-buffer.ts"],"names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","gl","gl2","handle","undefined","createBuffer","__SPECTOR_Metadata","data","target","getWebGLTarget","usage","webglUsage","getWebGLUsage","debugData","_initWithData","byteOffset","byteLength","_initWithByteLength","ArrayBuffer","isView","_getWriteTarget","bindBuffer","bufferData","bufferSubData","slice","bytesUsed","trackAllocatedMemory","Float32Array","destroy","destroyed","removeStats","trackDeallocatedMemory","deleteBuffer","write","srcOffset","isWebGL2","COPY_WRITE_BUFFER","assertWebGL2","offset","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"mappings":";AACA,SAAQA,MAAR,EAAgBC,MAAhB,QAA6B,cAA7B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAGA,MAAMC,iBAAiB,GAAG,EAA1B;AAGA,eAAe,MAAMC,WAAN,SAA0BJ,MAA1B,CAAiC;AAe9CK,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAkB,GAAG,EAA3C,EAA+C;AACxD,UAAMD,MAAN,EAAcC,KAAd;;AADwD;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,uCAN1B,IAM0B;;AAAA;;AAGxD,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,EAAL,GAAU,KAAKF,MAAL,CAAYE,EAAtB;AACA,SAAKC,GAAL,GAAW,KAAKH,MAAL,CAAYG,GAAvB;AAEA,UAAMC,MAAM,GAAG,OAAOH,KAAP,KAAiB,QAAjB,GAA6BA,KAAD,CAAuBG,MAAnD,GAA4DC,SAA3E;AACA,SAAKD,MAAL,GAAcA,MAAM,IAAI,KAAKF,EAAL,CAAQI,YAAR,EAAxB;AAEA,SAAKF,MAAL,CAAYG,kBAAZ,GAAiC,EAAC,GAAG,KAAKN,KAAT;AAAgBO,MAAAA,IAAI,EAAE,OAAO,KAAKP,KAAL,CAAWO;AAAxC,KAAjC;AAMA,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C,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACoD,oBAAV;AACD;;AACD,MAAIrC,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACsD,YAAV;AACD;;AACD,MAAIvC,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAACwD,cAAV;AACD;;AAUD,SAAOxD,EAAE,CAACsD,YAAV;AACD;;AAED,SAASrC,aAAT,CAAuBF,KAAvB,EAA0C;AACxC,MAAIA,KAAK,GAAGjB,MAAM,CAACqD,KAAnB,EAA0B;AACxB,WAAOnD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACuD,MAAnB,EAA2B;AACzB,WAAOrD,EAAE,CAACyD,WAAV;AACD;;AACD,MAAI1C,KAAK,GAAGjB,MAAM,CAACyD,OAAnB,EAA4B;AAC1B,WAAOvD,EAAE,CAAC0D,YAAV;AACD;;AACD,SAAO1D,EAAE,CAAC0D,YAAV;AACD","sourcesContent":["import type {BufferProps} from '@luma.gl/api';\nimport {Buffer, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport WebGLDevice from '../webgl-device';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n/** WebGL Buffer interface */\nexport default class WEBGLBuffer extends Buffer {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly handle: WebGLBuffer;\n readonly target: number;\n\n byteLength: number;\n bytesUsed: number;\n debugData: ArrayBuffer | null = null;\n\n webglUsage: number;\n\n // accessor: {};\n\n constructor(device: WebGLDevice, props: BufferProps = {}) {\n super(device, props);\n\n this.device = device;\n this.gl = this.device.gl;\n this.gl2 = this.device.gl2;\n\n const handle = typeof props === 'object' ? (props as BufferProps).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n // @ts-expect-error Add metadata for spector\n this.handle.__SPECTOR_Metadata = {...this.props, data: typeof this.props.data}; // {name: this.props.id};\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @ts-expect-error Hack - Checking for subclass prop\n this.target = this.props.target || getWebGLTarget(this.props.usage);\n // @ts-expect-error Hack - Checking for subclass prop\n this.webglUsage = this.props.webglUsage || getWebGLUsage(this.props.usage);\n this.debugData = null;\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._initWithData(props.data, props.byteOffset, props.byteLength);\n } else {\n this._initWithByteLength(props.byteLength || 0);\n }\n\n // Deprecated: Merge main props and accessor\n // this.accessor = {...props.accessor};\n\n // Object.seal(this);\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _initWithData(data, byteOffset: number = 0, byteLength: number = data.byteLength + byteOffset): this {\n assert(ArrayBuffer.isView(data));\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, byteOffset, 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 return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _initWithByteLength(byteLength: number): this {\n assert(byteLength >= 0);\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getWriteTarget();\n\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, this.webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n return this;\n }\n\n override destroy(): void {\n if (!this.destroyed && this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n this.destroyed = true;\n // this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const target = this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n this.device.assertWebGL2();\n\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, byteOffset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n // this.debugData = data.slice(byteOffset, 40);\n }\n\n /** Read data from the buffer */\n override async readAsync(\n byteOffset: number = 0,\n byteLength?: number\n ): Promise<ArrayBuffer> {\n this.device.assertWebGL2();\n\n const data = new Uint8Array(byteLength);\n const dstOffset = 0;\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2.getBufferSubData(GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n // this.debugData = null;\n\n return data;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n _invalidateDebugData() {\n this.debugData = null;\n }\n\n _getWriteTarget() {\n return this.target;\n // return this.device.isWebGL2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getReadTarget() {\n return this.target;\n return this.device.isWebGL2 ? GL.COPY_READ_BUFFER : this.target;\n }\n}\n\n// static MAP_READ = 0x01;\n// static MAP_WRITE = 0x02;\n// static COPY_SRC = 0x0004;\n// static COPY_DST = 0x0008;\n// static INDEX = 0x0010;\n// static VERTEX = 0x0020;\n// static UNIFORM = 0x0040;\n// static STORAGE = 0x0080;\n// static INDIRECT = 0x0100;\n// static QUERY_RESOLVE = 0x0200;\n\nfunction getWebGLTarget(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.ELEMENT_ARRAY_BUFFER;\n }\n if (usage & Buffer.VERTEX) {\n return GL.ARRAY_BUFFER;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.UNIFORM_BUFFER;\n }\n\n // gl.COPY_READ_BUFFER: Buffer for copying from one buffer object to another.\n // gl.COPY_WRITE_BUFFER: Buffer for copying from one buffer object to another.\n // gl.TRANSFORM_FEEDBACK_BUFFER: Buffer for transform feedback operations.\n // gl.PIXEL_PACK_BUFFER: Buffer used for pixel transfer operations.\n // gl.PIXEL_UNPACK_BUFFER: Buffer used for pixel transfer operations.\n\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 return GL.ARRAY_BUFFER;\n}\n\nfunction getWebGLUsage(usage: number): GL {\n if (usage & Buffer.INDEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.VERTEX) {\n return GL.STATIC_DRAW;\n }\n if (usage & Buffer.UNIFORM) {\n return GL.DYNAMIC_DRAW;\n }\n return GL.DYNAMIC_DRAW;\n}\n"],"file":"webgl-buffer.js"}
|
|
@@ -72,15 +72,6 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
72
72
|
Object.seal(this);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
destroy() {
|
|
76
|
-
if (this.handle) {
|
|
77
|
-
this.removeStats();
|
|
78
|
-
this.trackDeallocatedMemory();
|
|
79
|
-
this.gl.deleteBuffer(this.handle);
|
|
80
|
-
this.destroyed = true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
75
|
write(data, byteOffset) {
|
|
85
76
|
this.subData({
|
|
86
77
|
data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classic/buffer.ts"],"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","byteOffset","ClassicBuffer","constructor","device","attach","setAccessor","Object","assign","accessor","seal","destroy","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","write","subData","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","webglUsage","STATIC_DRAW","debugData","_setData","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","unbind","isIndexedBuffer","getDebugData","changed","invalidateDebugData","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"mappings":";AAGA,SAAQA,MAAR,EAAgBC,UAAhB,QAAiC,cAAjC;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,mBAAR,QAAkC,iCAAlC;AAEA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAAQC,uBAAR,EAAiCC,uBAAj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AAK3E,EAAL,CAAQ8B,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,WAAOiD,KAAP;AACD;;AAIO,MAAJ9G,IAAI,GAAG;AACT,WAAO,KAAK4B,QAAL,CAAc5B,IAArB;AACD;;AAxYoD","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\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: ClassicBufferProps | 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 as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\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 default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\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 ClassicBufferProps).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 destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: TypedArray, byteOffset?: number): 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: ClassicBufferProps = {}): 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 this.webglUsage = props.webglUsage || 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.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): 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: ClassicBufferProps) {\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 target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, 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.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, 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?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // 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 (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, 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.webglUsage);\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, webglUsage = this.webglUsage): 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 target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\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.target;\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.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, 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"],"file":"buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/classic/buffer.ts"],"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","byteOffset","ClassicBuffer","constructor","device","attach","setAccessor","Object","assign","accessor","seal","write","subData","getElementCount","Math","round","getBytesPerElement","getVertexCount","getBytesPerVertex","initialize","Number","isFinite","webglUsage","STATIC_DRAW","debugData","_setData","_setByteLength","setProps","buffer","reallocate","bytesUsed","setData","options","srcOffset","length","target","gl","webgl2","COPY_WRITE_BUFFER","bindBuffer","handle","undefined","bufferSubData","_inferType","copyData","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","getData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","bind","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","unbind","isIndexedBuffer","getDebugData","changed","invalidateDebugData","trackDeallocatedMemory","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getParameter","pname","value","getBufferParameter"],"mappings":";AAGA,SAAQA,MAAR,EAAgBC,UAAhB,QAAiC,cAAjC;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,mBAAR,QAAkC,iCAAlC;AAEA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAAQC,uBAAR,EAAiCC,uBAA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checkProps} from '@luma.gl/api';\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: ClassicBufferProps | 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 as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\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 default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\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 ClassicBufferProps).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): 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: ClassicBufferProps = {}): 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 this.webglUsage = props.webglUsage || 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.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): 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: ClassicBufferProps) {\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 target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, 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.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, 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?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // 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 (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, 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.webglUsage);\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, webglUsage = this.webglUsage): 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 target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\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.target;\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.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, 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"],"file":"buffer.js"}
|
|
@@ -90,9 +90,9 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
90
90
|
log.log(1, functionString)();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if (props.break) {
|
|
93
|
+
if (props.break && props.break.length > 0) {
|
|
94
94
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
95
|
-
const isBreakpoint = props.break
|
|
95
|
+
const isBreakpoint = props.break.every(breakOn => functionString.indexOf(breakOn) !== -1);
|
|
96
96
|
|
|
97
97
|
if (isBreakpoint) {
|
|
98
98
|
debugger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","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","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,cAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;AAYD,OAAO,eAAeC,uBAAf,GAAwD;AAC7D,MAAI,CAACC,UAAU,CAACC,eAAhB,EAAiC;AAE/BD,IAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,IAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AACA,UAAMV,UAAU,CAACE,mBAAD,CAAhB;AACD;AACF;AAID,OAAO,SAASS,gBAAT,CAA0BP,EAA1B,EAAqDQ,KAAwB,GAAG,EAAhF,EAAkH;AAEvH,MAAI,CAACR,EAAL,EAAS;AACP,WAAO,IAAP;AACD;;AAED,SAAOQ,KAAK,CAACC,KAAN,GAAcC,eAAe,CAACV,EAAD,EAAKQ,KAAL,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AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\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\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\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 (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\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 (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && 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"],"file":"webgl-developer-tools.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["log","loadScript","GL","WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","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","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":"AACA,SAAQA,GAAR,EAAaC,UAAb,QAA8B,cAA9B;AACA,OAAOC,EAAP,MAAe,oBAAf;AAEA,MAAMC,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;AAYD,OAAO,eAAeC,uBAAf,GAAwD;AAC7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,CAAmBC,OAAD,IAAqBL,cAAc,CAACM,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA5E,CAArB;;AACA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAED,OAAK,MAAMlB,GAAX,IAAkBJ,YAAlB,EAAgC;AAC9B,QAAII,GAAG,KAAKC,SAAZ,EAAuB;AACrBc,MAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,UAAIrB,KAAK,CAACsC,YAAV,EAAwB;AACtB,cAAM,IAAIC,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,OAFD,MAEO;AACLrD,QAAAA,GAAG,CAACkD,KAAJ,+BAAiCG,cAAjC;AACA;AACD;AACF;AACF;AACF","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\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\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\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 (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\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"],"file":"webgl-developer-tools.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.14",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
|
-
"@luma.gl/api": "9.0.0-alpha.
|
|
39
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
38
|
+
"@luma.gl/api": "9.0.0-alpha.14",
|
|
39
|
+
"@luma.gl/constants": "9.0.0-alpha.14",
|
|
40
40
|
"@probe.gl/env": "^3.5.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "777474ce360ac49de05d7de5ee36e7e276a96e08"
|
|
43
43
|
}
|
|
@@ -102,12 +102,12 @@ export default class WEBGLBuffer extends Buffer {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
override destroy(): void {
|
|
105
|
-
if (this.handle) {
|
|
105
|
+
if (!this.destroyed && this.handle) {
|
|
106
106
|
this.removeStats();
|
|
107
107
|
this.trackDeallocatedMemory();
|
|
108
108
|
this.gl.deleteBuffer(this.handle);
|
|
109
|
-
// this.handle = null;
|
|
110
109
|
this.destroyed = true;
|
|
110
|
+
// this.handle = null;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
package/src/classic/buffer.ts
CHANGED
|
@@ -108,16 +108,6 @@ export default class ClassicBuffer extends WEBGLBuffer {
|
|
|
108
108
|
Object.seal(this);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
override destroy(): void {
|
|
112
|
-
if (this.handle) {
|
|
113
|
-
this.removeStats();
|
|
114
|
-
this.trackDeallocatedMemory();
|
|
115
|
-
this.gl.deleteBuffer(this.handle);
|
|
116
|
-
// this.handle = null;
|
|
117
|
-
this.destroyed = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
111
|
override write(data: TypedArray, byteOffset?: number): void {
|
|
122
112
|
this.subData({data, offset: byteOffset});
|
|
123
113
|
}
|
|
@@ -139,10 +139,10 @@ function onValidateGLFunc(props: DebugContextProps, functionName: string, functi
|
|
|
139
139
|
log.log(1, functionString)();
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
if
|
|
142
|
+
// If array of breakpoint strings supplied, check if any of them is contained in current GL function
|
|
143
|
+
if (props.break && props.break.length > 0) {
|
|
143
144
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
144
|
-
const isBreakpoint =
|
|
145
|
-
props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);
|
|
145
|
+
const isBreakpoint = props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);
|
|
146
146
|
if (isBreakpoint) {
|
|
147
147
|
debugger; // eslint-disable-line
|
|
148
148
|
}
|