@luma.gl/webgl 9.0.0-alpha.7 → 9.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/resources/webgl-render-pipeline.js +12 -0
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +13 -7
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +65 -17
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +8 -2
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.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/polyfill/polyfill-context.js +0 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +12 -0
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/es5/adapter/webgl-device.js +79 -25
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/classic/accessor.js.map +1 -1
- package/dist/es5/context/context/create-browser-context.js +10 -2
- package/dist/es5/context/context/create-browser-context.js.map +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-context.js +0 -1
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +12 -0
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/esm/adapter/webgl-device.js +65 -17
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/classic/accessor.js.map +1 -1
- package/dist/esm/context/context/create-browser-context.js +8 -2
- package/dist/esm/context/context/create-browser-context.js.map +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-context.js +0 -1
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/adapter/resources/webgl-render-pipeline.ts +5 -1
- package/src/adapter/webgl-device.ts +79 -27
- package/src/classic/accessor.ts +0 -13
- package/src/context/context/create-browser-context.ts +6 -2
- package/src/context/debug/webgl-developer-tools.ts +2 -2
- package/src/context/polyfill/polyfill-context.ts +0 -2
- package/src/index.ts +1 -0
|
@@ -353,12 +353,18 @@ function getDrawMode(topology) {
|
|
|
353
353
|
case 'line-strip':
|
|
354
354
|
return GL.LINE_STRIP;
|
|
355
355
|
|
|
356
|
+
case 'line-loop':
|
|
357
|
+
return GL.LINE_LOOP;
|
|
358
|
+
|
|
356
359
|
case 'triangle-list':
|
|
357
360
|
return GL.TRIANGLES;
|
|
358
361
|
|
|
359
362
|
case 'triangle-strip':
|
|
360
363
|
return GL.TRIANGLE_STRIP;
|
|
361
364
|
|
|
365
|
+
case 'triangle-fan':
|
|
366
|
+
return GL.TRIANGLE_FAN;
|
|
367
|
+
|
|
362
368
|
default:
|
|
363
369
|
throw new Error(topology);
|
|
364
370
|
}
|
|
@@ -375,12 +381,18 @@ function getGLPrimitive(topology) {
|
|
|
375
381
|
case 'line-strip':
|
|
376
382
|
return GL.LINES;
|
|
377
383
|
|
|
384
|
+
case 'line-loop':
|
|
385
|
+
return GL.LINES;
|
|
386
|
+
|
|
378
387
|
case 'triangle-list':
|
|
379
388
|
return GL.TRIANGLES;
|
|
380
389
|
|
|
381
390
|
case 'triangle-strip':
|
|
382
391
|
return GL.TRIANGLES;
|
|
383
392
|
|
|
393
|
+
case 'triangle-fan':
|
|
394
|
+
return GL.TRIANGLES;
|
|
395
|
+
|
|
384
396
|
default:
|
|
385
397
|
throw new Error(topology);
|
|
386
398
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":["RenderPipeline","cast","log","decodeVertexFormat","GL","getWebGLDataType","getShaderLayout","withDeviceParameters","withGLParameters","setUniform","WEBGLBuffer","WEBGLTexture","WEBGLVertexArrayObject","LOG_PROGRAM_PERF_PRIORITY","WEBGLRenderPipeline","constructor","device","props","handle","gl","createProgram","__SPECTOR_Metadata","id","vs","fs","varyings","bufferMode","SEPARATE_ATTRIBS","length","assertWebGL2","gl2","transformFeedbackVaryings","_compileAndLink","layout","vertexArrayObject","destroy","deleteProgram","destroyed","setIndexBuffer","indexBuffer","webglBuffer","setElementBuffer","_indexBuffer","setAttributes","attributes","name","buffer","Object","entries","attribute","getAttributeLayout","warn","decoded","format","type","typeString","components","size","byteLength","stride","normalized","integer","divisor","stepMode","setBuffer","location","offset","setBindings","bindings","value","binding","find","Error","setUniforms","uniforms","assign","draw","options","renderPass","getDefaultRenderPass","vertexCount","indexCount","instanceCount","firstVertex","firstIndex","firstInstance","baseVertex","drawMode","getDrawMode","topology","isIndexed","Boolean","indexType","UNSIGNED_SHORT","UNSIGNED_INT","isInstanced","Number","_areTexturesRenderable","useProgram","bind","primitiveMode","getGLPrimitive","transformFeedback","begin","_applyBindings","_applyUniforms","parameters","framebuffer","drawElementsInstanced","drawElements","drawArraysInstanced","drawArrays","end","attachShader","time","linkProgram","timeEnd","debug","level","linked","getProgramParameter","LINK_STATUS","getProgramInfoLog","validateProgram","validated","VALIDATE_STATUS","texturesRenderable","texture","_textureUniforms","update","loaded","undefined","textureUnit","uniformBufferIndex","getUniformBlockIndex","INVALID_INDEX","uniformBlockBinding","bindBufferBase","UNIFORM_BUFFER","bindBufferRange","activeTexture","TEXTURE0","bindTexture","target","uniformLayout","POINTS","LINES","LINE_STRIP","TRIANGLES","TRIANGLE_STRIP","getAttributesByLocation","byLocation","getBindingLayout"],"mappings":";AAUA,SAAQA,cAAR,EAAwBC,IAAxB,EAA8BC,GAA9B,EAAmCC,kBAAnC,QAA4D,cAA5D;AACA,OAAOC,EAAP,MAAe,oBAAf;AAGA,SAAQC,gBAAR,QAA+B,+BAA/B;AACA,SAAQC,eAAR,QAA8B,8BAA9B;AACA,SAAQC,oBAAR,EAA8BC,gBAA9B,QAAqD,iCAArD;AACA,SAAQC,UAAR,QAAyB,wBAAzB;AAIA,OAAOC,WAAP,MAAwB,gBAAxB;AAEA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,sBAAP,MAAmC,sCAAnC;AAEA,MAAMC,yBAAyB,GAAG,CAAlC;AAGA,eAAe,MAAMC,mBAAN,SAAkCd,cAAlC,CAAiD;AAmB9De,EAAAA,WAAW,CAACC,MAAD,EAAsBC,KAAtB,EAAkD;AAC3D,UAAMD,MAAN,EAAcC,KAAd;;AAD2D;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,sCAVjC,IAUiC;;AAAA;;AAAA;;AAAA,sCAP7B,EAO6B;;AAAA,sCAN7B,EAM6B;;AAAA,8CALrB,EAKqB;;AAAA,kDAJ9B,CAI8B;;AAAA,2CAHrC,CAGqC;;AAAA,6CAFjB,EAEiB;;AAE3D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,IAAqB,KAAKF,MAAL,CAAYG,EAAZ,CAAeC,aAAf,EAAnC;AAEA,SAAKF,MAAL,CAAYG,kBAAZ,GAAiC;AAACC,MAAAA,EAAE,EAAE,KAAKL,KAAL,CAAWK;AAAhB,KAAjC;AAGA,SAAKC,EAAL,GAAUtB,IAAI,CAAcgB,KAAK,CAACM,EAApB,CAAd;AACA,SAA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B,CAAsBD,OAAD,IAAaA,OAAO,CAACzB,IAAR,KAAiBA,IAAnD,CAAhB;;AACA,MAAI,CAACyB,OAAL,EAAc;AACZ,UAAM,IAAIE,KAAJ,2BAA6B3B,IAA7B,EAAN;AACD;;AACD,SAAOyB,OAAP;AACD","sourcesContent":["import type {\n RenderPipelineProps,\n RenderPass,\n Buffer,\n Binding,\n ShaderLayout,\n PrimitiveTopology,\n BindingLayout,\n AttributeLayout\n} from '@luma.gl/api';\nimport {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\nimport type {GLParameters} from '../../types/webgl';\nimport {getWebGLDataType} from '../converters/texture-formats';\nimport {getShaderLayout} from '../helpers/get-shader-layout';\nimport {withDeviceParameters, withGLParameters} from '../converters/device-parameters';\nimport {setUniform} from '../helpers/set-uniform';\n// import {copyUniform, checkUniformValues} from '../../classes/uniforms';\n\nimport WebGLDevice from '../webgl-device';\nimport WEBGLBuffer from './webgl-buffer';\nimport WEBGLShader from './webgl-shader';\nimport WEBGLTexture from './webgl-texture';\nimport WEBGLVertexArrayObject from '../objects/webgl-vertex-array-object';\n\nconst LOG_PROGRAM_PERF_PRIORITY = 4;\n\n/** Creates a new render pipeline */\nexport default class WEBGLRenderPipeline extends RenderPipeline {\n device: WebGLDevice;\n handle: WebGLProgram;\n vs: WEBGLShader;\n fs: WEBGLShader;\n layout: ShaderLayout;\n\n // configuration: ProgramConfiguration;\n // Experimental flag to avoid deleting Program object while it is cached\n varyings: string[] | null = null;\n vertexArrayObject: WEBGLVertexArrayObject;\n _indexBuffer?: Buffer;\n uniforms: Record<string, any> = {};\n bindings: Record<string, any> = {};\n _textureUniforms: Record<string, any> = {};\n _textureIndexCounter: number = 0;\n _uniformCount: number = 0;\n _uniformSetters: Record<string, Function> = {}; // TODO are these used?\n\n constructor(device: WebGLDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.gl.createProgram();\n // @ts-expect-error\n this.handle.__SPECTOR_Metadata = {id: this.props.id};\n\n // Create shaders if needed\n this.vs = cast<WEBGLShader>(props.vs);\n this.fs = cast<WEBGLShader>(props.fs);\n // assert(this.vs.stage === 'vertex');\n // assert(this.fs.stage === 'fragment');\n\n // Setup varyings if supplied\n // @ts-expect-error WebGL only\n const {varyings, bufferMode = GL.SEPARATE_ATTRIBS} = props;\n if (varyings && varyings.length > 0) {\n this.device.assertWebGL2();\n this.varyings = varyings;\n this.device.gl2?.transformFeedbackVaryings(this.handle, varyings, bufferMode);\n }\n\n this._compileAndLink();\n\n this.layout = props.layout || getShaderLayout(this.device.gl, this.handle);\n this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);\n }\n\n destroy(): void {\n if (this.handle) {\n this.device.gl.deleteProgram(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n const webglBuffer = cast<WEBGLBuffer>(indexBuffer);\n this.vertexArrayObject.setElementBuffer(webglBuffer);\n this._indexBuffer = indexBuffer;\n }\n\n /** @todo needed for portable model */\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const webglBuffer = cast<WEBGLBuffer>(buffer);\n const attribute = getAttributeLayout(this.layout, name);\n if (!attribute) {\n log.warn(`Ignoring buffer supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\" (buffer \"${buffer.id}\")`)();\n continue;\n }\n const decoded = decodeVertexFormat(attribute.format);\n const {type: typeString, components: size, byteLength: stride, normalized, integer} = decoded;\n const divisor = attribute.stepMode === 'instance' ? 1 : 0;\n const type = getWebGLDataType(typeString);\n this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {\n size,\n type,\n stride,\n offset: 0,\n normalized,\n integer,\n divisor: attribute.stepMode === 'instance' ? 1 : 0\n });\n }\n }\n\n /** @todo needed for portable model */\n setBindings(bindings: Record<string, Binding>): void {\n // if (log.priority >= 2) {\n // checkUniformValues(uniforms, this.id, this._uniformSetters);\n // }\n\n for (const [name, value] of Object.entries(bindings)) {\n const binding = this.layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();\n continue;\n }\n if (!value) {\n log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();\n }\n switch (binding.type) {\n case 'uniform':\n // @ts-expect-error\n if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {\n throw new Error('buffer value');\n }\n break;\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture value');\n }\n break;\n case 'sampler':\n log.warn(`Ignoring sampler ${name}`)();\n break;\n default:\n throw new Error(binding.type);\n }\n\n this.bindings[name] = value;\n }\n }\n\n setUniforms(uniforms: Record<string, any>) {\n // TODO - check against layout\n Object.assign(this.uniforms, uniforms);\n }\n\n /** @todo needed for portable model\n * @note The WebGL API is offers many ways to draw things\n * This function unifies those ways into a single call using common parameters with sane defaults\n */\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): boolean {\n const {\n renderPass = this.device.getDefaultRenderPass(),\n vertexCount,\n indexCount,\n instanceCount,\n firstVertex = 0,\n firstIndex,\n firstInstance,\n baseVertex\n } = options;\n\n const drawMode = getDrawMode(this.props.topology);\n const isIndexed: boolean = Boolean(this._indexBuffer);\n const indexType = this._indexBuffer?.props.indexType === 'uint16' ? GL.UNSIGNED_SHORT : GL.UNSIGNED_INT;\n const isInstanced: boolean = Number(options.instanceCount) > 0;\n\n // Avoid WebGL draw call when not rendering any data or values are incomplete\n // Note: async textures set as uniforms might still be loading.\n // Now that all uniforms have been updated, check if any texture\n // in the uniforms is not yet initialized, then we don't draw\n if (!this._areTexturesRenderable() || options.vertexCount === 0) {\n // (isInstanced && instanceCount === 0)\n return false;\n }\n\n this.device.gl.useProgram(this.handle);\n\n this.vertexArrayObject.bind(() => {\n const primitiveMode = getGLPrimitive(this.props.topology);\n const transformFeedback: any = null;\n if (transformFeedback) {\n transformFeedback.begin(primitiveMode);\n }\n\n // We have to apply bindings before every draw call since other draw calls will overwrite\n this._applyBindings();\n this._applyUniforms();\n\n // TODO - double context push/pop\n withDeviceParameters(this.device, this.props.parameters, () => {\n withGLParameters(this.device, {framebuffer: renderPass.props.framebuffer}, () => {\n // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension\n if (isIndexed && isInstanced) {\n // ANGLE_instanced_arrays extension\n this.device.gl2?.drawElementsInstanced(\n drawMode,\n vertexCount || 0, // indexCount?\n indexType,\n firstVertex,\n instanceCount || 0\n );\n // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {\n // this.device.gl2.drawRangeElements(drawMode, start, end, vertexCount, indexType, offset);\n } else if (isIndexed) {\n this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?\n } else if (isInstanced) {\n this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);\n } else {\n this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);\n }\n });\n\n if (transformFeedback) {\n transformFeedback.end();\n }\n });\n });\n\n return true;\n }\n\n // setAttributes(attributes: Record<string, Buffer>): void {}\n // setBindings(bindings: Record<string, Binding>): void {}\n\n protected _compileAndLink() {\n const {gl} = this.device;\n gl.attachShader(this.handle, this.vs.handle);\n gl.attachShader(this.handle, this.fs.handle);\n log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n gl.linkProgram(this.handle);\n log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n\n // Avoid checking program linking error in production\n // @ts-expect-error\n if (gl.debug || log.level > 0) {\n const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);\n if (!linked) {\n throw new Error(`Error linking: ${gl.getProgramInfoLog(this.handle)}`);\n }\n\n gl.validateProgram(this.handle);\n const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);\n if (!validated) {\n throw new Error(`Error validating: ${gl.getProgramInfoLog(this.handle)}`);\n }\n }\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks if all texture-values uniforms are renderable (i.e. loaded)\n * Update a texture if needed (e.g. from video)\n * Note: This is currently done before every draw call\n */\n _areTexturesRenderable() {\n let texturesRenderable = true;\n\n for (const [name, texture] of Object.entries(this._textureUniforms)) {\n texture.update();\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n\n for (const [name, texture] of Object.entries(this.bindings)) {\n // texture.update();\n if (texture.loaded !== undefined) {\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n }\n\n return texturesRenderable;\n }\n\n /** Apply any bindings */\n _applyBindings() {\n this.device.gl.useProgram(this.handle);\n\n const {gl2} = this.device;\n if (!gl2) {\n throw new Error('bindings');\n }\n\n let textureUnit = 0;\n let uniformBufferIndex = 0;\n for (const binding of this.layout.bindings) {\n const value = this.bindings[binding.name];\n if (!value) {\n throw new Error(`No value for binding ${binding.name} in ${this.id}`);\n }\n switch (binding.type) {\n case 'uniform':\n // Set buffer\n const {name} = binding;\n const location = gl2.getUniformBlockIndex(this.handle, name);\n if (location === GL.INVALID_INDEX) {\n throw new Error(`Invalid uniform block name ${name}`);\n }\n gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);\n // console.debug(binding, location);\n if (value instanceof WEBGLBuffer) {\n gl2.bindBufferBase(GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);\n } else {\n gl2.bindBufferRange(\n GL.UNIFORM_BUFFER,\n uniformBufferIndex,\n value.buffer.handle,\n value.offset || 0,\n value.size || value.buffer.byteLength - value.offset\n );\n }\n uniformBufferIndex += 1;\n break;\n\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture');\n }\n const texture: WEBGLTexture = value;\n gl2.activeTexture(GL.TEXTURE0 + textureUnit);\n gl2.bindTexture(texture.target, texture.handle);\n // gl2.bindSampler(textureUnit, sampler.handle);\n textureUnit += 1;\n break;\n\n case 'sampler':\n // ignore\n break;\n\n case 'storage':\n case 'read-only-storage':\n throw new Error(`binding type '${binding.type}' not supported in WebGL`);\n }\n }\n }\n\n _applyUniforms() {\n for (const uniformLayout of this.layout.uniforms || []) {\n const {name, location, type, textureUnit} = uniformLayout;\n const value = this.uniforms[name] || textureUnit;\n if (value !== undefined) {\n setUniform(this.device.gl, location, type, value);\n }\n }\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getDrawMode(\n topology: PrimitiveTopology\n): GL.POINTS | GL.LINES | GL.LINE_STRIP | GL.TRIANGLES | GL.TRIANGLE_STRIP {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINE_STRIP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n default: throw new Error(topology);\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getGLPrimitive(topology: PrimitiveTopology): GL.POINTS | GL.LINES | GL.TRIANGLES {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n\nfunction getAttributesByLocation(\n attributes: Record<string, Buffer>,\n layout: ShaderLayout\n): Record<number, Buffer> {\n const byLocation: Record<number, Buffer> = {};\n for (const [name, buffer] of Object.entries(attributes)) {\n const attribute = getAttributeLayout(layout, name);\n if (attribute) {\n byLocation[attribute.location] = buffer;\n }\n }\n return byLocation;\n}\n\nfunction getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {\n return layout.attributes.find((binding) => binding.name === name) || null;\n}\n\nfunction getBindingLayout(layout: ShaderLayout, name: string): BindingLayout {\n const binding = layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n throw new Error(`Unknown binding ${name}`);\n }\n return binding;\n}\n"],"file":"webgl-render-pipeline.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/resources/webgl-render-pipeline.ts"],"names":["RenderPipeline","cast","log","decodeVertexFormat","GL","getWebGLDataType","getShaderLayout","withDeviceParameters","withGLParameters","setUniform","WEBGLBuffer","WEBGLTexture","WEBGLVertexArrayObject","LOG_PROGRAM_PERF_PRIORITY","WEBGLRenderPipeline","constructor","device","props","handle","gl","createProgram","__SPECTOR_Metadata","id","vs","fs","varyings","bufferMode","SEPARATE_ATTRIBS","length","assertWebGL2","gl2","transformFeedbackVaryings","_compileAndLink","layout","vertexArrayObject","destroy","deleteProgram","destroyed","setIndexBuffer","indexBuffer","webglBuffer","setElementBuffer","_indexBuffer","setAttributes","attributes","name","buffer","Object","entries","attribute","getAttributeLayout","warn","decoded","format","type","typeString","components","size","byteLength","stride","normalized","integer","divisor","stepMode","setBuffer","location","offset","setBindings","bindings","value","binding","find","Error","setUniforms","uniforms","assign","draw","options","renderPass","getDefaultRenderPass","vertexCount","indexCount","instanceCount","firstVertex","firstIndex","firstInstance","baseVertex","drawMode","getDrawMode","topology","isIndexed","Boolean","indexType","UNSIGNED_SHORT","UNSIGNED_INT","isInstanced","Number","_areTexturesRenderable","useProgram","bind","primitiveMode","getGLPrimitive","transformFeedback","begin","_applyBindings","_applyUniforms","parameters","framebuffer","drawElementsInstanced","drawElements","drawArraysInstanced","drawArrays","end","attachShader","time","linkProgram","timeEnd","debug","level","linked","getProgramParameter","LINK_STATUS","getProgramInfoLog","validateProgram","validated","VALIDATE_STATUS","texturesRenderable","texture","_textureUniforms","update","loaded","undefined","textureUnit","uniformBufferIndex","getUniformBlockIndex","INVALID_INDEX","uniformBlockBinding","bindBufferBase","UNIFORM_BUFFER","bindBufferRange","activeTexture","TEXTURE0","bindTexture","target","uniformLayout","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN","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CAA0BzH,MAA1B,EAAgDY,IAAhD,EAA6E;AAC3E,QAAMyB,OAAO,GAAGrC,MAAM,CAACmC,QAAP,CAAgBG,IAAhB,CAAsBD,OAAD,IAAaA,OAAO,CAACzB,IAAR,KAAiBA,IAAnD,CAAhB;;AACA,MAAI,CAACyB,OAAL,EAAc;AACZ,UAAM,IAAIE,KAAJ,2BAA6B3B,IAA7B,EAAN;AACD;;AACD,SAAOyB,OAAP;AACD","sourcesContent":["import type {\n RenderPipelineProps,\n RenderPass,\n Buffer,\n Binding,\n ShaderLayout,\n PrimitiveTopology,\n BindingLayout,\n AttributeLayout\n} from '@luma.gl/api';\nimport {RenderPipeline, cast, log, decodeVertexFormat} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\nimport type {GLParameters} from '../../types/webgl';\nimport {getWebGLDataType} from '../converters/texture-formats';\nimport {getShaderLayout} from '../helpers/get-shader-layout';\nimport {withDeviceParameters, withGLParameters} from '../converters/device-parameters';\nimport {setUniform} from '../helpers/set-uniform';\n// import {copyUniform, checkUniformValues} from '../../classes/uniforms';\n\nimport WebGLDevice from '../webgl-device';\nimport WEBGLBuffer from './webgl-buffer';\nimport WEBGLShader from './webgl-shader';\nimport WEBGLTexture from './webgl-texture';\nimport WEBGLVertexArrayObject from '../objects/webgl-vertex-array-object';\n\nconst LOG_PROGRAM_PERF_PRIORITY = 4;\n\n/** Creates a new render pipeline */\nexport default class WEBGLRenderPipeline extends RenderPipeline {\n device: WebGLDevice;\n handle: WebGLProgram;\n vs: WEBGLShader;\n fs: WEBGLShader;\n layout: ShaderLayout;\n\n // configuration: ProgramConfiguration;\n // Experimental flag to avoid deleting Program object while it is cached\n varyings: string[] | null = null;\n vertexArrayObject: WEBGLVertexArrayObject;\n _indexBuffer?: Buffer;\n uniforms: Record<string, any> = {};\n bindings: Record<string, any> = {};\n _textureUniforms: Record<string, any> = {};\n _textureIndexCounter: number = 0;\n _uniformCount: number = 0;\n _uniformSetters: Record<string, Function> = {}; // TODO are these used?\n\n constructor(device: WebGLDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.gl.createProgram();\n // @ts-expect-error\n this.handle.__SPECTOR_Metadata = {id: this.props.id};\n\n // Create shaders if needed\n this.vs = cast<WEBGLShader>(props.vs);\n this.fs = cast<WEBGLShader>(props.fs);\n // assert(this.vs.stage === 'vertex');\n // assert(this.fs.stage === 'fragment');\n\n // Setup varyings if supplied\n // @ts-expect-error WebGL only\n const {varyings, bufferMode = GL.SEPARATE_ATTRIBS} = props;\n if (varyings && varyings.length > 0) {\n this.device.assertWebGL2();\n this.varyings = varyings;\n this.device.gl2?.transformFeedbackVaryings(this.handle, varyings, bufferMode);\n }\n\n this._compileAndLink();\n\n this.layout = props.layout || getShaderLayout(this.device.gl, this.handle);\n this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);\n }\n\n destroy(): void {\n if (this.handle) {\n this.device.gl.deleteProgram(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n const webglBuffer = cast<WEBGLBuffer>(indexBuffer);\n this.vertexArrayObject.setElementBuffer(webglBuffer);\n this._indexBuffer = indexBuffer;\n }\n\n /** @todo needed for portable model */\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const webglBuffer = cast<WEBGLBuffer>(buffer);\n const attribute = getAttributeLayout(this.layout, name);\n if (!attribute) {\n log.warn(`Ignoring buffer supplied for unknown attribute \"${name}\" in pipeline \"${this.id}\" (buffer \"${buffer.id}\")`)();\n continue;\n }\n const decoded = decodeVertexFormat(attribute.format);\n const {type: typeString, components: size, byteLength: stride, normalized, integer} = decoded;\n const divisor = attribute.stepMode === 'instance' ? 1 : 0;\n const type = getWebGLDataType(typeString);\n this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {\n size,\n type,\n stride,\n offset: 0,\n normalized,\n integer,\n divisor: attribute.stepMode === 'instance' ? 1 : 0\n });\n }\n }\n\n /** @todo needed for portable model */\n setBindings(bindings: Record<string, Binding>): void {\n // if (log.priority >= 2) {\n // checkUniformValues(uniforms, this.id, this._uniformSetters);\n // }\n\n for (const [name, value] of Object.entries(bindings)) {\n const binding = this.layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n log.warn(`Unknown binding ${name} in render pipeline ${this.id}`)();\n continue;\n }\n if (!value) {\n log.warn(`Unsetting binding ${name} in render pipeline ${this.id}`)();\n }\n switch (binding.type) {\n case 'uniform':\n // @ts-expect-error\n if (!(value instanceof WEBGLBuffer) && !(value.buffer instanceof WEBGLBuffer)) {\n throw new Error('buffer value');\n }\n break;\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture value');\n }\n break;\n case 'sampler':\n log.warn(`Ignoring sampler ${name}`)();\n break;\n default:\n throw new Error(binding.type);\n }\n\n this.bindings[name] = value;\n }\n }\n\n setUniforms(uniforms: Record<string, any>) {\n // TODO - check against layout\n Object.assign(this.uniforms, uniforms);\n }\n\n /** @todo needed for portable model\n * @note The WebGL API is offers many ways to draw things\n * This function unifies those ways into a single call using common parameters with sane defaults\n */\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): boolean {\n const {\n renderPass = this.device.getDefaultRenderPass(),\n vertexCount,\n indexCount,\n instanceCount,\n firstVertex = 0,\n firstIndex,\n firstInstance,\n baseVertex\n } = options;\n\n const drawMode = getDrawMode(this.props.topology);\n const isIndexed: boolean = Boolean(this._indexBuffer);\n const indexType = this._indexBuffer?.props.indexType === 'uint16' ? GL.UNSIGNED_SHORT : GL.UNSIGNED_INT;\n const isInstanced: boolean = Number(options.instanceCount) > 0;\n\n // Avoid WebGL draw call when not rendering any data or values are incomplete\n // Note: async textures set as uniforms might still be loading.\n // Now that all uniforms have been updated, check if any texture\n // in the uniforms is not yet initialized, then we don't draw\n if (!this._areTexturesRenderable() || options.vertexCount === 0) {\n // (isInstanced && instanceCount === 0)\n return false;\n }\n\n this.device.gl.useProgram(this.handle);\n\n this.vertexArrayObject.bind(() => {\n const primitiveMode = getGLPrimitive(this.props.topology);\n const transformFeedback: any = null;\n if (transformFeedback) {\n transformFeedback.begin(primitiveMode);\n }\n\n // We have to apply bindings before every draw call since other draw calls will overwrite\n this._applyBindings();\n this._applyUniforms();\n\n // TODO - double context push/pop\n withDeviceParameters(this.device, this.props.parameters, () => {\n withGLParameters(this.device, {framebuffer: renderPass.props.framebuffer}, () => {\n // TODO - Use polyfilled WebGL2RenderingContext instead of ANGLE extension\n if (isIndexed && isInstanced) {\n // ANGLE_instanced_arrays extension\n this.device.gl2?.drawElementsInstanced(\n drawMode,\n vertexCount || 0, // indexCount?\n indexType,\n firstVertex,\n instanceCount || 0\n );\n // } else if (isIndexed && this.device.isWebGL2 && !isNaN(start) && !isNaN(end)) {\n // this.device.gl2.drawRangeElements(drawMode, start, end, vertexCount, indexType, offset);\n } else if (isIndexed) {\n this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex); // indexCount?\n } else if (isInstanced) {\n this.device.gl2?.drawArraysInstanced(drawMode, firstVertex, vertexCount || 0, instanceCount || 0);\n } else {\n this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);\n }\n });\n\n if (transformFeedback) {\n transformFeedback.end();\n }\n });\n });\n\n return true;\n }\n\n // setAttributes(attributes: Record<string, Buffer>): void {}\n // setBindings(bindings: Record<string, Binding>): void {}\n\n protected _compileAndLink() {\n const {gl} = this.device;\n gl.attachShader(this.handle, this.vs.handle);\n gl.attachShader(this.handle, this.fs.handle);\n log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n gl.linkProgram(this.handle);\n log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();\n\n // Avoid checking program linking error in production\n // @ts-expect-error\n if (gl.debug || log.level > 0) {\n const linked = gl.getProgramParameter(this.handle, gl.LINK_STATUS);\n if (!linked) {\n throw new Error(`Error linking: ${gl.getProgramInfoLog(this.handle)}`);\n }\n\n gl.validateProgram(this.handle);\n const validated = gl.getProgramParameter(this.handle, gl.VALIDATE_STATUS);\n if (!validated) {\n throw new Error(`Error validating: ${gl.getProgramInfoLog(this.handle)}`);\n }\n }\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks if all texture-values uniforms are renderable (i.e. loaded)\n * Update a texture if needed (e.g. from video)\n * Note: This is currently done before every draw call\n */\n _areTexturesRenderable() {\n let texturesRenderable = true;\n\n for (const [name, texture] of Object.entries(this._textureUniforms)) {\n texture.update();\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n\n for (const [name, texture] of Object.entries(this.bindings)) {\n // texture.update();\n if (texture.loaded !== undefined) {\n texturesRenderable = texturesRenderable && texture.loaded;\n }\n }\n\n return texturesRenderable;\n }\n\n /** Apply any bindings */\n _applyBindings() {\n this.device.gl.useProgram(this.handle);\n\n const {gl2} = this.device;\n if (!gl2) {\n throw new Error('bindings');\n }\n\n let textureUnit = 0;\n let uniformBufferIndex = 0;\n for (const binding of this.layout.bindings) {\n const value = this.bindings[binding.name];\n if (!value) {\n throw new Error(`No value for binding ${binding.name} in ${this.id}`);\n }\n switch (binding.type) {\n case 'uniform':\n // Set buffer\n const {name} = binding;\n const location = gl2.getUniformBlockIndex(this.handle, name);\n if (location === GL.INVALID_INDEX) {\n throw new Error(`Invalid uniform block name ${name}`);\n }\n gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);\n // console.debug(binding, location);\n if (value instanceof WEBGLBuffer) {\n gl2.bindBufferBase(GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);\n } else {\n gl2.bindBufferRange(\n GL.UNIFORM_BUFFER,\n uniformBufferIndex,\n value.buffer.handle,\n value.offset || 0,\n value.size || value.buffer.byteLength - value.offset\n );\n }\n uniformBufferIndex += 1;\n break;\n\n case 'texture':\n if (!(value instanceof WEBGLTexture)) {\n throw new Error('texture');\n }\n const texture: WEBGLTexture = value;\n gl2.activeTexture(GL.TEXTURE0 + textureUnit);\n gl2.bindTexture(texture.target, texture.handle);\n // gl2.bindSampler(textureUnit, sampler.handle);\n textureUnit += 1;\n break;\n\n case 'sampler':\n // ignore\n break;\n\n case 'storage':\n case 'read-only-storage':\n throw new Error(`binding type '${binding.type}' not supported in WebGL`);\n }\n }\n }\n\n _applyUniforms() {\n for (const uniformLayout of this.layout.uniforms || []) {\n const {name, location, type, textureUnit} = uniformLayout;\n const value = this.uniforms[name] || textureUnit;\n if (value !== undefined) {\n setUniform(this.device.gl, location, type, value);\n }\n }\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getDrawMode(\n topology: PrimitiveTopology\n): GL.POINTS | GL.LINES | GL.LINE_STRIP | GL.LINE_LOOP | GL.TRIANGLES | GL.TRIANGLE_STRIP | GL.TRIANGLE_FAN {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINE_STRIP;\n case 'line-loop': return GL.LINE_LOOP;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLE_STRIP;\n case 'triangle-fan': return GL.TRIANGLE_FAN;\n default: throw new Error(topology);\n }\n}\n\n/** Get the primitive type for transform feedback */\nfunction getGLPrimitive(topology: PrimitiveTopology): GL.POINTS | GL.LINES | GL.TRIANGLES {\n // prettier-ignore\n switch (topology) {\n case 'point-list': return GL.POINTS;\n case 'line-list': return GL.LINES;\n case 'line-strip': return GL.LINES;\n case 'line-loop': return GL.LINES;\n case 'triangle-list': return GL.TRIANGLES;\n case 'triangle-strip': return GL.TRIANGLES;\n case 'triangle-fan': return GL.TRIANGLES;\n default: throw new Error(topology);\n }\n}\n\nfunction getAttributesByLocation(\n attributes: Record<string, Buffer>,\n layout: ShaderLayout\n): Record<number, Buffer> {\n const byLocation: Record<number, Buffer> = {};\n for (const [name, buffer] of Object.entries(attributes)) {\n const attribute = getAttributeLayout(layout, name);\n if (attribute) {\n byLocation[attribute.location] = buffer;\n }\n }\n return byLocation;\n}\n\nfunction getAttributeLayout(layout: ShaderLayout, name: string): AttributeLayout | null {\n return layout.attributes.find((binding) => binding.name === name) || null;\n}\n\nfunction getBindingLayout(layout: ShaderLayout, name: string): BindingLayout {\n const binding = layout.bindings.find((binding) => binding.name === name);\n if (!binding) {\n throw new Error(`Unknown binding ${name}`);\n }\n return binding;\n}\n"],"file":"webgl-render-pipeline.js"}
|
|
@@ -17,26 +17,27 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
17
17
|
static isSupported(): boolean;
|
|
18
18
|
readonly info: DeviceInfo;
|
|
19
19
|
readonly canvasContext: WebGLCanvasContext;
|
|
20
|
+
readonly handle: WebGLRenderingContext;
|
|
21
|
+
get features(): Set<DeviceFeature>;
|
|
22
|
+
get limits(): DeviceLimits;
|
|
20
23
|
readonly lost: Promise<{
|
|
21
24
|
reason: 'destroyed';
|
|
22
25
|
message: string;
|
|
23
26
|
}>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
private _resolveContextLost?;
|
|
28
|
+
private _features?;
|
|
29
|
+
private _limits?;
|
|
27
30
|
/** WebGL1 typed context. Can always be used. */
|
|
28
31
|
readonly gl: WebGLRenderingContext;
|
|
29
32
|
/** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */
|
|
30
|
-
readonly gl2: WebGL2RenderingContext;
|
|
33
|
+
readonly gl2: WebGL2RenderingContext | null;
|
|
31
34
|
readonly debug: boolean;
|
|
32
35
|
/** `true` if this is a WebGL1 context. @note `false` if WebGL2 */
|
|
33
36
|
readonly isWebGL1: boolean;
|
|
34
37
|
/** `true` if this is a WebGL2 context. @note `false` if WebGL1 */
|
|
35
38
|
readonly isWebGL2: boolean;
|
|
36
39
|
get webglLimits(): WebGLLimits;
|
|
37
|
-
private
|
|
38
|
-
private _limits;
|
|
39
|
-
private _webglLimits;
|
|
40
|
+
private _webglLimits?;
|
|
40
41
|
/** State used by luma.gl classes: TODO - move to canvasContext*/
|
|
41
42
|
readonly _canvasSizeInfo: {
|
|
42
43
|
clientWidth: number;
|
|
@@ -62,6 +63,11 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
62
63
|
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
63
64
|
*/
|
|
64
65
|
destroy(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Loses the context
|
|
68
|
+
* @note Triggers context loss, mainly for testing
|
|
69
|
+
*/
|
|
70
|
+
loseDevice(): void;
|
|
65
71
|
get isLost(): boolean;
|
|
66
72
|
getSize(): [number, number];
|
|
67
73
|
isTextureFormatSupported(format: TextureFormat): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAc,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAC,YAAY,EAAC,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-device.d.ts","sourceRoot":"","sources":["../../src/adapter/webgl-device.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,MAAM,EAAE,aAAa,EAAc,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAC,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAQ9D,OAAO,EAAkC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAC5F,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AAUxD,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,YA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E,WAAW,GAAG,WAAW;IAI7C,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB;IAI5D,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB;IAIrE,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,eAAe;IAIxD,qBAAqB,CAAC,KAAK,CAAC,EAAE,oBAAoB,GAAG,eAAe;IAIpE,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW;IAItD,OAAO,CAAC,UAAU,CAAgC;IAElD,oBAAoB,IAAI,eAAe;IASvC;;;;OAIG;IACH,MAAM,IAAI,IAAI;CAKf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Device, CanvasContext, log
|
|
2
|
+
import { Device, CanvasContext, log } from '@luma.gl/api';
|
|
3
3
|
import { isBrowser } from '@probe.gl/env';
|
|
4
4
|
import { polyfillContext } from '../context/polyfill/polyfill-context';
|
|
5
5
|
import { trackContextState } from '../context/state-tracker/track-context-state';
|
|
@@ -59,7 +59,7 @@ export default class WebGLDevice extends Device {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
static async create(props) {
|
|
62
|
+
static async create(props = {}) {
|
|
63
63
|
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
|
|
64
64
|
|
|
65
65
|
if (typeof props.canvas === 'string') {
|
|
@@ -74,7 +74,12 @@ export default class WebGLDevice extends Device {
|
|
|
74
74
|
await loadSpectorJS();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
log.probe(LOG_LEVEL, 'DOM is loaded')();
|
|
77
|
+
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
78
|
+
|
|
79
|
+
if (props.gl && props.gl.device) {
|
|
80
|
+
return WebGLDevice.attach(props.gl);
|
|
81
|
+
}
|
|
82
|
+
|
|
78
83
|
return new WebGLDevice(props);
|
|
79
84
|
}
|
|
80
85
|
|
|
@@ -87,13 +92,19 @@ export default class WebGLDevice extends Device {
|
|
|
87
92
|
|
|
88
93
|
_defineProperty(this, "canvasContext", void 0);
|
|
89
94
|
|
|
95
|
+
_defineProperty(this, "handle", void 0);
|
|
96
|
+
|
|
90
97
|
_defineProperty(this, "lost", void 0);
|
|
91
98
|
|
|
92
|
-
_defineProperty(this, "
|
|
99
|
+
_defineProperty(this, "_resolveContextLost", void 0);
|
|
100
|
+
|
|
101
|
+
_defineProperty(this, "_features", void 0);
|
|
102
|
+
|
|
103
|
+
_defineProperty(this, "_limits", void 0);
|
|
93
104
|
|
|
94
105
|
_defineProperty(this, "gl", void 0);
|
|
95
106
|
|
|
96
|
-
_defineProperty(this, "gl2",
|
|
107
|
+
_defineProperty(this, "gl2", null);
|
|
97
108
|
|
|
98
109
|
_defineProperty(this, "debug", false);
|
|
99
110
|
|
|
@@ -101,10 +112,6 @@ export default class WebGLDevice extends Device {
|
|
|
101
112
|
|
|
102
113
|
_defineProperty(this, "isWebGL2", void 0);
|
|
103
114
|
|
|
104
|
-
_defineProperty(this, "_features", void 0);
|
|
105
|
-
|
|
106
|
-
_defineProperty(this, "_limits", void 0);
|
|
107
|
-
|
|
108
115
|
_defineProperty(this, "_webglLimits", void 0);
|
|
109
116
|
|
|
110
117
|
_defineProperty(this, "_canvasSizeInfo", {
|
|
@@ -119,19 +126,40 @@ export default class WebGLDevice extends Device {
|
|
|
119
126
|
|
|
120
127
|
_defineProperty(this, "spector", void 0);
|
|
121
128
|
|
|
122
|
-
_defineProperty(this, "renderPass",
|
|
129
|
+
_defineProperty(this, "renderPass", null);
|
|
123
130
|
|
|
124
131
|
const device = (_props$gl = props.gl) === null || _props$gl === void 0 ? void 0 : _props$gl.device;
|
|
125
132
|
|
|
126
133
|
if (device) {
|
|
127
|
-
|
|
128
|
-
return device;
|
|
134
|
+
throw new Error("WebGL context already attached to device ".concat(device.id));
|
|
129
135
|
}
|
|
130
136
|
|
|
131
137
|
this.canvasContext = new WebGLCanvasContext(this, props);
|
|
138
|
+
this.lost = new Promise(resolve => {
|
|
139
|
+
this._resolveContextLost = resolve;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const onContextLost = event => {
|
|
143
|
+
var _this$_resolveContext;
|
|
144
|
+
|
|
145
|
+
return (_this$_resolveContext = this._resolveContextLost) === null || _this$_resolveContext === void 0 ? void 0 : _this$_resolveContext.call(this, {
|
|
146
|
+
reason: 'destroyed',
|
|
147
|
+
message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
132
151
|
let gl = props.gl;
|
|
133
|
-
gl = gl || isBrowser()
|
|
134
|
-
|
|
152
|
+
gl = gl || (isBrowser() ? createBrowserContext(this.canvasContext.canvas, { ...props,
|
|
153
|
+
onContextLost
|
|
154
|
+
}) : null);
|
|
155
|
+
gl = gl || (!isBrowser() ? createHeadlessContext({ ...props,
|
|
156
|
+
onContextLost
|
|
157
|
+
}) : null);
|
|
158
|
+
|
|
159
|
+
if (!gl) {
|
|
160
|
+
throw new Error('WebGL context creation failed');
|
|
161
|
+
}
|
|
162
|
+
|
|
135
163
|
this.handle = gl;
|
|
136
164
|
this.gl = this.handle;
|
|
137
165
|
this.gl2 = this.gl;
|
|
@@ -175,13 +203,28 @@ export default class WebGLDevice extends Device {
|
|
|
175
203
|
}
|
|
176
204
|
|
|
177
205
|
destroy() {
|
|
178
|
-
|
|
206
|
+
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
179
207
|
|
|
180
208
|
if (ext) {
|
|
181
209
|
ext.destroy();
|
|
182
210
|
}
|
|
183
211
|
}
|
|
184
212
|
|
|
213
|
+
loseDevice() {
|
|
214
|
+
var _this$_resolveContext2;
|
|
215
|
+
|
|
216
|
+
const ext = this.gl.getExtension('WEBGL_lose_context');
|
|
217
|
+
|
|
218
|
+
if (ext) {
|
|
219
|
+
ext.loseContext();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
(_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
|
|
223
|
+
reason: 'destroyed',
|
|
224
|
+
message: 'Application triggered context loss'
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
185
228
|
get isLost() {
|
|
186
229
|
return this.gl.isContextLost();
|
|
187
230
|
}
|
|
@@ -203,7 +246,10 @@ export default class WebGLDevice extends Device {
|
|
|
203
246
|
}
|
|
204
247
|
|
|
205
248
|
assertWebGL2() {
|
|
206
|
-
|
|
249
|
+
if (!this.gl2) {
|
|
250
|
+
throw new Error('Requires WebGL2');
|
|
251
|
+
}
|
|
252
|
+
|
|
207
253
|
return this.gl2;
|
|
208
254
|
}
|
|
209
255
|
|
|
@@ -259,7 +305,9 @@ export default class WebGLDevice extends Device {
|
|
|
259
305
|
}
|
|
260
306
|
|
|
261
307
|
submit() {
|
|
262
|
-
|
|
308
|
+
var _this$renderPass;
|
|
309
|
+
|
|
310
|
+
(_this$renderPass = this.renderPass) === null || _this$renderPass === void 0 ? void 0 : _this$renderPass.endPass();
|
|
263
311
|
this.renderPass = null;
|
|
264
312
|
}
|
|
265
313
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","assert","isBrowser","polyfillContext","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","webglLimits","_webglLimits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","warn","id","canvasContext","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","message","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,EAAoCC,MAApC,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,iBAAR,QAAgC,8CAAhC;AAEA,SAAQC,oBAAR,QAAmC,2CAAnC;AACA,SAAQC,qBAAR,EAA+BC,sBAA/B,QAA4D,4CAA5D;AACA,SAAQC,aAAR,QAA4B,kCAA5B;AACA,SAAQC,iBAAR,QAAgC,kCAAhC;AACA,SAAQC,eAAR,EAAyBC,cAAzB,QAA2D,gCAA3D;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,SAAQC,aAAR,EAAuBC,mBAAvB,QAAiD,0BAAjD;AACA,SAAQC,uBAAR,EAAiCC,gBAAjC,QAAwD,wCAAxD;AACA,SACEC,wBADF,EAEEC,yBAFF,EAGEC,yBAHF,QAIO,8BAJP;AA0BA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AACA,OAAOC,eAAP,MAA4B,+BAA5B;AACA,OAAOC,mBAAP,MAAgC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F,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAEDuD,EAAAA,gBAAgB,CAACrD,KAAD,EAAuC;AACrD,UAAM,IAAIF,KAAJ,CAAU,wCAAV,CAAN;AACD;;AAIDwD,EAAAA,oBAAoB,GAAoB;AACtC,SAAKC,UAAL,GACE,KAAKA,UAAL,IACA,KAAKJ,eAAL,CAAqB;AACnBK,MAAAA,WAAW,EAAE,KAAK3C,aAAL,CAAmB4C,qBAAnB;AADM,KAArB,CAFF;AAKA,WAAO,KAAKF,UAAZ;AACD;;AAODG,EAAAA,MAAM,GAAS;AACb,SAAKH,UAAL,CAAgBI,OAAhB;AACA,SAAKJ,UAAL,GAAkB,IAAlB;AAED;;AApRqE;;gBAAnDtE,W,UAGG,O;;AAqRxB,SAASY,OAAT,CAAiBP,EAAjB,EAAmC;AACjC,MAAI,OAAOH,qBAAP,KAAiC,WAAjC,IAAgDG,EAAE,YAAYH,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOyE,sBAAP,KAAkC,WAAlC,IAAiDtE,EAAE,YAAYsE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACvE,EAAE,IAAIwE,MAAM,CAACC,QAAP,CAAgBzE,EAAE,CAAC6B,QAAnB,CAAP,CAAd;AACD;;AAID,SAASH,QAAT,CAAkB1B,EAAlB,EAAoC;AAClC,MAAI,OAAOsE,sBAAP,KAAkC,WAAlC,IAAiDtE,EAAE,YAAYsE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACvE,EAAE,IAAIA,EAAE,CAAC6B,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {createHeadlessContext, isHeadlessGLRegistered} 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} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\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';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n // Public API\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 readonly lost: Promise<{reason: 'destroyed'; message: string}>;\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 // WebGL specific API\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;\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 get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _features: Set<DeviceFeature>;\n private _limits: DeviceLimits;\n private _webglLimits: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\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 (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL, 'DOM is loaded')();\n return new WebGLDevice(props);\n }\n\n constructor(props: DeviceProps) {\n super(props);\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 log.warn(`WebGL context already attached to device ${device.id}`);\n return device;\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n let gl = props.gl;\n gl = gl || (isBrowser() && createBrowserContext(this.canvasContext.canvas, props));\n gl = gl || (!isBrowser() && createHeadlessContext(props));\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() {\n let ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n // ext = this.gl.getExtension('WEBGL_lose_context');\n // if (ext) {\n // // TODO - disconnect context lost callbacks?\n // ext.loseContext();\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 assert(this.isWebGL2, 'Requires WebGL2');\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): WEBGLBuffer {\n return new ClassicBuffer(this, props);\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 beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass;\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 /**\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.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\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\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"],"file":"webgl-device.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","isBrowser","polyfillContext","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","webglLimits","_webglLimits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","id","canvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","loseDevice","loseContext","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,iBAAR,QAAgC,8CAAhC;AAEA,SAAQC,oBAAR,QAAmC,2CAAnC;AACA,SACEC,qBADF,EAEEC,sBAFF,QAGO,4CAHP;AAIA,SAAQC,aAAR,QAA4B,kCAA5B;AACA,SAAQC,iBAAR,QAAgC,kCAAhC;AACA,SAAQC,eAAR,EAAyBC,cAAzB,QAA2D,gCAA3D;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,SAAQC,aAAR,EAAuBC,mBAAvB,QAAiD,0BAAjD;AACA,SA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Info,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/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} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\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';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\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 // 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 get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _webglLimits?: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\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 (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.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);\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;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : 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() {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n */\n loseDevice() {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\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): WEBGLBuffer {\n return new ClassicBuffer(this, props);\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 beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n /**\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?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\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"],"file":"webgl-device.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGpC,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AASF,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,cAAc;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAY1D,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ;gBAI5C,GAAG,SAAS,EAAE,cAAc,EAAE;IAK1C,QAAQ,IAAI,MAAM;IAOlB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA6E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/classic/accessor.ts"],"names":["assert","checkProps","GL","getTypedArrayFromGLType","DEFAULT_ACCESSOR_VALUES","offset","stride","type","FLOAT","size","divisor","normalized","integer","PROP_CHECKS","deprecatedProps","instanced","isInstanced","Accessor","getBytesPerElement","accessor","ArrayType","BYTES_PER_ELEMENT","getBytesPerVertex","resolve","accessors","constructor","forEach","_assign","Object","freeze","toString","JSON","stringify","BYTES_PER_VERTEX","props","undefined","INT","UNSIGNED_INT","normalize","buffer","index"],"mappings":";AAAA,SAAQA,MAAR,EAAgBC,UAAhB,QAAyD,cAAzD;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,uBAAR,QAAsC,qBAAtC;
|
|
1
|
+
{"version":3,"sources":["../../src/classic/accessor.ts"],"names":["assert","checkProps","GL","getTypedArrayFromGLType","DEFAULT_ACCESSOR_VALUES","offset","stride","type","FLOAT","size","divisor","normalized","integer","PROP_CHECKS","deprecatedProps","instanced","isInstanced","Accessor","getBytesPerElement","accessor","ArrayType","BYTES_PER_ELEMENT","getBytesPerVertex","resolve","accessors","constructor","forEach","_assign","Object","freeze","toString","JSON","stringify","BYTES_PER_VERTEX","props","undefined","INT","UNSIGNED_INT","normalize","buffer","index"],"mappings":";AAAA,SAAQA,MAAR,EAAgBC,UAAhB,QAAyD,cAAzD;AACA,OAAOC,EAAP,MAAe,oBAAf;AACA,SAAQC,uBAAR,QAAsC,qBAAtC;AAEA,MAAMC,uBAAuB,GAAG;AAC9BC,EAAAA,MAAM,EAAE,CADsB;AAE9BC,EAAAA,MAAM,EAAE,CAFsB;AAG9BC,EAAAA,IAAI,EAAEL,EAAE,CAACM,KAHqB;AAI9BC,EAAAA,IAAI,EAAE,CAJwB;AAK9BC,EAAAA,OAAO,EAAE,CALqB;AAM9BC,EAAAA,UAAU,EAAE,KANkB;AAO9BC,EAAAA,OAAO,EAAE;AAPqB,CAAhC;AAUA,MAAMC,WAAW,GAAG;AAClBC,EAAAA,eAAe,EAAE;AACfC,IAAAA,SAAS,EAAE,SADI;AAEfC,IAAAA,WAAW,EAAE;AAFE;AADC,CAApB;AAOA,eAAe,MAAMC,QAAN,CAAyC;AAY7B,SAAlBC,kBAAkB,CAACC,QAAD,EAA8C;AAGrE,UAAMC,SAAS,GAAGjB,uBAAuB,CAACgB,QAAQ,CAACZ,IAAT,IAAiBL,EAAE,CAACM,KAArB,CAAzC;AACA,WAAOY,SAAS,CAACC,iBAAjB;AACD;;AAEuB,SAAjBC,iBAAiB,CAACH,QAAD,EAAmC;AACzDnB,IAAAA,MAAM,CAACmB,QAAQ,CAACV,IAAV,CAAN;AAGA,UAAMW,SAAS,GAAGjB,uBAAuB,CAACgB,QAAQ,CAACZ,IAAT,IAAiBL,EAAE,CAACM,KAArB,CAAzC;AACA,WAAOY,SAAS,CAACC,iBAAV,GAA8BF,QAAQ,CAACV,IAA9C;AACD;;AAMa,SAAPc,OAAO,CAAC,GAA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C;AACD;;AAED,QAAI,KAAKX,MAAL,KAAgB8B,SAApB,EAA+B,OAAO,KAAK9B,MAAZ;AAC/B,QAAI,KAAKC,MAAL,KAAgB6B,SAApB,EAA+B,OAAO,KAAK7B,MAAZ;AAC/B,QAAI,KAAKC,IAAL,KAAc4B,SAAlB,EAA6B,OAAO,KAAK5B,IAAZ;AAC7B,QAAI,KAAKE,IAAL,KAAc0B,SAAlB,EAA6B,OAAO,KAAK1B,IAAZ;AAC7B,QAAI,KAAKC,OAAL,KAAiByB,SAArB,EAAgC,OAAO,KAAKzB,OAAZ;AAChC,QAAI,KAAKC,UAAL,KAAoBwB,SAAxB,EAAmC,OAAO,KAAKxB,UAAZ;AACnC,QAAI,KAAKC,OAAL,KAAiBuB,SAArB,EAAgC,OAAO,KAAKvB,OAAZ;AAEhC,QAAI,KAAK2B,MAAL,KAAgBJ,SAApB,EAA+B,OAAO,KAAKI,MAAZ;AAC/B,QAAI,KAAKC,KAAL,KAAeL,SAAnB,EAA8B,OAAO,KAAKK,KAAZ;AAE9B,WAAO,IAAP;AACD;;AAtIqD;AA0IxD,SAAQpC,uBAAR","sourcesContent":["import {assert, checkProps, Buffer, AccessorObject} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {getTypedArrayFromGLType} from './typed-array-utils';\n\nconst DEFAULT_ACCESSOR_VALUES = {\n offset: 0,\n stride: 0,\n type: GL.FLOAT,\n size: 1,\n divisor: 0,\n normalized: false,\n integer: false\n};\n\nconst PROP_CHECKS = {\n deprecatedProps: {\n instanced: 'divisor',\n isInstanced: 'divisor'\n }\n};\n\nexport default class Accessor implements AccessorObject {\n offset?: number;\n stride?: number;\n type?: number;\n size?: number;\n divisor?: number;\n normalized?: boolean;\n integer?: boolean;\n\n buffer?: Buffer;\n index?: number;\n\n static getBytesPerElement(accessor: Accessor | AccessorObject): number {\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT;\n }\n\n static getBytesPerVertex(accessor: AccessorObject): number {\n assert(accessor.size);\n // TODO: using `FLOAT` when type is not specified,\n // ensure this assumption is valid or force API to specify type.\n const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);\n return ArrayType.BYTES_PER_ELEMENT * accessor.size;\n }\n\n // Combines (merges) a list of accessors. On top of default values\n // Usually [programAccessor, bufferAccessor, appAccessor]\n // All props will be set in the returned object.\n // TODO check for conflicts between values in the supplied accessors\n static resolve(...accessors: AccessorObject[]): Accessor {\n return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]); // Default values\n }\n\n constructor(...accessors: AccessorObject[]) {\n accessors.forEach((accessor) => this._assign(accessor)); // Merge in sequence\n Object.freeze(this);\n }\n\n toString(): string {\n return JSON.stringify(this);\n }\n\n // ACCESSORS\n\n // TODO - remove>\n get BYTES_PER_ELEMENT(): number {\n return Accessor.getBytesPerElement(this);\n }\n\n get BYTES_PER_VERTEX(): number {\n return Accessor.getBytesPerVertex(this);\n }\n\n // PRIVATE\n\n // eslint-disable-next-line complexity, max-statements\n _assign(props: AccessorObject = {}): this {\n props = checkProps('Accessor', props, PROP_CHECKS);\n\n if (props.type !== undefined) {\n this.type = props.type;\n\n // Auto-deduce integer type?\n if (props.type === GL.INT || props.type === GL.UNSIGNED_INT) {\n this.integer = true;\n }\n }\n if (props.size !== undefined) {\n this.size = props.size;\n }\n if (props.offset !== undefined) {\n this.offset = props.offset;\n }\n if (props.stride !== undefined) {\n this.stride = props.stride;\n }\n // @ts-expect-error\n if (props.normalize !== undefined) {\n // @ts-expect-error\n this.normalized = props.normalize;\n }\n if (props.normalized !== undefined) {\n this.normalized = props.normalized;\n }\n if (props.integer !== undefined) {\n this.integer = props.integer;\n }\n\n // INSTANCE DIVISOR\n if (props.divisor !== undefined) {\n this.divisor = props.divisor;\n }\n\n // Buffer is optional\n if (props.buffer !== undefined) {\n this.buffer = props.buffer;\n }\n\n // The binding index (for binding e.g. Transform feedbacks and Uniform buffers)\n // TODO - should this be part of accessor?\n if (props.index !== undefined) {\n if (typeof props.index === 'boolean') {\n this.index = props.index ? 1 : 0;\n } else {\n this.index = props.index;\n }\n }\n\n // DEPRECATED\n // @ts-expect-error\n if (props.instanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.instanced ? 1 : 0;\n }\n // @ts-expect-error\n if (props.isInstanced !== undefined) {\n // @ts-expect-error\n this.divisor = props.isInstanced ? 1 : 0;\n }\n\n if (this.offset === undefined) delete this.offset;\n if (this.stride === undefined) delete this.stride;\n if (this.type === undefined) delete this.type;\n if (this.size === undefined) delete this.size;\n if (this.divisor === undefined) delete this.divisor;\n if (this.normalized === undefined) delete this.normalized;\n if (this.integer === undefined) delete this.integer;\n \n if (this.buffer === undefined) delete this.buffer;\n if (this.index === undefined) delete this.index;\n \n return this;\n }\n}\n\n// TEST EXPORTS\nexport {DEFAULT_ACCESSOR_VALUES};\n"],"file":"accessor.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-browser-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-browser-context.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;EAgBE;AACF,aAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAI,kBAAkB,GAAG,WAAW,CAAC;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC;AAUF;;;;GAIG;AACF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,qBAAqB,
|
|
1
|
+
{"version":3,"file":"create-browser-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-browser-context.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;EAgBE;AACF,aAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAI,kBAAkB,GAAG,WAAW,CAAC;IAChE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC;AAUF;;;;GAIG;AACF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,qBAAqB,CAiD7H"}
|
|
@@ -43,11 +43,17 @@ export function createBrowserContext(canvas, props) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (props.onContextLost) {
|
|
46
|
-
|
|
46
|
+
const {
|
|
47
|
+
onContextLost
|
|
48
|
+
} = props;
|
|
49
|
+
canvas.addEventListener('webglcontextlost', event => onContextLost(event), false);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
if (props.onContextRestored) {
|
|
50
|
-
|
|
53
|
+
const {
|
|
54
|
+
onContextRestored
|
|
55
|
+
} = props;
|
|
56
|
+
canvas.addEventListener('webglcontextrestored', event => onContextRestored(event), false);
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
return gl;
|