@luma.gl/webgl 9.0.0-alpha.24 → 9.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.d.ts +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +1 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +1 -1
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +1 -1
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +1 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +1 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.js +2 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/{buffer.d.ts → buffer-with-accessor.d.ts} +8 -8
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -0
- package/dist/classic/{buffer.js → buffer-with-accessor.js} +3 -3
- package/dist/classic/buffer-with-accessor.js.map +1 -0
- package/dist/classic/clear.js.map +1 -1
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +2 -2
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/classic/format-utils.js +1 -1
- package/dist/classic/format-utils.js.map +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +3 -3
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/dist.dev.js +32 -79
- package/dist/index.cjs +532 -543
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist.min.js +15 -15
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +1 -1
- package/src/adapter/converters/texture-formats.ts +1 -1
- package/src/adapter/converters/vertex-formats.ts +1 -1
- package/src/adapter/device-helpers/device-limits.ts +1 -1
- package/src/adapter/device-helpers/get-device-info.ts +1 -1
- package/src/adapter/helpers/get-shader-layout.ts +1 -1
- package/src/adapter/helpers/set-uniform.ts +1 -1
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/objects/webgl-vertex-array-object.ts +1 -1
- package/src/adapter/resources/webgl-buffer.ts +1 -1
- package/src/adapter/resources/webgl-command-buffer.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +1 -1
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/webgl-device.ts +2 -2
- package/src/classic/accessor.ts +1 -1
- package/src/classic/{buffer.ts → buffer-with-accessor.ts} +9 -9
- package/src/classic/copy-and-blit.ts +2 -2
- package/src/classic/format-utils.ts +1 -1
- package/src/context/debug/webgl-developer-tools.ts +1 -1
- package/src/context/polyfill/get-parameter-polyfill.ts +1 -1
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/index.ts +2 -2
- package/dist/classic/buffer.d.ts.map +0 -1
- package/dist/classic/buffer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-renderbuffer.js","names":["assert","GL","WebGLResource","isRenderbufferFormatSupported","convertTextureFormatToGL","getTextureFormatBytesPerPixel","_Symbol$toStringTag","Symbol","toStringTag","WEBGLRenderbuffer","width","props","height","format","samples","attachment","isTextureFormatSupported","device","gl","constructor","Error","defaultProps","_defineProperty","glFormat","isWebGL2","_initialize","resize","size","Object","assign","trackDeallocatedMemory","bindRenderbuffer","RENDERBUFFER","handle","gl2","renderbufferStorageMultisample","renderbufferStorage","trackAllocatedMemory","_createHandle","createRenderbuffer","_deleteHandle","deleteRenderbuffer","_bindHandle","id","undefined","userData"],"sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"sourcesContent":["import {assert, ResourceProps, TextureFormat} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {isRenderbufferFormatSupported} from '../converters/texture-formats';\nimport {convertTextureFormatToGL, getTextureFormatBytesPerPixel} from '../converters/texture-formats';\n\nexport type RenderbufferProps = ResourceProps & {\n format: TextureFormat;\n width?: number;\n height?: number;\n samples?: number;\n};\n\n/**\n * Renderbuffers are GPU objects that contain images.\n * In contrast to Textures they are optimized for use as render targets, with Framebuffers.\n * while Textures may not be, and are the logical choice when\n * you do not need to sample (i.e. in a post-pass shader)\n * from the produced image. If you need to resample\n * (such as when reading depth back in a second shader pass),\n * use Textures instead.\n * Renderbuffer objects also natively accommodate Multisampling (MSAA).\n */\nexport class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {\n static override readonly defaultProps: Required<RenderbufferProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n format: undefined, // 'depth16unorm'\n width: 1,\n height: 1, \n samples: 0\n }; \n\n override get [Symbol.toStringTag](): string { return 'Renderbuffer'; }\n\n get width(): number { return this.props.width; }\n get height(): number { return this.props.height; }\n get format(): TextureFormat { return this.props.format; }\n get samples(): number { return this.props.samples; }\n get attachment() { return }\n\n /** WebGL format constant */\n glFormat: GL;\n\n static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean {\n return isRenderbufferFormatSupported(device.gl, format);\n }\n\n constructor(device: WebGLDevice, props: RenderbufferProps) {\n // TODO - remove temporary sanity check\n if (typeof props.format === 'number') {\n throw new Error('Renderbuffer');\n }\n super(device, props, WEBGLRenderbuffer.defaultProps);\n this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);\n this._initialize(this.props);\n }\n\n resize(size: {width: number, height: number}): void {\n // Don't resize if width/height haven't changed\n if (size.width !== this.width || size.height !== this.height) {\n Object.assign(this.props, {...size, format: this.format, samples: this.samples});\n this._initialize(this.props);\n }\n }\n\n // PRIVATE METHODS\n\n /** Creates and initializes a renderbuffer object's data store */\n protected _initialize(props: Required<RenderbufferProps>): void {\n const {format, width, height, samples} = props;\n assert(format, 'Needs format');\n\n this.trackDeallocatedMemory();\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);\n\n if (samples !== 0 && this.device.isWebGL2) {\n this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);\n } else {\n this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);\n }\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);\n\n this.trackAllocatedMemory(\n width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)\n );\n }\n\n // RESOURCE IMPLEMENTATION\n\n override _createHandle() {\n return this.gl.createRenderbuffer();\n }\n\n override _deleteHandle(): void {\n this.gl.deleteRenderbuffer(this.handle);\n this.trackDeallocatedMemory();\n }\n\n override _bindHandle(handle: WEBGLRenderbuffer): void {\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);\n }\n}\n"],"mappings":";;AAAA,SAAQA,MAAM,QAAqC,cAAc;AACjE,
|
|
1
|
+
{"version":3,"file":"webgl-renderbuffer.js","names":["assert","GL","WebGLResource","isRenderbufferFormatSupported","convertTextureFormatToGL","getTextureFormatBytesPerPixel","_Symbol$toStringTag","Symbol","toStringTag","WEBGLRenderbuffer","width","props","height","format","samples","attachment","isTextureFormatSupported","device","gl","constructor","Error","defaultProps","_defineProperty","glFormat","isWebGL2","_initialize","resize","size","Object","assign","trackDeallocatedMemory","bindRenderbuffer","RENDERBUFFER","handle","gl2","renderbufferStorageMultisample","renderbufferStorage","trackAllocatedMemory","_createHandle","createRenderbuffer","_deleteHandle","deleteRenderbuffer","_bindHandle","id","undefined","userData"],"sources":["../../../src/adapter/objects/webgl-renderbuffer.ts"],"sourcesContent":["import {assert, ResourceProps, TextureFormat} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\nimport {isRenderbufferFormatSupported} from '../converters/texture-formats';\nimport {convertTextureFormatToGL, getTextureFormatBytesPerPixel} from '../converters/texture-formats';\n\nexport type RenderbufferProps = ResourceProps & {\n format: TextureFormat;\n width?: number;\n height?: number;\n samples?: number;\n};\n\n/**\n * Renderbuffers are GPU objects that contain images.\n * In contrast to Textures they are optimized for use as render targets, with Framebuffers.\n * while Textures may not be, and are the logical choice when\n * you do not need to sample (i.e. in a post-pass shader)\n * from the produced image. If you need to resample\n * (such as when reading depth back in a second shader pass),\n * use Textures instead.\n * Renderbuffer objects also natively accommodate Multisampling (MSAA).\n */\nexport class WEBGLRenderbuffer extends WebGLResource<RenderbufferProps> {\n static override readonly defaultProps: Required<RenderbufferProps> = {\n id: undefined,\n handle: undefined,\n userData: undefined,\n format: undefined, // 'depth16unorm'\n width: 1,\n height: 1, \n samples: 0\n }; \n\n override get [Symbol.toStringTag](): string { return 'Renderbuffer'; }\n\n get width(): number { return this.props.width; }\n get height(): number { return this.props.height; }\n get format(): TextureFormat { return this.props.format; }\n get samples(): number { return this.props.samples; }\n get attachment() { return }\n\n /** WebGL format constant */\n glFormat: GL;\n\n static isTextureFormatSupported(device: WebGLDevice, format: TextureFormat): boolean {\n return isRenderbufferFormatSupported(device.gl, format);\n }\n\n constructor(device: WebGLDevice, props: RenderbufferProps) {\n // TODO - remove temporary sanity check\n if (typeof props.format === 'number') {\n throw new Error('Renderbuffer');\n }\n super(device, props, WEBGLRenderbuffer.defaultProps);\n this.glFormat = convertTextureFormatToGL(this.props.format, device.isWebGL2);\n this._initialize(this.props);\n }\n\n resize(size: {width: number, height: number}): void {\n // Don't resize if width/height haven't changed\n if (size.width !== this.width || size.height !== this.height) {\n Object.assign(this.props, {...size, format: this.format, samples: this.samples});\n this._initialize(this.props);\n }\n }\n\n // PRIVATE METHODS\n\n /** Creates and initializes a renderbuffer object's data store */\n protected _initialize(props: Required<RenderbufferProps>): void {\n const {format, width, height, samples} = props;\n assert(format, 'Needs format');\n\n this.trackDeallocatedMemory();\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);\n\n if (samples !== 0 && this.device.isWebGL2) {\n this.gl2.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);\n } else {\n this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);\n }\n\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);\n\n this.trackAllocatedMemory(\n width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)\n );\n }\n\n // RESOURCE IMPLEMENTATION\n\n override _createHandle() {\n return this.gl.createRenderbuffer();\n }\n\n override _deleteHandle(): void {\n this.gl.deleteRenderbuffer(this.handle);\n this.trackDeallocatedMemory();\n }\n\n override _bindHandle(handle: WEBGLRenderbuffer): void {\n this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);\n }\n}\n"],"mappings":";;AAAA,SAAQA,MAAM,QAAqC,cAAc;AACjE,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,aAAa;AAAA,SACbC,6BAA6B;AAAA,SAC7BC,wBAAwB,EAAEC,6BAA6B;AAAAC,mBAAA,GA8B/CC,MAAM,CAACC,WAAW;AAXlC,OAAO,MAAMC,iBAAiB,SAASP,aAAa,CAAoB;EAWtE,KAAAI,mBAAA,IAA4C;IAAE,OAAO,cAAc;EAAE;EAErE,IAAII,KAAKA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACC,KAAK,CAACD,KAAK;EAAE;EAC/C,IAAIE,MAAMA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACD,KAAK,CAACC,MAAM;EAAE;EACjD,IAAIC,MAAMA,CAAA,EAAkB;IAAE,OAAO,IAAI,CAACF,KAAK,CAACE,MAAM;EAAE;EACxD,IAAIC,OAAOA,CAAA,EAAW;IAAE,OAAO,IAAI,CAACH,KAAK,CAACG,OAAO;EAAE;EACnD,IAAIC,UAAUA,CAAA,EAAG;IAAE;EAAQ;EAK3B,OAAOC,wBAAwBA,CAACC,MAAmB,EAAEJ,MAAqB,EAAW;IACnF,OAAOV,6BAA6B,CAACc,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|
3
|
-
import GL from '@luma.gl/constants';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from '../webgl-device';
|
|
5
5
|
/**
|
|
6
6
|
* Base class for WebGL object wrappers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAkC,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAkC,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAO5C;;GAEG;AACH,8BAAsB,aAAa,CAAC,KAAK,SAAS,aAAa,CAAE,SAAQ,QAAQ,CAAC,KAAK,CAAC;IACtF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,qBAAqB,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,sBAAsB,CAAC;IACrC,OAAO,CAAC,OAAO,CAAM;IAErB,OAAO,CAAC,MAAM,CAAS;IAEvB,UAAU,SAAK;gBAEH,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC;IA6B9D,QAAQ,IAAI,MAAM;IAI3B,IAAI,MAAM,QAWT;IAEQ,MAAM,CAAC,EAAC,cAAsB,EAAC;;KAAK;IAmB7C,IAAI,CAAC,YAAY,MAAc;IAuB/B,MAAM;IAIN;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,GAAQ,GAAG,GAAG;IAiCjD,aAAa,CAAC,OAAO,GAAE;QAAC,UAAU,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAM;IAoC1D;;;;;;;;OAQG;IACH,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAqClD,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;IAQzC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE;IAK5E,UAAU,CAAC,KAAK,EAAE,aAAa;IAG/B,aAAa;IAIb,aAAa;IAIb,WAAW,CAAC,MAAM,EAAE,GAAG;IAIvB,kBAAkB;IAIlB,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAI5D,aAAa,CAAC,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG;CAuC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-resource.js","names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","WebGLDevice","getKeyValue","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","_defineProperty","attach","gl","id","gl2","name","_handle","handle","undefined","_createHandle","byteLength","toString","concat","delete","deleteChildren","arguments","length","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","destroy","bind","funcOrHandle","_bindHandle","value","_bound","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","getGLKey","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"sources":["../../../src/adapter/objects/webgl-resource.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/api';\nimport type {Device, ResourceProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';\nimport {WebGLDevice} from '../webgl-device';\n\n// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?\nimport {getKeyValue} from './constants-to-keys';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\nexport abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n const {id} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n override toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n override delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.destroy());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props: any = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?: any, keys?: any} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values: Record<string, any> = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? this.device.getGLKey(pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = this.device.getGLKey(values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param pname - parameter (GL constant, value or key)\n * @param value {GLint|GLfloat|GLenum} \n * @return returns self to enable chaining\n */\n setParameter(pname: GL | string, value: any): this {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters: Record<GL, any>) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className: string, version: string, methodNames: string[]) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props: ResourceProps) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname: GL, props: Record<string, any>): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname: GL | string, value: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"mappings":";AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,cAAc;AAAC,SAG/DC,QAAQ,EAAEC,kBAAkB;AAAA,SAC5BC,WAAW;AAAA,SAGXC,WAAW;AAEnB,MAAMC,6BAA6B,GAAG,+CAA+C;A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ChD;EAEA+D,aAAaA,CAACzB,KAAkB,EAAEJ,KAAU,EAAE;IAC5C,MAAM,IAAI4B,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;AAqCF"}
|
|
1
|
+
{"version":3,"file":"webgl-resource.js","names":["Resource","assert","uid","stubRemovedMethods","isWebGL2","assertWebGLContext","WebGLDevice","getKeyValue","ERR_RESOURCE_METHOD_UNDEFINED","WebGLResource","constructor","device","props","defaultProps","_defineProperty","attach","gl","id","gl2","name","_handle","handle","undefined","_createHandle","byteLength","toString","concat","delete","deleteChildren","arguments","length","children","_deleteHandle","removeStats","filter","Boolean","forEach","child","destroy","bind","funcOrHandle","_bindHandle","value","_bound","unbind","getParameter","pname","parameters","PARAMETERS","parameter","isWebgl2","parameterAvailable","getExtension","extension","webgl1Default","webgl1","webgl2Default","webgl2","defaultValue","_getParameter","getParameters","options","keys","values","parameterKeys","Object","key","getGLKey","type","setParameter","Error","_setParameter","setParameters","className","version","methodNames","initialize","_getOptsFromHandle"],"sources":["../../../src/adapter/objects/webgl-resource.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Resource, assert, uid, stubRemovedMethods} from '@luma.gl/api';\nimport type {Device, ResourceProps} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {isWebGL2, assertWebGLContext} from '../../context/context/webgl-checks';\nimport {WebGLDevice} from '../webgl-device';\n\n// Requires full GL enum to be bundled... Make these bindings dependent on dynamic import (debug)?\nimport {getKeyValue} from './constants-to-keys';\n\nconst ERR_RESOURCE_METHOD_UNDEFINED = 'Resource subclass must define virtual methods';\n\n/**\n * Base class for WebGL object wrappers\n */\nexport abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {\n readonly device: WebGLDevice;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n private _handle: any;\n\n private _bound = false;\n // Only meaningful for resources that allocate GPU memory\n byteLength = 0;\n\n constructor(device: Device, props: Props, defaultProps: Required<Props>) {\n super(device, props, defaultProps);\n\n this.device = WebGLDevice.attach(device);\n const gl = this.device.gl;\n\n assertWebGLContext(gl);\n\n // extends \n const {id} = props || {};\n this.gl = gl;\n this.gl2 = gl as WebGL2RenderingContext;\n this.id = id || uid(this.constructor.name);\n\n // Set the handle\n // If handle was provided, use it, otherwise create a new handle\n\n // TODO - Stores the handle with context loss information\n // this.glCount = glGetContextLossCount(this.gl);\n\n // Default VertexArray needs to be created with null handle, so compare against undefined\n this._handle = props?.handle;\n if (this._handle === undefined) {\n this._handle = this._createHandle();\n }\n\n this.byteLength = 0;\n }\n\n override toString(): string {\n return `${this.constructor.name}(${this.id})`;\n }\n\n get handle() {\n // TODO - Add context loss handling\n // Will regenerate and reinitialize the handle if necessary\n // const glCount = glGetContextLossCount(this.gl);\n // if (this.glCount !== glCount) {\n // this._handle = this._createHandle(this.props);\n // this._glCount = glCount;\n // // Reinitialize object\n // this.initialize(this.props);\n // }\n return this._handle;\n }\n\n override delete({deleteChildren = false} = {}) {\n // Delete this object, and get refs to any children\n // @ts-expect-error\n const children = this._handle && this._deleteHandle(this._handle);\n if (this._handle) {\n this.removeStats();\n }\n this._handle = null;\n\n // Optionally, recursively delete the children\n // @ts-expect-error\n if (children && deleteChildren) {\n // @ts-expect-error\n children.filter(Boolean).forEach((child) => child.destroy());\n }\n\n return this;\n }\n\n bind(funcOrHandle = this.handle) {\n if (typeof funcOrHandle !== 'function') {\n this._bindHandle(funcOrHandle);\n return this;\n }\n\n let value;\n\n if (!this._bound) {\n this._bindHandle(this.handle);\n this._bound = true;\n\n value = funcOrHandle();\n\n this._bound = false;\n this._bindHandle(null);\n } else {\n value = funcOrHandle();\n }\n\n return value;\n }\n\n unbind() {\n this.bind(null);\n }\n\n /**\n * Query a Resource parameter\n *\n * @param name\n * @return param\n */\n getParameter(pname: number, props: any = {}): any {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n // Use parameter definitions to handle unsupported parameters\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if we can query for this parameter\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n const webgl1Default = parameter.webgl1;\n const webgl2Default = 'webgl2' in parameter ? parameter.webgl2 : parameter.webgl1;\n const defaultValue = isWebgl2 ? webgl2Default : webgl1Default;\n return defaultValue;\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // Attempt to query for it and let WebGL report errors\n return this._getParameter(pname, props);\n }\n\n // Many resources support a getParameter call -\n // getParameters will get all parameters - slow but useful for debugging\n // eslint-disable-next-line complexity\n getParameters(options: {parameters?: any, keys?: any} = {}) {\n const {parameters, keys} = options;\n\n // Get parameter definitions for this Resource\n // @ts-expect-error\n const PARAMETERS = this.constructor.PARAMETERS || {};\n\n const isWebgl2 = isWebGL2(this.gl);\n\n const values: Record<string, any> = {};\n\n // Query all parameters if no list provided\n const parameterKeys = parameters || Object.keys(PARAMETERS);\n\n // WEBGL limits\n for (const pname of parameterKeys) {\n const parameter = PARAMETERS[pname];\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n parameter &&\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (parameterAvailable) {\n const key = keys ? this.device.getGLKey(pname) : pname;\n values[key] = this.getParameter(pname, options);\n if (keys && parameter.type === 'GLenum') {\n values[key] = this.device.getGLKey(values[key]);\n }\n }\n }\n\n return values;\n }\n\n /**\n * Update a Resource setting\n *\n * @todo - cache parameter to avoid issuing WebGL calls?\n *\n * @param pname - parameter (GL constant, value or key)\n * @param value {GLint|GLfloat|GLenum} \n * @return returns self to enable chaining\n */\n setParameter(pname: GL | string, value: any): this {\n pname = getKeyValue(this.gl, pname);\n assert(pname);\n\n // @ts-expect-error\n const parameters = this.constructor.PARAMETERS || {};\n\n const parameter = parameters[pname];\n if (parameter) {\n const isWebgl2 = isWebGL2(this.gl);\n\n // Check if this parameter is available on this platform\n const parameterAvailable =\n (!('webgl2' in parameter) || isWebgl2) &&\n (!('extension' in parameter) || this.gl.getExtension(parameter.extension));\n\n if (!parameterAvailable) {\n throw new Error('Parameter not available on this platform');\n }\n\n // Handle string keys\n if (parameter.type === 'GLenum') {\n // @ts-expect-error\n value = getKeyValue(value);\n }\n }\n\n // If unknown parameter - Could be a valid parameter not covered by PARAMS\n // attempt to set it and let WebGL report errors\n this._setParameter(pname, value);\n return this;\n }\n\n /*\n * Batch update resource parameters\n * Assumes the subclass supports a setParameter call\n */\n setParameters(parameters: Record<GL, any>) {\n for (const pname in parameters) {\n this.setParameter(pname, parameters[pname]);\n }\n return this;\n }\n\n // Install stubs for removed methods\n stubRemovedMethods(className: string, version: string, methodNames: string[]) {\n return stubRemovedMethods(this, className, version, methodNames);\n }\n\n // PUBLIC VIRTUAL METHODS\n initialize(props: ResourceProps) {}\n\n // PROTECTED METHODS - These must be overridden by subclass\n _createHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _deleteHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _bindHandle(handle: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getOptsFromHandle() {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _getParameter(pname: GL, props: Record<string, any>): number {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n _setParameter(pname: GL | string, value: any) {\n throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);\n }\n\n // PRIVATE METHODS\n\n /*\n _addStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get('Resources Created').incrementCount();\n stats.get(`${name}s Created`).incrementCount();\n stats.get(`${name}s Active`).incrementCount();\n }\n\n _removeStats() {\n const name = this.constructor.name;\n const stats = lumaStats.get('Resource Counts');\n\n stats.get(`${name}s Active`).decrementCount();\n }\n\n trackAllocatedMemory(bytes, name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').addCount(bytes);\n stats.get(`${name} Memory`).addCount(bytes);\n this.byteLength = bytes;\n }\n\n trackDeallocatedMemory(name = this.constructor.name) {\n const stats = lumaStats.get('Memory Usage');\n\n stats.get('GPU Memory').subtractCount(this.byteLength);\n stats.get(`${name} Memory`).subtractCount(this.byteLength);\n this.byteLength = 0;\n }\n */\n}\n"],"mappings":";AACA,SAAQA,QAAQ,EAAEC,MAAM,EAAEC,GAAG,EAAEC,kBAAkB,QAAO,cAAc;AAAC,SAG/DC,QAAQ,EAAEC,kBAAkB;AAAA,SAC5BC,WAAW;AAAA,SAGXC,WAAW;AAEnB,MAAMC,6BAA6B,GAAG,+CAA+C;AAKrF,OAAO,MAAeC,aAAa,SAAsCT,QAAQ,CAAQ;EAUvFU,WAAWA,CAACC,MAAc,EAAEC,KAAY,EAAEC,YAA6B,EAAE;IACvE,KAAK,CAACF,MAAM,EAAEC,KAAK,EAAEC,YAAY,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,iBALpB,KAAK;IAAAA,eAAA,qBAET,CAAC;IAKZ,IAAI,CAACH,MAAM,GAAGL,WAAW,CAACS,MAAM,CAACJ,MAAM,CAAC;IACxC,MAAMK,EAAE,GAAG,IAAI,CAACL,MAAM,CAACK,EAAE;IAEzBX,kBAAkB,CAACW,EAAE,CAAC;IAGtB,MAAM;MAACC;IAAE,CAAC,GAAGL,KAAK,IAAI,CAAC,CAAC;IACxB,IAAI,CAACI,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACE,GAAG,GAAGF,EAA4B;IACvC,IAAI,CAACC,EAAE,GAAGA,EAAE,IAAIf,GAAG,CAAC,IAAI,CAACQ,WAAW,CAACS,IAAI,CAAC;IAS1C,IAAI,CAACC,OAAO,GAAGR,KAAK,aAALA,KAAK,uB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B,CAAC,IAAI,EAAEsE,SAAS,EAAEC,OAAO,EAAEC,WAAW,CAAC;EAClE;EAGAC,UAAUA,CAAChE,KAAoB,EAAE,CAAC;EAGlCW,aAAaA,CAAA,EAAG;IACd,MAAM,IAAI+C,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEAwB,aAAaA,CAAA,EAAG;IACd,MAAM,IAAIsC,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEAiC,WAAWA,CAACpB,MAAW,EAAE;IACvB,MAAM,IAAIiD,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEAqE,kBAAkBA,CAAA,EAAG;IACnB,MAAM,IAAIP,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEAmD,aAAaA,CAACb,KAAS,EAAElC,KAA0B,EAAU;IAC3D,MAAM,IAAI0D,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;EAEA+D,aAAaA,CAACzB,KAAkB,EAAEJ,KAAU,EAAE;IAC5C,MAAM,IAAI4B,KAAK,CAAC9D,6BAA6B,CAAC;EAChD;AAqCF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from '@luma.gl/api';
|
|
2
|
-
import GL from '@luma.gl/constants';
|
|
2
|
+
import { GL } from '@luma.gl/constants';
|
|
3
3
|
import { getBrowser } from '@probe.gl/env';
|
|
4
4
|
import { WebGLResource } from "./webgl-resource.js";
|
|
5
5
|
const ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-vertex-array-object.js","names":["assert","GL","getBrowser","WebGLResource","ERR_ELEMENTS","WEBGLVertexArrayObject","Symbol","toStringTag","constructor","device","props","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","setElementBuffer","elementBuffer","arguments","length","undefined","opts","target","ELEMENT_ARRAY_BUFFER","bind","gl","bindBuffer","setBuffer","location","buffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","canDisableAttributeZero","isWebGL2","canDisableAttribute","disableVertexAttribArray"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import {assert, ResourceProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\n\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n constructor(device: WebGLDevice, props?: VertexArrayObjectProps) {\n // @ts-expect-error\n super(device, props, {});\n }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n\n return this;\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, accessor);\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n\n return this;\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): this {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n }\n return this;\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAsB,cAAc;AAClD,
|
|
1
|
+
{"version":3,"file":"webgl-vertex-array-object.js","names":["assert","GL","getBrowser","WebGLResource","ERR_ELEMENTS","WEBGLVertexArrayObject","Symbol","toStringTag","constructor","device","props","_createHandle","gl2","createVertexArray","_deleteHandle","deleteVertexArray","handle","elements","_bindHandle","bindVertexArray","setElementBuffer","elementBuffer","arguments","length","undefined","opts","target","ELEMENT_ARRAY_BUFFER","bind","gl","bindBuffer","setBuffer","location","buffer","accessor","size","type","stride","offset","normalized","integer","divisor","Number","ARRAY_BUFFER","assertWebGL2","vertexAttribIPointer","vertexAttribPointer","enableVertexAttribArray","vertexAttribDivisor","enable","canDisableAttributeZero","isWebGL2","canDisableAttribute","disableVertexAttribArray"],"sources":["../../../src/adapter/objects/webgl-vertex-array-object.ts"],"sourcesContent":["import {assert, ResourceProps} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {getBrowser} from '@probe.gl/env';\n\nimport {WebGLDevice} from '../webgl-device';\nimport {WebGLResource} from './webgl-resource';\n\nimport {WEBGLBuffer} from '../resources/webgl-buffer';\n\nconst ERR_ELEMENTS = 'elements must be GL.ELEMENT_ARRAY_BUFFER';\n\n/**\n * VertexArrayObject properties\n */\nexport type VertexArrayObjectProps = ResourceProps & {\n};\n\n/** VertexArrayObject wrapper */\nexport class WEBGLVertexArrayObject extends WebGLResource<VertexArrayObjectProps> {\n override get [Symbol.toStringTag](): string {\n return 'BaseVertexArrayObject';\n }\n\n constructor(device: WebGLDevice, props?: VertexArrayObjectProps) {\n // @ts-expect-error\n super(device, props, {});\n }\n\n override _createHandle() {\n return this.gl2.createVertexArray();\n }\n\n override _deleteHandle(): void {\n this.gl2.deleteVertexArray(this.handle);\n // @ts-expect-error\n return [this.elements];\n // return [this.elements, ...this.buffers];\n }\n\n override _bindHandle(handle: WEBGLVertexArrayObject): void {\n this.gl2.bindVertexArray(handle);\n }\n\n // Set (bind) an elements buffer, for indexed rendering.\n // Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported\n setElementBuffer(elementBuffer: WEBGLBuffer | null = null, opts = {}) {\n assert(!elementBuffer || elementBuffer.target === GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);\n\n // The GL.ELEMENT_ARRAY_BUFFER_BINDING is stored on the VertexArrayObject...\n this.bind(() => {\n this.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);\n });\n\n return this;\n }\n\n /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */\n setBuffer(location: number, buffer: WEBGLBuffer, accessor: any): this {\n // Check target\n if (buffer.target === GL.ELEMENT_ARRAY_BUFFER) {\n return this.setElementBuffer(buffer, accessor);\n }\n\n const {size, type, stride, offset, normalized, integer, divisor} = accessor;\n\n const {gl, gl2} = this;\n location = Number(location);\n\n this.bind(() => {\n // A non-zero buffer object must be bound to the GL_ARRAY_BUFFER target\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer.handle);\n\n // WebGL2 supports *integer* data formats, i.e. GPU will see integer values\n if (integer) {\n this.device.assertWebGL2();\n gl2.vertexAttribIPointer(location, size, type, stride, offset);\n } else {\n // Attaches ARRAY_BUFFER with specified buffer format to location\n gl.vertexAttribPointer(location, size, type, normalized, stride, offset);\n }\n gl.enableVertexAttribArray(location);\n gl2.vertexAttribDivisor(location, divisor || 0);\n\n // NOTE We don't unbind buffer here, typically another buffer will be bound just after\n });\n\n return this;\n }\n\n /**\n * Enabling an attribute location makes it reference the currently bound buffer\n * Disabling an attribute location makes it reference the global constant value\n * TODO - handle single values for size 1 attributes?\n * TODO - convert classic arrays based on known type?\n */\n enable(location: number, enable = true): this {\n // Attribute 0 cannot be disabled in most desktop OpenGL based browsers...\n const canDisableAttributeZero = this.device.isWebGL2 || getBrowser() === 'Chrome';\n const canDisableAttribute = canDisableAttributeZero || location !== 0;\n\n if (enable || canDisableAttribute) {\n location = Number(location);\n this.bind(() =>\n enable\n ? this.gl.enableVertexAttribArray(location)\n : this.gl.disableVertexAttribArray(location)\n );\n }\n return this;\n }\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAsB,cAAc;AAClD,SAAQC,EAAE,QAAO,oBAAoB;AACrC,SAAQC,UAAU,QAAO,eAAe;AAAC,SAGjCC,aAAa;AAIrB,MAAMC,YAAY,GAAG,0CAA0C;AAS/D,OAAO,MAA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AmB,EAAE;MACjCpB,QAAQ,GAAGU,MAAM,CAACV,QAAQ,CAAC;MAC3B,IAAI,CAACJ,IAAI,CAAC,MACRqB,MAAM,GACF,IAAI,CAACpB,EAAE,CAACkB,uBAAuB,CAACf,QAAQ,CAAC,GACzC,IAAI,CAACH,EAAE,CAACwB,wBAAwB,CAACrB,QAAQ,CAC/C,CAAC;IACH;IACA,OAAO,IAAI;EACb;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Buffer, assert } from '@luma.gl/api';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
4
|
const DEBUG_DATA_LENGTH = 10;
|
|
5
5
|
export class WEBGLBuffer extends Buffer {
|
|
6
6
|
constructor(device) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","arguments","length","undefined","_defineProperty","gl","gl2","handle","createBuffer","setSpectorMetadata","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","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"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 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 \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 ).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @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 // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const 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 this.gl2.bufferSubData(target, byteOffset, 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 &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AI,CAAC;IAK7C,OAAOlC,IAAI;EACb;EAIAoC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAAC9B,SAAS,GAAG,IAAI;EACvB;EAEAO,eAAeA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACZ,MAAM;EAEpB;EAEAoC,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACpC,MAAM;EAEpB;AACF;AAaA,SAASC,cAAcA,CAACC,KAAa,EAAM;EACzC,IAAIA,KAAK,GAAGpB,MAAM,CAACuD,KAAK,EAAE;IACxB,OAAOrD,EAAE,CAACsD,oBAAoB;EAChC;EACA,IAAIpC,KAAK,GAAGpB,MAAM,CAACyD,MAAM,EAAE;IACzB,OAAOvD,EAAE,CAACwD,YAAY;EACxB;EACA,IAAItC,KAAK,GAAGpB,MAAM,CAAC2D,OAAO,EAAE;IAC1B,OAAOzD,EAAE,CAAC0D,cAAc;EAC1B;EAUA,OAAO1D,EAAE,CAACwD,YAAY;AACxB;AAEA,SAASpC,aAAaA,CAACF,KAAa,EAAM;EACxC,IAAIA,KAAK,GAAGpB,MAAM,CAACuD,KAAK,EAAE;IACxB,OAAOrD,EAAE,CAAC2D,WAAW;EACvB;EACA,IAAIzC,KAAK,GAAGpB,MAAM,CAACyD,MAAM,EAAE;IACzB,OAAOvD,EAAE,CAAC2D,WAAW;EACvB;EACA,IAAIzC,KAAK,GAAGpB,MAAM,CAAC2D,OAAO,EAAE;IAC1B,OAAOzD,EAAE,CAAC4D,YAAY;EACxB;EACA,OAAO5D,EAAE,CAAC4D,YAAY;AACxB"}
|
|
1
|
+
{"version":3,"file":"webgl-buffer.js","names":["Buffer","assert","GL","DEBUG_DATA_LENGTH","WEBGLBuffer","constructor","device","props","arguments","length","undefined","_defineProperty","gl","gl2","handle","createBuffer","setSpectorMetadata","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","readAsync","Uint8Array","dstOffset","COPY_READ_BUFFER","getBufferSubData","_invalidateDebugData","_getReadTarget","INDEX","ELEMENT_ARRAY_BUFFER","VERTEX","ARRAY_BUFFER","UNIFORM","UNIFORM_BUFFER","STATIC_DRAW","DYNAMIC_DRAW"],"sources":["../../../src/adapter/resources/webgl-buffer.ts"],"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 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 \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 ).handle : undefined;\n this.handle = handle || this.gl.createBuffer();\n device.setSpectorMetadata(this.handle, {...this.props, data: typeof this.props.data});\n\n // In WebGL1, need to make sure we use GL.ELEMENT_ARRAY_BUFFER when initializing element buffers\n // otherwise buffer type will lock to generic (non-element) buffer\n // In WebGL2, we can use GL.COPY_READ_BUFFER which avoids locking the type here\n // @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 // @ts-expect-error\n this.handle = null;\n }\n }\n\n override write(data: ArrayBufferView, byteOffset: number = 0): void {\n const srcOffset = 0;\n const byteLength = undefined; // data.byteLength;\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n const 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 this.gl2.bufferSubData(target, byteOffset, 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"],"mappings":";AACA,SAAQA,MAAM,EAAEC,MAAM,QAAO,cAAc;AAC3C,SAAQC,EAAE,QAAO,oBAAoB;AAGrC,MAAMC,iBAAiB,GAAG,EAAE;AAG5B,OAAO,MAAMC,WAAW,SAASJ,MAAM,CAAC;EAgBtCK,WAAWA,CAACC,MAAmB,EAA2B;IAAA,IAAzBC,KAAkB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACtD,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAACI,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,oBARS,IAAI;IAAAA,eAAA;IAUlC,IAAI,CAACL,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACM,EAAE,GAAG,IAAI,CAACN,MAAM,CAACM,EAAE;IACxB,IAAI,CAACC,GAAG,GAAG,IAAI,CAACP,MAAM,CAACO,GAAG;IAE1B,MAAMC,MAAM,GAAG,OAAOP,KAAK,KAAK,QAAQ,GAAIA,KAAK,CAAGO,MAAM,GAAGJ,SAAS;IACtE,IAA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yD,MAAM,EAAE;IACzB,OAAOvD,EAAE,CAAC2D,WAAW;EACvB;EACA,IAAIzC,KAAK,GAAGpB,MAAM,CAAC2D,OAAO,EAAE;IAC1B,OAAOzD,EAAE,CAAC4D,YAAY;EACxB;EACA,OAAO5D,EAAE,CAAC4D,YAAY;AACxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CopyBufferToBufferOptions, CopyBufferToTextureOptions, CopyTextureToBufferOptions, CopyTextureToTextureOptions } from '@luma.gl/api';
|
|
2
2
|
import { CommandBuffer } from '@luma.gl/api';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from '../webgl-device';
|
|
5
5
|
type CopyBufferToBufferCommand = {
|
|
6
6
|
name: 'copy-buffer-to-buffer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EAId,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-command-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EAId,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAS5C,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,yBAAyB,CAAC;CACpC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,0BAA0B,CAAC;CACrC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,0BAA0B,CAAC;CACrC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,2BAA2B,CAAC;CACtC,CAAC;AAEF,KAAK,OAAO,GACR,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,2BAA2B,CAAC;AAEhC,qBAAa,kBAAmB,SAAQ,aAAa;IACnD,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAM;gBAEb,MAAM,EAAE,WAAW;IAK/B,cAAc,CAAC,QAAQ,GAAE,OAAO,EAAkB;CAkBnD;AAyQD,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAmB1D;AAGD,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAcjD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { CommandBuffer, Texture } from '@luma.gl/api';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
4
|
import { WEBGLTexture } from "./webgl-texture.js";
|
|
5
5
|
function cast(value) {
|
|
6
6
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-buffer.js","names":["CommandBuffer","Texture","GL","WEBGLTexture","cast","value","WEBGLCommandBuffer","constructor","device","_defineProperty","submitCommands","commands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","assertWebGL2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error","mipLevel","aspect","width","height","depthOrArrayLayers","origin","byteOffset","bytesPerRow","rowsPerImage","framebuffer","destroyFramebuffer","getFramebuffer","webglBuffer","sourceWidth","sourceHeight","sourceFormat","RGBA","sourceType","UNSIGNED_BYTE","PIXEL_PACK_BUFFER","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","destinationMipmaplevel","destinationInternalFormat","sourceX","sourceY","isSubCopy","gl","texture","textureTarget","Number","isFinite","bind","copyTexImage2D","unbind","prevHandle","glFormatToComponents","format","ALPHA","R32F","RED","RG32F","RG","RGB","RGB32F","RGBA32F","glTypeToBytes","type","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","FLOAT","id","createFramebuffer","concat","colorAttachments"],"sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\nimport {\n CommandBuffer,\n Texture,\n // Buffer,\n Framebuffer\n} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\n// import {getTypedArrayFromGLType, getGLTypeFromTypedArray} from '../../classic/typed-array-utils';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device: WebGLDevice;\n commands: Command[] = [];\n\n constructor(device: WebGLDevice) {\n super({});\n this.device = device;\n }\n\n submitCommands(commands: Command[] = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n }\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const gl2 = device.assertWebGL2();\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {\n throw new Error('Not implemented');\n}\n\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all',\n\n /** Width to copy */\n width = options.source.width,\n /** Height to copy */\n height = options.source.height,\n depthOrArrayLayers = 0,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Destination buffer */\n destination,\n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0,\n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow,\n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage\n } = options;\n\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('not supported');\n }\n\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const gl2 = device.assertWebGL2();\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n try {\n const webglBuffer = destination as WEBGLBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n\n // TODO - hack - should be deduced\n const sourceFormat = GL.RGBA;\n const sourceType = GL.UNSIGNED_BYTE;\n\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n\n gl2.readPixels(\n origin[0],\n origin[1],\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n byteOffset\n );\n } finally {\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, null);\n\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Texture to copy to/from. */\n destination,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n\n } = options;\n\n let {\n width = options.destination.width,\n height = options.destination.width,\n // depthOrArrayLayers = 0\n } = options;\n\n const destinationMipmaplevel = 0;\n const destinationInternalFormat = GL.RGBA;\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n const [sourceX, sourceY] = origin;\n\n const isSubCopy = false;\n // typeof destinationX !== 'undefined' ||\n // typeof destinationY !== 'undefined' ||\n // typeof destinationZ !== 'undefined';\n\n // destinationX = destinationX || 0;\n // destinationY = destinationY || 0;\n // destinationZ = destinationZ || 0;\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n\n let texture = null;\n let textureTarget: GL;\n if (destination instanceof WEBGLTexture) {\n texture = destination;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.destination;\n } else {\n throw new Error('whoops');\n // textureTarget = destination;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n destinationMipmaplevel,\n destinationInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n // switch (textureTarget) {\n // case GL.TEXTURE_2D:\n // case GL.TEXTURE_CUBE_MAP:\n // device.gl.copyTexSubImage2D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // case GL.TEXTURE_2D_ARRAY:\n // case GL.TEXTURE_3D:\n // const gl2 = device.assertWebGL2();\n // gl2.copyTexSubImage3D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // destinationZ,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // default:\n // }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format): 1 | 2 | 3 | 4 {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type: GL): 1 | 2 | 4 {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n\n// Helper methods\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n destroyFramebuffer: boolean;\n} {\n if (source instanceof Texture) {\n const {width, height, id} = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n }) as unknown as WEBGLFramebuffer;\n\n return {framebuffer, destroyFramebuffer: true};\n }\n return {framebuffer: source as unknown as WEBGLFramebuffer, destroyFramebuffer: false};\n}\n"],"mappings":";AAQA,SACEA,aAAa,EACbC,OAAO,QAGF,cAAc;AACrB,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAK5BC,YAAY;AAGpB,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,OAAO,MAAMC,kBAAkB,SAASN,aAAa,CAAC;EAIpDO,WAAWA,CAACC,MAAmB,EAA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C;MAClDD,EAAE,qBAAAE,MAAA,CAAqBF,EAAE,CAAE;MAC3BpD,KAAK;MACLC,MAAM;MACNsD,gBAAgB,EAAE,CAACxE,MAAM;IAC3B,CAAC,CAAgC;IAEjC,OAAO;MAACwB,WAAW;MAAEC,kBAAkB,EAAE;IAAI,CAAC;EAChD;EACA,OAAO;IAACD,WAAW,EAAExB,MAAqC;IAAEyB,kBAAkB,EAAE;EAAK,CAAC;AACxF"}
|
|
1
|
+
{"version":3,"file":"webgl-command-buffer.js","names":["CommandBuffer","Texture","GL","WEBGLTexture","cast","value","WEBGLCommandBuffer","constructor","device","_defineProperty","submitCommands","commands","arguments","length","undefined","command","name","_copyBufferToBuffer","options","_copyBufferToTexture","_copyTextureToBuffer","_copyTextureToTexture","source","destination","gl2","assertWebGL2","_options$sourceOffset","_options$destinationO","bindBuffer","COPY_READ_BUFFER","handle","COPY_WRITE_BUFFER","copyBufferSubData","sourceOffset","destinationOffset","size","Error","mipLevel","aspect","width","height","depthOrArrayLayers","origin","byteOffset","bytesPerRow","rowsPerImage","framebuffer","destroyFramebuffer","getFramebuffer","webglBuffer","sourceWidth","sourceHeight","sourceFormat","RGBA","sourceType","UNSIGNED_BYTE","PIXEL_PACK_BUFFER","bindFramebuffer","FRAMEBUFFER","readPixels","destroy","destinationMipmaplevel","destinationInternalFormat","sourceX","sourceY","isSubCopy","gl","texture","textureTarget","Number","isFinite","bind","copyTexImage2D","unbind","prevHandle","glFormatToComponents","format","ALPHA","R32F","RED","RG32F","RG","RGB","RGB32F","RGBA32F","glTypeToBytes","type","UNSIGNED_SHORT_5_6_5","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","FLOAT","id","createFramebuffer","concat","colorAttachments"],"sources":["../../../src/adapter/resources/webgl-command-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\nimport {\n CommandBuffer,\n Texture,\n // Buffer,\n Framebuffer\n} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\n\n// import {getTypedArrayFromGLType, getGLTypeFromTypedArray} from '../../classic/typed-array-utils';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLBuffer} from './webgl-buffer';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLFramebuffer} from './webgl-framebuffer';\n\nfunction cast<T>(value: unknown): T {\n return value as T;\n}\n\ntype CopyBufferToBufferCommand = {\n name: 'copy-buffer-to-buffer';\n options: CopyBufferToBufferOptions;\n};\n\ntype CopyBufferToTextureCommand = {\n name: 'copy-buffer-to-texture';\n options: CopyBufferToTextureOptions;\n};\n\ntype CopyTextureToBufferCommand = {\n name: 'copy-texture-to-buffer';\n options: CopyTextureToBufferOptions;\n};\n\ntype CopyTextureToTextureCommand = {\n name: 'copy-texture-to-texture';\n options: CopyTextureToTextureOptions;\n};\n\ntype Command =\n | CopyBufferToBufferCommand\n | CopyBufferToTextureCommand\n | CopyTextureToBufferCommand\n | CopyTextureToTextureCommand;\n\nexport class WEBGLCommandBuffer extends CommandBuffer {\n device: WebGLDevice;\n commands: Command[] = [];\n\n constructor(device: WebGLDevice) {\n super({});\n this.device = device;\n }\n\n submitCommands(commands: Command[] = this.commands) {\n for (const command of commands) {\n switch (command.name) {\n case 'copy-buffer-to-buffer':\n _copyBufferToBuffer(this.device, command.options);\n break;\n case 'copy-buffer-to-texture':\n _copyBufferToTexture(this.device, command.options);\n break;\n case 'copy-texture-to-buffer':\n _copyTextureToBuffer(this.device, command.options);\n break;\n case 'copy-texture-to-texture':\n _copyTextureToTexture(this.device, command.options);\n break;\n }\n }\n }\n}\n\nfunction _copyBufferToBuffer(device: WebGLDevice, options: CopyBufferToBufferOptions): void {\n const source = cast<WEBGLBuffer>(options.source);\n const destination = cast<WEBGLBuffer>(options.destination);\n\n const gl2 = device.assertWebGL2();\n if (gl2) {\n // In WebGL2 we can perform the copy on the GPU\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl2.bindBuffer(GL.COPY_READ_BUFFER, source.handle);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, destination.handle);\n gl2.copyBufferSubData(\n GL.COPY_READ_BUFFER,\n GL.COPY_WRITE_BUFFER,\n options.sourceOffset ?? 0,\n options.destinationOffset ?? 0,\n options.size\n );\n gl2.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl2.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n } else {\n // TODO - in WebGL1 we would have to read back to CPU\n // read / write buffer from / to CPU\n throw new Error('copyBufferToBuffer not implemented in WebGL1');\n }\n}\n\n/**\n * Copies data from a Buffer object into a Texture object\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyBufferToTexture(device: WebGLDevice, options: CopyBufferToTextureOptions): void {\n throw new Error('Not implemented');\n}\n\n/**\n * Copies data from a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete\n */\nfunction _copyTextureToBuffer(device: WebGLDevice, options: CopyTextureToBufferOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n aspect = 'all',\n\n /** Width to copy */\n width = options.source.width,\n /** Height to copy */\n height = options.source.height,\n depthOrArrayLayers = 0,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Destination buffer */\n destination,\n /** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */\n byteOffset = 0,\n /**\n * The stride, in bytes, between the beginning of each block row and the subsequent block row.\n * Required if there are multiple block rows (i.e. the copy height or depth is more than one block).\n */\n bytesPerRow,\n /**\n * Number of block rows per single image of the texture.\n * rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.\n * Required if there are multiple images (i.e. the copy depth is more than one).\n */\n rowsPerImage\n } = options;\n\n // TODO - Not possible to read just stencil or depth part in WebGL?\n if (aspect !== 'all') {\n throw new Error('not supported');\n }\n\n // TODO - mipLevels are set when attaching texture to framebuffer\n if (mipLevel !== 0 || depthOrArrayLayers !== undefined || bytesPerRow || rowsPerImage) {\n throw new Error('not implemented');\n }\n\n // Asynchronous read (PIXEL_PACK_BUFFER) is WebGL2 only feature\n const gl2 = device.assertWebGL2();\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n try {\n const webglBuffer = destination as WEBGLBuffer;\n const sourceWidth = width || framebuffer.width;\n const sourceHeight = height || framebuffer.height;\n\n // TODO - hack - should be deduced\n const sourceFormat = GL.RGBA;\n const sourceType = GL.UNSIGNED_BYTE;\n\n // if (!target) {\n // // Create new buffer with enough size\n // const components = glFormatToComponents(sourceFormat);\n // const byteCount = glTypeToBytes(sourceType);\n // const byteLength = byteOffset + sourceWidth * sourceHeight * components * byteCount;\n // target = device.createBuffer({byteLength});\n // }\n\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, webglBuffer.handle);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n\n gl2.readPixels(\n origin[0],\n origin[1],\n sourceWidth,\n sourceHeight,\n sourceFormat,\n sourceType,\n byteOffset\n );\n } finally {\n gl2.bindBuffer(GL.PIXEL_PACK_BUFFER, null);\n gl2.bindFramebuffer(GL.FRAMEBUFFER, null);\n\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n }\n}\n\n/**\n * Copies data from a Framebuffer or a Texture object into a Buffer object.\n * NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transfer.\nexport function readPixelsToBuffer(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n): Buffer\n */\n\n/**\n * Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)\n */\n// eslint-disable-next-line complexity, max-statements\nfunction _copyTextureToTexture(device: WebGLDevice, options: CopyTextureToTextureOptions): void {\n const {\n /** Texture to copy to/from. */\n source,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // mipLevel = 0,\n /** Defines which aspects of the texture to copy to/from. */\n // aspect = 'all',\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n origin = [0, 0],\n\n /** Texture to copy to/from. */\n destination,\n /** Mip-map level of the texture to copy to/from. (Default 0) */\n // destinationMipLevel = options.mipLevel,\n /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */\n // destinationOrigin = [0, 0],\n /** Defines which aspects of the texture to copy to/from. */\n // destinationAspect = options.aspect,\n\n } = options;\n\n let {\n width = options.destination.width,\n height = options.destination.width,\n // depthOrArrayLayers = 0\n } = options;\n\n const destinationMipmaplevel = 0;\n const destinationInternalFormat = GL.RGBA;\n\n const {framebuffer, destroyFramebuffer} = getFramebuffer(source);\n const [sourceX, sourceY] = origin;\n\n const isSubCopy = false;\n // typeof destinationX !== 'undefined' ||\n // typeof destinationY !== 'undefined' ||\n // typeof destinationZ !== 'undefined';\n\n // destinationX = destinationX || 0;\n // destinationY = destinationY || 0;\n // destinationZ = destinationZ || 0;\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, framebuffer.handle);\n // TODO - support gl.readBuffer (WebGL2 only)\n // const prevBuffer = gl.readBuffer(attachment);\n\n let texture = null;\n let textureTarget: GL;\n if (destination instanceof WEBGLTexture) {\n texture = destination;\n width = Number.isFinite(width) ? width : texture.width;\n height = Number.isFinite(height) ? height : texture.height;\n texture.bind(0);\n textureTarget = texture.destination;\n } else {\n throw new Error('whoops');\n // textureTarget = destination;\n }\n\n if (!isSubCopy) {\n device.gl.copyTexImage2D(\n textureTarget,\n destinationMipmaplevel,\n destinationInternalFormat,\n sourceX,\n sourceY,\n width,\n height,\n 0 /* border must be 0 */\n );\n } else {\n // switch (textureTarget) {\n // case GL.TEXTURE_2D:\n // case GL.TEXTURE_CUBE_MAP:\n // device.gl.copyTexSubImage2D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // case GL.TEXTURE_2D_ARRAY:\n // case GL.TEXTURE_3D:\n // const gl2 = device.assertWebGL2();\n // gl2.copyTexSubImage3D(\n // textureTarget,\n // destinationMipmaplevel,\n // destinationX,\n // destinationY,\n // destinationZ,\n // sourceX,\n // sourceY,\n // width,\n // height\n // );\n // break;\n // default:\n // }\n }\n if (texture) {\n texture.unbind();\n }\n // @ts-expect-error\n device.gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (destroyFramebuffer) {\n framebuffer.destroy();\n }\n return texture;\n}\n\n// Returns number of components in a specific readPixels WebGL format\nexport function glFormatToComponents(format): 1 | 2 | 3 | 4 {\n switch (format) {\n case GL.ALPHA:\n case GL.R32F:\n case GL.RED:\n return 1;\n case GL.RG32F:\n case GL.RG:\n return 2;\n case GL.RGB:\n case GL.RGB32F:\n return 3;\n case GL.RGBA:\n case GL.RGBA32F:\n return 4;\n // TODO: Add support for additional WebGL2 formats\n default:\n throw new Error('GLFormat');\n }\n}\n\n// Return byte count for given readPixels WebGL type\nexport function glTypeToBytes(type: GL): 1 | 2 | 4 {\n switch (type) {\n case GL.UNSIGNED_BYTE:\n return 1;\n case GL.UNSIGNED_SHORT_5_6_5:\n case GL.UNSIGNED_SHORT_4_4_4_4:\n case GL.UNSIGNED_SHORT_5_5_5_1:\n return 2;\n case GL.FLOAT:\n return 4;\n // TODO: Add support for additional WebGL2 types\n default:\n throw new Error('GLType');\n }\n}\n\n// Helper methods\n\nfunction getFramebuffer(source: Texture | Framebuffer): {\n framebuffer: WEBGLFramebuffer;\n destroyFramebuffer: boolean;\n} {\n if (source instanceof Texture) {\n const {width, height, id} = source;\n const framebuffer = source.device.createFramebuffer({\n id: `framebuffer-for-${id}`,\n width,\n height,\n colorAttachments: [source]\n }) as unknown as WEBGLFramebuffer;\n\n return {framebuffer, destroyFramebuffer: true};\n }\n return {framebuffer: source as unknown as WEBGLFramebuffer, destroyFramebuffer: false};\n}\n"],"mappings":";AAQA,SACEA,aAAa,EACbC,OAAO,QAGF,cAAc;AACrB,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAK9BC,YAAY;AAGpB,SAASC,IAAIA,CAAIC,KAAc,EAAK;EAClC,OAAOA,KAAK;AACd;AA4BA,OAAO,MAAMC,kBAAkB,SAASN,aAAa,CAAC;EAIpDO,WAAWA,CAACC,MAAmB,EAAE;IAC/B,KAAK,CAAC,CAAC,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA,mBAHU,EAAE;IAItB,IAAI,CAACD,MAAM,GAAGA,MAAM;EACtB;EAEAE,cAAcA,CAAA,EAAsC;IAAA,IAArCC,QAAmB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACD,QAAQ;IAChD,KAAK,MAAMI,OAAO,IAAIJ,QAAQ,EAAE;MAC9B,QAAQI,OAAO,CAACC,IAAI;QAClB,KAAK,uBAAuB;UAC1BC,mBAAmB,CAAC,IAAI,CAACT,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UACjD;QACF,KAAK,wBAAwB;UAC3BC,oBAAoB,CAAC,IAAI,CAACX,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UAClD;QACF,KAAK,wBAAwB;UAC3BE,oBAAoB,CAAC,IAAI,CAACZ,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UAClD;QACF,KAAK,yBAAyB;UAC5BG,qBAAqB,CAAC,IAAI,CAACb,MAAM,EAAEO,OAAO,CAACG,OAAO,CAAC;UACnD;MACJ;IACF;EACF;AACF;AAEA,SAASD,mBAAmBA,CAACT,MAAmB,EAAEU,OAAkC,EAAQ;EAC1F,MAAMI,MAAM,GAA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AC5B,KAAKrF,EAAE,CAACsF,sBAAsB;IAC9B,KAAKtF,EAAE,CAACuF,sBAAsB;MAC5B,OAAO,CAAC;IACV,KAAKvF,EAAE,CAACwF,KAAK;MACX,OAAO,CAAC;IAEV;MACE,MAAM,IAAItD,KAAK,CAAC,QAAQ,CAAC;EAC7B;AACF;AAIA,SAASY,cAAcA,CAAC1B,MAA6B,EAGnD;EACA,IAAIA,MAAM,YAAYrB,OAAO,EAAE;IAC7B,MAAM;MAACsC,KAAK;MAAEC,MAAM;MAAEmD;IAAE,CAAC,GAAGrE,MAAM;IAClC,MAAMwB,WAAW,GAAGxB,MAAM,CAACd,MAAM,CAACoF,iBAAiB,CAAC;MAClDD,EAAE,qBAAAE,MAAA,CAAqBF,EAAE,CAAE;MAC3BpD,KAAK;MACLC,MAAM;MACNsD,gBAAgB,EAAE,CAACxE,MAAM;IAC3B,CAAC,CAAgC;IAEjC,OAAO;MAACwB,WAAW;MAAEC,kBAAkB,EAAE;IAAI,CAAC;EAChD;EACA,OAAO;IAACD,WAAW,EAAExB,MAAqC;IAAEyB,kBAAkB,EAAE;EAAK,CAAC;AACxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/api';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}\n"],"mappings":";AAAA,SAAQA,cAAc,QAA4B,cAAc;AAAC,SAQzDC,kBAAkB;AAG1B,OAAO,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAKtDG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACb,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,aAAa,GAAG,IAAIN,kBAAkB,CAACG,MAAM,CAAC;EACrD;EAESI,OAAOA,CAAA,EAAS,CAAC;EAEjBC,MAAMA,CAAA,EAAS;IACtB,IAAI,CAACF,aAAa,CAACG,cAAc,
|
|
1
|
+
{"version":3,"file":"webgl-command-encoder.js","names":["CommandEncoder","WEBGLCommandBuffer","WEBGLCommandEncoder","constructor","device","props","_defineProperty","commandBuffer","destroy","finish","submitCommands","copyBufferToBuffer","options","commands","push","name","copyBufferToTexture","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgl-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps} from '@luma.gl/api';\nimport type {\n CopyBufferToBufferOptions,\n CopyBufferToTextureOptions,\n CopyTextureToBufferOptions,\n CopyTextureToTextureOptions\n} from '@luma.gl/api';\n\nimport {WEBGLCommandBuffer} from './webgl-command-buffer';\nimport {WebGLDevice} from '../webgl-device';\n\nexport class WEBGLCommandEncoder extends CommandEncoder {\n readonly device: WebGLDevice;\n\n readonly commandBuffer: WEBGLCommandBuffer;\n\n constructor(device: WebGLDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.commandBuffer = new WEBGLCommandBuffer(device);\n }\n\n override destroy(): void {}\n\n override finish(): void {\n this.commandBuffer.submitCommands();\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n // finish(options?: {id?: string}): GPUCommandBuffer;\n\n copyBufferToBuffer(options: CopyBufferToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-buffer', options});\n }\n\n copyBufferToTexture(options: CopyBufferToTextureOptions) {\n this.commandBuffer.commands.push({name: 'copy-buffer-to-texture', options});\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-buffer', options});\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n this.commandBuffer.commands.push({name: 'copy-texture-to-texture', options});\n }\n\n override pushDebugGroup(groupLabel: string): void {}\n override popDebugGroup() {}\n\n override insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}\n"],"mappings":";AAAA,SAAQA,cAAc,QAA4B,cAAc;AAAC,SAQzDC,kBAAkB;AAG1B,OAAO,MAAMC,mBAAmB,SAASF,cAAc,CAAC;EAKtDG,WAAWA,CAACC,MAAmB,EAAEC,KAA0B,EAAE;IAC3D,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACb,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,aAAa,GAAG,IAAIN,kBAAkB,CAACG,MAAM,CAAC;EACrD;EAESI,OAAOA,CAAA,EAAS,CAAC;EAEjBC,MAAMA,CAAA,EAAS;IACtB,IAAI,CAACF,aAAa,CAACG,cAAc,CAAC,CAAC;EACrC;EAMAC,kBAAkBA,CAACC,OAAkC,EAAQ;IAC3D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,uBAAuB;MAAEH;IAAO,CAAC,CAAC;EAC5E;EAEAI,mBAAmBA,CAACJ,OAAmC,EAAE;IACvD,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAK,mBAAmBA,CAACL,OAAmC,EAAQ;IAC7D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,wBAAwB;MAAEH;IAAO,CAAC,CAAC;EAC7E;EAEAM,oBAAoBA,CAACN,OAAoC,EAAQ;IAC/D,IAAI,CAACL,aAAa,CAACM,QAAQ,CAACC,IAAI,CAAC;MAACC,IAAI,EAAE,yBAAyB;MAAEH;IAAO,CAAC,CAAC;EAC9E;EAESO,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAG,CAAC;EAEjBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;AAWzD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FramebufferProps, TextureFormat } from '@luma.gl/api';
|
|
2
2
|
import { Framebuffer, Texture } from '@luma.gl/api';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
4
|
import { WebGLDevice } from '../webgl-device';
|
|
5
5
|
import { WEBGLTexture } from './webgl-texture';
|
|
6
6
|
import { WEBGLRenderbuffer } from '../objects/webgl-renderbuffer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAClE,OAAO,EAAC,WAAW,EAAE,OAAO,EAAS,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAClE,OAAO,EAAC,WAAW,EAAE,OAAO,EAAS,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAGhE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC5D,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAE9E,iDAAiD;AACjD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,qBAAqB,CAAC;IAC1B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,IAAI,OAAO,iDAEV;gBAEW,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB;IA8CxD,+CAA+C;IACtC,OAAO,IAAI,IAAI;IAUxB,uBAAuB;IACvB,SAAS,CAAC,YAAY,IAAI,IAAI;IAW9B,mGAAmG;cAChF,yBAAyB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAW5E;;OAEG;cACgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA2BzE,4BAA4B;IAC5B,SAAS,CAAC,UAAU,CAClB,eAAe,EAAE,EAAE,EACnB,UAAU,EAAE,UAAU,GACrB,YAAY,GAAG,iBAAiB;IAenC,SAAS,CAAC,wBAAwB,CAAC,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,iBAAiB,GAAG,IAAI;IASzF;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CACtB,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI;CA2BR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Framebuffer, assert } from '@luma.gl/api';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
4
|
import { WEBGLTexture } from "./webgl-texture.js";
|
|
5
5
|
import { WEBGLRenderbuffer } from "../objects/webgl-renderbuffer.js";
|
|
6
6
|
import { getDepthStencilAttachmentWebGL } from "../converters/texture-formats.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getDepthStencilAttachmentWebGL","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","isDefaultFramebuffer","handle","gl","createFramebuffer","setSpectorMetadata","id","autoCreateAttachmentTextures","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","depthStencilAttachment","format","check","_checkStatus","destroy","destroyed","deleteFramebuffer","prevHandle","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","createDepthStencilTexture","width","height","resizeAttachments","drawingBufferWidth","drawingBufferHeight","undefined","colorAttachment","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, TextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture, assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() {\n return this.colorAttachments[0];\n }\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n /** Attach from a map of attachments */\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment as WEBGLTexture);\n }\n }\n\n if (this.depthStencilAttachment) {\n this._attachOne(\n getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),\n this.depthStencilAttachment as WEBGLTexture\n );\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);\n }\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n // TODO - should we really rely on this trick? \n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n protected override createDepthStencilTexture(format: TextureFormat): Texture {\n return new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n }) as unknown as WEBGLTexture;\n }\n\n /** \n * Attachment resize is expected to be a noop if size is same \n */\n protected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n (colorAttachment as WEBGLTexture).resize({width, height});\n }\n if (this.depthStencilAttachment) {\n (this.depthStencilAttachment as WEBGLTexture).resize({width, height});\n }\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(\n attachmentPoint: GL,\n attachment: Attachment\n ): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(\n attachment: GL,\n texture: WEBGLTexture,\n layer: number,\n level: number\n ): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAWC,MAAM,QAAO,cAAc;AACzD,OAAOC,EAAE,MAAM,oBAAoB;AAAC,SAE5BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,8BAA8B;AAMtC,OAAO,MAAMC,gBAAgB,SAASN,WAAW,CAAC;EAKhD,IAAIO,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EACjC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAAuB,EAAE;IACxD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAGrB,MAAMC,oBAAoB,GAAGF,KAAK,CAACG,MAAM,KAAK,IAAI;IAElD,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAGL,MAAM,CAACK,EAAE;IACnB,IAAI,CAACD,MAAM,GACT,IAAI,CAACH,KAAK,CAACG,MAAM,IAAID,oBAAoB,GAAG,IAAI,CAACF,KAAK,CAACG,MAAM,GAAG,IAAI,CAACC,EAAE,CAACC,iBAAiB,EAAE;IAE7F,IAAI,CAACH,oBAAoB,EAAE;MAEzBH,MAAM,CAACO,kBAAkB,CAAC,IAAI,CAACH,MAAM,EAAE;QAACI,EAAE,EAA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E,CAACwE,yCAAyC;MAC/C,OAAO,gBAAgB;IACzB,KAAKxE,EAAE,CAACyE,iCAAiC;MACvC,OAAO,uBAAuB;IAChC,KAAKzE,EAAE,CAAC0E,uBAAuB;MAC7B,OAAO,kCAAkC;IAE3C,KAAK1E,EAAE,CAAC2E,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,UAAArC,MAAA,CAAUJ,MAAM;EAAG;AAEzB"}
|
|
1
|
+
{"version":3,"file":"webgl-framebuffer.js","names":["Framebuffer","assert","GL","WEBGLTexture","WEBGLRenderbuffer","getDepthStencilAttachmentWebGL","WEBGLFramebuffer","texture","colorAttachments","constructor","device","props","_defineProperty","isDefaultFramebuffer","handle","gl","createFramebuffer","setSpectorMetadata","id","autoCreateAttachmentTextures","bindFramebuffer","FRAMEBUFFER","i","length","attachment","attachmentPoint","COLOR_ATTACHMENT0","_attachOne","depthStencilAttachment","format","check","_checkStatus","destroy","destroyed","deleteFramebuffer","prevHandle","status","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","Error","concat","_getFrameBufferStatus","createDepthStencilTexture","width","height","resizeAttachments","drawingBufferWidth","drawingBufferHeight","undefined","colorAttachment","resize","_attachWEBGLRenderbuffer","Array","isArray","layer","level","_attachTexture","renderbuffer","framebufferRenderbuffer","RENDERBUFFER","gl2","bindTexture","target","TEXTURE_2D_ARRAY","TEXTURE_3D","assertWebGL2","framebufferTextureLayer","TEXTURE_CUBE_MAP","face","mapIndexToCubeMapFace","framebufferTexture2D","TEXTURE_2D","TEXTURE_CUBE_MAP_POSITIVE_X","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"],"sources":["../../../src/adapter/resources/webgl-framebuffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {FramebufferProps, TextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture, assert} from '@luma.gl/api';\nimport {GL} from '@luma.gl/constants';\nimport {WebGLDevice} from '../webgl-device';\nimport {WEBGLTexture} from './webgl-texture';\nimport {WEBGLRenderbuffer} from '../objects/webgl-renderbuffer';\nimport {getDepthStencilAttachmentWebGL} from '../converters/texture-formats';\n\nexport type TextureAttachment = [Texture, number?, number?];\nexport type Attachment = WEBGLTexture | WEBGLRenderbuffer | TextureAttachment;\n\n/** luma.gl Framebuffer, WebGL implementation */\nexport class WEBGLFramebuffer extends Framebuffer {\n device: WebGLDevice;\n gl: WebGLRenderingContext;\n handle: WebGLFramebuffer;\n\n get texture() {\n return this.colorAttachments[0];\n }\n\n constructor(device: WebGLDevice, props: FramebufferProps) {\n super(device, props);\n\n // WebGL default framebuffer handle is null\n const isDefaultFramebuffer = props.handle === null;\n\n this.device = device;\n this.gl = device.gl;\n this.handle =\n this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();\n\n if (!isDefaultFramebuffer) {\n // default framebuffer handle is null, so we can't set spector metadata...\n device.setSpectorMetadata(this.handle, {id: this.props.id, props: this.props});\n\n // Auto create textures for attachments if needed\n this.autoCreateAttachmentTextures();\n\n /** Attach from a map of attachments */\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle);\n\n // Walk the attachments\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n const attachment = this.colorAttachments[i];\n const attachmentPoint = GL.COLOR_ATTACHMENT0 + i;\n if (attachment) {\n this._attachOne(attachmentPoint, attachment as WEBGLTexture);\n }\n }\n\n if (this.depthStencilAttachment) {\n this._attachOne(\n getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format),\n this.depthStencilAttachment as WEBGLTexture\n );\n }\n\n this.gl.bindFramebuffer(GL.FRAMEBUFFER, null);\n }\n\n // @ts-expect-error\n if (props.check !== false) {\n this._checkStatus();\n }\n }\n\n /** destroys any auto created resources etc. */\n override destroy(): void {\n super.destroy(); // destroys owned resources etc.\n if (!this.destroyed && this.handle !== null) {\n this.gl.deleteFramebuffer(this.handle);\n // this.handle = null;\n }\n }\n\n // PRIVATE\n\n /** Check the status */\n protected _checkStatus(): void {\n const {gl} = this;\n // TODO - should we really rely on this trick? \n const prevHandle = gl.bindFramebuffer(GL.FRAMEBUFFER, this.handle) as unknown as WebGLFramebuffer;\n const status = gl.checkFramebufferStatus(GL.FRAMEBUFFER);\n gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);\n }\n }\n\n /** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */\n protected override createDepthStencilTexture(format: TextureFormat): Texture {\n return new WEBGLRenderbuffer(this.device, {\n id: `${this.id}-depth-stencil`, // TODO misleading if not depth and stencil?\n format,\n // dataFormat: GL.DEPTH_STENCIL,\n // type: GL.UNSIGNED_INT_24_8,\n width: this.width,\n height: this.height\n }) as unknown as WEBGLTexture;\n }\n\n /** \n * Attachment resize is expected to be a noop if size is same \n */\n protected override resizeAttachments(width: number, height: number): this {\n // for default framebuffer, just update the stored size\n if (this.handle === null) {\n // assert(width === undefined && height === undefined);\n this.width = this.gl.drawingBufferWidth;\n this.height = this.gl.drawingBufferHeight;\n return this;\n }\n\n if (width === undefined) {\n width = this.gl.drawingBufferWidth;\n }\n if (height === undefined) {\n height = this.gl.drawingBufferHeight;\n }\n\n // TODO Not clear that this is better than default destroy/create implementation\n\n for (const colorAttachment of this.colorAttachments) {\n (colorAttachment as WEBGLTexture).resize({width, height});\n }\n if (this.depthStencilAttachment) {\n (this.depthStencilAttachment as WEBGLTexture).resize({width, height});\n }\n return this;\n }\n\n /** Attach one attachment */\n protected _attachOne(\n attachmentPoint: GL,\n attachment: Attachment\n ): WEBGLTexture | WEBGLRenderbuffer {\n if (attachment instanceof WEBGLRenderbuffer) {\n this._attachWEBGLRenderbuffer(attachmentPoint, attachment);\n return attachment;\n } else if (Array.isArray(attachment)) {\n const [texture, layer = 0, level = 0] = attachment;\n this._attachTexture(attachmentPoint, texture as unknown as WEBGLTexture, layer, level);\n return texture as unknown as WEBGLTexture;\n } else if (attachment instanceof WEBGLTexture) {\n this._attachTexture(attachmentPoint, attachment, 0, 0);\n return attachment;\n }\n throw new Error('attach');\n }\n\n protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {\n this.gl.framebufferRenderbuffer(\n GL.FRAMEBUFFER,\n attachment,\n GL.RENDERBUFFER,\n renderbuffer.handle\n );\n }\n\n /**\n * @param attachment\n * @param texture\n * @param layer = 0 - index into WEBGLTextureArray and Texture3D or face for `TextureCubeMap`\n * @param level = 0 - mipmapLevel (must be 0 in WebGL1)\n */\n protected _attachTexture(\n attachment: GL,\n texture: WEBGLTexture,\n layer: number,\n level: number\n ): void {\n const {gl, gl2} = this.device;\n gl.bindTexture(texture.target, texture.handle);\n\n switch (texture.target) {\n case GL.TEXTURE_2D_ARRAY:\n case GL.TEXTURE_3D:\n this.device.assertWebGL2();\n gl2?.framebufferTextureLayer(GL.FRAMEBUFFER, attachment, texture.target, level, layer);\n break;\n\n case GL.TEXTURE_CUBE_MAP:\n // layer must be a cubemap face (or if index, converted to cube map face)\n const face = mapIndexToCubeMapFace(layer);\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, face, texture.handle, level);\n break;\n\n case GL.TEXTURE_2D:\n gl.framebufferTexture2D(GL.FRAMEBUFFER, attachment, GL.TEXTURE_2D, texture.handle, level);\n break;\n\n default:\n assert(false, 'Illegal texture type');\n }\n\n gl.bindTexture(texture.target, null);\n }\n}\n\n// Helper functions\n\n// Map an index to a cube map face constant\nfunction mapIndexToCubeMapFace(layer: number | GL): GL {\n // TEXTURE_CUBE_MAP_POSITIVE_X is a big value (0x8515)\n // if smaller assume layer is index, otherwise assume it is already a cube map face constant\n return layer < GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;\n}\n\n// Helper METHODS\n// Get a string describing the framebuffer error if installed\nfunction _getFrameBufferStatus(status: GL) {\n switch (status) {\n case GL.FRAMEBUFFER_COMPLETE:\n return 'success';\n case GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n return 'Mismatched attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n return 'No attachments';\n case GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n return 'Height/width mismatch';\n case GL.FRAMEBUFFER_UNSUPPORTED:\n return 'Unsupported or split attachments';\n // WebGL2\n case GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:\n return 'Samples mismatch';\n // OVR_multiview2 extension\n // case GL.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR: return 'baseViewIndex mismatch';\n default:\n return `${status}`;\n }\n}\n"],"mappings":";AAGA,SAAQA,WAAW,EAAWC,MAAM,QAAO,cAAc;AACzD,SAAQC,EAAE,QAAO,oBAAoB;AAAC,SAE9BC,YAAY;AAAA,SACZC,iBAAiB;AAAA,SACjBC,8BAA8B;AAMtC,OAAO,MAAMC,gBAAgB,SAASN,WAAW,CAAC;EAKhD,IAAIO,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAAC;EACjC;EAEAC,WAAWA,CAACC,MAAmB,EAAEC,KAAuB,EAAE;IACxD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAGrB,MAAMC,oBAAoB,GAAGF,KAAK,CAACG,MAAM,KAAK,IAAI;IAElD,IAAI,CAACJ,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACK,EAAE,GAAGL,MAAM,CAACK,EAAE;IACnB,IAAI,CAACD,MAAM,GACT,IAAI,CAACH,KAAK,CAACG,MAAM,IAAID,oBAAoB,GAAG,IAAI,CAACF,KAAK,CAACG,MAAM,GAAG,I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AAqBA,CAACL,MAAU,EAAE;EACzC,QAAQA,MAAM;IACZ,KAAKlC,EAAE,CAACoC,oBAAoB;MAC1B,OAAO,SAAS;IAClB,KAAKpC,EAAE,CAACuE,iCAAiC;MACvC,OAAO,wBAAwB;IACjC,KAAKvE,EAAE,CAACwE,yCAAyC;MAC/C,OAAO,gBAAgB;IACzB,KAAKxE,EAAE,CAACyE,iCAAiC;MACvC,OAAO,uBAAuB;IAChC,KAAKzE,EAAE,CAAC0E,uBAAuB;MAC7B,OAAO,kCAAkC;IAE3C,KAAK1E,EAAE,CAAC2E,kCAAkC;MACxC,OAAO,kBAAkB;IAG3B;MACE,UAAArC,MAAA,CAAUJ,MAAM;EACpB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-render-pass.js","names":["RenderPass","GL","withParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","WEBGLRenderPass","constructor","device","props","_defineProperty","setParameters","parameters","clear","end","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","arguments","length","undefined","glParameters","framebuffer","depthReadOnly","depthMask","stencilMask","stencilReadOnly","RASTERIZER_DISCARD","discard","viewport","depthRange","scissorTest","Boolean","scissorRect","scissor","blendConstant","blendColor","stencilReference","console","warn","STENCIL_REF","clearMask","clearColor","clearDepth","clearStencil","gl","clearColorBuffer","drawBuffer","value","gl2","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv"],"sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"sourcesContent":["import {RenderPass, RenderPassProps, NumericArray, RenderPassParameters} from '@luma.gl/api';\nimport {WebGLDevice} from '../webgl-device';\nimport {GL, GLParameters} from '@luma.gl/constants';\nimport {withParameters} from '../../context/state-tracker/with-parameters';\n\n// Should collapse during minification\n\nconst GL_DEPTH_BUFFER_BIT = 0x00000100;\nconst GL_STENCIL_BUFFER_BIT = 0x00000400;\nconst GL_COLOR_BUFFER_BIT = 0x00004000;\n\nconst GL_COLOR = 0x1800;\n\nexport class WEBGLRenderPass extends RenderPass {\n readonly device: WebGLDevice;\n\n /** Parameters that should be applied before each draw call */\n glParameters: GLParameters;\n\n constructor(device: WebGLDevice, props: RenderPassProps) {\n super(device, props);\n this.device = device;\n\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.setParameters(this.props.parameters);\n\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n\n end(): void {\n // should add commands to CommandEncoder.\n }\n\n pushDebugGroup(groupLabel: string): void {}\n popDebugGroup(): void {}\n insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters: RenderPassParameters = {}): void {\n const glParameters: GLParameters = {};\n\n // Framebuffers are specified using parameters in WebGL\n if (this.props.framebuffer) {\n glParameters.framebuffer = this.props.framebuffer;\n }\n\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n\n glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;\n\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n glParameters.viewport = parameters.viewport;\n glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];\n }\n glParameters.scissorTest = Boolean(parameters.scissorRect);\n if (parameters.scissorRect) {\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n parameters[GL.STENCIL_REF] = parameters.stencilReference;\n }\n\n this.glParameters = glParameters;\n }\n\n // Internal\n\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n protected clear(): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n let clearMask = 0;\n\n if (this.props.clearColor !== false) {\n clearMask |= GL_COLOR_BUFFER_BIT;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= GL_DEPTH_BUFFER_BIT;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= GL_STENCIL_BUFFER_BIT;\n glParameters.clearStencil = this.props.clearStencil;\n }\n\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withParameters(this.device, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n\n // TODO - clear multiple color attachments\n // for (attachment of this.framebuffer.colorAttachments) {\n // this.clearColorBuffer \n // }\n }\n }\n\n /** \n * WebGL2 - clear a specific color buffer \n */\n protected clearColorBuffer(drawBuffer: number = 0, value: NumericArray = [0, 0, 0, 0]) {\n withParameters(this.device.gl2, {framebuffer: this.props.framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int32Array:\n this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);\n break;\n case Uint32Array:\n this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);\n break;\n case Float32Array:\n default:\n this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);\n break;\n }\n });\n }\n\n // clearDepthStencil() {\n // const GL_DEPTH = 0x1801;\n // const GL_STENCIL = 0x1802;\n // const GL_DEPTH_STENCIL = 0x84f9;\n\n // case GL_DEPTH:\n // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);\n // break;\n\n // case GL_STENCIL:\n // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);\n // break;\n\n // case GL_DEPTH_STENCIL:\n // const [depth, stencil] = value;\n // this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);\n // break;\n\n // default:\n // assert(false, ERR_ARGUMENTS);\n // }\n // });\n}\n\n"],"mappings":";AAAA,SAAQA,UAAU,QAA4D,cAAc;AAE5F,SAAQC,EAAE,QAAqB,oBAAoB;AAAC,SAC5CC,cAAc;AAItB,MAAMC,mBAAmB,GAAG,UAAU;AACtC,MAAMC,qBAAqB,GAAG,UAAU;AACxC,MAAMC,mBAAmB,GAAG,UAAU;AAEtC,MAAMC,QAAQ,GAAG,MAAM;AAEvB,OAAO,MAAMC,eAAe,SAASP,UAAU,CAAC;EAM9CQ,WAAWA,CAACC,MAAmB,EAAEC,KAAsB,EAAE;IACvD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,IAAI,CAACG,aAAa,CAAC,IAAI,CAACF,KAAK,CAACG,UAAU,CAAC;IAGzC,IAAI,CAACC,KAAK,
|
|
1
|
+
{"version":3,"file":"webgl-render-pass.js","names":["RenderPass","GL","withParameters","GL_DEPTH_BUFFER_BIT","GL_STENCIL_BUFFER_BIT","GL_COLOR_BUFFER_BIT","GL_COLOR","WEBGLRenderPass","constructor","device","props","_defineProperty","setParameters","parameters","clear","end","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel","arguments","length","undefined","glParameters","framebuffer","depthReadOnly","depthMask","stencilMask","stencilReadOnly","RASTERIZER_DISCARD","discard","viewport","depthRange","scissorTest","Boolean","scissorRect","scissor","blendConstant","blendColor","stencilReference","console","warn","STENCIL_REF","clearMask","clearColor","clearDepth","clearStencil","gl","clearColorBuffer","drawBuffer","value","gl2","Int32Array","clearBufferiv","Uint32Array","clearBufferuiv","Float32Array","clearBufferfv"],"sources":["../../../src/adapter/resources/webgl-render-pass.ts"],"sourcesContent":["import {RenderPass, RenderPassProps, NumericArray, RenderPassParameters} from '@luma.gl/api';\nimport {WebGLDevice} from '../webgl-device';\nimport {GL, GLParameters} from '@luma.gl/constants';\nimport {withParameters} from '../../context/state-tracker/with-parameters';\n\n// Should collapse during minification\n\nconst GL_DEPTH_BUFFER_BIT = 0x00000100;\nconst GL_STENCIL_BUFFER_BIT = 0x00000400;\nconst GL_COLOR_BUFFER_BIT = 0x00004000;\n\nconst GL_COLOR = 0x1800;\n\nexport class WEBGLRenderPass extends RenderPass {\n readonly device: WebGLDevice;\n\n /** Parameters that should be applied before each draw call */\n glParameters: GLParameters;\n\n constructor(device: WebGLDevice, props: RenderPassProps) {\n super(device, props);\n this.device = device;\n\n // TODO - do parameters (scissorRect) affect the clear operation?\n this.setParameters(this.props.parameters);\n\n // Hack - for now WebGL draws in \"immediate mode\" (instead of queueing the operations)...\n this.clear();\n }\n\n end(): void {\n // should add commands to CommandEncoder.\n }\n\n pushDebugGroup(groupLabel: string): void {}\n popDebugGroup(): void {}\n insertDebugMarker(markerLabel: string): void {}\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n\n /**\n * Maps RenderPass parameters to GL parameters\n */\n setParameters(parameters: RenderPassParameters = {}): void {\n const glParameters: GLParameters = {};\n\n // Framebuffers are specified using parameters in WebGL\n if (this.props.framebuffer) {\n glParameters.framebuffer = this.props.framebuffer;\n }\n\n if (this.props.depthReadOnly) {\n glParameters.depthMask = !this.props.depthReadOnly;\n }\n\n glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;\n\n glParameters[GL.RASTERIZER_DISCARD] = this.props.discard;\n\n // Map the four renderpass parameters to WebGL parameters\n if (parameters.viewport) {\n glParameters.viewport = parameters.viewport;\n glParameters.depthRange = [parameters.viewport[4], parameters.viewport[5]];\n }\n glParameters.scissorTest = Boolean(parameters.scissorRect);\n if (parameters.scissorRect) {\n glParameters.scissor = parameters.scissorRect;\n }\n if (parameters.blendConstant) {\n glParameters.blendColor = parameters.blendConstant;\n }\n if (parameters.stencilReference) {\n // eslint-disable-next-line no-console\n console.warn('RenderPassParameters.stencilReference not yet implemented in WebGL');\n // parameters.stencilFunc = [func, ref, mask];\n // Does this work?\n parameters[GL.STENCIL_REF] = parameters.stencilReference;\n }\n\n this.glParameters = glParameters;\n }\n\n // Internal\n\n /**\n * Optionally clears depth, color and stencil buffers based on parameters\n */\n protected clear(): void {\n const glParameters: GLParameters = {...this.glParameters};\n\n let clearMask = 0;\n\n if (this.props.clearColor !== false) {\n clearMask |= GL_COLOR_BUFFER_BIT;\n glParameters.clearColor = this.props.clearColor;\n }\n if (this.props.clearDepth !== false) {\n clearMask |= GL_DEPTH_BUFFER_BIT;\n glParameters.clearDepth = this.props.clearDepth;\n }\n if (this.props.clearStencil !== false) {\n clearMask |= GL_STENCIL_BUFFER_BIT;\n glParameters.clearStencil = this.props.clearStencil;\n }\n\n if (clearMask !== 0) {\n // Temporarily set any clear \"colors\" and call clear\n withParameters(this.device, glParameters, () => {\n this.device.gl.clear(clearMask);\n });\n\n // TODO - clear multiple color attachments\n // for (attachment of this.framebuffer.colorAttachments) {\n // this.clearColorBuffer \n // }\n }\n }\n\n /** \n * WebGL2 - clear a specific color buffer \n */\n protected clearColorBuffer(drawBuffer: number = 0, value: NumericArray = [0, 0, 0, 0]) {\n withParameters(this.device.gl2, {framebuffer: this.props.framebuffer}, () => {\n // Method selection per OpenGL ES 3 docs\n switch (value.constructor) {\n case Int32Array:\n this.device.gl2.clearBufferiv(GL_COLOR, drawBuffer, value);\n break;\n case Uint32Array:\n this.device.gl2.clearBufferuiv(GL_COLOR, drawBuffer, value);\n break;\n case Float32Array:\n default:\n this.device.gl2.clearBufferfv(GL_COLOR, drawBuffer, value);\n break;\n }\n });\n }\n\n // clearDepthStencil() {\n // const GL_DEPTH = 0x1801;\n // const GL_STENCIL = 0x1802;\n // const GL_DEPTH_STENCIL = 0x84f9;\n\n // case GL_DEPTH:\n // this.device.gl2.clearBufferfv(GL_DEPTH, 0, [value]);\n // break;\n\n // case GL_STENCIL:\n // this.device.gl2.clearBufferiv(GL_STENCIL, 0, [value]);\n // break;\n\n // case GL_DEPTH_STENCIL:\n // const [depth, stencil] = value;\n // this.device.gl2.clearBufferfi(GL_DEPTH_STENCIL, 0, depth, stencil);\n // break;\n\n // default:\n // assert(false, ERR_ARGUMENTS);\n // }\n // });\n}\n\n"],"mappings":";AAAA,SAAQA,UAAU,QAA4D,cAAc;AAE5F,SAAQC,EAAE,QAAqB,oBAAoB;AAAC,SAC5CC,cAAc;AAItB,MAAMC,mBAAmB,GAAG,UAAU;AACtC,MAAMC,qBAAqB,GAAG,UAAU;AACxC,MAAMC,mBAAmB,GAAG,UAAU;AAEtC,MAAMC,QAAQ,GAAG,MAAM;AAEvB,OAAO,MAAMC,eAAe,SAASP,UAAU,CAAC;EAM9CQ,WAAWA,CAACC,MAAmB,EAAEC,KAAsB,EAAE;IACvD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IAGpB,IAAI,CAACG,aAAa,CAAC,IAAI,CAACF,KAAK,CAACG,UAAU,CAAC;IAGzC,IAAI,CAACC,KAAK,CAAC,CAAC;EACd;EAEAC,GAAGA,CAAA,EAAS,CAEZ;EAEAC,cAAcA,CAACC,UAAkB,EAAQ,CAAC;EAC1CC,aAAaA,CAAA,EAAS,CAAC;EACvBC,iBAAiBA,CAACC,WAAmB,EAAQ,CAAC;EAY9CR,aAAaA,CAAA,EAA8C;IAAA,IAA7CC,UAAgC,GAAAQ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IACjD,MAAMG,YAA0B,GAAG,CAAC,CAAC;IAGrC,IAAI,IAAI,CAACd,KAAK,CAACe,WAAW,EAAE;MAC1BD,YAAY,CAACC,WAAW,GAAG,IAAI,CAACf,KAAK,CAACe,WAAW;IACnD;IAEA,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