@luma.gl/webgl 8.6.0-alpha.4 → 8.6.0-alpha.5
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/_deprecated/context-api.d.ts.map +1 -1
- package/dist/_deprecated/context-api.js +13 -7
- package/dist/_deprecated/context-api.js.map +1 -1
- package/dist/_deprecated/features.d.ts +1 -1
- package/dist/_deprecated/features.d.ts.map +1 -1
- package/dist/_deprecated/features.js +24 -24
- package/dist/_deprecated/features.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +0 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +8 -9
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/es5/_deprecated/context-api.js +12 -6
- package/dist/es5/_deprecated/context-api.js.map +1 -1
- package/dist/es5/_deprecated/features.js +5 -5
- package/dist/es5/_deprecated/features.js.map +1 -1
- package/dist/es5/adapter/webgl-device.js +8 -8
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/index.js +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/esm/_deprecated/context-api.js +13 -7
- package/dist/esm/_deprecated/context-api.js.map +1 -1
- package/dist/esm/_deprecated/features.js +24 -24
- package/dist/esm/_deprecated/features.js.map +1 -1
- package/dist/esm/adapter/webgl-device.js +8 -9
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/_deprecated/context-api.ts +13 -7
- package/src/_deprecated/features.ts +24 -24
- package/src/adapter/webgl-device.ts +9 -16
- package/src/index.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","log","polyfillContext","trackContextState","getDevicePixelRatio","setDevicePixelRatio","createBrowserContext","getCanvas","isWebGL","isWebGL2","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WEBGLBuffer","WEBGLShader","Texture2D","DEFAULT_DEVICE_PROPS","canvas","undefined","gl","webgl2","webgl1","manageState","width","height","debug","break","onContextLost","console","error","onContextRestored","info","alpha","depth","stencil","antialias","premultipliedAlpha","preserveDrawingBuffer","failIfMajorPerformanceCaveat","glToContextMap","WeakMap","getWebGLDevice","get","counter","WebGLDevice","fromContext","device","attach","props","Error","constructor","clientWidth","clientHeight","devicePixelRatio","_state","offScreen","OffscreenCanvas","_createContext","gl2","_version","WebGL2RenderingContext","set","webGL","group","vendor","renderer","probe","copyState","args","features","limits","webglLimits","groupEnd","destroy","ext","getExtension","resize","options","useDevicePixels","_createBuffer","createTexture","createShader","commit","targetCanvas"],"mappings":";AACA,SAAQA,MAAR,EAA0CC,GAA1C,QAAoD,cAApD;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,iBAAR,QAAgC,8CAAhC;AAEA,SAAQC,mBAAR,EAA6BC,mBAA7B,QAAuD,kCAAvD;AACA,SAAQC,oBAAR,QAAmC,mCAAnC;AACA,SAAQC,SAAR,QAAwB,+BAAxB;AACA,SAAQC,OAAR,EAAiBC,QAAjB,QAAgC,iCAAhC;AACA,SAAQC,aAAR,QAA4B,kCAA5B;AACA,SAAQC,iBAAR,QAAyC,kCAAzC;AACA,SAAQC,eAAR,EAAyBC,cAAzB,QAA2D,gCAA3D;AAIA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,SAAQC,WAAR,QAA0B,yBAA1B;AACA,OAAOC,SAAP,MAAwC,uBAAxC;AA6BA,MAAMC,oBAAgD,GAAG;AACvDC,EAAAA,MAAM,EAAEC,SAD+C;AAEvDC,EAAAA,EAAE,EAAED,SAFmD;AAGvDE,EAAAA,MAAM,EAAE,IAH+C;AAIvDC,EAAAA,MAAM,EAAE,IAJ+C;AAKvDC,EAAAA,WAAW,EAAE,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,WAAJ,CAAgB,IAAhB,EAAsBkC,KAAtB,CAAP;AACD;;AAODkC,EAAAA,MAAM,GAAS;AAEb,QAAI,KAAK3B,SAAL,IAAkB,KAAKpC,EAAL,CAAQ+D,MAA9B,EAAsC;AAEpC,WAAK/D,EAAL,CAAQ+D,MAAR;AACD;AACF;;AAODzB,EAAAA,cAAc,CAACoB,OAAD,EAAoD;AAChE,UAAM;AAACtD,MAAAA,KAAD;AAAQC,MAAAA,MAAR;AAAgBP,MAAAA;AAAhB,QAA0B,KAAK+B,KAArC;AAEA,UAAMmC,YAAY,GAAG7E,SAAS,CAAC;AAACW,MAAAA,MAAD;AAASM,MAAAA,KAAT;AAAgBC,MAAAA;AAAhB,KAAD,CAA9B;AAEA,WAAOnB,oBAAoB,CAAC8E,YAAD,EAAeN,OAAf,CAA3B;AACD;;AAtOqE","sourcesContent":["// luma.gl, MIT license\nimport {Device, DeviceInfo, DeviceLimits, log} from '@luma.gl/api';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport { ContextState } from '../context/context/context-state';\nimport {getDevicePixelRatio, setDevicePixelRatio} from '../context/context/device-pixels';\nimport {createBrowserContext} from '../context/context/create-context';\nimport {getCanvas} from '../context/context/get-canvas';\nimport {isWebGL, isWebGL2} from '../context/context/webgl-checks';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures, Feature} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\n\n// WebGL classes\nimport type {BufferProps, ShaderProps} from '@luma.gl/api';\nimport WEBGLBuffer from '../classes/webgl-buffer';\nimport {WEBGLShader} from '../adapter/webgl-shader';\nimport Texture2D, {Texture2DProps} from '../classes/texture-2d';\nimport type {default as Framebuffer} from '../classes/framebuffer';\nimport type {default as VertexArrayObject} from '../classes/vertex-array-object';\n\n/** WebGLDevice options */\nexport type WebGLDeviceProps = {\n canvas?: HTMLCanvasElement | OffscreenCanvas | string; // A canvas element or a canvas string id\n width?: number /** width is only used when creating a new canvas */;\n height?: number /** height is only used when creating a new canvas */;\n // Attach to existing context\n gl?: WebGLRenderingContext | WebGL2RenderingContext;\n // COMMON CONTEXT PARAMETERS\n webgl2?: boolean; // Set to false to not create a WebGL2 context (force webgl1)\n webgl1?: boolean; // set to false to not create a WebGL1 context (fails if webgl2 not available)\n manageState?: boolean; // Set to false to disable WebGL state management instrumentation\n debug?: boolean; // Instrument context (at the expense of performance)\n break?: Array<any>; // TODO: types\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n // BROWSER CONTEXT PARAMETERS\n alpha?: boolean; // Default render target has an alpha buffer.\n depth?: boolean; // Default render target has a depth buffer of at least 16 bits.\n stencil?: boolean; // Default render target has a stencil buffer of at least 8 bits.\n antialias?: boolean; // Boolean that indicates whether or not to perform anti-aliasing.\n premultipliedAlpha?: boolean; // Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean; // Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n failIfMajorPerformanceCaveat?: boolean; // Do not create if the system performance is low.\n};\n\nconst DEFAULT_DEVICE_PROPS: Required<WebGLDeviceProps> = {\n canvas: undefined, // A canvas element or a canvas string id\n gl: undefined,\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n manageState: true,\n width: 800, // width are height are only used by headless gl\n height: 600,\n debug: false, // Instrument context (at the expense of performance)\n break: undefined,\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n\n alpha: undefined,\n depth: undefined,\n stencil: undefined,\n antialias: undefined,\n premultipliedAlpha: undefined,\n preserveDrawingBuffer: undefined,\n failIfMajorPerformanceCaveat: undefined\n};\n\n// TODO use weakmap instead of modifying context\nconst glToContextMap = new WeakMap<WebGLRenderingContext | WebGL2RenderingContext, WebGLDevice>();\n\nexport function getWebGLDevice(gl: WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice | undefined {\n return glToContextMap.get(gl);\n}\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n // WebGPU style API\n\n /** A set like interface to test features */\n readonly features: Set<Feature>;\n readonly limits: DeviceLimits;\n readonly info: DeviceInfo;\n\n /** Promise that rejects when context is lost */\n readonly lost: Promise<string>;\n\n // Common API\n props: Required<WebGLDeviceProps>;\n userData: {[key: string]: any};\n\n // WebGL specific API\n readonly isWebGL2: boolean;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n /** Is this device attached to an offscreen context */\n readonly offScreen: boolean = false;\n\n readonly webglFeatures: Set<string>;\n readonly webglLimits: WebGLLimits;\n\n defaultFramebuffer?: Framebuffer;\n defaultVertexArray?: VertexArrayObject;\n\n // State used by luma.gl classes\n _state: 'uninitialized' | 'initializing' | 'initialized' = 'uninitialized';\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /**\n *\n */\n static fromContext(gl: WebGLRenderingContext): WebGLDevice {\n // @ts-expect-error\n return gl.device as WebGLDevice;\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(\n gl: Device | WebGLRenderingContext | WebGL2RenderingContext,\n props?: WebGLDeviceProps\n ): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({...props, gl: gl as WebGLRenderingContext});\n }\n\n\n constructor(props: WebGLDeviceProps) {\n super();\n\n this.props = {...DEFAULT_DEVICE_PROPS, ...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 = this.props.gl?.device;\n if (device) {\n if (device._state !== 'initialized') {\n log.error('recursive context');\n throw new Error('recursive context');\n }\n return device;\n }\n\n this.offScreen =\n typeof OffscreenCanvas !== 'undefined' &&\n props.canvas instanceof OffscreenCanvas;\n\n // Create an instrument context\n this.gl = (this.props.gl || this._createContext(props)) as WebGLRenderingContext;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this._state = 'initializing';\n // Avoid multiple instrumentations\n // @ts-expect-error\n if (this.gl.device) {\n log.error('device already created');\n throw new Error('device already created'); // ASSERT this device;\n }\n // @ts-expect-error\n this.gl.device = this;\n // @ts-ignore\n this.gl._version = typeof WebGL2RenderingContext !== 'undefined' && this.gl instanceof WebGL2RenderingContext ? 2 : 1;\n // TODO - move to weak map indexing\n glToContextMap.set(this.gl, this);\n\n // Luma Device fields\n this.info = getDeviceInfo(this.gl);\n // Log some debug info about the newly created context\n // @ts-expect-error device is attached to context\n const debug = this.gl.debug ? ' debug' : '';\n const webGL = isWebGL2(this.gl) ? 'WebGL2' : 'WebGL1';\n log.group(0, `${webGL}${debug} context: ${this.info.vendor}, ${this.info.renderer}`)();\n\n polyfillContext(this.gl);\n log.probe(0, 'polyfilled context')();\n\n // Install context state tracking\n trackContextState(this.gl, {\n copyState: false,\n log: (...args) => log.log(1, ...args)()\n });\n log.probe(0, 'instrumented context')();\n\n // WebGPU Device fields\n this.features = getDeviceFeatures(this.gl);\n log.probe(0, `queried device features ${counter}`)();\n this.limits = getDeviceLimits(this.gl);\n log.probe(0, 'queried device limits')();\n\n // Add seer integration - TODO - currently removed\n\n // WEBGL specific fields\n this.webglLimits = getWebGLLimits(this.gl);\n log.probe(0, 'queried webgl limits')();\n\n // Add debug instrumentation to the context\n // if (isBrowser() && props.debug) {\n // // @ts-ignore\n // const {makeDebugContext} = global;\n // if (!makeDebugContext) {\n // log.warn('WebGL debug mode not activated. import \"@luma.gl/debug\" to enable.')();\n // } else {\n // // @ts-ignore\n // this.gl = global.makeDebugContext(this.gl, props);\n // this.gl2 = this.gl as WebGL2RenderingContext;\n // // Debug forces log level to at least 1\n // log.level = Math.max(log.level, 1);\n // }\n // }\n\n log.groupEnd(0)();\n this._state = 'initialized';\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 // WEBGL SPECIFIC METHODS\n\n /**\n * Resize the canvas' drawing buffer.\n *\n * Can match the canvas CSS size, and optionally also consider devicePixelRatio\n * Can be called every frame\n *\n * Regardless of size, the drawing buffer will always be scaled to the viewport, but\n * for best visual results, usually set to either:\n * canvas CSS width x canvas CSS height\n * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio\n * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n */\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n // Resize browser context .\n if (this.gl.canvas) {\n const devicePixelRatio = getDevicePixelRatio(options?.useDevicePixels);\n setDevicePixelRatio(this.gl, devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = this.gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && `width` in options && `height` in options) {\n ext.resize(options.width, options.height);\n }\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new WEBGLBuffer(this.gl, props);\n }\n\n createTexture(props: Texture2DProps): Texture2D {\n return new Texture2D(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n commit(): void {\n // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n if (this.offScreen && this.gl.commit) {\n // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n this.gl.commit();\n }\n }\n\n // PRIVATE METHODS\n\n /**\n * Creates a context giving access to the WebGL API\n */\n _createContext(options?: WebGLDeviceProps): WebGLRenderingContext {\n const {width, height, canvas} = this.props;\n // Get or create a canvas\n const targetCanvas = getCanvas({canvas, width, height});\n // Create a WebGL context in the canvas\n return createBrowserContext(targetCanvas, options);\n }\n}\n\n/*\nimport {\n isWebGL, isWebGL2,\n createGLContext,\n instrumentGLContext,\n getContextDebugInfo,\n resizeGLContext\n} from '@luma.gl/gltools';\n\n// prettier-ignore\nimport {\n Device, DeviceInfo, DeviceLimits,\n Buffer, BufferProps\n} from '@luma.gl/api';\n\nimport {getWebGLDeviceInfo} from '../converters/webgl-device-info';\nimport {getWebGLLimits} from '../converters/webgl-limits';\nimport {getWebGLFeatures} from '../converters/webgl-features';\n\nexport default class WEBGLDevice implements Device {\n readonly handle: WebGLRenderingContext;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly canvas: HTMLCanvasElement;\n\n static isSupported(options: {canvas?: HTMLCanvasElement}): boolean {\n const {canvas} = options;\n let gl;\n try {\n gl = canvas && canvas.getContext(\"webgl\");\n gl = gl && canvas && canvas.getContext(\"experimental-webgl\");\n } catch (x) {\n gl = null;\n }\n return Boolean(gl);\n }\n\n constructor(props = {}) {\n const {canvas, swapChainFormat = \"bgra8unorm\"} = props;\n\n const gl = createGLContext(props);\n this.handle =\n this.gl = gl;\n this.gl2 = gl instanceof WebGL2RenderingContext ? gl : null;\n this.canvas = canvas;\n }\n\n resize(width, height) {\n resizeGLContext(this.gl);\n }\n\n getInfo(): DeviceInfo {\n return getWebGLDeviceInfo(this.gl);\n }\n\n getLimits(): DeviceLimits {\n return getWebGLLimits(this.gl, this.gl2);\n }\n\n getFeatures(): string[] {\n return getWebGLFeatures(this.gl);\n }\n\n createBuffer(props: WebGPUBufferProps): WEBGLBuffer {\n return new WEBGLBuffer(this.gl2 || this.gl, props);\n }\n\n createTexture(props: WebGPUTextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createSampler(props: WebGPUSamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: WebGPUShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createRenderPipeline(props: WebGPURenderPipelineProps): WEBGLPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n createComputePipeline(props: WebGPUComputePipelineProps): WebGPUPipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n\n // PRIVATE\n\n _startFrame() {}\n\n _endFrame() {}\n}\n*/\n"],"file":"webgl-device.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["Device","log","polyfillContext","trackContextState","getDevicePixelRatio","setDevicePixelRatio","createBrowserContext","getCanvas","isWebGL","isWebGL2","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WEBGLBuffer","WEBGLShader","Texture2D","DEFAULT_DEVICE_PROPS","canvas","undefined","gl","webgl2","webgl1","manageState","width","height","debug","break","onContextLost","console","error","onContextRestored","info","alpha","depth","stencil","antialias","premultipliedAlpha","preserveDrawingBuffer","failIfMajorPerformanceCaveat","LOG_LEVEL","glToContextMap","WeakMap","getWebGLDevice","get","counter","WebGLDevice","fromContext","device","attach","props","Error","constructor","clientWidth","clientHeight","devicePixelRatio","_state","offScreen","OffscreenCanvas","_createContext","gl2","_version","WebGL2RenderingContext","set","webGL","groupCollapsed","vendor","renderer","probe","copyState","args","features","limits","webglLimits","groupEnd","destroy","ext","getExtension","resize","options","useDevicePixels","_createBuffer","createTexture","createShader","commit","targetCanvas"],"mappings":";AACA,SAAQA,MAAR,EAA0CC,GAA1C,QAAoD,cAApD;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,iBAAR,QAAgC,8CAAhC;AAEA,SAAQC,mBAAR,EAA6BC,mBAA7B,QAAuD,kCAAvD;AACA,SAAQC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CAAnB;AACA;AACD;;AAGD,UAAMH,GAAG,GAAG,KAAKxD,EAAL,CAAQyD,YAAR,CAAqB,8BAArB,CAAZ;;AACA,QAAID,GAAG,IAAIG,OAAP,IAAkB,WAAWA,OAA7B,IAAwC,YAAYA,OAAxD,EAAiE;AAC/DH,MAAAA,GAAG,CAACE,MAAJ,CAAWC,OAAO,CAACvD,KAAnB,EAA0BuD,OAAO,CAACtD,MAAlC;AACD;AACF;;AAEDwD,EAAAA,aAAa,CAAC/B,KAAD,EAAkC;AAC7C,WAAO,IAAIpC,WAAJ,CAAgB,KAAKM,EAArB,EAAyB8B,KAAzB,CAAP;AACD;;AAEDgC,EAAAA,aAAa,CAAChC,KAAD,EAAmC;AAC9C,WAAO,IAAIlC,SAAJ,CAAc,IAAd,EAAoBkC,KAApB,CAAP;AACD;;AAEDiC,EAAAA,YAAY,CAACjC,KAAD,EAAkC;AAC5C,WAAO,IAAInC,WAAJ,CAAgB,IAAhB,EAAsBmC,KAAtB,CAAP;AACD;;AAODkC,EAAAA,MAAM,GAAS;AAEb,QAAI,KAAK3B,SAAL,IAAkB,KAAKrC,EAAL,CAAQgE,MAA9B,EAAsC;AAEpC,WAAKhE,EAAL,CAAQgE,MAAR;AACD;AACF;;AAODzB,EAAAA,cAAc,CAACoB,OAAD,EAAoD;AAChE,UAAM;AAACvD,MAAAA,KAAD;AAAQC,MAAAA,MAAR;AAAgBP,MAAAA;AAAhB,QAA0B,KAAKgC,KAArC;AAEA,UAAMmC,YAAY,GAAG9E,SAAS,CAAC;AAACW,MAAAA,MAAD;AAASM,MAAAA,KAAT;AAAgBC,MAAAA;AAAhB,KAAD,CAA9B;AAEA,WAAOnB,oBAAoB,CAAC+E,YAAD,EAAeN,OAAf,CAA3B;AACD;;AArOqE","sourcesContent":["// luma.gl, MIT license\nimport {Device, DeviceInfo, DeviceLimits, log} from '@luma.gl/api';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport { ContextState } from '../context/context/context-state';\nimport {getDevicePixelRatio, setDevicePixelRatio} from '../context/context/device-pixels';\nimport {createBrowserContext} from '../context/context/create-context';\nimport {getCanvas} from '../context/context/get-canvas';\nimport {isWebGL, isWebGL2} from '../context/context/webgl-checks';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures, Feature} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\n\n// WebGL classes\nimport type {BufferProps, ShaderProps} from '@luma.gl/api';\nimport WEBGLBuffer from '../classes/webgl-buffer';\nimport {WEBGLShader} from '../adapter/webgl-shader';\nimport Texture2D, {Texture2DProps} from '../classes/texture-2d';\nimport type {default as Framebuffer} from '../classes/framebuffer';\nimport type {default as VertexArrayObject} from '../classes/vertex-array-object';\n\n/** WebGLDevice options */\nexport type WebGLDeviceProps = {\n canvas?: HTMLCanvasElement | OffscreenCanvas | string; // A canvas element or a canvas string id\n width?: number /** width is only used when creating a new canvas */;\n height?: number /** height is only used when creating a new canvas */;\n // Attach to existing context\n gl?: WebGLRenderingContext | WebGL2RenderingContext;\n // COMMON CONTEXT PARAMETERS\n webgl2?: boolean; // Set to false to not create a WebGL2 context (force webgl1)\n webgl1?: boolean; // set to false to not create a WebGL1 context (fails if webgl2 not available)\n manageState?: boolean; // Set to false to disable WebGL state management instrumentation\n debug?: boolean; // Instrument context (at the expense of performance)\n break?: Array<any>; // TODO: types\n onContextLost?: (event: Event) => void;\n onContextRestored?: (event: Event) => void;\n // BROWSER CONTEXT PARAMETERS\n alpha?: boolean; // Default render target has an alpha buffer.\n depth?: boolean; // Default render target has a depth buffer of at least 16 bits.\n stencil?: boolean; // Default render target has a stencil buffer of at least 8 bits.\n antialias?: boolean; // Boolean that indicates whether or not to perform anti-aliasing.\n premultipliedAlpha?: boolean; // Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.\n preserveDrawingBuffer?: boolean; // Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten\n failIfMajorPerformanceCaveat?: boolean; // Do not create if the system performance is low.\n};\n\nconst DEFAULT_DEVICE_PROPS: Required<WebGLDeviceProps> = {\n canvas: undefined, // A canvas element or a canvas string id\n gl: undefined,\n webgl2: true, // Attempt to create a WebGL2 context\n webgl1: true, // Attempt to create a WebGL1 context (false to fail if webgl2 not available)\n manageState: true,\n width: 800, // width are height are only used by headless gl\n height: 600,\n debug: false, // Instrument context (at the expense of performance)\n break: undefined,\n onContextLost: () => console.error('WebGL context lost'),\n onContextRestored: () => console.info('WebGL context restored'),\n\n alpha: undefined,\n depth: undefined,\n stencil: undefined,\n antialias: undefined,\n premultipliedAlpha: undefined,\n preserveDrawingBuffer: undefined,\n failIfMajorPerformanceCaveat: undefined\n};\n\nconst LOG_LEVEL = 1;\n\n// TODO use weakmap instead of modifying context\nconst glToContextMap = new WeakMap<WebGLRenderingContext | WebGL2RenderingContext, WebGLDevice>();\n\nexport function getWebGLDevice(gl: WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice | undefined {\n return glToContextMap.get(gl);\n}\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n // WebGPU style API\n\n /** A set like interface to test features */\n readonly features: Set<Feature>;\n readonly limits: DeviceLimits;\n readonly info: DeviceInfo;\n\n /** Promise that rejects when context is lost */\n readonly lost: Promise<string>;\n\n // Common API\n props: Required<WebGLDeviceProps>;\n userData: {[key: string]: any};\n\n // WebGL specific API\n readonly isWebGL2: boolean;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext;\n /** Is this device attached to an offscreen context */\n readonly offScreen: boolean = false;\n\n readonly webglLimits: WebGLLimits;\n\n defaultFramebuffer?: Framebuffer;\n defaultVertexArray?: VertexArrayObject;\n\n // State used by luma.gl classes\n _state: 'uninitialized' | 'initializing' | 'initialized' = 'uninitialized';\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /**\n *\n */\n static fromContext(gl: WebGLRenderingContext): WebGLDevice {\n // @ts-expect-error\n return gl.device as WebGLDevice;\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(\n gl: Device | WebGLRenderingContext | WebGL2RenderingContext,\n props?: WebGLDeviceProps\n ): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({...props, gl: gl as WebGLRenderingContext});\n }\n\n\n constructor(props: WebGLDeviceProps) {\n super();\n\n this.props = {...DEFAULT_DEVICE_PROPS, ...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 = this.props.gl?.device;\n if (device) {\n if (device._state !== 'initialized') {\n log.error('recursive context');\n throw new Error('recursive context');\n }\n return device;\n }\n\n this.offScreen =\n typeof OffscreenCanvas !== 'undefined' &&\n props.canvas instanceof OffscreenCanvas;\n\n // Create an instrument context\n this.gl = (this.props.gl || this._createContext(props)) as WebGLRenderingContext;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this._state = 'initializing';\n // Avoid multiple instrumentations\n // @ts-expect-error\n if (this.gl.device) {\n log.error('device already created');\n throw new Error('device already created'); // ASSERT this device;\n }\n // @ts-expect-error\n this.gl.device = this;\n // @ts-ignore\n this.gl._version = typeof WebGL2RenderingContext !== 'undefined' && this.gl instanceof WebGL2RenderingContext ? 2 : 1;\n // TODO - move to weak map indexing\n glToContextMap.set(this.gl, this);\n\n // Luma Device fields\n this.info = getDeviceInfo(this.gl);\n // Log some debug info about the newly created context\n // @ts-expect-error device is attached to context\n const debug = this.gl.debug ? ' debug' : '';\n const webGL = isWebGL2(this.gl) ? 'WebGL2' : 'WebGL1';\n log.groupCollapsed(LOG_LEVEL, `${webGL}${debug} context: ${this.info.vendor}, ${this.info.renderer}`)();\n\n polyfillContext(this.gl);\n log.probe(LOG_LEVEL, 'polyfilled context')();\n\n // Install context state tracking\n trackContextState(this.gl, {\n copyState: false,\n log: (...args) => log.log(1, ...args)()\n });\n log.probe(LOG_LEVEL, 'instrumented context')();\n\n // WebGPU Device fields\n this.features = getDeviceFeatures(this.gl);\n log.probe(LOG_LEVEL, `queried device features ${counter}`)();\n this.limits = getDeviceLimits(this.gl);\n log.probe(LOG_LEVEL, 'queried device limits')();\n\n // Add seer integration - TODO - currently removed\n\n // WEBGL specific fields\n this.webglLimits = getWebGLLimits(this.gl);\n log.probe(LOG_LEVEL, 'queried webgl limits')();\n\n // Add debug instrumentation to the context\n // if (isBrowser() && props.debug) {\n // // @ts-ignore\n // const {makeDebugContext} = global;\n // if (!makeDebugContext) {\n // log.warn('WebGL debug mode not activated. import \"@luma.gl/debug\" to enable.')();\n // } else {\n // // @ts-ignore\n // this.gl = global.makeDebugContext(this.gl, props);\n // this.gl2 = this.gl as WebGL2RenderingContext;\n // // Debug forces log level to at least 1\n // log.level = Math.max(log.level, 1);\n // }\n // }\n\n log.groupEnd(LOG_LEVEL)();\n this._state = 'initialized';\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 // WEBGL SPECIFIC METHODS\n\n /**\n * Resize the canvas' drawing buffer.\n *\n * Can match the canvas CSS size, and optionally also consider devicePixelRatio\n * Can be called every frame\n *\n * Regardless of size, the drawing buffer will always be scaled to the viewport, but\n * for best visual results, usually set to either:\n * canvas CSS width x canvas CSS height\n * canvas CSS width * devicePixelRatio x canvas CSS height * devicePixelRatio\n * See http://webgl2fundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html\n */\n resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {\n // Resize browser context .\n if (this.gl.canvas) {\n const devicePixelRatio = getDevicePixelRatio(options?.useDevicePixels);\n setDevicePixelRatio(this.gl, devicePixelRatio, options);\n return;\n }\n\n // Resize headless gl context\n const ext = this.gl.getExtension('STACKGL_resize_drawingbuffer');\n if (ext && options && `width` in options && `height` in options) {\n ext.resize(options.width, options.height);\n }\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new WEBGLBuffer(this.gl, props);\n }\n\n createTexture(props: Texture2DProps): Texture2D {\n return new Texture2D(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n commit(): void {\n // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n if (this.offScreen && this.gl.commit) {\n // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext\n this.gl.commit();\n }\n }\n\n // PRIVATE METHODS\n\n /**\n * Creates a context giving access to the WebGL API\n */\n _createContext(options?: WebGLDeviceProps): WebGLRenderingContext {\n const {width, height, canvas} = this.props;\n // Get or create a canvas\n const targetCanvas = getCanvas({canvas, width, height});\n // Create a WebGL context in the canvas\n return createBrowserContext(targetCanvas, options);\n }\n}\n\n/*\n// prettier-ignore\nimport {\n Device, DeviceInfo, DeviceLimits,\n Buffer, BufferProps\n} from '@luma.gl/api';\n\nimport {getWebGLDeviceInfo} from '../converters/webgl-device-info';\nimport {getWebGLLimits} from '../converters/webgl-limits';\nimport {getWebGLFeatures} from '../converters/webgl-features';\n\nexport default class WEBGLDevice implements Device {\n readonly handle: WebGLRenderingContext;\n readonly gl: WebGLRenderingContext;\n readonly gl2: WebGL2RenderingContext | null;\n readonly canvas: HTMLCanvasElement;\n\n static isSupported(options: {canvas?: HTMLCanvasElement}): boolean {\n const {canvas} = options;\n let gl;\n try {\n gl = canvas && canvas.getContext(\"webgl\");\n gl = gl && canvas && canvas.getContext(\"experimental-webgl\");\n } catch (x) {\n gl = null;\n }\n return Boolean(gl);\n }\n\n constructor(props = {}) {\n const {canvas, swapChainFormat = \"bgra8unorm\"} = props;\n\n const gl = createGLContext(props);\n this.handle =\n this.gl = gl;\n this.gl2 = gl instanceof WebGL2RenderingContext ? gl : null;\n this.canvas = canvas;\n }\n\n resize(width, height) {\n resizeGLContext(this.gl);\n }\n\n getInfo(): DeviceInfo {\n return getWebGLDeviceInfo(this.gl);\n }\n\n getLimits(): DeviceLimits {\n return getWebGLLimits(this.gl, this.gl2);\n }\n\n getFeatures(): string[] {\n return getWebGLFeatures(this.gl);\n }\n\n createBuffer(props: WebGPUBufferProps): WEBGLBuffer {\n return new WEBGLBuffer(this.gl2 || this.gl, props);\n }\n\n createTexture(props: WebGPUTextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createSampler(props: WebGPUSamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: WebGPUShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createRenderPipeline(props: WebGPURenderPipelineProps): WEBGLPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n createComputePipeline(props: WebGPUComputePipelineProps): WebGPUPipeline {\n return new WebGPUComputePipeline(this, props);\n }\n\n\n // PRIVATE\n\n _startFrame() {}\n\n _endFrame() {}\n}\n*/\n"],"file":"webgl-device.js"}
|
package/dist/esm/index.js
CHANGED
|
@@ -35,5 +35,5 @@ export { lumaStats } from './init';
|
|
|
35
35
|
export { log, assert, uid, isObjectEmpty } from '@luma.gl/api';
|
|
36
36
|
export { setPathPrefix, loadFile, loadImage } from '@luma.gl/api';
|
|
37
37
|
export { createGLContext, instrumentGLContext, resizeGLContext, hasFeature, hasFeatures, getFeatures, getContextInfo, getGLContextInfo, getContextLimits, getContextDebugInfo } from './_deprecated/context-api';
|
|
38
|
-
export { FEATURES } from './_deprecated/features';
|
|
38
|
+
export { DEPRECATED_FEATURES as FEATURES } from './_deprecated/features';
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["default","WebGLDevice","getWebGLDevice","requestAnimationFrame","cancelAnimationFrame","cloneTextureFrom","getKeyValue","getKey","Accessor","Buffer","Texture2D","TextureCube","Program","Framebuffer","Renderbuffer","Shader","VertexShader","FragmentShader","clear","clearBuffer","readPixelsToArray","readPixelsToBuffer","copyToDataUrl","copyToImage","copyToTexture","blit","Query","Texture3D","TransformFeedback","VertexArrayObject","VertexArray","UniformBufferLayout","setDeviceParameters","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","parseUniformName","getUniformSetter","getDebugTableForUniforms","getDebugTableForVertexArray","getDebugTableForProgramConfiguration","getProgramBindings","lumaStats","log","assert","uid","isObjectEmpty","setPathPrefix","loadFile","loadImage","createGLContext","instrumentGLContext","resizeGLContext","hasFeature","hasFeatures","getFeatures","getContextInfo","getGLContextInfo","getContextLimits","getContextDebugInfo","FEATURES"],"mappings":"AAOA,OAAO,QAAP;AAIA,SAAQA,OAAO,IAAIC,WAAnB,EAAgCC,cAAhC,QAAqD,wBAArD;AAGA,SAAQC,qBAAR,EAA+BC,oBAA/B,QAA0D,uCAA1D;AAGA,SAAQC,gBAAR,QAA+B,6BAA/B;AACA,SAAQC,WAAR,EAAqBC,MAArB,QAAkC,iCAAlC;AAGA,SAAQP,OAAO,IAAIQ,QAAnB,QAAkC,oBAAlC;AAIA,SAAQR,OAAO,IAAIS,MAAnB,QAAgC,wBAAhC;AAEA,SAAQT,OAAO,IAAIU,SAAnB,QAAmC,sBAAnC;AAEA,S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,SAAQC,kBAAR,QAAiC,gCAAjC;AAKA,SAAQC,SAAR,QAAwB,QAAxB;AACA,SAAQC,GAAR,EAAaC,MAAb,EAAqBC,GAArB,EAA0BC,aAA1B,QAA8C,cAA9C;AACA,SAAQC,aAAR,EAAuBC,QAAvB,EAAiCC,SAAjC,QAAiD,cAAjD;AAIA,SACEC,eADF,EAEEC,mBAFF,EAGEC,eAHF,EAIEC,UAJF,EAKEC,WALF,EAMEC,WANF,EAOEC,cAPF,EAQEC,gBARF,EASEC,gBATF,EAUEC,mBAVF,QAWO,2BAXP;AAcA,SAAQC,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":["default","WebGLDevice","getWebGLDevice","requestAnimationFrame","cancelAnimationFrame","cloneTextureFrom","getKeyValue","getKey","Accessor","Buffer","Texture2D","TextureCube","Program","Framebuffer","Renderbuffer","Shader","VertexShader","FragmentShader","clear","clearBuffer","readPixelsToArray","readPixelsToBuffer","copyToDataUrl","copyToImage","copyToTexture","blit","Query","Texture3D","TransformFeedback","VertexArrayObject","VertexArray","UniformBufferLayout","setDeviceParameters","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","parseUniformName","getUniformSetter","getDebugTableForUniforms","getDebugTableForVertexArray","getDebugTableForProgramConfiguration","getProgramBindings","lumaStats","log","assert","uid","isObjectEmpty","setPathPrefix","loadFile","loadImage","createGLContext","instrumentGLContext","resizeGLContext","hasFeature","hasFeatures","getFeatures","getContextInfo","getGLContextInfo","getContextLimits","getContextDebugInfo","DEPRECATED_FEATURES","FEATURES"],"mappings":"AAOA,OAAO,QAAP;AAIA,SAAQA,OAAO,IAAIC,WAAnB,EAAgCC,cAAhC,QAAqD,wBAArD;AAGA,SAAQC,qBAAR,EAA+BC,oBAA/B,QAA0D,uCAA1D;AAGA,SAAQC,gBAAR,QAA+B,6BAA/B;AACA,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P;AAOA,SAAQC,eAAR,QAA8B,qCAA9B;AAGA,SAAQC,gBAAR,EAA0BC,gBAA1B,QAAiD,oBAAjD;AACA,SAAQC,wBAAR,QAAuC,wBAAvC;AACA,SAAQC,2BAAR,QAA0C,4BAA1C;AACA,SAAQC,oCAAR,QAAmD,qCAAnD;AAGA,SAAQC,kBAAR,QAAiC,gCAAjC;AAKA,SAAQC,SAAR,QAAwB,QAAxB;AACA,SAAQC,GAAR,EAAaC,MAAb,EAAqBC,GAArB,EAA0BC,aAA1B,QAA8C,cAA9C;AACA,SAAQC,aAAR,EAAuBC,QAAvB,EAAiCC,SAAjC,QAAiD,cAAjD;AAIA,SACEC,eADF,EAEEC,mBAFF,EAGEC,eAHF,EAIEC,UAJF,EAKEC,WALF,EAMEC,WANF,EAOEC,cAPF,EAQEC,gBARF,EASEC,gBATF,EAUEC,mBAVF,QAWO,2BAXP;AAcA,SAAQC,mBAAmB,IAAIC,QAA/B,QAA8C,wBAA9C","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 './init';\n\n// export type {WebGLDeviceProps, WebGLDeviceInfo, WebGPUDeviceLimits} from './lib/webgl-device';\nexport type {WebGLDeviceProps} from './adapter/webgl-device';\nexport {default as WebGLDevice, getWebGLDevice} from './adapter/webgl-device';\n\n// UTILS\nexport {requestAnimationFrame, cancelAnimationFrame} from './webgl-utils/request-animation-frame';\n\n// WebGL Functions\nexport {cloneTextureFrom} from './webgl-utils/texture-utils';\nexport {getKeyValue, getKey} from './webgl-utils/constants-to-keys';\n\n// WebGL Helper Classes\nexport {default as Accessor} from './classes/accessor';\n\n// WebGL1 classes\nexport type {BufferProps} from '@luma.gl/api';\nexport {default as Buffer} from './classes/webgl-buffer';\nexport type {Texture2DProps} from './classes/texture-2d';\nexport {default as Texture2D} from './classes/texture-2d';\nexport type {TextureCubeProps} from './classes/texture-cube';\nexport {default as TextureCube} from './classes/texture-cube';\n\nexport type {ProgramProps} from './classes/program';\nexport {default as Program} from './classes/program';\nexport type {FramebufferProps} from './classes/framebuffer';\nexport {default as Framebuffer} from './classes/framebuffer';\nexport type {RenderbufferProps} from './classes/renderbuffer';\nexport {default as Renderbuffer} from './classes/renderbuffer';\n\n// Classic luma.gl classes (For backwards compatibility)\nexport type {ShaderProps} from './classes/shader';\nexport {Shader, VertexShader, FragmentShader} from './classes/shader';\n\nexport {clear, clearBuffer} from './classes/clear';\n\n// Copy and Blit\nexport {\n readPixelsToArray,\n readPixelsToBuffer,\n copyToDataUrl,\n copyToImage,\n copyToTexture,\n blit\n} from './classes/copy-and-blit';\n\n// WebGL2 classes & Extensions\nexport type {QueryProps} from './classes/query';\nexport {default as Query} from './classes/query';\nexport type {Texture3DProps} from './classes/texture-3d';\nexport {default as Texture3D} from './classes/texture-3d';\nexport type {TransformFeedbackProps} from './classes/transform-feedback';\nexport {default as TransformFeedback} from './classes/transform-feedback';\nexport type {VertexArrayObjectProps} from './classes/vertex-array-object';\nexport {default as VertexArrayObject} from './classes/vertex-array-object';\nexport type {VertexArrayProps} from './classes/vertex-array';\nexport {default as VertexArray} from './classes/vertex-array';\nexport {default as UniformBufferLayout} from './classes/uniform-buffer-layout';\n\nexport {setDeviceParameters} from './adapter/converters/set-device-parameters';\n\n// experimental WebGL exports\n\n// UTILS\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 type {GLParameters} from './context/parameters/webgl-parameters';\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// INTERNAL\nexport {parseUniformName, getUniformSetter} from './classes/uniforms';\nexport {getDebugTableForUniforms} from './debug/debug-uniforms';\nexport {getDebugTableForVertexArray} from './debug/debug-vertex-array';\nexport {getDebugTableForProgramConfiguration} from './debug/debug-program-configuration';\n\n// HELPERS - EXPERIMENTAL\nexport {getProgramBindings} from './helpers/get-program-bindings';\n\n// DEPRECATED\n\n// Deprecated re-exports\nexport {lumaStats} from './init';\nexport {log, assert, uid, isObjectEmpty} from '@luma.gl/api';\nexport {setPathPrefix, loadFile, loadImage} from '@luma.gl/api';\n\n// GLTOOLS\nexport type {GLContextOptions} from './_deprecated/context-api';\nexport {\n createGLContext,\n instrumentGLContext,\n resizeGLContext,\n hasFeature,\n hasFeatures,\n getFeatures,\n getContextInfo,\n getGLContextInfo,\n getContextLimits,\n getContextDebugInfo\n} from './_deprecated/context-api';\n\n// Features\nexport {DEPRECATED_FEATURES as FEATURES} from './_deprecated/features';\n\n// REMOVED in v8.7\n// getShaderInfo,\n// getShaderName\n// getShaderVersion\n"],"file":"index.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -50,5 +50,5 @@ export { log, assert, uid, isObjectEmpty } from '@luma.gl/api';
|
|
|
50
50
|
export { setPathPrefix, loadFile, loadImage } from '@luma.gl/api';
|
|
51
51
|
export type { GLContextOptions } from './_deprecated/context-api';
|
|
52
52
|
export { createGLContext, instrumentGLContext, resizeGLContext, hasFeature, hasFeatures, getFeatures, getContextInfo, getGLContextInfo, getContextLimits, getContextDebugInfo } from './_deprecated/context-api';
|
|
53
|
-
export { FEATURES } from './_deprecated/features';
|
|
53
|
+
export { DEPRECATED_FEATURES as FEATURES } from './_deprecated/features';
|
|
54
54
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","s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E,OAAO,EAAC,2BAA2B,EAAC,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAC,oCAAoC,EAAC,MAAM,qCAAqC,CAAC;AAGzF,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAKlE,OAAO,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAGhE,YAAY,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAC,mBAAmB,IAAI,QAAQ,EAAC,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -35,5 +35,5 @@ export { lumaStats } from './init';
|
|
|
35
35
|
export { log, assert, uid, isObjectEmpty } from '@luma.gl/api';
|
|
36
36
|
export { setPathPrefix, loadFile, loadImage } from '@luma.gl/api';
|
|
37
37
|
export { createGLContext, instrumentGLContext, resizeGLContext, hasFeature, hasFeatures, getFeatures, getContextInfo, getGLContextInfo, getContextLimits, getContextDebugInfo } from './_deprecated/context-api';
|
|
38
|
-
export { FEATURES } from './_deprecated/features';
|
|
38
|
+
export { DEPRECATED_FEATURES as FEATURES } from './_deprecated/features';
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["default","WebGLDevice","getWebGLDevice","requestAnimationFrame","cancelAnimationFrame","cloneTextureFrom","getKeyValue","getKey","Accessor","Buffer","Texture2D","TextureCube","Program","Framebuffer","Renderbuffer","Shader","VertexShader","FragmentShader","clear","clearBuffer","readPixelsToArray","readPixelsToBuffer","copyToDataUrl","copyToImage","copyToTexture","blit","Query","Texture3D","TransformFeedback","VertexArrayObject","VertexArray","UniformBufferLayout","setDeviceParameters","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","parseUniformName","getUniformSetter","getDebugTableForUniforms","getDebugTableForVertexArray","getDebugTableForProgramConfiguration","getProgramBindings","lumaStats","log","assert","uid","isObjectEmpty","setPathPrefix","loadFile","loadImage","createGLContext","instrumentGLContext","resizeGLContext","hasFeature","hasFeatures","getFeatures","getContextInfo","getGLContextInfo","getContextLimits","getContextDebugInfo","FEATURES"],"mappings":"AAOA,OAAO,QAAP;AAIA,SAAQA,OAAO,IAAIC,WAAnB,EAAgCC,cAAhC,QAAqD,wBAArD;AAGA,SAAQC,qBAAR,EAA+BC,oBAA/B,QAA0D,uCAA1D;AAGA,SAAQC,gBAAR,QAA+B,6BAA/B;AACA,SAAQC,WAAR,EAAqBC,MAArB,QAAkC,iCAAlC;AAGA,SAAQP,OAAO,IAAIQ,QAAnB,QAAkC,oBAAlC;AAIA,SAAQR,OAAO,IAAIS,MAAnB,QAAgC,wBAAhC;AAEA,SAAQT,OAAO,IAAIU,SAAnB,QAAmC,sBAAnC;AAEA,SAAQV,OAAO,IAAIW,WAAnB,QAAqC,wBAArC;AAGA,SAAQX,OAAO,IAAIY,OAAnB,QAAiC,mBAAjC;AAEA,SAAQZ,OAAO,IAAIa,WAAnB,QAAqC,uBAArC;AAEA,SAAQb,OAAO,IAAIc,YAAnB,QAAsC,wBAAtC;AAIA,SAAQC,MAAR,EAAgBC,YAAhB,EAA8BC,cAA9B,QAAmD,kBAAnD;AAEA,SAAQC,KAAR,EAAeC,WAAf,QAAiC,iBAAjC;AAGA,SACEC,iBADF,EAEE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AUEC,mBAVF,QAWO,2BAXP;AAcA,SAAQC,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["default","WebGLDevice","getWebGLDevice","requestAnimationFrame","cancelAnimationFrame","cloneTextureFrom","getKeyValue","getKey","Accessor","Buffer","Texture2D","TextureCube","Program","Framebuffer","Renderbuffer","Shader","VertexShader","FragmentShader","clear","clearBuffer","readPixelsToArray","readPixelsToBuffer","copyToDataUrl","copyToImage","copyToTexture","blit","Query","Texture3D","TransformFeedback","VertexArrayObject","VertexArray","UniformBufferLayout","setDeviceParameters","isWebGL","isWebGL2","getWebGL2Context","assertWebGLContext","assertWebGL2Context","cssToDeviceRatio","cssToDevicePixels","getParameters","setParameters","resetParameters","withParameters","trackContextState","pushContextState","popContextState","polyfillContext","parseUniformName","getUniformSetter","getDebugTableForUniforms","getDebugTableForVertexArray","getDebugTableForProgramConfiguration","getProgramBindings","lumaStats","log","assert","uid","isObjectEmpty","setPathPrefix","loadFile","loadImage","createGLContext","instrumentGLContext","resizeGLContext","hasFeature","hasFeatures","getFeatures","getContextInfo","getGLContextInfo","getContextLimits","getContextDebugInfo","DEPRECATED_FEATURES","FEATURES"],"mappings":"AAOA,OAAO,QAAP;AAIA,SAAQA,OAAO,IAAIC,WAAnB,EAAgCC,cAAhC,QAAqD,wBAArD;AAGA,SAAQC,qBAAR,EAA+BC,oBAA/B,QAA0D,uCAA1D;AAGA,SAAQC,gBAAR,QAA+B,6BAA/B;AACA,SAAQC,WAAR,EAAqBC,MAArB,QAAkC,iCAAlC;AAGA,SAAQP,OAAO,IAAIQ,QAAnB,QAAkC,oBAAlC;AAIA,SAAQR,OAAO,IAAIS,MAAnB,QAAgC,wBAAhC;AAEA,SAAQT,OAAO,IAAIU,SAAnB,QAAmC,sBAAnC;AAEA,SAAQV,OAAO,IAAIW,WAAnB,QAAqC,wBAArC;AAGA,SAAQX,OAAO,IAAIY,OAAnB,QAAiC,mBAAjC;AAEA,SAAQZ,OAAO,IAAIa,WAAnB,QA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AA8C,cAA9C;AACA,SAAQC,aAAR,EAAuBC,QAAvB,EAAiCC,SAAjC,QAAiD,cAAjD;AAIA,SACEC,eADF,EAEEC,mBAFF,EAGEC,eAHF,EAIEC,UAJF,EAKEC,WALF,EAMEC,WANF,EAOEC,cAPF,EAQEC,gBARF,EASEC,gBATF,EAUEC,mBAVF,QAWO,2BAXP;AAcA,SAAQC,mBAAmB,IAAIC,QAA/B,QAA8C,wBAA9C","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 './init';\n\n// export type {WebGLDeviceProps, WebGLDeviceInfo, WebGPUDeviceLimits} from './lib/webgl-device';\nexport type {WebGLDeviceProps} from './adapter/webgl-device';\nexport {default as WebGLDevice, getWebGLDevice} from './adapter/webgl-device';\n\n// UTILS\nexport {requestAnimationFrame, cancelAnimationFrame} from './webgl-utils/request-animation-frame';\n\n// WebGL Functions\nexport {cloneTextureFrom} from './webgl-utils/texture-utils';\nexport {getKeyValue, getKey} from './webgl-utils/constants-to-keys';\n\n// WebGL Helper Classes\nexport {default as Accessor} from './classes/accessor';\n\n// WebGL1 classes\nexport type {BufferProps} from '@luma.gl/api';\nexport {default as Buffer} from './classes/webgl-buffer';\nexport type {Texture2DProps} from './classes/texture-2d';\nexport {default as Texture2D} from './classes/texture-2d';\nexport type {TextureCubeProps} from './classes/texture-cube';\nexport {default as TextureCube} from './classes/texture-cube';\n\nexport type {ProgramProps} from './classes/program';\nexport {default as Program} from './classes/program';\nexport type {FramebufferProps} from './classes/framebuffer';\nexport {default as Framebuffer} from './classes/framebuffer';\nexport type {RenderbufferProps} from './classes/renderbuffer';\nexport {default as Renderbuffer} from './classes/renderbuffer';\n\n// Classic luma.gl classes (For backwards compatibility)\nexport type {ShaderProps} from './classes/shader';\nexport {Shader, VertexShader, FragmentShader} from './classes/shader';\n\nexport {clear, clearBuffer} from './classes/clear';\n\n// Copy and Blit\nexport {\n readPixelsToArray,\n readPixelsToBuffer,\n copyToDataUrl,\n copyToImage,\n copyToTexture,\n blit\n} from './classes/copy-and-blit';\n\n// WebGL2 classes & Extensions\nexport type {QueryProps} from './classes/query';\nexport {default as Query} from './classes/query';\nexport type {Texture3DProps} from './classes/texture-3d';\nexport {default as Texture3D} from './classes/texture-3d';\nexport type {TransformFeedbackProps} from './classes/transform-feedback';\nexport {default as TransformFeedback} from './classes/transform-feedback';\nexport type {VertexArrayObjectProps} from './classes/vertex-array-object';\nexport {default as VertexArrayObject} from './classes/vertex-array-object';\nexport type {VertexArrayProps} from './classes/vertex-array';\nexport {default as VertexArray} from './classes/vertex-array';\nexport {default as UniformBufferLayout} from './classes/uniform-buffer-layout';\n\nexport {setDeviceParameters} from './adapter/converters/set-device-parameters';\n\n// experimental WebGL exports\n\n// UTILS\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 type {GLParameters} from './context/parameters/webgl-parameters';\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// INTERNAL\nexport {parseUniformName, getUniformSetter} from './classes/uniforms';\nexport {getDebugTableForUniforms} from './debug/debug-uniforms';\nexport {getDebugTableForVertexArray} from './debug/debug-vertex-array';\nexport {getDebugTableForProgramConfiguration} from './debug/debug-program-configuration';\n\n// HELPERS - EXPERIMENTAL\nexport {getProgramBindings} from './helpers/get-program-bindings';\n\n// DEPRECATED\n\n// Deprecated re-exports\nexport {lumaStats} from './init';\nexport {log, assert, uid, isObjectEmpty} from '@luma.gl/api';\nexport {setPathPrefix, loadFile, loadImage} from '@luma.gl/api';\n\n// GLTOOLS\nexport type {GLContextOptions} from './_deprecated/context-api';\nexport {\n createGLContext,\n instrumentGLContext,\n resizeGLContext,\n hasFeature,\n hasFeatures,\n getFeatures,\n getContextInfo,\n getGLContextInfo,\n getContextLimits,\n getContextDebugInfo\n} from './_deprecated/context-api';\n\n// Features\nexport {DEPRECATED_FEATURES as FEATURES} from './_deprecated/features';\n\n// REMOVED in v8.7\n// getShaderInfo,\n// getShaderName\n// getShaderVersion\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "8.6.0-alpha.
|
|
3
|
+
"version": "8.6.0-alpha.5",
|
|
4
4
|
"description": "WebGL2 Classes",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
|
-
"@luma.gl/api": "8.6.0-alpha.
|
|
39
|
-
"@luma.gl/constants": "8.6.0-alpha.
|
|
38
|
+
"@luma.gl/api": "8.6.0-alpha.5",
|
|
39
|
+
"@luma.gl/constants": "8.6.0-alpha.5",
|
|
40
40
|
"@probe.gl/env": "^3.5.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c07a1da6a4cac293a1b10658adcaafe872ac9efe"
|
|
43
43
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/* eslint-disable quotes */
|
|
6
6
|
import GL from '@luma.gl/constants';
|
|
7
7
|
import {WebGLDevice, WebGLDeviceProps} from '@luma.gl/webgl';
|
|
8
|
-
import {
|
|
8
|
+
import {DEPRECATED_FEATURES} from './features';
|
|
9
9
|
|
|
10
10
|
export type GLContextOptions = WebGLDeviceProps & {
|
|
11
11
|
throwOnError?: boolean; // If set to false, return `null` if context creation fails.
|
|
@@ -61,12 +61,17 @@ export function resizeGLContext(
|
|
|
61
61
|
export function hasFeatures(gl: WebGLRenderingContext, features: string | string[]): boolean {
|
|
62
62
|
const webglDevice = WebGLDevice.attach(gl);
|
|
63
63
|
const normalizedFeatures = Array.isArray(features) ? features : [features];
|
|
64
|
-
const deviceFeatures = normalizedFeatures.map(feature =>
|
|
65
|
-
|
|
64
|
+
const deviceFeatures = normalizedFeatures.map(feature => classicToDeviceFeature(feature));
|
|
65
|
+
// @ts-expect-error Feature is a string enum
|
|
66
|
+
return deviceFeatures.every((feature) => webglDevice.features.has(feature));
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function
|
|
69
|
-
|
|
69
|
+
function classicToDeviceFeature(feature: string): string {
|
|
70
|
+
const deviceFeature = feature.toLowerCase().replace(/\_/g, '-');
|
|
71
|
+
if (deviceFeature.startsWith('webgl2') || deviceFeature.startsWith('glsl-')) {
|
|
72
|
+
return deviceFeature;
|
|
73
|
+
}
|
|
74
|
+
return `webgl-${deviceFeature}`;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/**
|
|
@@ -84,8 +89,9 @@ export function hasFeature(gl: WebGLRenderingContext, feature: string): boolean
|
|
|
84
89
|
export function getFeatures(gl: WebGLRenderingContext): Record<string, boolean> {
|
|
85
90
|
const webglDevice = WebGLDevice.attach(gl);
|
|
86
91
|
const featureMap: Record<string, boolean> = {};
|
|
87
|
-
for (const feature in
|
|
88
|
-
|
|
92
|
+
for (const feature in DEPRECATED_FEATURES) {
|
|
93
|
+
// @ts-expect-error Feature is a string enum
|
|
94
|
+
featureMap[feature] = webglDevice.features.has(classicToDeviceFeature(feature));
|
|
89
95
|
}
|
|
90
96
|
return featureMap;
|
|
91
97
|
}
|
|
@@ -7,7 +7,7 @@ import {isWebGL2} from '@luma.gl/webgl';
|
|
|
7
7
|
import {assert} from '@luma.gl/api';
|
|
8
8
|
|
|
9
9
|
// TODO - this should be the default export, test cases need updating
|
|
10
|
-
export const
|
|
10
|
+
export const DEPRECATED_FEATURES = {
|
|
11
11
|
WEBGL2: 'WEBGL2',
|
|
12
12
|
|
|
13
13
|
// API SUPPORT
|
|
@@ -72,7 +72,7 @@ function isFeatureSupported(gl: WebGLRenderingContext, cap: string): boolean {
|
|
|
72
72
|
// Get extension name from table
|
|
73
73
|
const featureDefinition = isWebGL2(gl) ? webgl2Feature : webgl1Feature;
|
|
74
74
|
|
|
75
|
-
if (cap ===
|
|
75
|
+
if (cap === DEPRECATED_FEATURES.COLOR_ATTACHMENT_RGBA32F && !isWebGL2(gl)) {
|
|
76
76
|
return checkFloat32ColorAttachment(gl);
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -119,41 +119,41 @@ function checkFloat32ColorAttachment(gl: WebGLRenderingContext) {
|
|
|
119
119
|
// Defines luma.gl "feature" names and semantics
|
|
120
120
|
// Format: 'feature-name: [WebGL1 support, WebGL2 support] / [WebGL1 and WebGL2 support]', when support is 'string' it is the name of the extension
|
|
121
121
|
const WEBGL_FEATURES: Record<string, [boolean | string, boolean | string]> = {
|
|
122
|
-
[
|
|
122
|
+
[DEPRECATED_FEATURES.WEBGL2]: [false, true],
|
|
123
123
|
|
|
124
124
|
// API SUPPORT
|
|
125
|
-
[
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
[
|
|
125
|
+
[DEPRECATED_FEATURES.VERTEX_ARRAY_OBJECT]: ['OES_vertex_array_object', true],
|
|
126
|
+
[DEPRECATED_FEATURES.TIMER_QUERY]: ['EXT_disjoint_timer_query', 'EXT_disjoint_timer_query_webgl2'],
|
|
127
|
+
[DEPRECATED_FEATURES.INSTANCED_RENDERING]: ['ANGLE_instanced_arrays', true],
|
|
128
|
+
[DEPRECATED_FEATURES.MULTIPLE_RENDER_TARGETS]: ['WEBGL_draw_buffers', true],
|
|
129
129
|
|
|
130
130
|
// FEATURES
|
|
131
|
-
[
|
|
131
|
+
[DEPRECATED_FEATURES.ELEMENT_INDEX_UINT32]: ['OES_element_index_uint', true],
|
|
132
132
|
|
|
133
133
|
// BLENDING
|
|
134
|
-
[
|
|
135
|
-
[
|
|
134
|
+
[DEPRECATED_FEATURES.BLEND_EQUATION_MINMAX]: ['EXT_blend_minmax', true],
|
|
135
|
+
[DEPRECATED_FEATURES.FLOAT_BLEND]: ['EXT_float_blend', 'EXT_float_blend'],
|
|
136
136
|
|
|
137
137
|
// TEXTURES, RENDERBUFFERS
|
|
138
|
-
[
|
|
138
|
+
[DEPRECATED_FEATURES.COLOR_ENCODING_SRGB]: ['EXT_sRGB', true],
|
|
139
139
|
|
|
140
140
|
// TEXTURES
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
[
|
|
141
|
+
[DEPRECATED_FEATURES.TEXTURE_DEPTH]: ['WEBGL_depth_texture', true],
|
|
142
|
+
[DEPRECATED_FEATURES.TEXTURE_FLOAT]: ['OES_texture_float', true],
|
|
143
|
+
[DEPRECATED_FEATURES.TEXTURE_HALF_FLOAT]: ['OES_texture_half_float', true],
|
|
144
144
|
|
|
145
|
-
[
|
|
146
|
-
[
|
|
147
|
-
[
|
|
145
|
+
[DEPRECATED_FEATURES.TEXTURE_FILTER_LINEAR_FLOAT]: ['OES_texture_float_linear', 'OES_texture_float_linear'],
|
|
146
|
+
[DEPRECATED_FEATURES.TEXTURE_FILTER_LINEAR_HALF_FLOAT]: ['OES_texture_half_float_linear', 'OES_texture_half_float_linear'],
|
|
147
|
+
[DEPRECATED_FEATURES.TEXTURE_FILTER_ANISOTROPIC]: ['EXT_texture_filter_anisotropic', 'EXT_texture_filter_anisotropic'],
|
|
148
148
|
|
|
149
149
|
// FRAMEBUFFERS, TEXTURES AND RENDERBUFFERS
|
|
150
|
-
[
|
|
151
|
-
[
|
|
152
|
-
[
|
|
150
|
+
[DEPRECATED_FEATURES.COLOR_ATTACHMENT_RGBA32F]: [false, 'EXT_color_buffer_float'], // Note override check
|
|
151
|
+
[DEPRECATED_FEATURES.COLOR_ATTACHMENT_FLOAT]: [false, 'EXT_color_buffer_float'],
|
|
152
|
+
[DEPRECATED_FEATURES.COLOR_ATTACHMENT_HALF_FLOAT]: ['EXT_color_buffer_half_float', 'EXT_color_buffer_half_float'],
|
|
153
153
|
|
|
154
154
|
// GLSL extensions
|
|
155
|
-
[
|
|
156
|
-
[
|
|
157
|
-
[
|
|
158
|
-
[
|
|
155
|
+
[DEPRECATED_FEATURES.GLSL_FRAG_DATA]: ['WEBGL_draw_buffers', true],
|
|
156
|
+
[DEPRECATED_FEATURES.GLSL_FRAG_DEPTH]: ['EXT_frag_depth', true],
|
|
157
|
+
[DEPRECATED_FEATURES.GLSL_DERIVATIVES]: ['OES_standard_derivatives', true],
|
|
158
|
+
[DEPRECATED_FEATURES.GLSL_TEXTURE_LOD]: ['EXT_shader_texture_lod', true]
|
|
159
159
|
};
|
|
@@ -66,6 +66,8 @@ const DEFAULT_DEVICE_PROPS: Required<WebGLDeviceProps> = {
|
|
|
66
66
|
failIfMajorPerformanceCaveat: undefined
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
const LOG_LEVEL = 1;
|
|
70
|
+
|
|
69
71
|
// TODO use weakmap instead of modifying context
|
|
70
72
|
const glToContextMap = new WeakMap<WebGLRenderingContext | WebGL2RenderingContext, WebGLDevice>();
|
|
71
73
|
|
|
@@ -98,7 +100,6 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
98
100
|
/** Is this device attached to an offscreen context */
|
|
99
101
|
readonly offScreen: boolean = false;
|
|
100
102
|
|
|
101
|
-
readonly webglFeatures: Set<string>;
|
|
102
103
|
readonly webglLimits: WebGLLimits;
|
|
103
104
|
|
|
104
105
|
defaultFramebuffer?: Framebuffer;
|
|
@@ -182,29 +183,29 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
182
183
|
// @ts-expect-error device is attached to context
|
|
183
184
|
const debug = this.gl.debug ? ' debug' : '';
|
|
184
185
|
const webGL = isWebGL2(this.gl) ? 'WebGL2' : 'WebGL1';
|
|
185
|
-
log.
|
|
186
|
+
log.groupCollapsed(LOG_LEVEL, `${webGL}${debug} context: ${this.info.vendor}, ${this.info.renderer}`)();
|
|
186
187
|
|
|
187
188
|
polyfillContext(this.gl);
|
|
188
|
-
log.probe(
|
|
189
|
+
log.probe(LOG_LEVEL, 'polyfilled context')();
|
|
189
190
|
|
|
190
191
|
// Install context state tracking
|
|
191
192
|
trackContextState(this.gl, {
|
|
192
193
|
copyState: false,
|
|
193
194
|
log: (...args) => log.log(1, ...args)()
|
|
194
195
|
});
|
|
195
|
-
log.probe(
|
|
196
|
+
log.probe(LOG_LEVEL, 'instrumented context')();
|
|
196
197
|
|
|
197
198
|
// WebGPU Device fields
|
|
198
199
|
this.features = getDeviceFeatures(this.gl);
|
|
199
|
-
log.probe(
|
|
200
|
+
log.probe(LOG_LEVEL, `queried device features ${counter}`)();
|
|
200
201
|
this.limits = getDeviceLimits(this.gl);
|
|
201
|
-
log.probe(
|
|
202
|
+
log.probe(LOG_LEVEL, 'queried device limits')();
|
|
202
203
|
|
|
203
204
|
// Add seer integration - TODO - currently removed
|
|
204
205
|
|
|
205
206
|
// WEBGL specific fields
|
|
206
207
|
this.webglLimits = getWebGLLimits(this.gl);
|
|
207
|
-
log.probe(
|
|
208
|
+
log.probe(LOG_LEVEL, 'queried webgl limits')();
|
|
208
209
|
|
|
209
210
|
// Add debug instrumentation to the context
|
|
210
211
|
// if (isBrowser() && props.debug) {
|
|
@@ -221,7 +222,7 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
221
222
|
// }
|
|
222
223
|
// }
|
|
223
224
|
|
|
224
|
-
log.groupEnd(
|
|
225
|
+
log.groupEnd(LOG_LEVEL)();
|
|
225
226
|
this._state = 'initialized';
|
|
226
227
|
}
|
|
227
228
|
|
|
@@ -310,14 +311,6 @@ export default class WebGLDevice extends Device implements ContextState {
|
|
|
310
311
|
}
|
|
311
312
|
|
|
312
313
|
/*
|
|
313
|
-
import {
|
|
314
|
-
isWebGL, isWebGL2,
|
|
315
|
-
createGLContext,
|
|
316
|
-
instrumentGLContext,
|
|
317
|
-
getContextDebugInfo,
|
|
318
|
-
resizeGLContext
|
|
319
|
-
} from '@luma.gl/gltools';
|
|
320
|
-
|
|
321
314
|
// prettier-ignore
|
|
322
315
|
import {
|
|
323
316
|
Device, DeviceInfo, DeviceLimits,
|
package/src/index.ts
CHANGED