@luma.gl/webgl 9.0.0-alpha.6 → 9.0.0-alpha.8
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 +76 -19
- 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/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +1 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/context/context/{create-context.js → create-browser-context.js} +9 -3
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +43 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- 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 +91 -27
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/classic/accessor.js.map +1 -1
- package/dist/es5/classic/typed-array-utils.js.map +1 -1
- package/dist/es5/context/context/{create-context.js → create-browser-context.js} +11 -3
- package/dist/es5/context/context/create-browser-context.js.map +1 -0
- package/dist/es5/context/context/create-headless-context.js +60 -0
- package/dist/es5/context/context/create-headless-context.js.map +1 -0
- 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 +8 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/types/webgl.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 +76 -19
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/classic/accessor.js.map +1 -1
- package/dist/esm/classic/typed-array-utils.js.map +1 -1
- package/dist/esm/context/context/{create-context.js → create-browser-context.js} +9 -3
- package/dist/esm/context/context/create-browser-context.js.map +1 -0
- package/dist/esm/context/context/create-headless-context.js +43 -0
- package/dist/esm/context/context/create-headless-context.js.map +1 -0
- 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 +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/webgl.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/webgl.d.ts +1 -1
- package/dist/types/webgl.d.ts.map +1 -1
- package/dist/types/webgl.js.map +1 -1
- package/package.json +4 -7
- package/src/adapter/resources/webgl-render-pipeline.ts +5 -1
- package/src/adapter/webgl-device.ts +90 -26
- package/src/classic/accessor.ts +0 -13
- package/src/classic/typed-array-utils.ts +3 -1
- package/src/context/context/{create-context.ts → create-browser-context.ts} +6 -2
- package/src/context/context/create-headless-context.ts +48 -0
- package/src/context/debug/webgl-developer-tools.ts +2 -2
- package/src/context/polyfill/polyfill-context.ts +0 -2
- package/src/index.ts +3 -0
- package/src/types/webgl.ts +1 -1
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/create-context.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/polyfill/polyfill-context.ts"],"names":["polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","WEBGL2_CONTEXT_POLYFILLS","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","defaults","meta","suffix","ext","key","extKey","polyfill","bind","keys","WEBGL2_CONTEXT_OVERRIDES","forEach","originalFunc"],"mappings":";;;;;;;AASA;;AACA;;AAEA;;AACA;;;;;;;;AAKO,SAASA,eAAT,CAAyBC,EAAzB,EAA4E;AACjF,MAAMC,YAAY,GAAG,mCAAgBD,EAAhB,CAArB;;AAEA,MAAI,CAACC,YAAY,CAACC,WAAlB,EAA+B;AAC7B,8DAA0BF,EAA1B;AACAG,IAAAA,oBAAoB,CAACH,EAAD,CAApB;AACAI,IAAAA,gBAAgB,CAACJ,EAAD,EAAKK,uCAAL,CAAhB;AACAC,IAAAA,gBAAgB,CAACN,EAAD,EAAK;AAACO,MAAAA,MAAM,EAAEN,YAAT;AAAuBO,MAAAA,OAAO,EAAER;AAAhC,KAAL,CAAhB;AACAC,IAAAA,YAAY,CAACC,WAAb,GAA2B,IAA3B;AACD;;AAGD,SAAOF,EAAP;AACD;;AAED,SAASG,oBAAT,CAA8BH,EAA9B,EAA+D;AAC7D,MAAMC,YAAY,GAAG,mCAAgBD,EAAhB,CAArB;AAEA,MAAMS,UAAU,GAAGT,EAAE,CAACU,sBAAH,MAA+B,EAAlD;;AAH6D,6CAIjCD,UAJiC;AAAA;;AAAA;AAI7D,wDAAwC;AAAA,UAA7BE,aAA6B;AACtC,UAAMC,SAAS,GAAGZ,EAAE,CAACa,YAAH,CAAgBF,aAAhB,CAAlB;AACAV,MAAAA,YAAY,CAACa,WAAb,CAAyBH,aAAzB,IAA0CC,SAA1C;
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/polyfill/polyfill-context.ts"],"names":["polyfillContext","gl","contextState","_polyfilled","initializeExtensions","installPolyfills","WEBGL2_CONTEXT_POLYFILLS","installOverrides","target","target2","EXTENSIONS","getSupportedExtensions","extensionName","extension","getExtension","_extensions","polyfills","Object","getOwnPropertyNames","polyfillExtension","defaults","meta","suffix","ext","key","extKey","polyfill","bind","keys","WEBGL2_CONTEXT_OVERRIDES","forEach","originalFunc"],"mappings":";;;;;;;AASA;;AACA;;AAEA;;AACA;;;;;;;;AAKO,SAASA,eAAT,CAAyBC,EAAzB,EAA4E;AACjF,MAAMC,YAAY,GAAG,mCAAgBD,EAAhB,CAArB;;AAEA,MAAI,CAACC,YAAY,CAACC,WAAlB,EAA+B;AAC7B,8DAA0BF,EAA1B;AACAG,IAAAA,oBAAoB,CAACH,EAAD,CAApB;AACAI,IAAAA,gBAAgB,CAACJ,EAAD,EAAKK,uCAAL,CAAhB;AACAC,IAAAA,gBAAgB,CAACN,EAAD,EAAK;AAACO,MAAAA,MAAM,EAAEN,YAAT;AAAuBO,MAAAA,OAAO,EAAER;AAAhC,KAAL,CAAhB;AACAC,IAAAA,YAAY,CAACC,WAAb,GAA2B,IAA3B;AACD;;AAGD,SAAOF,EAAP;AACD;;AAED,SAASG,oBAAT,CAA8BH,EAA9B,EAA+D;AAC7D,MAAMC,YAAY,GAAG,mCAAgBD,EAAhB,CAArB;AAEA,MAAMS,UAAU,GAAGT,EAAE,CAACU,sBAAH,MAA+B,EAAlD;;AAH6D,6CAIjCD,UAJiC;AAAA;;AAAA;AAI7D,wDAAwC;AAAA,UAA7BE,aA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AACgB,GAAD,CAAN,GAAcE,QAAd;AACAjB,MAAAA,OAAO,CAACe,GAAD,CAAP,GAAeE,QAAf;AACD;AACF,GARD;AASD","sourcesContent":["// WebGL1/WebGL2 extension polyfill support\n//\n// Provides a function that creates polyfills for WebGL2 functions based\n// on available extensions and installs them on a supplied target (could be\n// the WebGLContext or its prototype, or a separate object).\n//\n// This is intended to be a stand-alone file with minimal dependencies,\n// easy to reuse or repurpose in other projects.\n\nimport {assert} from '@luma.gl/api';\nimport {polyfillVertexArrayObject} from './polyfill-vertex-array-object';\n\nimport {WEBGL2_CONTEXT_POLYFILLS, WEBGL2_CONTEXT_OVERRIDES} from './polyfill-table';\nimport {getContextState} from '../context/context-state';\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 = getContextState(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 = getContextState(gl);\n // `getSupportedExtensions` can return null when context is lost.\n const EXTENSIONS = gl.getSupportedExtensions() || [];\n for (const extensionName of EXTENSIONS) {\n const extension = gl.getExtension(extensionName);\n contextState._extensions[extensionName] = extension;\n }\n}\n\nfunction installPolyfills(gl: WebGLRenderingContext, polyfills): void {\n const contextState = getContextState(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, {target, target2}) {\n Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {\n if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === 'function') {\n // install an override, if no implementation was detected\n const originalFunc = gl[key] ? gl[key].bind(gl) : () => {};\n const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl, originalFunc);\n target[key] = polyfill;\n target2[key] = polyfill;\n }\n });\n}\n"],"file":"polyfill-context.js"}
|
package/dist/es5/index.js
CHANGED
|
@@ -5,6 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "registerHeadlessGL", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _createHeadlessContext.registerHeadlessGL;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
8
14
|
Object.defineProperty(exports, "WebGLDevice", {
|
|
9
15
|
enumerable: true,
|
|
10
16
|
get: function get() {
|
|
@@ -232,6 +238,8 @@ require("@luma.gl/api");
|
|
|
232
238
|
|
|
233
239
|
require("./init");
|
|
234
240
|
|
|
241
|
+
var _createHeadlessContext = require("./context/context/create-headless-context");
|
|
242
|
+
|
|
235
243
|
var _webglDevice = _interopRequireDefault(require("./adapter/webgl-device"));
|
|
236
244
|
|
|
237
245
|
var _webglCanvasContext = _interopRequireDefault(require("./adapter/webgl-canvas-context"));
|
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;AACA;;AAKA;;AAGA;;AACA;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAKA;;AACA;;AAGA;;AAGA;;AAEA;;AASA;;AAIA;;AAGA;;AAMA;;AAKA;;AAOA;;AAGA;;AACA","sourcesContent":["// luma.gl Base WebGL wrapper library\n// Provides simple class/function wrappers around the low level webgl objects\n// These classes are intentionally close to the WebGL API\n// but make it easier to use.\n// Higher level abstractions can be built on these classes\n\n// Initialize any global state\nimport '@luma.gl/api';\nimport './init'\n\n// Types\nexport type {WebGLLimits} from './adapter/device-helpers/device-limits';\n\nexport {registerHeadlessGL} from './context/context/create-headless-context';\n\n// WebGL adapter classes\nexport {default as WebGLDevice} from './adapter/webgl-device';\nexport {default as WebGLCanvasContext} from './adapter/webgl-canvas-context';\n\n// WebGL Resource classes\nexport {default as WEBGLResource, default as WebGLResource} from './adapter/objects/webgl-resource';\nexport {default as WEBGLBuffer} from './adapter/resources/webgl-buffer';\nexport {default as WEBGLTexture} from './adapter/resources/webgl-texture';\n// export {default as WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';\nexport {default as WEBGLShader} from './adapter/resources/webgl-shader';\nexport {default as WEBGLSampler} from './adapter/resources/webgl-sampler';\nexport {default as WEBGLFramebuffer} from './adapter/resources/webgl-framebuffer';\n\nexport {default as WEBGLRenderPipeline} from './adapter/resources/webgl-render-pipeline';\n// export {default as WEBGLComputePipeline} from './adapter/resources/webgl-compute-pipeline';\nexport {default as WEBGLCommandEncoder} from './adapter/resources/webgl-command-encoder';\nexport {default as WEBGLRenderPass} from './adapter/resources/webgl-render-pass';\n//export {default as WEBGLComputePass} from './adapter/resources/webgl-compute-pass';\n\n// non-api resources\nexport type {RenderbufferProps} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLRenderbuffer} from './adapter/objects/webgl-renderbuffer';\nexport {default as WEBGLVertexArrayObject} from './adapter/objects/webgl-vertex-array-object';\n\n// WebGL adapter classes (Legacy, will be moved to gltools)\nexport {default as Accessor} from './classic/accessor';\nexport type {AccessorObject} from './types';\nexport type {ClassicBufferProps, ClassicBufferProps as BufferProps} from './classic/buffer';\nexport {default as ClassicBuffer, default as Buffer} from './classic/buffer';\n\nexport {\n isWebGL,\n isWebGL2,\n getWebGL2Context,\n assertWebGLContext,\n assertWebGL2Context\n} from './context/context/webgl-checks';\n\n// Device ratio\nexport {cssToDeviceRatio, cssToDevicePixels} from './context/context/device-pixels';\n\n// Unified parameter API\n\nexport {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';\n\nexport type {GLParameters} from './types/webgl';\nexport {\n getParameters,\n setParameters,\n resetParameters\n} from './context/parameters/unified-parameter-api';\n\nexport {\n withParameters\n} from './context/state-tracker/with-parameters';\n\n// State tracking\nexport {\n trackContextState,\n pushContextState,\n popContextState\n} from './context/state-tracker/track-context-state';\n\n// Polyfills (supports a subset of WebGL2 APIs on WebGL1 contexts)\nexport {polyfillContext} from './context/polyfill/polyfill-context';\n\n// HELPERS - EXPERIMENTAL\nexport {getShaderLayout, getProgramBindings} from './adapter/helpers/get-shader-layout';\nexport {_checkFloat32ColorAttachment} from './adapter/converters/texture-formats';\n"],"file":"index.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/webgl.ts"],"names":[],"mappings":";;;;AACA","sourcesContent":["import type {NumberArray} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\ntype Framebuffer = any;\n\nexport type GLDrawMode =\n | GL.POINTS\n | GL.LINES\n | GL.LINE_STRIP\n | GL.LINE_LOOP\n | GL.TRIANGLES\n | GL.TRIANGLE_STRIP\n | GL.TRIANGLE_FAN;\n\nexport type GLPrimitive = GL.POINTS | GL.LINES | GL.TRIANGLES;\n\nexport type GLType =\n | GL.FLOAT\n | GL.UNSIGNED_SHORT\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_BYTE\n | GL.BYTE\n | GL.SHORT\n | GL.INT;\n\nexport type GLPackedType =\n | GL.UNSIGNED_SHORT_5_6_5\n | GL.UNSIGNED_SHORT_4_4_4_4\n | GL.UNSIGNED_SHORT_5_5_5_1;\n\nexport type GLUniformType = GLSamplerType | GLCompositeType;\n\nexport type GLSamplerType =\n | GL.SAMPLER_2D\n | GL.SAMPLER_CUBE\n | GL.SAMPLER_3D\n | GL.SAMPLER_2D_SHADOW\n | GL.SAMPLER_2D_ARRAY\n | GL.SAMPLER_2D_ARRAY_SHADOW\n | GL.SAMPLER_CUBE_SHADOW\n | GL.INT_SAMPLER_2D\n | GL.INT_SAMPLER_3D\n | GL.INT_SAMPLER_CUBE\n | GL.INT_SAMPLER_2D_ARRAY\n | GL.UNSIGNED_INT_SAMPLER_2D\n | GL.UNSIGNED_INT_SAMPLER_3D\n | GL.UNSIGNED_INT_SAMPLER_CUBE\n | GL.UNSIGNED_INT_SAMPLER_2D_ARRAY;\n\n// Composite types table\nexport type GLCompositeType =\n | GL.FLOAT\n | GL.FLOAT_VEC2\n | GL.FLOAT_VEC3\n | GL.FLOAT_VEC4\n | GL.INT\n | GL.INT_VEC2\n | GL.INT_VEC3\n | GL.INT_VEC4\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_INT_VEC2\n | GL.UNSIGNED_INT_VEC3\n | GL.UNSIGNED_INT_VEC4\n | GL.BOOL\n | GL.BOOL_VEC2\n | GL.BOOL_VEC3\n | GL.BOOL_VEC4\n | GL.FLOAT_MAT2\n | GL.FLOAT_MAT2x3\n | GL.FLOAT_MAT2x4\n | GL.FLOAT_MAT3x2\n | GL.FLOAT_MAT3\n | GL.FLOAT_MAT3x4\n | GL.FLOAT_MAT4x2\n | GL.FLOAT_MAT4x3\n | GL.FLOAT_MAT4;\n\nexport type GLFunction =\n | GL.NEVER\n | GL.LESS\n | GL.EQUAL\n | GL.LEQUAL\n | GL.GREATER\n | GL.NOTEQUAL\n | GL.GEQUAL\n | GL.ALWAYS;\n\nexport type GLBlendEquation =\n | GL.FUNC_ADD\n | GL.FUNC_SUBTRACT\n | GL.FUNC_REVERSE_SUBTRACT\n | GL.MIN_EXT\n | GL.MAX_EXT;\n\nexport type GLBlendFunction =\n | GL.ZERO\n | GL.ONE\n | GL.SRC_COLOR\n | GL.ONE_MINUS_SRC_COLOR\n | GL.DST_COLOR\n | GL.ONE_MINUS_DST_COLOR\n | GL.SRC_ALPHA\n | GL.ONE_MINUS_SRC_ALPHA\n | GL.DST_ALPHA\n | GL.ONE_MINUS_DST_ALPHA\n | GL.CONSTANT_COLOR\n | GL.ONE_MINUS_CONSTANT_COLOR\n | GL.CONSTANT_ALPHA\n | GL.ONE_MINUS_CONSTANT_ALPHA\n | GL.SRC_ALPHA_SATURATE;\n\nexport type GLStencilOp =\n | GL.KEEP\n | GL.ZERO\n | GL.REPLACE\n | GL.INCR\n | GL.INCR_WRAP\n | GL.DECR\n | GL.DECR_WRAP\n | GL.INVERT;\n\n/** Parameters for textures and samplers */\nexport type GLSamplerParameters = {\n [GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_MAG_FILTER]?: GL.NEAREST | GL.LINEAR;\n [GL.TEXTURE_MIN_FILTER]?:\n | GL.NEAREST\n | GL.LINEAR\n | GL.NEAREST_MIPMAP_NEAREST\n | GL.NEAREST_MIPMAP_LINEAR\n | GL.LINEAR_MIPMAP_NEAREST\n | GL.LINEAR_MIPMAP_LINEAR;\n [GL.TEXTURE_MIN_LOD]?: number;\n [GL.TEXTURE_MAX_LOD]?: number;\n [GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);\n [GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;\n [GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number; //\n};\n\n/**\n * All global WebGL values set by a variety of setter gl.enable ...\n */\nexport type GLValueParameters = {\n [GL.BLEND]?: boolean;\n [GL.BLEND_COLOR]?: [number, number, number, number] | NumberArray;\n [GL.BLEND_EQUATION_RGB]?: GLBlendEquation;\n [GL.BLEND_EQUATION_ALPHA]?: GLBlendEquation;\n [GL.BLEND_SRC_RGB]?: GLBlendFunction;\n [GL.BLEND_DST_RGB]?: GLBlendFunction;\n [GL.BLEND_SRC_ALPHA]?: GLBlendFunction;\n [GL.BLEND_DST_ALPHA]?: GLBlendFunction;\n [GL.COLOR_CLEAR_VALUE]?: [number, number, number, number] | NumberArray;\n [GL.COLOR_WRITEMASK]?: [boolean, boolean, boolean, boolean] | boolean[];\n [GL.CULL_FACE]?: boolean;\n [GL.CULL_FACE_MODE]?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n [GL.DEPTH_TEST]?: boolean;\n [GL.DEPTH_CLEAR_VALUE]?: number;\n [GL.DEPTH_FUNC]?: GLFunction;\n [GL.DEPTH_RANGE]?: [number, number] | NumberArray;\n [GL.DEPTH_WRITEMASK]?: boolean;\n [GL.DITHER]?: boolean;\n [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.CURRENT_PROGRAM]?: WebGLProgram | null;\n [GL.FRAMEBUFFER_BINDING]?: WebGLFramebuffer | null;\n [GL.RENDERBUFFER_BINDING]?: WebGLRenderbuffer | null;\n [GL.TRANSFORM_FEEDBACK_BINDING]?: WebGLTransformFeedback | null;\n [GL.VERTEX_ARRAY_BINDING]?: WebGLVertexArrayObject | null;\n [GL.ARRAY_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_READ_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_WRITE_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_PACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_UNPACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.TEXTURE_BINDING_2D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_2D_ARRAY]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_3D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_CUBE_MAP]?: WebGLTexture | null;\n [GL.FRONT_FACE]?: GL.CW | GL.CCW;\n [GL.GENERATE_MIPMAP_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.LINE_WIDTH]?: number;\n [GL.POLYGON_OFFSET_FILL]?: boolean;\n [GL.POLYGON_OFFSET_FACTOR]?: number;\n [GL.POLYGON_OFFSET_UNITS]?: number;\n [GL.SAMPLE_ALPHA_TO_COVERAGE]?: boolean;\n [GL.SAMPLE_COVERAGE]?: boolean;\n [GL.RASTERIZER_DISCARD]?: boolean;\n [GL.SAMPLE_COVERAGE_VALUE]?: number;\n [GL.SAMPLE_COVERAGE_INVERT]?: boolean;\n [GL.SCISSOR_TEST]?: boolean;\n [GL.SCISSOR_BOX]?: [number, number, number, number] | NumberArray;\n [GL.STENCIL_TEST]?: boolean;\n [GL.STENCIL_CLEAR_VALUE]?: number;\n [GL.STENCIL_WRITEMASK]?: number;\n [GL.STENCIL_BACK_WRITEMASK]?: number;\n [GL.STENCIL_FUNC]?: GLFunction;\n [GL.STENCIL_REF]?: GLFunction;\n [GL.STENCIL_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_BACK_FUNC]?: GLFunction;\n [GL.STENCIL_BACK_REF]?: GLFunction;\n [GL.STENCIL_BACK_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.STENCIL_BACK_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.VIEWPORT]?: [number, number, number, number] | NumberArray;\n\n // WEBGL1 PIXEL PACK/UNPACK MODES\n [GL.PACK_ALIGNMENT]?: number;\n [GL.UNPACK_ALIGNMENT]?: number;\n [GL.UNPACK_FLIP_Y_WEBGL]?: boolean;\n [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?: boolean;\n [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]?: GL.NONE | GL.BROWSER_DEFAULT_WEBGL;\n\n // WEBGL2 PIXEL PACK/UNPACK MODES\n // RASTERIZER_DISCARD ...\n [GL.PACK_ROW_LENGTH]?: number;\n [GL.PACK_SKIP_PIXELS]?: number;\n [GL.PACK_SKIP_ROWS]?: number;\n [GL.READ_FRAMEBUFFER_BINDING]?: Framebuffer | null;\n [GL.UNPACK_ROW_LENGTH]?: number;\n [GL.UNPACK_IMAGE_HEIGHT]?: number;\n [GL.UNPACK_SKIP_PIXELS]?: number;\n [GL.UNPACK_SKIP_ROWS]?: number;\n [GL.UNPACK_SKIP_IMAGES]?: number;\n};\n\nexport type GLFunctionParameters = {\n // Function-style setters\n framebuffer?: Framebuffer | null;\n blend?: boolean;\n blendColor?: [number, number, number, number] | NumberArray;\n blendEquation?: GLBlendEquation | [GLBlendEquation, GLBlendEquation];\n blendFunc?:\n | [GLBlendFunction, GLBlendFunction]\n | [GLBlendFunction, GLBlendFunction, GLBlendFunction, GLBlendFunction];\n\n clearColor?: [number, number, number, number] | NumberArray;\n clearDepth?: number;\n clearStencil?: number;\n\n colorMask?: [boolean, boolean, boolean, boolean];\n\n cull?: boolean;\n cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n\n depthTest?: boolean;\n depthFunc?: GLFunction;\n depthMask?: boolean;\n depthRange?: [number, number] | NumberArray;\n\n dither?: boolean;\n\n derivativeHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n frontFace?: GL.CW | GL.CCW;\n\n mipmapHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n lineWidth?: number;\n\n polygonOffsetFill?: boolean;\n polygonOffset?: [number, number];\n\n sampleCoverage?: [number, boolean];\n\n scissorTest?: boolean;\n scissor?: [number, number, number, number] | NumberArray;\n\n stencilTest?: boolean;\n stencilMask?: number | [number, number];\n stencilFunc?:\n | [GLFunction, number, number]\n | [GLFunction, number, number, GLFunction, number, number];\n stencilOp?:\n | [GLStencilOp, GLStencilOp, GLStencilOp]\n | [GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp];\n viewport?: [number, number, number, number] | NumberArray;\n};\n\n/** WebGL style parameters object (with both GL constants and function style fields) */\nexport type GLParameters = GLValueParameters & GLFunctionParameters;\n"],"file":"webgl.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/types/webgl.ts"],"names":[],"mappings":";;;;AACA","sourcesContent":["import type {NumberArray} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\ntype Framebuffer = any;\n\nexport type GLDrawMode =\n | GL.POINTS\n | GL.LINES\n | GL.LINE_STRIP\n | GL.LINE_LOOP\n | GL.TRIANGLES\n | GL.TRIANGLE_STRIP\n | GL.TRIANGLE_FAN;\n\nexport type GLPrimitive = GL.POINTS | GL.LINES | GL.TRIANGLES;\n\nexport type GLType =\n | GL.FLOAT\n | GL.UNSIGNED_SHORT\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_BYTE\n | GL.BYTE\n | GL.SHORT\n | GL.INT;\n\nexport type GLPackedType =\n | GL.UNSIGNED_SHORT_5_6_5\n | GL.UNSIGNED_SHORT_4_4_4_4\n | GL.UNSIGNED_SHORT_5_5_5_1;\n\nexport type GLUniformType = GLSamplerType | GLCompositeType;\n\nexport type GLSamplerType =\n | GL.SAMPLER_2D\n | GL.SAMPLER_CUBE\n | GL.SAMPLER_3D\n | GL.SAMPLER_2D_SHADOW\n | GL.SAMPLER_2D_ARRAY\n | GL.SAMPLER_2D_ARRAY_SHADOW\n | GL.SAMPLER_CUBE_SHADOW\n | GL.INT_SAMPLER_2D\n | GL.INT_SAMPLER_3D\n | GL.INT_SAMPLER_CUBE\n | GL.INT_SAMPLER_2D_ARRAY\n | GL.UNSIGNED_INT_SAMPLER_2D\n | GL.UNSIGNED_INT_SAMPLER_3D\n | GL.UNSIGNED_INT_SAMPLER_CUBE\n | GL.UNSIGNED_INT_SAMPLER_2D_ARRAY;\n\n// Composite types table\nexport type GLCompositeType =\n | GL.FLOAT\n | GL.FLOAT_VEC2\n | GL.FLOAT_VEC3\n | GL.FLOAT_VEC4\n | GL.INT\n | GL.INT_VEC2\n | GL.INT_VEC3\n | GL.INT_VEC4\n | GL.UNSIGNED_INT\n | GL.UNSIGNED_INT_VEC2\n | GL.UNSIGNED_INT_VEC3\n | GL.UNSIGNED_INT_VEC4\n | GL.BOOL\n | GL.BOOL_VEC2\n | GL.BOOL_VEC3\n | GL.BOOL_VEC4\n | GL.FLOAT_MAT2\n | GL.FLOAT_MAT2x3\n | GL.FLOAT_MAT2x4\n | GL.FLOAT_MAT3x2\n | GL.FLOAT_MAT3\n | GL.FLOAT_MAT3x4\n | GL.FLOAT_MAT4x2\n | GL.FLOAT_MAT4x3\n | GL.FLOAT_MAT4;\n\nexport type GLFunction =\n | GL.NEVER\n | GL.LESS\n | GL.EQUAL\n | GL.LEQUAL\n | GL.GREATER\n | GL.NOTEQUAL\n | GL.GEQUAL\n | GL.ALWAYS;\n\nexport type GLBlendEquation =\n | GL.FUNC_ADD\n | GL.FUNC_SUBTRACT\n | GL.FUNC_REVERSE_SUBTRACT\n | GL.MIN_EXT\n | GL.MAX_EXT;\n\nexport type GLBlendFunction =\n | GL.ZERO\n | GL.ONE\n | GL.SRC_COLOR\n | GL.ONE_MINUS_SRC_COLOR\n | GL.DST_COLOR\n | GL.ONE_MINUS_DST_COLOR\n | GL.SRC_ALPHA\n | GL.ONE_MINUS_SRC_ALPHA\n | GL.DST_ALPHA\n | GL.ONE_MINUS_DST_ALPHA\n | GL.CONSTANT_COLOR\n | GL.ONE_MINUS_CONSTANT_COLOR\n | GL.CONSTANT_ALPHA\n | GL.ONE_MINUS_CONSTANT_ALPHA\n | GL.SRC_ALPHA_SATURATE;\n\nexport type GLStencilOp =\n | GL.KEEP\n | GL.ZERO\n | GL.REPLACE\n | GL.INCR\n | GL.INCR_WRAP\n | GL.DECR\n | GL.DECR_WRAP\n | GL.INVERT;\n\n/** Parameters for textures and samplers */\nexport type GLSamplerParameters = {\n [GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;\n [GL.TEXTURE_MAG_FILTER]?: GL.NEAREST | GL.LINEAR;\n [GL.TEXTURE_MIN_FILTER]?:\n | GL.NEAREST\n | GL.LINEAR\n | GL.NEAREST_MIPMAP_NEAREST\n | GL.NEAREST_MIPMAP_LINEAR\n | GL.LINEAR_MIPMAP_NEAREST\n | GL.LINEAR_MIPMAP_LINEAR;\n [GL.TEXTURE_MIN_LOD]?: number;\n [GL.TEXTURE_MAX_LOD]?: number;\n [GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);\n [GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;\n [GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number; //\n};\n\n/**\n * All global WebGL values set by a variety of setter gl.enable ...\n */\nexport type GLValueParameters = {\n [GL.BLEND]?: boolean;\n [GL.BLEND_COLOR]?: [number, number, number, number] | NumberArray;\n [GL.BLEND_EQUATION_RGB]?: GLBlendEquation;\n [GL.BLEND_EQUATION_ALPHA]?: GLBlendEquation;\n [GL.BLEND_SRC_RGB]?: GLBlendFunction;\n [GL.BLEND_DST_RGB]?: GLBlendFunction;\n [GL.BLEND_SRC_ALPHA]?: GLBlendFunction;\n [GL.BLEND_DST_ALPHA]?: GLBlendFunction;\n [GL.COLOR_CLEAR_VALUE]?: [number, number, number, number] | NumberArray;\n [GL.COLOR_WRITEMASK]?: [boolean, boolean, boolean, boolean] | boolean[];\n [GL.CULL_FACE]?: boolean;\n [GL.CULL_FACE_MODE]?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n [GL.DEPTH_TEST]?: boolean;\n [GL.DEPTH_CLEAR_VALUE]?: number;\n [GL.DEPTH_FUNC]?: GLFunction;\n [GL.DEPTH_RANGE]?: [number, number] | NumberArray;\n [GL.DEPTH_WRITEMASK]?: boolean;\n [GL.DITHER]?: boolean;\n [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.CURRENT_PROGRAM]?: WebGLProgram | null;\n [GL.FRAMEBUFFER_BINDING]?: WebGLFramebuffer | null;\n [GL.RENDERBUFFER_BINDING]?: WebGLRenderbuffer | null;\n [GL.TRANSFORM_FEEDBACK_BINDING]?: WebGLTransformFeedback | null;\n [GL.VERTEX_ARRAY_BINDING]?: WebGLVertexArrayObject | null;\n [GL.ARRAY_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_READ_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.COPY_WRITE_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_PACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.PIXEL_UNPACK_BUFFER_BINDING]?: WebGLBuffer | null;\n [GL.TEXTURE_BINDING_2D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_2D_ARRAY]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_3D]?: WebGLTexture | null;\n [GL.TEXTURE_BINDING_CUBE_MAP]?: WebGLTexture | null;\n [GL.FRONT_FACE]?: GL.CW | GL.CCW;\n [GL.GENERATE_MIPMAP_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n [GL.LINE_WIDTH]?: number;\n [GL.POLYGON_OFFSET_FILL]?: boolean;\n [GL.POLYGON_OFFSET_FACTOR]?: number;\n [GL.POLYGON_OFFSET_UNITS]?: number;\n [GL.SAMPLE_ALPHA_TO_COVERAGE]?: boolean;\n [GL.SAMPLE_COVERAGE]?: boolean;\n [GL.RASTERIZER_DISCARD]?: boolean;\n [GL.SAMPLE_COVERAGE_VALUE]?: number;\n [GL.SAMPLE_COVERAGE_INVERT]?: boolean;\n [GL.SCISSOR_TEST]?: boolean;\n [GL.SCISSOR_BOX]?: [number, number, number, number] | NumberArray;\n [GL.STENCIL_TEST]?: boolean;\n [GL.STENCIL_CLEAR_VALUE]?: number;\n [GL.STENCIL_WRITEMASK]?: number;\n [GL.STENCIL_BACK_WRITEMASK]?: number;\n [GL.STENCIL_FUNC]?: GLFunction;\n [GL.STENCIL_REF]?: GLFunction;\n [GL.STENCIL_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_BACK_FUNC]?: GLFunction;\n [GL.STENCIL_BACK_REF]?: GLFunction;\n [GL.STENCIL_BACK_VALUE_MASK]?: GLFunction;\n [GL.STENCIL_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.STENCIL_BACK_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_FAIL]?: GLStencilOp;\n [GL.STENCIL_BACK_PASS_DEPTH_PASS]?: GLStencilOp;\n [GL.VIEWPORT]?: [number, number, number, number] | NumberArray;\n\n // WEBGL1 PIXEL PACK/UNPACK MODES\n [GL.PACK_ALIGNMENT]?: number;\n [GL.UNPACK_ALIGNMENT]?: number;\n [GL.UNPACK_FLIP_Y_WEBGL]?: boolean;\n [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?: boolean;\n [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]?: GL.NONE | GL.BROWSER_DEFAULT_WEBGL;\n\n // WEBGL2 PIXEL PACK/UNPACK MODES\n // RASTERIZER_DISCARD ...\n [GL.PACK_ROW_LENGTH]?: number;\n [GL.PACK_SKIP_PIXELS]?: number;\n [GL.PACK_SKIP_ROWS]?: number;\n [GL.READ_FRAMEBUFFER_BINDING]?: Framebuffer | null;\n [GL.UNPACK_ROW_LENGTH]?: number;\n [GL.UNPACK_IMAGE_HEIGHT]?: number;\n [GL.UNPACK_SKIP_PIXELS]?: number;\n [GL.UNPACK_SKIP_ROWS]?: number;\n [GL.UNPACK_SKIP_IMAGES]?: number;\n};\n\nexport type GLFunctionParameters = {\n // Function-style setters\n framebuffer?: Framebuffer | null;\n blend?: boolean;\n blendColor?: [number, number, number, number] | NumberArray;\n blendEquation?: GLBlendEquation | [GLBlendEquation, GLBlendEquation];\n blendFunc?:\n | [GLBlendFunction, GLBlendFunction]\n | [GLBlendFunction, GLBlendFunction, GLBlendFunction, GLBlendFunction];\n\n clearColor?: [number, number, number, number] | NumberArray;\n clearDepth?: number;\n clearStencil?: number;\n\n colorMask?: [boolean, boolean, boolean, boolean] | boolean[];\n\n cull?: boolean;\n cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;\n\n depthTest?: boolean;\n depthFunc?: GLFunction;\n depthMask?: boolean;\n depthRange?: [number, number] | NumberArray;\n\n dither?: boolean;\n\n derivativeHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n frontFace?: GL.CW | GL.CCW;\n\n mipmapHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;\n\n lineWidth?: number;\n\n polygonOffsetFill?: boolean;\n polygonOffset?: [number, number];\n\n sampleCoverage?: [number, boolean];\n\n scissorTest?: boolean;\n scissor?: [number, number, number, number] | NumberArray;\n\n stencilTest?: boolean;\n stencilMask?: number | [number, number];\n stencilFunc?:\n | [GLFunction, number, number]\n | [GLFunction, number, number, GLFunction, number, number];\n stencilOp?:\n | [GLStencilOp, GLStencilOp, GLStencilOp]\n | [GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp];\n viewport?: [number, number, number, number] | NumberArray;\n};\n\n/** WebGL style parameters object (with both GL constants and function style fields) */\nexport type GLParameters = GLValueParameters & GLFunctionParameters;\n"],"file":"webgl.js"}
|
|
@@ -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,G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AA8D,IAArE;AACD;;AAED,SAAS2G,gBAAT,CAA0BvH,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.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","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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tF,SAAOZ,MAAM,CAACW,UAAP,CAAkB2B,IAAlB,CAAwBD,OAAD,IAAaA,OAAO,CAACzB,IAAR,KAAiBA,IAArD,KAA8D,IAArE;AACD;;AAED,SAAS6G,gBAAT,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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
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';
|
|
6
|
-
import { createBrowserContext } from '../context/context/create-context';
|
|
6
|
+
import { createBrowserContext } from '../context/context/create-browser-context';
|
|
7
|
+
import { createHeadlessContext, isHeadlessGLRegistered } from '../context/context/create-headless-context';
|
|
7
8
|
import { getDeviceInfo } from './device-helpers/get-device-info';
|
|
8
9
|
import { getDeviceFeatures } from './device-helpers/device-features';
|
|
9
10
|
import { getDeviceLimits, getWebGLLimits } from './device-helpers/device-limits';
|
|
@@ -22,7 +23,7 @@ const LOG_LEVEL = 1;
|
|
|
22
23
|
let counter = 0;
|
|
23
24
|
export default class WebGLDevice extends Device {
|
|
24
25
|
static isSupported() {
|
|
25
|
-
return typeof WebGLRenderingContext !== 'undefined';
|
|
26
|
+
return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
get features() {
|
|
@@ -58,7 +59,7 @@ export default class WebGLDevice extends Device {
|
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
static async create(props) {
|
|
62
|
+
static async create(props = {}) {
|
|
62
63
|
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
|
|
63
64
|
|
|
64
65
|
if (typeof props.canvas === 'string') {
|
|
@@ -73,7 +74,12 @@ export default class WebGLDevice extends Device {
|
|
|
73
74
|
await loadSpectorJS();
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
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
|
+
|
|
77
83
|
return new WebGLDevice(props);
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -86,13 +92,19 @@ export default class WebGLDevice extends Device {
|
|
|
86
92
|
|
|
87
93
|
_defineProperty(this, "canvasContext", void 0);
|
|
88
94
|
|
|
95
|
+
_defineProperty(this, "handle", void 0);
|
|
96
|
+
|
|
89
97
|
_defineProperty(this, "lost", void 0);
|
|
90
98
|
|
|
91
|
-
_defineProperty(this, "
|
|
99
|
+
_defineProperty(this, "_resolveContextLost", void 0);
|
|
100
|
+
|
|
101
|
+
_defineProperty(this, "_features", void 0);
|
|
102
|
+
|
|
103
|
+
_defineProperty(this, "_limits", void 0);
|
|
92
104
|
|
|
93
105
|
_defineProperty(this, "gl", void 0);
|
|
94
106
|
|
|
95
|
-
_defineProperty(this, "gl2",
|
|
107
|
+
_defineProperty(this, "gl2", null);
|
|
96
108
|
|
|
97
109
|
_defineProperty(this, "debug", false);
|
|
98
110
|
|
|
@@ -100,10 +112,6 @@ export default class WebGLDevice extends Device {
|
|
|
100
112
|
|
|
101
113
|
_defineProperty(this, "isWebGL2", void 0);
|
|
102
114
|
|
|
103
|
-
_defineProperty(this, "_features", void 0);
|
|
104
|
-
|
|
105
|
-
_defineProperty(this, "_limits", void 0);
|
|
106
|
-
|
|
107
115
|
_defineProperty(this, "_webglLimits", void 0);
|
|
108
116
|
|
|
109
117
|
_defineProperty(this, "_canvasSizeInfo", {
|
|
@@ -118,17 +126,41 @@ export default class WebGLDevice extends Device {
|
|
|
118
126
|
|
|
119
127
|
_defineProperty(this, "spector", void 0);
|
|
120
128
|
|
|
121
|
-
_defineProperty(this, "renderPass",
|
|
129
|
+
_defineProperty(this, "renderPass", null);
|
|
122
130
|
|
|
123
131
|
const device = (_props$gl = props.gl) === null || _props$gl === void 0 ? void 0 : _props$gl.device;
|
|
124
132
|
|
|
125
133
|
if (device) {
|
|
126
|
-
|
|
127
|
-
return device;
|
|
134
|
+
throw new Error("WebGL context already attached to device ".concat(device.id));
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
this.canvasContext = new WebGLCanvasContext(this, props);
|
|
131
|
-
this.
|
|
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
|
+
|
|
151
|
+
let gl = props.gl;
|
|
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
|
+
|
|
163
|
+
this.handle = gl;
|
|
132
164
|
this.gl = this.handle;
|
|
133
165
|
this.gl2 = this.gl;
|
|
134
166
|
this.isWebGL2 = isWebGL2(this.gl);
|
|
@@ -137,8 +169,13 @@ export default class WebGLDevice extends Device {
|
|
|
137
169
|
this.gl.device = this;
|
|
138
170
|
this.gl._version = this.isWebGL2 ? 2 : 1;
|
|
139
171
|
polyfillContext(this.gl);
|
|
172
|
+
const {
|
|
173
|
+
enable = true,
|
|
174
|
+
copyState = false
|
|
175
|
+
} = props;
|
|
140
176
|
trackContextState(this.gl, {
|
|
141
|
-
|
|
177
|
+
enable,
|
|
178
|
+
copyState,
|
|
142
179
|
log: (...args) => log.log(1, ...args)()
|
|
143
180
|
});
|
|
144
181
|
|
|
@@ -166,13 +203,28 @@ export default class WebGLDevice extends Device {
|
|
|
166
203
|
}
|
|
167
204
|
|
|
168
205
|
destroy() {
|
|
169
|
-
|
|
206
|
+
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
170
207
|
|
|
171
208
|
if (ext) {
|
|
172
209
|
ext.destroy();
|
|
173
210
|
}
|
|
174
211
|
}
|
|
175
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
|
+
|
|
176
228
|
get isLost() {
|
|
177
229
|
return this.gl.isContextLost();
|
|
178
230
|
}
|
|
@@ -194,7 +246,10 @@ export default class WebGLDevice extends Device {
|
|
|
194
246
|
}
|
|
195
247
|
|
|
196
248
|
assertWebGL2() {
|
|
197
|
-
|
|
249
|
+
if (!this.gl2) {
|
|
250
|
+
throw new Error('Requires WebGL2');
|
|
251
|
+
}
|
|
252
|
+
|
|
198
253
|
return this.gl2;
|
|
199
254
|
}
|
|
200
255
|
|
|
@@ -250,7 +305,9 @@ export default class WebGLDevice extends Device {
|
|
|
250
305
|
}
|
|
251
306
|
|
|
252
307
|
submit() {
|
|
253
|
-
|
|
308
|
+
var _this$renderPass;
|
|
309
|
+
|
|
310
|
+
(_this$renderPass = this.renderPass) === null || _this$renderPass === void 0 ? void 0 : _this$renderPass.endPass();
|
|
254
311
|
this.renderPass = null;
|
|
255
312
|
}
|
|
256
313
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","assert","isBrowser","polyfillContext","trackContextState","createBrowserContext","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","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,mCAAnC;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,mCAAhC;AAEA,MAAMC,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;AAGA,eAAe,MAAMC,WAAN,SAA0B7B,MAA1B,CAAyD;AAKpD,SAAX8B,WAAW,GAAY;AAC5B,WAAO,OAAOC,qBAAP,KAAiC,WAAxC;AACD;;AAOW,MAARC,QAAQ,GAAuB;AACjC,SAAKC,SAAL,GAAiB,KAAKA,SAAL,IAAkBxB,iBAAiB,CAAC,KAAKyB,EAAN,CAApD;AACA,WAAO,KAAKD,SAAZ;AACD;;AAES,MAANE,MAAM,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YAAYqE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACtE,EAAE,IAAIuE,MAAM,CAACC,QAAP,CAAgBxE,EAAE,CAAC6B,QAAnB,CAAP,CAAd;AACD;;AAID,SAASH,QAAT,CAAkB1B,EAAlB,EAAoC;AAClC,MAAI,OAAOqE,sBAAP,KAAkC,WAAlC,IAAiDrE,EAAE,YAAYqE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACtE,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-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';\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 this.handle = props.gl || createBrowserContext(this.canvasContext.canvas, props);\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 // Install context state tracking\n trackContextState(this.gl, {copyState: false, log: (...args: any[]) => log.log(1, ...args)()});\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,Q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,OAAO,CAAChF,EAAE,IAAIiF,MAAM,CAACC,QAAP,CAAgBlF,EAAE,CAACoC,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBjC,EAAlB,EAAoC;AAClC,MAAI,OAAO+E,sBAAP,KAAkC,WAAlC,IAAiD/E,EAAE,YAAY+E,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAChF,EAAE,IAAIA,EAAE,CAACoC,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 {\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"}
|