@luma.gl/webgl 9.0.0-alpha.52 → 9.0.0-alpha.53
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/sampler-parameters.d.ts +2 -8
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +12 -107
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +21 -3
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +2 -3
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +9 -7
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +5 -2
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/dist.dev.js +63 -40
- package/dist/index.cjs +148 -126
- package/dist.min.js +38 -38
- package/package.json +5 -5
- package/src/adapter/converters/sampler-parameters.ts +26 -151
- package/src/adapter/device-helpers/get-device-info.ts +24 -5
- package/src/adapter/resources/webgl-texture.ts +3 -4
- package/src/adapter/webgl-device.ts +13 -10
- package/src/context/polyfill/polyfill-context.ts +6 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAetE,OAAO,EAAkC,WAAW,EA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Q,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,iEAAiE;IACjE,QAAQ,CAAC,eAAe;;;;MAA0D;IAElF,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IAC/C,WAAW,EAAE,OAAO,CAAS;IAE7B,8CAA8C;IAC9C,OAAO,MAAC;IAER,OAAO,CAAC,YAAY,CAAC,CAAc;IAEnC,mCAAmC;IACnC,IAAI,WAAW,IAAI,WAAW,CAG7B;IAED;;;OAGG;IACM,UAAU,IAAI,OAAO;IAe9B,8DAA8D;IAC9D,SAAS,IAAI,IAAI;IAIjB,8CAA8C;IAC9C,QAAQ,IAAI,IAAI;IAIhB;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMlE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,qBAAqB,GAAG,MAAM;IAc5D,sBAAsB;IACtB,UAAU,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IAElC;;;;;OAKG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI;CAsBnE"}
|
|
@@ -50,7 +50,7 @@ export class WebGLDevice extends Device {
|
|
|
50
50
|
}
|
|
51
51
|
static async create() {
|
|
52
52
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
53
|
-
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
|
|
53
|
+
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();
|
|
54
54
|
if (typeof props.canvas === 'string') {
|
|
55
55
|
await CanvasContext.pageLoaded;
|
|
56
56
|
}
|
|
@@ -67,7 +67,14 @@ export class WebGLDevice extends Device {
|
|
|
67
67
|
if (props.gl && props.gl.device) {
|
|
68
68
|
return WebGLDevice.attach(props.gl);
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
const device = new WebGLDevice(props);
|
|
71
|
+
const message = `\
|
|
72
|
+
Created ${device.info.type}${device.debug ? ' debug' : ''} context: \
|
|
73
|
+
${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
74
|
+
log.probe(LOG_LEVEL, message)();
|
|
75
|
+
log.table(LOG_LEVEL, device.info)();
|
|
76
|
+
log.groupEnd(LOG_LEVEL)();
|
|
77
|
+
return device;
|
|
71
78
|
}
|
|
72
79
|
constructor(props) {
|
|
73
80
|
var _props$gl;
|
|
@@ -166,11 +173,6 @@ export class WebGLDevice extends Device {
|
|
|
166
173
|
canvas
|
|
167
174
|
});
|
|
168
175
|
}
|
|
169
|
-
const message = `\
|
|
170
|
-
Created ${this.info.type}${this.debug ? ' debug' : ''} context: \
|
|
171
|
-
${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
|
|
172
|
-
log.probe(LOG_LEVEL, message)();
|
|
173
|
-
log.groupEnd(LOG_LEVEL)();
|
|
174
176
|
}
|
|
175
177
|
destroy() {
|
|
176
178
|
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.js","names":["Device","CanvasContext","log","uid","assert","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","WEBGLBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLVertexArray","WEBGLTransformFeedback","LOG_LEVEL","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","arguments","length","undefined","groupCollapsed","canvas","pageLoaded","get","debug","spector","probe","constructor","_props$gl","id","info","canvasContext","handle","lost","_resolveContextLost","renderPass","gl2","isWebGL1","isWebGL2","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_extensions","_polyfilled","_webglLimits","_constants","Promise","resolve","onContextLost","event","_this$_resolveContext","call","reason","message","_version","enable","copyState","_len","args","Array","_key","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","createVertexArray","beginRenderPass","createComputePipeline","beginComputePass","createTransformFeedback","getDefaultRenderPass","framebuffer","getCurrentFramebuffer","createCommandEncoder","submit","_this$renderPass","end","webglLimits","loseDevice","_this$_resolveContext2","deviceLossTriggered","loseContext","pushState","popState","setSpectorMetadata","__SPECTOR_Metadata","getGLKey","value","number","Number","key","String","setConstantAttribute","location","constant","maxVertexAttributes","fill","currentConstant","compareConstantArrayValues","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","WebGL2RenderingContext","Boolean","isFinite","array","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","v1","v2","i"],"sources":["../../src/adapter/webgl-device.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat,\n VertexArray,\n VertexArrayProps,\n TypedArray\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {\n popContextState,\n pushContextState,\n trackContextState\n} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n // Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n // RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n // RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps,\n // CommandEncoder,\n CommandEncoderProps,\n TransformFeedbackProps\n} from '@luma.gl/core';\n\nimport {WEBGLBuffer} from './resources/webgl-buffer';\nimport {WEBGLShader} from './resources/webgl-shader';\nimport {WEBGLSampler} from './resources/webgl-sampler';\nimport {WEBGLTexture} from './resources/webgl-texture';\nimport {WEBGLFramebuffer} from './resources/webgl-framebuffer';\nimport {WEBGLRenderPass} from './resources/webgl-render-pass';\nimport {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';\nimport {WEBGLCommandEncoder} from './resources/webgl-command-encoder';\nimport {WEBGLVertexArray} from './resources/webgl-vertex-array';\nimport {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (log.get('debug') || props.debug) {\n await loadWebGLDeveloperTools();\n }\n\n // @ts-expect-error spector not on props\n const {spector} = props;\n if (log.get('spector') || spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser()\n ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})\n : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {\n const newProps = this._getBufferProps(props);\n return new WEBGLBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n override createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('ComputePass not supported in WebGL');\n }\n\n createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {\n return new WEBGLTransformFeedback(this, props);\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n override createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder {\n return new WEBGLCommandEncoder(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.end();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** State used by luma.gl classes - TODO - not used? */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n /**\n * Triggers device (or WebGL context) loss.\n * @note primarily intended for testing how application reacts to device loss\n */\n override loseDevice(): boolean {\n let deviceLossTriggered = false;\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n deviceLossTriggered = true;\n ext.loseContext();\n // ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly\n }\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n return deviceLossTriggered;\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\n }\n\n /**\n * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension\n * luma.gl ids and props can be inspected\n */\n setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant\n * Be aware that there are some duplicates especially for constants that are 0,\n * so this isn't guaranteed to return the right key in all cases.\n */\n getGLKey(value: unknown, gl?: WebGLRenderingContext): string {\n // @ts-ignore expect-error depends on settings\n gl = gl || this.gl2 || this.gl;\n const number = Number(value);\n for (const key in gl) {\n // @ts-ignore expect-error depends on settings\n if (gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return String(value);\n }\n\n /** Store constants */\n _constants: (TypedArray | null)[];\n\n /**\n * Set a constant value for a location. Disabled attributes at that location will read from this value\n * @note WebGL constants are stored globally on the WebGL context, not the VertexArray\n * so they need to be updated before every render\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstantAttribute(location: number, constant: TypedArray): void {\n this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();\n }\n this._constants[location] = constant;\n\n switch (constant.constructor) {\n case Float32Array:\n setConstantFloatArray(this, location, constant as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this, location, constant as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this, location, constant as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n/** Set constant float array attribute */\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\n/** Set constant signed int array attribute */\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** Set constant unsigned int array attribute */\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** \n * Compares contents of two typed arrays \n * @todo max length?\n */\nfunction compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":"AAcA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AACrE,SAAQC,SAAS,QAAO,eAAe;AAAC,SAChCC,eAAe;AAAA,SAErBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB;AAAA,SAEXC,oBAAoB;AAAA,SAE1BC,qBAAqB,EACrBC,sBAAsB;AAAA,SAEhBC,aAAa;AAAA,SACbC,iBAAiB;AAAA,SACjBC,eAAe,EAAEC,cAAc;AAAA,SAC/BC,kBAAkB;AAAA,SAClBC,aAAa,EAAEC,mBAAmB;AAAA,SAClCC,uBAAuB,EAAEC,gBAAgB;AAAA,SAE/CC,wBAAwB,EACxBC,y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BAAVA,UAAA,CAAYC,gBAAgB,CAACrB,QAAQ,EAAEe,KAAK,CAAC;AAiB/C;AAGA,SAASJ,oBAAoBA,CAACvH,MAAmB,EAAE4G,QAAgB,EAAEe,KAAkB,EAAE;EAAA,IAAAO,WAAA;EACvFlI,MAAM,CAACqE,YAAY,CAAC,CAAC;EACrB,CAAA6D,WAAA,GAAAlI,MAAM,CAACwB,GAAG,cAAA0G,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAACvB,QAAQ,EAAEe,KAAK,CAAC;AAkBhD;AAMA,SAASV,0BAA0BA,CAACmB,EAAc,EAAEC,EAAc,EAAW;EAC3E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAC9H,MAAM,KAAK+H,EAAE,CAAC/H,MAAM,IAAI8H,EAAE,CAACrH,WAAW,KAAKsH,EAAE,CAACtH,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAIuH,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAC9H,MAAM,EAAE,EAAEgI,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"webgl-device.js","names":["Device","CanvasContext","log","uid","assert","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","WEBGLBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","WEBGLCommandEncoder","WEBGLVertexArray","WEBGLTransformFeedback","LOG_LEVEL","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","arguments","length","undefined","groupCollapsed","canvas","pageLoaded","get","debug","spector","probe","message","info","type","vendor","renderer","canvasContext","id","table","groupEnd","constructor","_props$gl","handle","lost","_resolveContextLost","renderPass","gl2","isWebGL1","isWebGL2","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_extensions","_polyfilled","_webglLimits","_constants","Promise","resolve","onContextLost","event","_this$_resolveContext","call","reason","_version","enable","copyState","_len","args","Array","_key","webgl2","throwOnError","level","Math","max","warn","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","createBuffer","newProps","_getBufferProps","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","createVertexArray","beginRenderPass","createComputePipeline","beginComputePass","createTransformFeedback","getDefaultRenderPass","framebuffer","getCurrentFramebuffer","createCommandEncoder","submit","_this$renderPass","end","webglLimits","loseDevice","_this$_resolveContext2","deviceLossTriggered","loseContext","pushState","popState","setSpectorMetadata","__SPECTOR_Metadata","getGLKey","value","number","Number","key","String","setConstantAttribute","location","constant","maxVertexAttributes","fill","currentConstant","compareConstantArrayValues","Float32Array","setConstantFloatArray","Int32Array","setConstantIntArray","Uint32Array","setConstantUintArray","WebGL2RenderingContext","Boolean","isFinite","array","vertexAttrib1fv","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","_device$gl","vertexAttribI4iv","_device$gl2","vertexAttribI4uiv","v1","v2","i"],"sources":["../../src/adapter/webgl-device.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat,\n VertexArray,\n VertexArrayProps,\n TypedArray\n} from '@luma.gl/core';\nimport {Device, CanvasContext, log, uid, assert} from '@luma.gl/core';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {\n popContextState,\n pushContextState,\n trackContextState\n} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport {WebGLCanvasContext} from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n // Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n // RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n // RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps,\n // CommandEncoder,\n CommandEncoderProps,\n TransformFeedbackProps\n} from '@luma.gl/core';\n\nimport {WEBGLBuffer} from './resources/webgl-buffer';\nimport {WEBGLShader} from './resources/webgl-shader';\nimport {WEBGLSampler} from './resources/webgl-sampler';\nimport {WEBGLTexture} from './resources/webgl-texture';\nimport {WEBGLFramebuffer} from './resources/webgl-framebuffer';\nimport {WEBGLRenderPass} from './resources/webgl-render-pass';\nimport {WEBGLRenderPipeline} from './resources/webgl-render-pipeline';\nimport {WEBGLCommandEncoder} from './resources/webgl-command-encoder';\nimport {WEBGLVertexArray} from './resources/webgl-vertex-array';\nimport {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created')();\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (log.get('debug') || props.debug) {\n await loadWebGLDeveloperTools();\n }\n\n // @ts-expect-error spector not on props\n const {spector} = props;\n if (log.get('spector') || spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n const device = new WebGLDevice(props);\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${device.info.type}${device.debug ? ' debug' : ''} context: \\\n${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n log.table(LOG_LEVEL, device.info)();\n\n log.groupEnd(LOG_LEVEL)();\n\n return device;\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser()\n ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost})\n : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {\n const newProps = this._getBufferProps(props);\n return new WEBGLBuffer(this, newProps);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n override createVertexArray(props: VertexArrayProps): VertexArray {\n return new WEBGLVertexArray(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('ComputePass not supported in WebGL');\n }\n\n createTransformFeedback(props: TransformFeedbackProps): WEBGLTransformFeedback {\n return new WEBGLTransformFeedback(this, props);\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n override createCommandEncoder(props?: CommandEncoderProps): WEBGLCommandEncoder {\n return new WEBGLCommandEncoder(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.end();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** State used by luma.gl classes - TODO - not used? */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n /**\n * Triggers device (or WebGL context) loss.\n * @note primarily intended for testing how application reacts to device loss\n */\n override loseDevice(): boolean {\n let deviceLossTriggered = false;\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n deviceLossTriggered = true;\n ext.loseContext();\n // ext.loseContext should trigger context loss callback but the platform may not do this, so do it explicitly\n }\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n return deviceLossTriggered;\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\n }\n\n /**\n * Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension\n * luma.gl ids and props can be inspected\n */\n setSpectorMetadata(handle: unknown, props: Record<string, unknown>) {\n // @ts-expect-error\n // eslint-disable-next-line camelcase\n handle.__SPECTOR_Metadata = props;\n }\n\n /**\n * Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant\n * Be aware that there are some duplicates especially for constants that are 0,\n * so this isn't guaranteed to return the right key in all cases.\n */\n getGLKey(value: unknown, gl?: WebGLRenderingContext): string {\n // @ts-ignore expect-error depends on settings\n gl = gl || this.gl2 || this.gl;\n const number = Number(value);\n for (const key in gl) {\n // @ts-ignore expect-error depends on settings\n if (gl[key] === number) {\n return `GL.${key}`;\n }\n }\n // No constant found. Stringify the value and return it.\n return String(value);\n }\n\n /** Store constants */\n _constants: (TypedArray | null)[];\n\n /**\n * Set a constant value for a location. Disabled attributes at that location will read from this value\n * @note WebGL constants are stored globally on the WebGL context, not the VertexArray\n * so they need to be updated before every render\n * @todo - remember/cache values to avoid setting them unnecessarily?\n */\n setConstantAttribute(location: number, constant: TypedArray): void {\n this._constants = this._constants || new Array(this.limits.maxVertexAttributes).fill(null);\n const currentConstant = this._constants[location];\n if (currentConstant && compareConstantArrayValues(currentConstant, constant)) {\n log.info(1, `setConstantAttribute(${location}) could have been skipped, value unchanged`)();\n }\n this._constants[location] = constant;\n\n switch (constant.constructor) {\n case Float32Array:\n setConstantFloatArray(this, location, constant as Float32Array);\n break;\n case Int32Array:\n setConstantIntArray(this, location, constant as Int32Array);\n break;\n case Uint32Array:\n setConstantUintArray(this, location, constant as Uint32Array);\n break;\n default:\n assert(false);\n }\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n\n/** Set constant float array attribute */\nfunction setConstantFloatArray(device: WebGLDevice, location: number, array: Float32Array): void {\n switch (array.length) {\n case 1:\n device.gl.vertexAttrib1fv(location, array);\n break;\n case 2:\n device.gl.vertexAttrib2fv(location, array);\n break;\n case 3:\n device.gl.vertexAttrib3fv(location, array);\n break;\n case 4:\n device.gl.vertexAttrib4fv(location, array);\n break;\n default:\n assert(false);\n }\n}\n\n/** Set constant signed int array attribute */\nfunction setConstantIntArray(device: WebGLDevice, location: number, array: Int32Array): void {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4iv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1iv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2iv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3iv(location, array);\n // break;\n // case 4:\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** Set constant unsigned int array attribute */\nfunction setConstantUintArray(device: WebGLDevice, location: number, array: Uint32Array) {\n device.assertWebGL2();\n device.gl2?.vertexAttribI4uiv(location, array);\n // TODO - not clear if we need to use the special forms, more testing needed\n // switch (array.length) {\n // case 1:\n // gl.vertexAttribI1uiv(location, array);\n // break;\n // case 2:\n // gl.vertexAttribI2uiv(location, array);\n // break;\n // case 3:\n // gl.vertexAttribI3uiv(location, array);\n // break;\n // case 4:\n // gl.vertexAttribI4uiv(location, array);\n // break;\n // default:\n // assert(false);\n // }\n}\n\n/** \n * Compares contents of two typed arrays \n * @todo max length?\n */\nfunction compareConstantArrayValues(v1: TypedArray, v2: TypedArray): boolean {\n if (!v1 || !v2 || v1.length !== v2.length || v1.constructor !== v2.constructor) {\n return false;\n }\n for (let i = 0; i < v1.length; ++i) {\n if (v1[i] !== v2[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":"AAcA,SAAQA,MAAM,EAAEC,aAAa,EAAEC,GAAG,EAAEC,GAAG,EAAEC,MAAM,QAAO,eAAe;AACrE,SAAQC,SAAS,QAAO,eAAe;AAAC,SAChCC,eAAe;AAAA,SAErBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB;AAAA,SAEXC,oBAAoB;AAAA,SAE1BC,qBAAqB,EACrBC,sBAAsB;AAAA,SAEhBC,aAAa;AAAA,SACbC,iBAAiB;AAAA,SACjBC,eAAe,EAAEC,cAAc;AAAA,SAC/BC,kBAAkB;AAAA,SAClBC,aAAa,EAAEC,mBAAmB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AAGA,SAAS+J,mBAAmBA,CAACtH,MAAmB,EAAE6G,QAAgB,EAAEe,KAAiB,EAAQ;EAAA,IAAAK,UAAA;EAC3FjI,MAAM,CAACsE,YAAY,CAAC,CAAC;EACrB,CAAA2D,UAAA,GAAAjI,MAAM,CAAC8B,GAAG,cAAAmG,UAAA,uBAAVA,UAAA,CAAYC,gBAAgB,CAACrB,QAAQ,EAAEe,KAAK,CAAC;AAiB/C;AAGA,SAASJ,oBAAoBA,CAACxH,MAAmB,EAAE6G,QAAgB,EAAEe,KAAkB,EAAE;EAAA,IAAAO,WAAA;EACvFnI,MAAM,CAACsE,YAAY,CAAC,CAAC;EACrB,CAAA6D,WAAA,GAAAnI,MAAM,CAAC8B,GAAG,cAAAqG,WAAA,uBAAVA,WAAA,CAAYC,iBAAiB,CAACvB,QAAQ,EAAEe,KAAK,CAAC;AAkBhD;AAMA,SAASV,0BAA0BA,CAACmB,EAAc,EAAEC,EAAc,EAAW;EAC3E,IAAI,CAACD,EAAE,IAAI,CAACC,EAAE,IAAID,EAAE,CAAC/H,MAAM,KAAKgI,EAAE,CAAChI,MAAM,IAAI+H,EAAE,CAAC7G,WAAW,KAAK8G,EAAE,CAAC9G,WAAW,EAAE;IAC9E,OAAO,KAAK;EACd;EACA,KAAK,IAAI+G,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,EAAE,CAAC/H,MAAM,EAAE,EAAEiI,CAAC,EAAE;IAClC,IAAIF,EAAE,CAACE,CAAC,CAAC,KAAKD,EAAE,CAACC,CAAC,CAAC,EAAE;MACnB,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb"}
|
|
@@ -19,9 +19,12 @@ export function polyfillContext(gl) {
|
|
|
19
19
|
function initializeExtensions(gl) {
|
|
20
20
|
const contextState = getContextData(gl);
|
|
21
21
|
const EXTENSIONS = gl.getSupportedExtensions() || [];
|
|
22
|
+
const IGNORE_EXTENSIONS = ['WEBGL_polygon_mode'];
|
|
22
23
|
for (const extensionName of EXTENSIONS) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (!IGNORE_EXTENSIONS.includes(extensionName)) {
|
|
25
|
+
const extension = gl.getExtension(extensionName);
|
|
26
|
+
contextState._extensions[extensionName] = extension;
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
function installPolyfills(gl, polyfills) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill-context.js","names":["assert","polyfillVertexArrayObject","WEBGL2_CONTEXT_POLYFILLS","WEBGL2_CONTEXT_OVERRIDES","getContextData","polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","_ref","defaults","meta","suffix","ext","key","keys","extKey","polyfill","arguments","bind","_ref2","forEach","originalFunc"],"sources":["../../../src/context/polyfill/polyfill-context.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// WebGL1/WebGL2 extension polyfill support\n//\n// Provides a function that creates polyfills for WebGL2 functions based\n// on available extensions and installs them on a supplied target (could be\n// the WebGLContext or its prototype, or a separate object).\n//\n// This is intended to be a stand-alone file with minimal dependencies,\n// easy to reuse or repurpose in other projects.\n\nimport {assert} from '@luma.gl/core';\nimport {polyfillVertexArrayObject} from './polyfill-vertex-array-object';\n\nimport {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';\nimport {getContextData} from './context-data';\n\n/**\n * Registers extensions, polyfills or mock functions for extensions in the polyfills list\n */\nexport function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {\n const contextState = getContextData(gl);\n\n if (!contextState._polyfilled) {\n polyfillVertexArrayObject(gl);\n initializeExtensions(gl);\n installPolyfills(gl, WEBGL2_CONTEXT_POLYFILLS);\n installOverrides(gl, {target: contextState, target2: gl});\n contextState._polyfilled = true;\n }\n\n // Note - only supports a subset of WebGL2\n return gl as WebGL2RenderingContext;\n}\n\nfunction initializeExtensions(gl: WebGLRenderingContext): void {\n const contextState = getContextData(gl);\n // `getSupportedExtensions` can return null when context is lost.\n const EXTENSIONS = gl.getSupportedExtensions() || [];\n for (const extensionName of EXTENSIONS) {\n const extension = gl.getExtension(extensionName);\n
|
|
1
|
+
{"version":3,"file":"polyfill-context.js","names":["assert","polyfillVertexArrayObject","WEBGL2_CONTEXT_POLYFILLS","WEBGL2_CONTEXT_OVERRIDES","getContextData","polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","IGNORE_EXTENSIONS","extensionName","includes","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","_ref","defaults","meta","suffix","ext","key","keys","extKey","polyfill","arguments","bind","_ref2","forEach","originalFunc"],"sources":["../../../src/context/polyfill/polyfill-context.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n// WebGL1/WebGL2 extension polyfill support\n//\n// Provides a function that creates polyfills for WebGL2 functions based\n// on available extensions and installs them on a supplied target (could be\n// the WebGLContext or its prototype, or a separate object).\n//\n// This is intended to be a stand-alone file with minimal dependencies,\n// easy to reuse or repurpose in other projects.\n\nimport {assert} from '@luma.gl/core';\nimport {polyfillVertexArrayObject} from './polyfill-vertex-array-object';\n\nimport {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';\nimport {getContextData} from './context-data';\n\n/**\n * Registers extensions, polyfills or mock functions for extensions in the polyfills list\n */\nexport function polyfillContext(gl: WebGLRenderingContext): WebGL2RenderingContext {\n const contextState = getContextData(gl);\n\n if (!contextState._polyfilled) {\n polyfillVertexArrayObject(gl);\n initializeExtensions(gl);\n installPolyfills(gl, WEBGL2_CONTEXT_POLYFILLS);\n installOverrides(gl, {target: contextState, target2: gl});\n contextState._polyfilled = true;\n }\n\n // Note - only supports a subset of WebGL2\n return gl as WebGL2RenderingContext;\n}\n\nfunction initializeExtensions(gl: WebGLRenderingContext): void {\n const contextState = getContextData(gl);\n // `getSupportedExtensions` can return null when context is lost.\n const EXTENSIONS = gl.getSupportedExtensions() || [];\n // Generates warnings in Chrome\n const IGNORE_EXTENSIONS = ['WEBGL_polygon_mode'];\n for (const extensionName of EXTENSIONS) {\n if (!IGNORE_EXTENSIONS.includes(extensionName)) {\n const extension = gl.getExtension(extensionName);\n contextState._extensions[extensionName] = extension;\n }\n }\n}\n\nfunction installPolyfills(gl: WebGLRenderingContext, polyfills): void {\n const contextState = getContextData(gl);\n for (const extension of Object.getOwnPropertyNames(polyfills)) {\n if (extension !== 'overrides') {\n polyfillExtension(gl, {extension, target: contextState, target2: gl});\n }\n }\n}\n\n/** Polyfills a single WebGL extension into the `target` object */\nfunction polyfillExtension(gl: WebGLRenderingContext, {extension, target, target2}): void {\n const defaults = WEBGL2_CONTEXT_POLYFILLS[extension];\n assert(defaults);\n\n const {meta = {}} = defaults;\n const {suffix = ''} = meta;\n\n const ext = gl.getExtension(extension);\n\n for (const key of Object.keys(defaults)) {\n const extKey = `${key}${suffix}`;\n\n let polyfill: Function | null = null;\n if (key === 'meta') {\n // ignore\n } else if (typeof gl[key] === 'function') {\n // WebGL2 implementation is already\n } else if (ext && typeof ext[extKey] === 'function') {\n // pick extension implementation,if available\n polyfill = (...args) => ext[extKey](...args);\n } else if (typeof defaults[key] === 'function') {\n // pick the mock implementation, if no implementation was detected\n polyfill = defaults[key].bind(target);\n }\n\n if (polyfill) {\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n }\n}\n\n/** Install simple overrides (mostly get* functions) */\nfunction installOverrides(gl: WebGLRenderingContext, {target, target2}) {\n Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {\n if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {\n // install an override, if no implementation was detected\n const originalFunc = gl[key] ? gl[key].bind(gl) : () => {};\n const polyfill =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I,CAACxB,MAAM,CAAC;IACvC;IAEA,IAAIsB,QAAQ,EAAE;MACZtB,MAAM,CAACmB,GAAG,CAAC,GAAGG,QAAQ;MACtBrB,OAAO,CAACkB,GAAG,CAAC,GAAGG,QAAQ;IACzB;EACF;AACF;AAGA,SAASvB,gBAAgBA,CAACL,EAAyB,EAAA+B,KAAA,EAAqB;EAAA,IAAnB;IAACzB,MAAM;IAAEC;EAAO,CAAC,GAAAwB,KAAA;EACpEd,MAAM,CAACS,IAAI,CAAC7B,wBAAwB,CAAC,CAACmC,OAAO,CAAEP,GAAG,IAAK;IACrD,IAAI,OAAO5B,wBAAwB,CAAC4B,GAAG,CAAC,KAAK,UAAU,EAAE;MAEvD,MAAMQ,YAAY,GAAGjC,EAAE,CAACyB,GAAG,CAAC,GAAGzB,EAAE,CAACyB,GAAG,CAAC,CAACK,IAAI,CAAC9B,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;MAC1D,MAAM4B,QAAQ,GAAG/B,wBAAwB,CAAC4B,GAAG,CAAC,CAACK,IAAI,CAAC,IAAI,EAAE9B,EAAE,EAAEiC,YAAY,CAAC;MAC3E3B,MAAM,CAACmB,GAAG,CAAC,GAAGG,QAAQ;MACtBrB,OAAO,CAACkB,GAAG,CAAC,GAAGG,QAAQ;IACzB;EACF,CAAC,CAAC;AACJ"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -671,7 +671,7 @@ var __exports__ = (() => {
|
|
|
671
671
|
id: "@probe.gl/log"
|
|
672
672
|
});
|
|
673
673
|
|
|
674
|
-
// ../core/src/
|
|
674
|
+
// ../core/src/utils/log.ts
|
|
675
675
|
var log = new Log({
|
|
676
676
|
id: "luma.gl"
|
|
677
677
|
});
|
|
@@ -867,7 +867,7 @@ var __exports__ = (() => {
|
|
|
867
867
|
}
|
|
868
868
|
};
|
|
869
869
|
|
|
870
|
-
// ../core/src/
|
|
870
|
+
// ../core/src/utils/stats-manager.ts
|
|
871
871
|
var StatsManager = class {
|
|
872
872
|
stats = /* @__PURE__ */ new Map();
|
|
873
873
|
getStats(name2) {
|
|
@@ -886,14 +886,14 @@ var __exports__ = (() => {
|
|
|
886
886
|
|
|
887
887
|
// ../core/src/init.ts
|
|
888
888
|
function initializeLuma() {
|
|
889
|
-
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "
|
|
889
|
+
const VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "running from source";
|
|
890
890
|
const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
|
|
891
891
|
if (globalThis.luma && globalThis.luma.VERSION !== VERSION3) {
|
|
892
892
|
throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${VERSION3}`);
|
|
893
893
|
}
|
|
894
894
|
if (!globalThis.luma) {
|
|
895
895
|
if (isBrowser()) {
|
|
896
|
-
log.log(1,
|
|
896
|
+
log.log(1, `${VERSION3} - ${STARTUP_MESSAGE}`)();
|
|
897
897
|
}
|
|
898
898
|
globalThis.luma = globalThis.luma || {
|
|
899
899
|
VERSION: VERSION3,
|
|
@@ -906,7 +906,7 @@ var __exports__ = (() => {
|
|
|
906
906
|
}
|
|
907
907
|
var VERSION2 = initializeLuma();
|
|
908
908
|
|
|
909
|
-
// ../core/src/
|
|
909
|
+
// ../core/src/utils/is-array.ts
|
|
910
910
|
function isTypedArray(value) {
|
|
911
911
|
return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
|
|
912
912
|
}
|
|
@@ -917,7 +917,7 @@ var __exports__ = (() => {
|
|
|
917
917
|
return isTypedArray(value);
|
|
918
918
|
}
|
|
919
919
|
|
|
920
|
-
// ../core/src/
|
|
920
|
+
// ../core/src/utils/utils.ts
|
|
921
921
|
var uidCounters = {};
|
|
922
922
|
function uid(id = "id") {
|
|
923
923
|
uidCounters[id] = uidCounters[id] || 1;
|
|
@@ -1155,6 +1155,13 @@ var __exports__ = (() => {
|
|
|
1155
1155
|
});
|
|
1156
1156
|
__publicField(Device, "VERSION", VERSION2);
|
|
1157
1157
|
|
|
1158
|
+
// ../core/src/utils/assert.ts
|
|
1159
|
+
function assert2(condition, message2) {
|
|
1160
|
+
if (!condition) {
|
|
1161
|
+
throw new Error(message2 || "luma.gl: assertion failed.");
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1158
1165
|
// ../core/src/adapter/canvas-context.ts
|
|
1159
1166
|
var isPage = isBrowser() && typeof document !== "undefined";
|
|
1160
1167
|
var isPageLoaded = () => isPage && document.readyState === "complete";
|
|
@@ -2103,14 +2110,7 @@ ${htmlLog}
|
|
|
2103
2110
|
buffers: {}
|
|
2104
2111
|
});
|
|
2105
2112
|
|
|
2106
|
-
// ../core/src/
|
|
2107
|
-
function assert2(condition, message2) {
|
|
2108
|
-
if (!condition) {
|
|
2109
|
-
throw new Error(message2 || "luma.gl: assertion failed.");
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
|
-
// ../core/src/lib/utils/array-utils-flat.ts
|
|
2113
|
+
// ../core/src/utils/array-utils-flat.ts
|
|
2114
2114
|
var arrayBuffer;
|
|
2115
2115
|
function getScratchArrayBuffer(byteLength) {
|
|
2116
2116
|
if (!arrayBuffer || arrayBuffer.byteLength < byteLength) {
|
|
@@ -2247,7 +2247,7 @@ ${htmlLog}
|
|
|
2247
2247
|
};
|
|
2248
2248
|
}
|
|
2249
2249
|
|
|
2250
|
-
// ../core/src/
|
|
2250
|
+
// ../core/src/utils/cast.ts
|
|
2251
2251
|
function cast(value) {
|
|
2252
2252
|
return value;
|
|
2253
2253
|
}
|
|
@@ -2272,7 +2272,7 @@ ${htmlLog}
|
|
|
2272
2272
|
return result;
|
|
2273
2273
|
}
|
|
2274
2274
|
|
|
2275
|
-
// ../core/src/
|
|
2275
|
+
// ../core/src/utils/stub-methods.ts
|
|
2276
2276
|
function stubRemovedMethods(instance, className, version, methodNames) {
|
|
2277
2277
|
const upgradeMessage = `See luma.gl ${version} Upgrade Guide at https://luma.gl/docs/upgrade-guide`;
|
|
2278
2278
|
const prototype = Object.getPrototypeOf(instance);
|
|
@@ -2287,7 +2287,7 @@ ${htmlLog}
|
|
|
2287
2287
|
});
|
|
2288
2288
|
}
|
|
2289
2289
|
|
|
2290
|
-
// ../core/src/
|
|
2290
|
+
// ../core/src/utils/check-props.ts
|
|
2291
2291
|
function checkProps(className, props, propChecks) {
|
|
2292
2292
|
const {
|
|
2293
2293
|
removedProps = {},
|
|
@@ -2319,7 +2319,7 @@ ${htmlLog}
|
|
|
2319
2319
|
return newProps || props;
|
|
2320
2320
|
}
|
|
2321
2321
|
|
|
2322
|
-
// ../core/src/
|
|
2322
|
+
// ../core/src/utils/load-file.ts
|
|
2323
2323
|
var pathPrefix = "";
|
|
2324
2324
|
async function loadImage(url, opts) {
|
|
2325
2325
|
return new Promise((resolve, reject) => {
|
|
@@ -2904,9 +2904,12 @@ ${htmlLog}
|
|
|
2904
2904
|
function initializeExtensions(gl) {
|
|
2905
2905
|
const contextState = getContextData(gl);
|
|
2906
2906
|
const EXTENSIONS = gl.getSupportedExtensions() || [];
|
|
2907
|
+
const IGNORE_EXTENSIONS = ["WEBGL_polygon_mode"];
|
|
2907
2908
|
for (const extensionName of EXTENSIONS) {
|
|
2908
|
-
|
|
2909
|
-
|
|
2909
|
+
if (!IGNORE_EXTENSIONS.includes(extensionName)) {
|
|
2910
|
+
const extension = gl.getExtension(extensionName);
|
|
2911
|
+
contextState._extensions[extensionName] = extension;
|
|
2912
|
+
}
|
|
2910
2913
|
}
|
|
2911
2914
|
}
|
|
2912
2915
|
function installPolyfills(gl, polyfills) {
|
|
@@ -3663,11 +3666,13 @@ ${htmlLog}
|
|
|
3663
3666
|
const version = gl.getParameter(7938);
|
|
3664
3667
|
const gpu = identifyGPUVendor(vendor, renderer);
|
|
3665
3668
|
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
3669
|
+
const gpuType = identifyGPUType(vendor, renderer);
|
|
3666
3670
|
const shadingLanguage = "glsl";
|
|
3667
3671
|
const shadingLanguageVersion = isWebGL2(gl) ? 300 : 100;
|
|
3668
3672
|
return {
|
|
3669
3673
|
type: isWebGL2(gl) ? "webgl2" : "webgl",
|
|
3670
3674
|
gpu,
|
|
3675
|
+
gpuType,
|
|
3671
3676
|
gpuBackend,
|
|
3672
3677
|
vendor,
|
|
3673
3678
|
renderer,
|
|
@@ -3695,14 +3700,30 @@ ${htmlLog}
|
|
|
3695
3700
|
return "unknown";
|
|
3696
3701
|
}
|
|
3697
3702
|
function identifyGPUBackend(vendor, renderer) {
|
|
3698
|
-
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
3699
|
-
return "angle";
|
|
3700
|
-
}
|
|
3701
3703
|
if (/Metal/i.exec(vendor) || /Metal/i.exec(renderer)) {
|
|
3702
3704
|
return "metal";
|
|
3703
3705
|
}
|
|
3706
|
+
if (/ANGLE/i.exec(vendor) || /ANGLE/i.exec(renderer)) {
|
|
3707
|
+
return "opengl";
|
|
3708
|
+
}
|
|
3704
3709
|
return "unknown";
|
|
3705
3710
|
}
|
|
3711
|
+
function identifyGPUType(vendor, renderer) {
|
|
3712
|
+
if (/SwiftShader/i.exec(vendor) || /SwiftShader/i.exec(renderer)) {
|
|
3713
|
+
return "cpu";
|
|
3714
|
+
}
|
|
3715
|
+
const gpuVendor = identifyGPUVendor(vendor, renderer);
|
|
3716
|
+
switch (gpuVendor) {
|
|
3717
|
+
case "intel":
|
|
3718
|
+
return "integrated";
|
|
3719
|
+
case "software":
|
|
3720
|
+
return "cpu";
|
|
3721
|
+
case "unknown":
|
|
3722
|
+
return "unknown";
|
|
3723
|
+
default:
|
|
3724
|
+
return "discrete";
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3706
3727
|
|
|
3707
3728
|
// src/adapter/device-helpers/is-old-ie.ts
|
|
3708
3729
|
function isOldIE(opts = {}) {
|
|
@@ -5036,6 +5057,17 @@ void main(void) {}`;
|
|
|
5036
5057
|
}
|
|
5037
5058
|
return params;
|
|
5038
5059
|
}
|
|
5060
|
+
function updateSamplerParametersForNPOT(parameters) {
|
|
5061
|
+
const newParameters = {
|
|
5062
|
+
...parameters
|
|
5063
|
+
};
|
|
5064
|
+
if (parameters[10241] !== 9728) {
|
|
5065
|
+
newParameters[10241] = 9729;
|
|
5066
|
+
}
|
|
5067
|
+
newParameters[10242] = 33071;
|
|
5068
|
+
newParameters[10243] = 33071;
|
|
5069
|
+
return newParameters;
|
|
5070
|
+
}
|
|
5039
5071
|
function convertAddressMode(addressMode) {
|
|
5040
5072
|
switch (addressMode) {
|
|
5041
5073
|
case "clamp-to-edge":
|
|
@@ -5065,17 +5097,6 @@ void main(void) {}`;
|
|
|
5065
5097
|
return mipmapFilter === "nearest" ? 9985 : 9987;
|
|
5066
5098
|
}
|
|
5067
5099
|
}
|
|
5068
|
-
function updateSamplerParametersForNPOT(parameters) {
|
|
5069
|
-
const newParameters = {
|
|
5070
|
-
...parameters
|
|
5071
|
-
};
|
|
5072
|
-
if (parameters[10241] !== 9728) {
|
|
5073
|
-
newParameters[10241] = 9729;
|
|
5074
|
-
}
|
|
5075
|
-
newParameters[10242] = 33071;
|
|
5076
|
-
newParameters[10243] = 33071;
|
|
5077
|
-
return newParameters;
|
|
5078
|
-
}
|
|
5079
5100
|
|
|
5080
5101
|
// src/adapter/resources/webgl-buffer.ts
|
|
5081
5102
|
var DEBUG_DATA_LENGTH = 10;
|
|
@@ -5258,7 +5279,7 @@ void main(void) {}`;
|
|
|
5258
5279
|
format: "rgba8unorm",
|
|
5259
5280
|
...props
|
|
5260
5281
|
});
|
|
5261
|
-
this.device =
|
|
5282
|
+
this.device = device;
|
|
5262
5283
|
this.gl = this.device.gl;
|
|
5263
5284
|
this.gl2 = this.device.gl2;
|
|
5264
5285
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
@@ -8731,7 +8752,7 @@ ${source2}`;
|
|
|
8731
8752
|
});
|
|
8732
8753
|
}
|
|
8733
8754
|
static async create(props = {}) {
|
|
8734
|
-
log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created");
|
|
8755
|
+
log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
8735
8756
|
if (typeof props.canvas === "string") {
|
|
8736
8757
|
await CanvasContext.pageLoaded;
|
|
8737
8758
|
}
|
|
@@ -8748,7 +8769,12 @@ ${source2}`;
|
|
|
8748
8769
|
if (props.gl && props.gl.device) {
|
|
8749
8770
|
return _WebGLDevice.attach(props.gl);
|
|
8750
8771
|
}
|
|
8751
|
-
|
|
8772
|
+
const device = new _WebGLDevice(props);
|
|
8773
|
+
const message2 = `Created ${device.info.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
8774
|
+
log.probe(LOG_LEVEL2, message2)();
|
|
8775
|
+
log.table(LOG_LEVEL2, device.info)();
|
|
8776
|
+
log.groupEnd(LOG_LEVEL2)();
|
|
8777
|
+
return device;
|
|
8752
8778
|
}
|
|
8753
8779
|
constructor(props) {
|
|
8754
8780
|
super({
|
|
@@ -8815,9 +8841,6 @@ ${source2}`;
|
|
|
8815
8841
|
canvas
|
|
8816
8842
|
});
|
|
8817
8843
|
}
|
|
8818
|
-
const message2 = `Created ${this.info.type}${this.debug ? " debug" : ""} context: ${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;
|
|
8819
|
-
log.probe(LOG_LEVEL2, message2)();
|
|
8820
|
-
log.groupEnd(LOG_LEVEL2)();
|
|
8821
8844
|
}
|
|
8822
8845
|
destroy() {
|
|
8823
8846
|
const ext = this.gl.getExtension("STACKGL_destroy_context");
|