@luma.gl/core 9.0.0-alpha.9 → 9.0.0-beta.2
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/LICENSE +3 -1
- package/README.md +4 -4
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts +52 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +1 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js +130 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js.map +1 -0
- package/dist/adapter/canvas-context.d.ts +109 -0
- package/dist/adapter/canvas-context.d.ts.map +1 -0
- package/dist/adapter/canvas-context.js +254 -0
- package/dist/adapter/canvas-context.js.map +1 -0
- package/dist/adapter/device.d.ts +219 -0
- package/dist/adapter/device.d.ts.map +1 -0
- package/dist/adapter/device.js +99 -0
- package/dist/adapter/device.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +56 -0
- package/dist/adapter/resources/buffer.d.ts.map +1 -0
- package/dist/adapter/resources/buffer.js +62 -0
- package/dist/adapter/resources/buffer.js.map +1 -0
- package/dist/adapter/resources/command-buffer.d.ts +12 -0
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/command-buffer.js +15 -0
- package/dist/adapter/resources/command-buffer.js.map +1 -0
- package/dist/adapter/resources/command-encoder.d.ts +113 -0
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -0
- package/dist/adapter/resources/command-encoder.js +19 -0
- package/dist/adapter/resources/command-encoder.js.map +1 -0
- package/dist/adapter/resources/compute-pass.d.ts +31 -0
- package/dist/adapter/resources/compute-pass.d.ts.map +1 -0
- package/dist/adapter/resources/compute-pass.js +15 -0
- package/dist/adapter/resources/compute-pass.js.map +1 -0
- package/dist/adapter/resources/compute-pipeline.d.ts +24 -0
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/compute-pipeline.js +20 -0
- package/dist/adapter/resources/compute-pipeline.js.map +1 -0
- package/dist/adapter/resources/external-texture.d.ts +12 -0
- package/dist/adapter/resources/external-texture.d.ts.map +1 -0
- package/dist/adapter/resources/external-texture.js +17 -0
- package/dist/adapter/resources/external-texture.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +50 -0
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -0
- package/dist/adapter/resources/framebuffer.js +102 -0
- package/dist/adapter/resources/framebuffer.js.map +1 -0
- package/dist/adapter/resources/render-pass.d.ts +51 -0
- package/dist/adapter/resources/render-pass.d.ts.map +1 -0
- package/dist/adapter/resources/render-pass.js +23 -0
- package/dist/adapter/resources/render-pass.js.map +1 -0
- package/dist/adapter/resources/render-pipeline.d.ts +89 -0
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/render-pipeline.js +36 -0
- package/dist/adapter/resources/render-pipeline.js.map +1 -0
- package/dist/adapter/resources/resource.d.ts +73 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -0
- package/dist/adapter/resources/resource.js +101 -0
- package/dist/adapter/resources/resource.js.map +1 -0
- package/dist/adapter/resources/sampler.d.ts +42 -0
- package/dist/adapter/resources/sampler.d.ts.map +1 -0
- package/dist/adapter/resources/sampler.js +26 -0
- package/dist/adapter/resources/sampler.js.map +1 -0
- package/dist/adapter/resources/shader.d.ts +45 -0
- package/dist/adapter/resources/shader.d.ts.map +1 -0
- package/dist/adapter/resources/shader.js +90 -0
- package/dist/adapter/resources/shader.js.map +1 -0
- package/dist/adapter/resources/texture.d.ts +90 -0
- package/dist/adapter/resources/texture.d.ts.map +1 -0
- package/dist/adapter/resources/texture.js +45 -0
- package/dist/adapter/resources/texture.js.map +1 -0
- package/dist/adapter/resources/transform-feedback.d.ts +30 -0
- package/dist/adapter/resources/transform-feedback.d.ts.map +1 -0
- package/dist/adapter/resources/transform-feedback.js +17 -0
- package/dist/adapter/resources/transform-feedback.js.map +1 -0
- package/dist/adapter/resources/vertex-array.d.ts +40 -0
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -0
- package/dist/adapter/resources/vertex-array.js +24 -0
- package/dist/adapter/resources/vertex-array.js.map +1 -0
- package/dist/adapter/type-utils/decode-attribute-type.d.ts +20 -0
- package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-attribute-type.js +60 -0
- package/dist/adapter/type-utils/decode-attribute-type.js.map +1 -0
- package/dist/adapter/type-utils/decode-data-type.d.ts +16 -0
- package/dist/adapter/type-utils/decode-data-type.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-data-type.js +43 -0
- package/dist/adapter/type-utils/decode-data-type.js.map +1 -0
- package/dist/adapter/type-utils/decode-shader-types.d.ts +9 -0
- package/dist/adapter/type-utils/decode-shader-types.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-shader-types.js +103 -0
- package/dist/adapter/type-utils/decode-shader-types.js.map +1 -0
- package/dist/adapter/type-utils/decode-texture-format.d.ts +19 -0
- package/dist/adapter/type-utils/decode-texture-format.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-texture-format.js +101 -0
- package/dist/adapter/type-utils/decode-texture-format.js.map +1 -0
- package/dist/adapter/type-utils/decode-vertex-format.d.ts +22 -0
- package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-vertex-format.js +25 -0
- package/dist/adapter/type-utils/decode-vertex-format.js.map +1 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts +10 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +1 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.js +76 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.js.map +1 -0
- package/dist/adapter/type-utils/wgsl-utils.d.ts +4 -0
- package/dist/adapter/type-utils/wgsl-utils.d.ts.map +1 -0
- package/dist/adapter/type-utils/wgsl-utils.js +15 -0
- package/dist/adapter/type-utils/wgsl-utils.js.map +1 -0
- package/dist/adapter/types/accessor.d.ts +23 -0
- package/dist/adapter/types/accessor.d.ts.map +1 -0
- package/dist/adapter/types/accessor.js +2 -0
- package/dist/adapter/types/accessor.js.map +1 -0
- package/dist/adapter/types/buffer-layout.d.ts +59 -0
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -0
- package/dist/adapter/types/buffer-layout.js +2 -0
- package/dist/adapter/types/buffer-layout.js.map +1 -0
- package/dist/adapter/types/parameters.d.ts +97 -0
- package/dist/adapter/types/parameters.d.ts.map +1 -0
- package/dist/adapter/types/parameters.js +28 -0
- package/dist/adapter/types/parameters.js.map +1 -0
- package/dist/adapter/types/shader-layout.d.ts +145 -0
- package/dist/adapter/types/shader-layout.d.ts.map +1 -0
- package/dist/adapter/types/shader-layout.js +2 -0
- package/dist/adapter/types/shader-layout.js.map +1 -0
- package/dist/adapter/types/shader-types.d.ts +21 -0
- package/dist/adapter/types/shader-types.d.ts.map +1 -0
- package/dist/adapter/types/shader-types.js +2 -0
- package/dist/adapter/types/shader-types.js.map +1 -0
- package/dist/adapter/types/texture-formats.d.ts +12 -0
- package/dist/adapter/types/texture-formats.d.ts.map +1 -0
- package/dist/adapter/types/texture-formats.js +2 -0
- package/dist/adapter/types/texture-formats.js.map +1 -0
- package/dist/adapter/types/types.d.ts +90 -0
- package/dist/adapter/types/types.d.ts.map +1 -0
- package/dist/adapter/types/types.js +2 -0
- package/dist/adapter/types/types.js.map +1 -0
- package/dist/adapter/types/vertex-formats.d.ts +14 -0
- package/dist/adapter/types/vertex-formats.d.ts.map +1 -0
- package/dist/adapter/types/vertex-formats.js +2 -0
- package/dist/adapter/types/vertex-formats.js.map +1 -0
- package/dist/dist.dev.js +2976 -0
- package/dist/index.cjs +2445 -0
- package/dist/index.d.ts +81 -128
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -18
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +5 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +24 -0
- package/dist/init.js.map +1 -0
- package/dist/lib/compiler-log/compiler-message.d.ts +8 -0
- package/dist/lib/compiler-log/compiler-message.d.ts.map +1 -0
- package/dist/lib/compiler-log/compiler-message.js +2 -0
- package/dist/lib/compiler-log/compiler-message.js.map +1 -0
- package/dist/lib/compiler-log/format-compiler-log.d.ts +8 -0
- package/dist/lib/compiler-log/format-compiler-log.d.ts.map +1 -0
- package/dist/lib/compiler-log/format-compiler-log.js +64 -0
- package/dist/lib/compiler-log/format-compiler-log.js.map +1 -0
- package/dist/lib/compiler-log/get-shader-info.d.ts +9 -0
- package/dist/lib/compiler-log/get-shader-info.d.ts.map +1 -0
- package/dist/lib/compiler-log/get-shader-info.js +25 -0
- package/dist/lib/compiler-log/get-shader-info.js.map +1 -0
- package/dist/lib/luma.d.ts +22 -0
- package/dist/lib/luma.d.ts.map +1 -0
- package/dist/lib/luma.js +63 -0
- package/dist/lib/luma.js.map +1 -0
- package/dist/lib/uniforms/uniform-block.d.ts +29 -0
- package/dist/lib/uniforms/uniform-block.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-block.js +48 -0
- package/dist/lib/uniforms/uniform-block.js.map +1 -0
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts +27 -0
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-buffer-layout.js +76 -0
- package/dist/lib/uniforms/uniform-buffer-layout.js.map +1 -0
- package/dist/lib/uniforms/uniform-store.d.ts +62 -0
- package/dist/lib/uniforms/uniform-store.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-store.js +89 -0
- package/dist/lib/uniforms/uniform-store.js.map +1 -0
- package/dist/lib/uniforms/uniform.d.ts +10 -0
- package/dist/lib/uniforms/uniform.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform.js +20 -0
- package/dist/lib/uniforms/uniform.js.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/array-equal.d.ts +5 -0
- package/dist/utils/array-equal.d.ts.map +1 -0
- package/dist/utils/array-equal.js +28 -0
- package/dist/utils/array-equal.js.map +1 -0
- package/dist/utils/array-utils-flat.d.ts +10 -0
- package/dist/utils/array-utils-flat.d.ts.map +1 -0
- package/dist/utils/array-utils-flat.js +36 -0
- package/dist/utils/array-utils-flat.js.map +1 -0
- package/dist/utils/assert.d.ts +2 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +6 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/cast.d.ts +3 -0
- package/dist/utils/cast.d.ts.map +1 -0
- package/dist/utils/cast.js +4 -0
- package/dist/utils/cast.js.map +1 -0
- package/dist/utils/check-props.d.ts +7 -0
- package/dist/utils/check-props.d.ts.map +1 -0
- package/dist/utils/check-props.js +32 -0
- package/dist/utils/check-props.js.map +1 -0
- package/dist/utils/deep-equal.d.ts +9 -0
- package/dist/utils/deep-equal.d.ts.map +1 -0
- package/dist/utils/deep-equal.js +40 -0
- package/dist/utils/deep-equal.js.map +1 -0
- package/dist/utils/format-value.d.ts +7 -0
- package/dist/utils/format-value.d.ts.map +1 -0
- package/dist/utils/format-value.js +42 -0
- package/dist/utils/format-value.js.map +1 -0
- package/dist/utils/is-array.d.ts +16 -0
- package/dist/utils/is-array.d.ts.map +1 -0
- package/dist/utils/is-array.js +10 -0
- package/dist/utils/is-array.js.map +1 -0
- package/dist/utils/load-file.d.ts +35 -0
- package/dist/utils/load-file.d.ts.map +1 -0
- package/dist/utils/load-file.js +48 -0
- package/dist/utils/load-file.js.map +1 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +5 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/random.d.ts +5 -0
- package/dist/utils/random.d.ts.map +1 -0
- package/dist/utils/random.js +14 -0
- package/dist/utils/random.js.map +1 -0
- package/dist/utils/request-animation-frame.d.ts +3 -0
- package/dist/utils/request-animation-frame.d.ts.map +1 -0
- package/dist/utils/request-animation-frame.js +7 -0
- package/dist/utils/request-animation-frame.js.map +1 -0
- package/dist/utils/stats-manager.d.ts +12 -0
- package/dist/utils/stats-manager.d.ts.map +1 -0
- package/dist/utils/stats-manager.js +19 -0
- package/dist/utils/stats-manager.js.map +1 -0
- package/dist/utils/stub-methods.d.ts +2 -0
- package/dist/utils/stub-methods.d.ts.map +1 -0
- package/dist/utils/stub-methods.js +16 -0
- package/dist/utils/stub-methods.js.map +1 -0
- package/dist/utils/utils.d.ts +15 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +19 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist.min.js +33 -0
- package/package.json +17 -12
- package/src/adapter/attribute-utils/get-attribute-from-layouts.ts +259 -0
- package/src/adapter/canvas-context.ts +433 -0
- package/src/adapter/device.ts +435 -0
- package/src/adapter/resources/buffer.ts +106 -0
- package/src/adapter/resources/command-buffer.ts +38 -0
- package/src/adapter/resources/command-encoder.ts +172 -0
- package/src/adapter/resources/compute-pass.ts +52 -0
- package/src/adapter/resources/compute-pipeline.ts +39 -0
- package/src/adapter/resources/external-texture.ts +20 -0
- package/src/adapter/resources/framebuffer.ts +230 -0
- package/src/adapter/resources/render-pass.ts +117 -0
- package/src/adapter/resources/render-pipeline.ts +133 -0
- package/src/adapter/resources/resource.ts +176 -0
- package/src/adapter/resources/sampler.ts +69 -0
- package/src/adapter/resources/shader.ts +143 -0
- package/src/adapter/resources/texture.ts +140 -0
- package/src/adapter/resources/transform-feedback.ts +45 -0
- package/src/adapter/resources/vertex-array.ts +65 -0
- package/src/adapter/type-utils/decode-attribute-type.ts +82 -0
- package/src/adapter/type-utils/decode-data-type.ts +62 -0
- package/src/adapter/type-utils/decode-shader-types.ts +48 -0
- package/src/adapter/type-utils/decode-texture-format.ts +190 -0
- package/src/adapter/type-utils/decode-vertex-format.ts +49 -0
- package/src/adapter/type-utils/vertex-format-from-attribute.ts +103 -0
- package/src/adapter/type-utils/wgsl-utils.ts +18 -0
- package/src/adapter/types/accessor.ts +34 -0
- package/src/adapter/types/buffer-layout.ts +62 -0
- package/src/adapter/types/parameters.ts +250 -0
- package/src/adapter/types/shader-layout.ts +193 -0
- package/src/adapter/types/shader-types.ts +77 -0
- package/src/adapter/types/texture-formats.ts +168 -0
- package/src/adapter/types/types.ts +109 -0
- package/src/adapter/types/vertex-formats.ts +91 -0
- package/src/index.ts +160 -92
- package/src/init.ts +47 -0
- package/src/lib/compiler-log/compiler-message.ts +10 -0
- package/src/lib/compiler-log/format-compiler-log.ts +113 -0
- package/src/lib/compiler-log/get-shader-info.ts +41 -0
- package/src/lib/luma.ts +84 -0
- package/src/lib/uniforms/uniform-block.ts +80 -0
- package/src/lib/uniforms/uniform-buffer-layout.ts +109 -0
- package/src/lib/uniforms/uniform-store.ts +173 -0
- package/src/lib/uniforms/uniform.ts +25 -0
- package/src/types.ts +33 -0
- package/src/utils/array-equal.ts +33 -0
- package/src/utils/array-utils-flat.ts +43 -0
- package/src/utils/assert.ts +7 -0
- package/src/utils/cast.ts +4 -0
- package/src/utils/check-props.ts +74 -0
- package/src/utils/deep-equal.ts +47 -0
- package/src/utils/format-value.ts +40 -0
- package/src/utils/is-array.ts +24 -0
- package/src/utils/load-file.ts +89 -0
- package/src/utils/log.ts +4 -0
- package/src/utils/random.ts +17 -0
- package/src/utils/request-animation-frame.ts +15 -0
- package/src/utils/stats-manager.ts +23 -0
- package/src/utils/stub-methods.ts +20 -0
- package/src/utils/utils.ts +36 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/src/bundle.ts +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvas-context.js","names":["isBrowser","log","isPage","document","isPageLoaded","readyState","DEFAULT_CANVAS_CONTEXT_PROPS","canvas","width","height","useDevicePixels","autoResize","container","visible","colorSpace","alphaMode","CanvasContext","constructor","props","device","id","htmlCanvas","offscreenCanvas","type","resizeObserver","_canvasSizeInfo","clientWidth","clientHeight","devicePixelRatio","_props","_props2","createCanvas","getContainer","insertBefore","firstChild","style","visibility","getCanvasFromDOM","HTMLCanvasElement","ResizeObserver","entries","entry","target","update","observe","getDevicePixelRatio","OffscreenCanvas","undefined","dpr","window","getPixelSize","parentElement","Error","getAspect","cssToDeviceRatio","drawingBufferWidth","getDrawingBufferSize","cssToDevicePixels","cssPixel","yInvert","arguments","length","ratio","scalePixels","setDevicePixelRatio","options","cachedSize","clampedPixelRatio","canvasWidth","Math","floor","canvasHeight","drawingBufferHeight","min","warn","gl","_setAutoCreatedCanvasId","_this$htmlCanvas","pageLoaded","getPageLoadPromise","Promise","resolve","addEventListener","element","getElementById","body","canvasId","targetCanvas","createElement","Number","isFinite","pixel","point","x","scaleX","y","scaleY","t","xHigh","yHigh","max","r","round"],"sources":["../../src/adapter/canvas-context.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {isBrowser} from '@probe.gl/env';\nimport type {Device} from './device';\nimport type {Framebuffer} from './resources/framebuffer';\nimport {log} from '../utils/log';\n\nconst isPage: boolean = isBrowser() && typeof document !== 'undefined';\nconst isPageLoaded: () => boolean = () => isPage && document.readyState === 'complete';\n\n/** Properties for a CanvasContext */\nexport type CanvasContextProps = {\n /** If canvas not supplied, will be created and added to the DOM. If string, will be looked up in the DOM */\n canvas?: HTMLCanvasElement | OffscreenCanvas | string | null;\n /** If new canvas is created, it will be created in the specified container, otherwise appended to body */\n container?: HTMLElement | string | null;\n /** Width in pixels of the canvas */\n width?: number;\n /** Height in pixels of the canvas */\n height?: number;\n /** Whether to apply a device pixels scale factor (`true` uses browser DPI) */\n useDevicePixels?: boolean | number;\n /** Whether to track resizes (if not ) */\n autoResize?: boolean;\n /** Visibility (only used if new canvas is created). */\n visible?: boolean;\n /** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */\n colorSpace?: 'srgb'; // GPUPredefinedColorSpace\n /** WebGPU only https://www.w3.org/TR/webgpu/#canvas-configuration */\n alphaMode?: 'opaque' | 'premultiplied';\n};\n\nconst DEFAULT_CANVAS_CONTEXT_PROPS: Required<CanvasContextProps> = {\n canvas: null,\n width: 800, // width are height are only used by headless gl\n height: 600,\n useDevicePixels: true,\n autoResize: true,\n container: null,\n visible: true,\n colorSpace: 'srgb',\n alphaMode: 'opaque'\n};\n\n/**\n * Manages a canvas. Supports both HTML or offscreen canvas\n * - Creates a new canvas or looks up a canvas from the DOM\n * - Provides check for DOM loaded\n * @todo commit(): https://github.com/w3ctag/design-reviews/issues/288\n * @todo transferControlToOffscreen: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen\n */\nexport abstract class CanvasContext {\n abstract readonly device: Device;\n readonly id: string;\n readonly props: Required<CanvasContextProps>;\n readonly canvas: HTMLCanvasElement | OffscreenCanvas;\n readonly htmlCanvas?: HTMLCanvasElement;\n readonly offscreenCanvas?: OffscreenCanvas;\n readonly type: 'html-canvas' | 'offscreen-canvas' | 'node';\n\n width: number = 1;\n height: number = 1;\n\n readonly resizeObserver: ResizeObserver | undefined;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** Check if the DOM is loaded */\n static get isPageLoaded(): boolean {\n return isPageLoaded();\n }\n\n /**\n * Get a 'lazy' promise that resolves when the DOM is loaded.\n * @note Since there may be limitations on number of `load` event listeners,\n * it is recommended avoid calling this function until actually needed.\n * I.e. don't call it until you know that you will be looking up a string in the DOM.\n */\n static pageLoaded: Promise<void> = getPageLoadPromise();\n\n constructor(props?: CanvasContextProps) {\n this.props = {...DEFAULT_CANVAS_CONTEXT_PROPS, ...props};\n props = this.props;\n\n if (!isBrowser()) {\n this.id = 'node-canvas-context';\n this.type = 'node';\n this.width = this.props.width;\n this.height = this.props.height;\n // TODO - does this prevent app from using jsdom style polyfills?\n this.canvas = null!;\n return;\n }\n\n if (!props.canvas) {\n const canvas = createCanvas(props);\n const container = getContainer(props?.container || null);\n container.insertBefore(canvas, container.firstChild);\n\n this.canvas = canvas;\n\n if (!props?.visible) {\n this.canvas.style.visibility = 'hidden';\n }\n } else if (typeof props.canvas === 'string') {\n this.canvas = getCanvasFromDOM(props.canvas);\n } else {\n this.canvas = props.canvas;\n }\n\n if (this.canvas instanceof HTMLCanvasElement) {\n this.id = this.canvas.id;\n this.type = 'html-canvas';\n this.htmlCanvas = this.canvas;\n } else {\n this.id = 'offscreen-canvas';\n this.type = 'offscreen-canvas';\n this.offscreenCanvas = this.canvas;\n }\n\n // React to size changes\n if (this.canvas instanceof HTMLCanvasElement && props.autoResize) {\n this.resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n if (entry.target === this.canvas) {\n this.update();\n }\n }\n });\n this.resizeObserver.observe(this.canvas);\n }\n }\n\n /** Returns a framebuffer with properly resized current 'swap chain' textures */\n abstract getCurrentFramebuffer(): Framebuffer;\n\n /**\n * Returns the current DPR, if props.useDevicePixels is true\n * Device refers to physical\n */\n getDevicePixelRatio(useDevicePixels?: boolean | number): number {\n if (typeof OffscreenCanvas !== 'undefined' && this.canvas instanceof OffscreenCanvas) {\n return 1;\n }\n\n useDevicePixels = useDevicePixels === undefined ? this.props.useDevicePixels : useDevicePixels;\n\n if (!useDevicePixels || useDevicePixels as number <= 0) {\n return 1;\n }\n\n // The param was mainly provide to support the test cases, could be removed\n if (useDevicePixels === true) {\n const dpr = typeof window !== 'undefined' && window.devicePixelRatio;\n return dpr || 1;\n }\n\n return useDevicePixels;\n }\n\n /**\n * Returns the size of drawing buffer in device pixels.\n * @note This can be different from the 'CSS' size of a canvas, and also from the\n * canvas' internal drawing buffer size (.width, .height).\n * This is the size required to cover the canvas, adjusted for DPR\n */\n getPixelSize(): [number, number] {\n switch (this.type) {\n case 'node':\n return [this.width, this.height];\n case 'offscreen-canvas':\n return [this.canvas.width, this.canvas.height];\n case 'html-canvas':\n const dpr = this.getDevicePixelRatio();\n const canvas = this.canvas as HTMLCanvasElement;\n // If not attached to DOM client size can be 0\n return canvas.parentElement\n ? [canvas.clientWidth * dpr, canvas.clientHeight * dpr]\n : [this.canvas.width, this.canvas.height];\n default:\n throw new Error(this.type);\n }\n }\n\n getAspect(): number {\n const [width, height] = this.getPixelSize();\n return width / height;\n }\n\n /**\n * Returns multiplier need to convert CSS size to Device size\n */\n cssToDeviceRatio(): number {\n try {\n // For headless gl we might have used custom width and height\n // hence use cached clientWidth\n const [drawingBufferWidth] = this.getDrawingBufferSize();\n const {clientWidth} = this._canvasSizeInfo;\n return clientWidth ? drawingBufferWidth / clientWidth : 1;\n } catch {\n return 1;\n }\n }\n\n /**\n * Maps CSS pixel position to device pixel position\n */\n cssToDevicePixels(\n cssPixel: number[],\n yInvert: boolean = true\n ): {\n x: number;\n y: number;\n width: number;\n height: number;\n } {\n const ratio = this.cssToDeviceRatio();\n const [width, height] = this.getDrawingBufferSize();\n return scalePixels(cssPixel, ratio, width, height, yInvert);\n }\n\n /**\n * Use devicePixelRatio to set canvas width and height\n * @note this is a raw port of luma.gl v8 code. Might be worth a review\n */\n setDevicePixelRatio(\n devicePixelRatio: number,\n options: {width?: number; height?: number} = {}\n ): void {\n if (!this.htmlCanvas) {\n return;\n }\n\n // NOTE: if options.width and options.height not used remove in v8\n let clientWidth = 'width' in options ? options.width : this.htmlCanvas.clientWidth;\n let clientHeight = 'height' in options ? options.height : this.htmlCanvas.clientHeight;\n\n if (!clientWidth || !clientHeight) {\n log.log(1, 'Canvas clientWidth/clientHeight is 0')();\n // by forcing devicePixel ratio to 1, we do not scale canvas.width and height in each frame.\n devicePixelRatio = 1;\n clientWidth = this.htmlCanvas.width || 1;\n clientHeight = this.htmlCanvas.height || 1;\n }\n\n const cachedSize = this._canvasSizeInfo;\n // Check if canvas needs to be resized\n if (\n cachedSize.clientWidth !== clientWidth ||\n cachedSize.clientHeight !== clientHeight ||\n cachedSize.devicePixelRatio !== devicePixelRatio\n ) {\n let clampedPixelRatio = devicePixelRatio;\n\n const canvasWidth = Math.floor(clientWidth * clampedPixelRatio);\n const canvasHeight = Math.floor(clientHeight * clampedPixelRatio);\n this.htmlCanvas.width = canvasWidth;\n this.htmlCanvas.height = canvasHeight;\n\n // Note: when devicePixelRatio is too high, it is possible we might hit system limit for\n // drawing buffer width and hight, in those cases they get clamped and resulting aspect ration may not be maintained\n // for those cases, reduce devicePixelRatio.\n const [drawingBufferWidth, drawingBufferHeight] = this.getDrawingBufferSize();\n\n if (drawingBufferWidth !== canvasWidth || drawingBufferHeight !== canvasHeight) {\n clampedPixelRatio = Math.min(\n drawingBufferWidth / clientWidth,\n drawingBufferHeight / clientHeight\n );\n\n this.htmlCanvas.width = Math.floor(clientWidth * clampedPixelRatio);\n this.htmlCanvas.height = Math.floor(clientHeight * clampedPixelRatio);\n\n log.warn('Device pixel ratio clamped')();\n }\n\n this._canvasSizeInfo.clientWidth = clientWidth;\n this._canvasSizeInfo.clientHeight = clientHeight;\n this._canvasSizeInfo.devicePixelRatio = devicePixelRatio;\n }\n }\n\n // PRIVATE\n\n /** @todo Major hack done to port the CSS methods above, base canvas context should not depend on WebGL */\n getDrawingBufferSize(): [number, number] {\n // @ts-expect-error This only works for WebGL\n const gl = this.device.gl;\n if (!gl) {\n // use default device pixel ratio\n throw new Error('canvas size');\n }\n return [gl.drawingBufferWidth, gl.drawingBufferHeight];\n }\n\n abstract resize(options?: {\n width?: number;\n height?: number;\n useDevicePixels?: boolean | number;\n }): void;\n\n /** Perform platform specific updates (WebGPU vs WebGL) */\n protected abstract update(): void;\n\n /**\n * Allows subclass constructor to override the canvas id for auto created canvases.\n * This can really help when debugging DOM in apps that create multiple devices\n */\n protected _setAutoCreatedCanvasId(id: string) {\n if (this.htmlCanvas?.id === 'lumagl-auto-created-canvas') {\n this.htmlCanvas.id = id;\n }\n }\n}\n\n// HELPER FUNCTIONS\n\n/** Returns a promise that resolves when the page is loaded */\nfunction getPageLoadPromise(): Promise<void> {\n if (isPageLoaded() || typeof window === 'undefined') {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n window.addEventListener('load', () => resolve());\n });\n}\n\nfunction getContainer(container: HTMLElement | string | null): HTMLElement {\n if (typeof container === 'string') {\n const element = document.getElementById(container);\n if (!element && !isPageLoaded()) {\n throw new Error(`Accessing '${container}' before page was loaded`);\n }\n if (!element) {\n throw new Error(`${container} is not an HTML element`);\n }\n return element;\n } else if (container) {\n return container;\n }\n return document.body;\n}\n\n/** Get a Canvas element from DOM id */\nfunction getCanvasFromDOM(canvasId: string): HTMLCanvasElement {\n const canvas = document.getElementById(canvasId);\n if (!canvas && !isPageLoaded()) {\n throw new Error(`Accessing '${canvasId}' before page was loaded`);\n }\n if (!(canvas instanceof HTMLCanvasElement)) {\n throw new Error('Object is not a canvas element');\n }\n return canvas;\n}\n\n/** Create a new canvas */\nfunction createCanvas(props: CanvasContextProps) {\n const {width, height} = props;\n const targetCanvas = document.createElement('canvas');\n targetCanvas.id = 'lumagl-auto-created-canvas';\n targetCanvas.width = width || 1;\n targetCanvas.height = height || 1;\n targetCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';\n targetCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';\n return targetCanvas;\n}\n\n/**\n *\n * @param pixel\n * @param ratio\n * @param width\n * @param height\n * @param yInvert\n * @returns\n */\nfunction scalePixels(\n pixel: number[],\n ratio: number,\n width: number,\n height: number,\n yInvert: boolean\n): {\n x: number;\n y: number;\n width: number;\n height: number;\n} {\n const point = pixel as [number, number];\n \n const x = scaleX(point[0], ratio, width);\n let y = scaleY(point[1], ratio, height, yInvert);\n\n // Find boundaries of next pixel to provide valid range of device pixel locations\n\n let t = scaleX(point[0] + 1, ratio, width);\n // If next pixel's position is clamped to boundary, use it as is, otherwise subtract 1 for current pixel boundary\n const xHigh = t === width - 1 ? t : t - 1;\n\n t = scaleY(point[1] + 1, ratio, height, yInvert);\n let yHigh;\n if (yInvert) {\n // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range\n t = t === 0 ? t : t + 1;\n // swap y and yHigh\n yHigh = y;\n y = t;\n } else {\n // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range\n yHigh = t === height - 1 ? t : t - 1;\n // y remains same\n }\n return {\n x,\n y,\n // when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.\n width: Math.max(xHigh - x + 1, 1),\n height: Math.max(yHigh - y + 1, 1)\n };\n}\n\nfunction scaleX(x: number, ratio: number, width: number): number {\n // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit\n const r = Math.min(Math.round(x * ratio), width - 1);\n return r;\n}\n\nfunction scaleY(y: number, ratio: number, height: number, yInvert: boolean): number {\n // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit\n return yInvert\n ? Math.max(0, height - 1 - Math.round(y * ratio))\n : Math.min(Math.round(y * ratio), height - 1);\n}\n"],"mappings":"AACA,SAAQA,SAAS,QAAO,eAAe;AAAC,SAGhCC,GAAG;AAEX,MAAMC,MAAe,GAAGF,SAAS,CAAC,CAAC,IAAI,OAAOG,QAAQ,KAAK,WAAW;AACtE,MAAMC,YAA2B,GAAGA,CAAA,KAAMF,MAAM,IAAIC,QAAQ,CAACE,UAAU,KAAK,UAAU;AAwBtF,MAAMC,4BAA0D,GAAG;EACjEC,MAAM,EAAE,IAAI;EACZC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,GAAG;EACXC,eAAe,EAAE,IAAI;EACrBC,UAAU,EAAE,IAAI;EAChBC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,IAAI;EACbC,UAAU,EAAE,MAAM;EAClBC,SAAS,EAAE;AACb,CAAC;AASD,OAAO,MAAeC,aAAa,CAAC;EAkBlC,WAAWZ,YAAYA,CAAA,EAAY;IACjC,OAAOA,YAAY,CAAC,CAAC;EACvB;EAUAa,WAAWA,CAACC,KAA0B,EAAE;IAAA,KA7BtBC,M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AO6F,CAAC;AACV;AAEA,SAASL,MAAMA,CAACD,CAAS,EAAEjC,KAAa,EAAErD,MAAc,EAAEkD,OAAgB,EAAU;EAElF,OAAOA,OAAO,GACVU,IAAI,CAAC+B,GAAG,CAAC,CAAC,EAAE3F,MAAM,GAAG,CAAC,GAAG4D,IAAI,CAACiC,KAAK,CAACP,CAAC,GAAGjC,KAAK,CAAC,CAAC,GAC/CO,IAAI,CAACI,GAAG,CAACJ,IAAI,CAACiC,KAAK,CAACP,CAAC,GAAGjC,KAAK,CAAC,EAAErD,MAAM,GAAG,CAAC,CAAC;AACjD"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { StatsManager } from '../utils/stats-manager';
|
|
2
|
+
import type { TextureFormat } from './types/texture-formats';
|
|
3
|
+
import type { CanvasContext, CanvasContextProps } from './canvas-context';
|
|
4
|
+
import type { BufferProps } from './resources/buffer';
|
|
5
|
+
import { Buffer } from './resources/buffer';
|
|
6
|
+
import type { RenderPipeline, RenderPipelineProps } from './resources/render-pipeline';
|
|
7
|
+
import type { ComputePipeline, ComputePipelineProps } from './resources/compute-pipeline';
|
|
8
|
+
import type { Sampler, SamplerProps } from './resources/sampler';
|
|
9
|
+
import type { Shader, ShaderProps } from './resources/shader';
|
|
10
|
+
import type { Texture, TextureProps, TextureData } from './resources/texture';
|
|
11
|
+
import type { ExternalTexture, ExternalTextureProps } from './resources/external-texture';
|
|
12
|
+
import type { Framebuffer, FramebufferProps } from './resources/framebuffer';
|
|
13
|
+
import type { RenderPass, RenderPassProps } from './resources/render-pass';
|
|
14
|
+
import type { ComputePass, ComputePassProps } from './resources/compute-pass';
|
|
15
|
+
import type { CommandEncoder, CommandEncoderProps } from './resources/command-encoder';
|
|
16
|
+
import type { VertexArray, VertexArrayProps } from './resources/vertex-array';
|
|
17
|
+
import type { TransformFeedback, TransformFeedbackProps } from './resources/transform-feedback';
|
|
18
|
+
/** Device properties */
|
|
19
|
+
export type DeviceProps = {
|
|
20
|
+
id?: string;
|
|
21
|
+
type?: 'webgl' | 'webgl1' | 'webgl2' | 'webgpu' | 'best-available';
|
|
22
|
+
canvas?: HTMLCanvasElement | OffscreenCanvas | string | null;
|
|
23
|
+
container?: HTMLElement | string | null;
|
|
24
|
+
width?: number /** width is only used when creating a new canvas */;
|
|
25
|
+
height?: number /** height is only used when creating a new canvas */;
|
|
26
|
+
webgl2?: boolean;
|
|
27
|
+
webgl1?: boolean;
|
|
28
|
+
debug?: boolean;
|
|
29
|
+
manageState?: boolean;
|
|
30
|
+
break?: string[];
|
|
31
|
+
gl?: WebGLRenderingContext | WebGL2RenderingContext | null;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Identifies the GPU vendor and driver.
|
|
35
|
+
* @note Chrome WebGPU does not provide much information, though more can be enabled with
|
|
36
|
+
* @see https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates
|
|
37
|
+
* chrome://flags/#enable-webgpu-developer-features
|
|
38
|
+
*/
|
|
39
|
+
export type DeviceInfo = {
|
|
40
|
+
/** Type of device */
|
|
41
|
+
type: 'webgl' | 'webgl2' | 'webgpu';
|
|
42
|
+
/** Vendor (name of GPU vendor, Apple, nVidia etc */
|
|
43
|
+
vendor: string;
|
|
44
|
+
/** Renderer (usually driver name) */
|
|
45
|
+
renderer: string;
|
|
46
|
+
/** version of driver */
|
|
47
|
+
version: string;
|
|
48
|
+
/** family of GPU */
|
|
49
|
+
gpu: 'nvidia' | 'amd' | 'intel' | 'apple' | 'software' | 'unknown';
|
|
50
|
+
/** Type of GPU () */
|
|
51
|
+
gpuType: 'discrete' | 'integrated' | 'cpu' | 'unknown';
|
|
52
|
+
/** GPU architecture */
|
|
53
|
+
gpuArchitecture?: string;
|
|
54
|
+
/** GPU driver backend. Can sometimes be sniffed */
|
|
55
|
+
gpuBackend?: 'opengl' | 'opengles' | 'metal' | 'd3d11' | 'd3d12' | 'vulkan' | 'unknown';
|
|
56
|
+
/** If this is a fallback adapter */
|
|
57
|
+
fallback?: boolean;
|
|
58
|
+
/** Shader language supported by device.createShader() */
|
|
59
|
+
shadingLanguage: 'wgsl' | 'glsl';
|
|
60
|
+
/** Highest supported shader language version (GLSL 3.00 = 300, GLSL 1.00 = 100) */
|
|
61
|
+
shadingLanguageVersion: number;
|
|
62
|
+
};
|
|
63
|
+
/** Limits for a device */
|
|
64
|
+
export type DeviceLimits = {
|
|
65
|
+
readonly maxTextureDimension1D?: number;
|
|
66
|
+
readonly maxTextureDimension2D?: number;
|
|
67
|
+
readonly maxTextureDimension3D?: number;
|
|
68
|
+
readonly maxTextureArrayLayers?: number;
|
|
69
|
+
readonly maxBindGroups: number;
|
|
70
|
+
readonly maxDynamicUniformBuffersPerPipelineLayout: number;
|
|
71
|
+
readonly maxDynamicStorageBuffersPerPipelineLayout: number;
|
|
72
|
+
readonly maxSampledTexturesPerShaderStage: number;
|
|
73
|
+
readonly maxSamplersPerShaderStage: number;
|
|
74
|
+
readonly maxStorageBuffersPerShaderStage: number;
|
|
75
|
+
readonly maxStorageTexturesPerShaderStage: number;
|
|
76
|
+
readonly maxUniformBuffersPerShaderStage: number;
|
|
77
|
+
readonly maxUniformBufferBindingSize: number;
|
|
78
|
+
readonly maxStorageBufferBindingSize?: number;
|
|
79
|
+
readonly minUniformBufferOffsetAlignment?: number;
|
|
80
|
+
readonly minStorageBufferOffsetAlignment?: number;
|
|
81
|
+
readonly maxVertexBuffers?: number;
|
|
82
|
+
readonly maxVertexAttributes: number;
|
|
83
|
+
readonly maxVertexBufferArrayStride?: number;
|
|
84
|
+
readonly maxInterStageShaderComponents?: number;
|
|
85
|
+
readonly maxComputeWorkgroupStorageSize?: number;
|
|
86
|
+
readonly maxComputeInvocationsPerWorkgroup?: number;
|
|
87
|
+
readonly maxComputeWorkgroupSizeX?: number;
|
|
88
|
+
readonly maxComputeWorkgroupSizeY?: number;
|
|
89
|
+
readonly maxComputeWorkgroupSizeZ?: number;
|
|
90
|
+
readonly maxComputeWorkgroupsPerDimension?: number;
|
|
91
|
+
};
|
|
92
|
+
export type WebGPUDeviceFeature = 'depth-clip-control' | 'depth24unorm-stencil8' | 'depth32float-stencil8' | 'timestamp-query' | 'indirect-first-instance' | 'texture-compression-bc' | 'texture-compression-etc2' | 'texture-compression-astc';
|
|
93
|
+
export type WebGLDeviceFeature = 'webgpu' | 'webgl2' | 'webgl' | 'timer-query-webgl' | 'uniform-buffers-webgl' | 'uniforms-webgl' | 'texture-filter-linear-float32-webgl' | 'texture-filter-linear-float16-webgl' | 'texture-filter-anisotropic-webgl' | 'texture-renderable-float32-webgl' | 'texture-renderable-float16-webgl' | 'texture-renderable-rgba32float-webgl' | 'texture-blend-float-webgl1' | 'texture-formats-norm16-webgl' | 'texture-formats-srgb-webgl1' | 'texture-formats-depth-webgl1' | 'texture-formats-float32-webgl1' | 'texture-formats-float16-webgl1' | 'vertex-array-object-webgl1' | 'instanced-rendering-webgl1' | 'multiple-render-targets-webgl1' | 'index-uint32-webgl1' | 'blend-minmax-webgl1' | 'transform-feedback-webgl2' | 'glsl-frag-data' | 'glsl-frag-depth' | 'glsl-derivatives' | 'glsl-texture-lod';
|
|
94
|
+
type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl';
|
|
95
|
+
/** Valid feature strings */
|
|
96
|
+
export type DeviceFeature = WebGPUDeviceFeature | WebGLDeviceFeature | WebGLCompressedTextureFeatures;
|
|
97
|
+
/**
|
|
98
|
+
* WebGPU Device/WebGL context abstraction
|
|
99
|
+
*/
|
|
100
|
+
export declare abstract class Device {
|
|
101
|
+
static defaultProps: Required<DeviceProps>;
|
|
102
|
+
get [Symbol.toStringTag](): string;
|
|
103
|
+
static VERSION: string;
|
|
104
|
+
constructor(props: DeviceProps);
|
|
105
|
+
/** id of this device, primarily for debugging */
|
|
106
|
+
readonly id: string;
|
|
107
|
+
/** stats */
|
|
108
|
+
readonly statsManager: StatsManager;
|
|
109
|
+
/** A copy of the device props */
|
|
110
|
+
readonly props: Required<DeviceProps>;
|
|
111
|
+
/** Available for the application to store data on the device */
|
|
112
|
+
userData: {
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
};
|
|
115
|
+
/** Used by other luma.gl modules to store data on the device */
|
|
116
|
+
_lumaData: {
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
};
|
|
119
|
+
abstract destroy(): void;
|
|
120
|
+
/** Information about the device (vendor, versions etc) */
|
|
121
|
+
abstract info: DeviceInfo;
|
|
122
|
+
/** Optional capability discovery */
|
|
123
|
+
abstract get features(): Set<DeviceFeature>;
|
|
124
|
+
/** WebGPU style device limits */
|
|
125
|
+
abstract get limits(): DeviceLimits;
|
|
126
|
+
/** Check if device supports a specific texture format (creation and `nearest` sampling) */
|
|
127
|
+
abstract isTextureFormatSupported(format: TextureFormat): boolean;
|
|
128
|
+
/** Check if linear filtering (sampler interpolation) is supported for a specific texture format */
|
|
129
|
+
abstract isTextureFormatFilterable(format: TextureFormat): boolean;
|
|
130
|
+
/** Check if device supports rendering to a specific texture format */
|
|
131
|
+
abstract isTextureFormatRenderable(format: TextureFormat): boolean;
|
|
132
|
+
/** `true` if device is already lost */
|
|
133
|
+
abstract get isLost(): boolean;
|
|
134
|
+
/** Promise that resolves when device is lost */
|
|
135
|
+
abstract readonly lost: Promise<{
|
|
136
|
+
reason: 'destroyed';
|
|
137
|
+
message: string;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Trigger device loss.
|
|
141
|
+
* @returns `true` if context loss could actually be triggered.
|
|
142
|
+
* @note primarily intended for testing how application reacts to device loss
|
|
143
|
+
*/
|
|
144
|
+
loseDevice(): boolean;
|
|
145
|
+
/** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */
|
|
146
|
+
abstract canvasContext: CanvasContext | null;
|
|
147
|
+
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
148
|
+
getCanvasContext(): CanvasContext;
|
|
149
|
+
/** Creates a new CanvasContext (WebGPU only) */
|
|
150
|
+
abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;
|
|
151
|
+
/** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
|
|
152
|
+
abstract submit(): void;
|
|
153
|
+
/** Create a buffer */
|
|
154
|
+
abstract createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): Buffer;
|
|
155
|
+
/** Create a texture */
|
|
156
|
+
abstract _createTexture(props: TextureProps): Texture;
|
|
157
|
+
createTexture(props: TextureProps): Texture;
|
|
158
|
+
createTexture(data: Promise<TextureData>): Texture;
|
|
159
|
+
createTexture(url: string): Texture;
|
|
160
|
+
/** Create a temporary texture view of a video source */
|
|
161
|
+
abstract createExternalTexture(props: ExternalTextureProps): ExternalTexture;
|
|
162
|
+
/** Create a sampler */
|
|
163
|
+
abstract createSampler(props: SamplerProps): Sampler;
|
|
164
|
+
/** Create a Framebuffer. Must have at least one attachment. */
|
|
165
|
+
abstract createFramebuffer(props: FramebufferProps): Framebuffer;
|
|
166
|
+
/** Create a shader */
|
|
167
|
+
abstract createShader(props: ShaderProps): Shader;
|
|
168
|
+
/** Create a render pipeline (aka program) */
|
|
169
|
+
abstract createRenderPipeline(props: RenderPipelineProps): RenderPipeline;
|
|
170
|
+
/** Create a compute pipeline (aka program). WebGPU only. */
|
|
171
|
+
abstract createComputePipeline(props: ComputePipelineProps): ComputePipeline;
|
|
172
|
+
/** Create a vertex array */
|
|
173
|
+
abstract createVertexArray(props: VertexArrayProps): VertexArray;
|
|
174
|
+
/** Create a RenderPass */
|
|
175
|
+
abstract beginRenderPass(props?: RenderPassProps): RenderPass;
|
|
176
|
+
/** Create a ComputePass */
|
|
177
|
+
abstract beginComputePass(props?: ComputePassProps): ComputePass;
|
|
178
|
+
/** Get a renderpass that is set up to render to the primary CanvasContext */
|
|
179
|
+
abstract getDefaultRenderPass(): RenderPass;
|
|
180
|
+
/** Create a transform feedback (immutable set of output buffer bindings). WebGL 2 only. */
|
|
181
|
+
abstract createTransformFeedback(props: TransformFeedbackProps): TransformFeedback;
|
|
182
|
+
createCommandEncoder(props?: CommandEncoderProps): CommandEncoder;
|
|
183
|
+
/** @deprecated - will be removed - should use command encoder */
|
|
184
|
+
readPixelsToArrayWebGL(source: Framebuffer | Texture, options?: {
|
|
185
|
+
sourceX?: number;
|
|
186
|
+
sourceY?: number;
|
|
187
|
+
sourceFormat?: number;
|
|
188
|
+
sourceAttachment?: number;
|
|
189
|
+
target?: Uint8Array | Uint16Array | Float32Array;
|
|
190
|
+
sourceWidth?: number;
|
|
191
|
+
sourceHeight?: number;
|
|
192
|
+
sourceType?: number;
|
|
193
|
+
}): Uint8Array | Uint16Array | Float32Array;
|
|
194
|
+
/** @deprecated - will be removed - should use command encoder */
|
|
195
|
+
readPixelsToBufferWebGL2(source: Framebuffer | Texture, options?: {
|
|
196
|
+
sourceX?: number;
|
|
197
|
+
sourceY?: number;
|
|
198
|
+
sourceFormat?: number;
|
|
199
|
+
target?: Buffer;
|
|
200
|
+
targetByteOffset?: number;
|
|
201
|
+
sourceWidth?: number;
|
|
202
|
+
sourceHeight?: number;
|
|
203
|
+
sourceType?: number;
|
|
204
|
+
}): Buffer;
|
|
205
|
+
/** @deprecated - will be removed - should use WebGPU parameters (pipeline) */
|
|
206
|
+
setParametersWebGL(parameters: any): void;
|
|
207
|
+
/** @deprecated - will be removed - should use WebGPU parameters (pipeline) */
|
|
208
|
+
withParametersWebGL(parameters: any, func: any): any;
|
|
209
|
+
/** @deprecated - will be removed - should use clear arguments in RenderPass */
|
|
210
|
+
clearWebGL(options?: {
|
|
211
|
+
framebuffer?: Framebuffer;
|
|
212
|
+
color?: any;
|
|
213
|
+
depth?: any;
|
|
214
|
+
stencil?: any;
|
|
215
|
+
}): void;
|
|
216
|
+
protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps;
|
|
217
|
+
}
|
|
218
|
+
export {};
|
|
219
|
+
//# sourceMappingURL=device.d.ts.map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E,mBAAmB,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG;IAIpD,+EAA+E;IAC/E,UAAU,CAAC,OAAO,CAAC,EAAE;QAAC,WAAW,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAC,GAAG,IAAI;IAMhG,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,WAAW;CAqB3F"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
let _Symbol$toStringTag;
|
|
2
|
+
import { VERSION } from "../init.js";
|
|
3
|
+
import { lumaStats } from "../utils/stats-manager.js";
|
|
4
|
+
import { log } from "../utils/log.js";
|
|
5
|
+
import { uid } from "../utils/utils.js";
|
|
6
|
+
import { Buffer } from "./resources/buffer.js";
|
|
7
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
8
|
+
export class Device {
|
|
9
|
+
get [_Symbol$toStringTag]() {
|
|
10
|
+
return 'Device';
|
|
11
|
+
}
|
|
12
|
+
constructor(props) {
|
|
13
|
+
this.id = void 0;
|
|
14
|
+
this.statsManager = lumaStats;
|
|
15
|
+
this.props = void 0;
|
|
16
|
+
this.userData = {};
|
|
17
|
+
this._lumaData = {};
|
|
18
|
+
this.info = void 0;
|
|
19
|
+
this.lost = void 0;
|
|
20
|
+
this.canvasContext = void 0;
|
|
21
|
+
this.props = {
|
|
22
|
+
...Device.defaultProps,
|
|
23
|
+
...props
|
|
24
|
+
};
|
|
25
|
+
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
26
|
+
}
|
|
27
|
+
loseDevice() {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
getCanvasContext() {
|
|
31
|
+
if (!this.canvasContext) {
|
|
32
|
+
throw new Error('Device has no CanvasContext');
|
|
33
|
+
}
|
|
34
|
+
return this.canvasContext;
|
|
35
|
+
}
|
|
36
|
+
createTexture(props) {
|
|
37
|
+
if (props instanceof Promise || typeof props === 'string') {
|
|
38
|
+
props = {
|
|
39
|
+
data: props
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return this._createTexture(props);
|
|
43
|
+
}
|
|
44
|
+
createCommandEncoder() {
|
|
45
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
46
|
+
throw new Error('not implemented');
|
|
47
|
+
}
|
|
48
|
+
readPixelsToArrayWebGL(source, options) {
|
|
49
|
+
throw new Error('not implemented');
|
|
50
|
+
}
|
|
51
|
+
readPixelsToBufferWebGL2(source, options) {
|
|
52
|
+
throw new Error('not implemented');
|
|
53
|
+
}
|
|
54
|
+
setParametersWebGL(parameters) {
|
|
55
|
+
throw new Error('not implemented');
|
|
56
|
+
}
|
|
57
|
+
withParametersWebGL(parameters, func) {
|
|
58
|
+
throw new Error('not implemented');
|
|
59
|
+
}
|
|
60
|
+
clearWebGL(options) {
|
|
61
|
+
throw new Error('not implemented');
|
|
62
|
+
}
|
|
63
|
+
_getBufferProps(props) {
|
|
64
|
+
if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {
|
|
65
|
+
props = {
|
|
66
|
+
data: props
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const newProps = {
|
|
70
|
+
...props
|
|
71
|
+
};
|
|
72
|
+
if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {
|
|
73
|
+
if (props.data instanceof Uint32Array) {
|
|
74
|
+
newProps.indexType = 'uint32';
|
|
75
|
+
} else if (props.data instanceof Uint16Array) {
|
|
76
|
+
newProps.indexType = 'uint16';
|
|
77
|
+
} else {
|
|
78
|
+
log.warn('indices buffer content must be of integer type')();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return newProps;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
Device.defaultProps = {
|
|
85
|
+
id: null,
|
|
86
|
+
type: 'best-available',
|
|
87
|
+
canvas: null,
|
|
88
|
+
container: null,
|
|
89
|
+
webgl2: true,
|
|
90
|
+
webgl1: true,
|
|
91
|
+
manageState: true,
|
|
92
|
+
width: 800,
|
|
93
|
+
height: 600,
|
|
94
|
+
debug: Boolean(log.get('debug')),
|
|
95
|
+
break: [],
|
|
96
|
+
gl: null
|
|
97
|
+
};
|
|
98
|
+
Device.VERSION = VERSION;
|
|
99
|
+
//# sourceMappingURL=device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.js","names":["VERSION","lumaStats","log","uid","Buffer","_Symbol$toStringTag","Symbol","toStringTag","Device","constructor","props","id","statsManager","userData","_lumaData","info","lost","canvasContext","defaultProps","toLowerCase","loseDevice","getCanvasContext","Error","createTexture","Promise","data","_createTexture","createCommandEncoder","arguments","length","undefined","readPixelsToArrayWebGL","source","options","readPixelsToBufferWebGL2","setParametersWebGL","parameters","withParametersWebGL","func","clearWebGL","_getBufferProps","ArrayBuffer","isView","newProps","usage","INDEX","indexType","Uint32Array","Uint16Array","warn","type","canvas","container","webgl2","webgl1","manageState","width","height","debug","Boolean","get","break","gl"],"sources":["../../src/adapter/device.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {VERSION} from '../init';\nimport {StatsManager, lumaStats} from '../utils/stats-manager';\nimport {log} from '../utils/log';\nimport {uid} from '../utils/utils';\nimport type {TextureFormat} from './types/texture-formats';\nimport type {CanvasContext, CanvasContextProps} from './canvas-context';\nimport type {BufferProps} from './resources/buffer';\nimport {Buffer} from './resources/buffer';\nimport type {RenderPipeline, RenderPipelineProps} from './resources/render-pipeline';\nimport type {ComputePipeline, ComputePipelineProps} from './resources/compute-pipeline';\nimport type {Sampler, SamplerProps} from './resources/sampler';\nimport type {Shader, ShaderProps} from './resources/shader';\nimport type {Texture, TextureProps, TextureData} from './resources/texture';\nimport type {ExternalTexture, ExternalTextureProps} from './resources/external-texture';\nimport type {Framebuffer, FramebufferProps} from './resources/framebuffer';\nimport type {RenderPass, RenderPassProps} from './resources/render-pass';\nimport type {ComputePass, ComputePassProps} from './resources/compute-pass';\nimport type {CommandEncoder, CommandEncoderProps} from './resources/command-encoder';\nimport type {VertexArray, VertexArrayProps} from './resources/vertex-array';\nimport type {TransformFeedback, TransformFeedbackProps} from './resources/transform-feedback';\n\n/** Device properties */\nexport type DeviceProps = {\n id?: string;\n\n type?: 'webgl' | 'webgl1' | 'webgl2' | 'webgpu' | 'best-available';\n\n // Common parameters\n canvas?: HTMLCanvasElement | OffscreenCanvas | string | null; // A canvas element or a canvas string id\n container?: HTMLElement | string | null;\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\n // WebGLDevice 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\n // WebGLContext PARAMETERS - Can only be set on context creation...\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 // Unclear if these are still supported\n debug?: boolean; // Instrument context (at the expense of performance)\n manageState?: boolean; // Set to false to disable WebGL state management instrumentation\n break?: string[]; // TODO: types\n\n // @deprecated Attach to existing context\n gl?: WebGLRenderingContext | WebGL2RenderingContext | null;\n};\n\n/**\n * Identifies the GPU vendor and driver.\n * @note Chrome WebGPU does not provide much information, though more can be enabled with\n * @see https://developer.chrome.com/blog/new-in-webgpu-120#adapter_information_updates\n * chrome://flags/#enable-webgpu-developer-features\n */\nexport type DeviceInfo = {\n /** Type of device */\n type: 'webgl' | 'webgl2' | 'webgpu';\n /** Vendor (name of GPU vendor, Apple, nVidia etc */\n vendor: string;\n /** Renderer (usually driver name) */\n renderer: string;\n /** version of driver */\n version: string;\n /** family of GPU */\n gpu: 'nvidia' | 'amd' | 'intel' | 'apple' | 'software' | 'unknown';\n /** Type of GPU () */\n gpuType: 'discrete' | 'integrated' | 'cpu' | 'unknown';\n /** GPU architecture */\n gpuArchitecture?: string; // 'common-3' on Apple\n /** GPU driver backend. Can sometimes be sniffed */\n gpuBackend?: 'opengl' | 'opengles' | 'metal' | 'd3d11' | 'd3d12' | 'vulkan' | 'unknown';\n /** If this is a fallback adapter */\n fallback?: boolean;\n /** Shader language supported by device.createShader() */\n shadingLanguage: 'wgsl' | 'glsl';\n /** Highest supported shader language version (GLSL 3.00 = 300, GLSL 1.00 = 100) */\n shadingLanguageVersion: number;\n};\n\n/** Limits for a device */\nexport type DeviceLimits = {\n readonly maxTextureDimension1D?: number;\n readonly maxTextureDimension2D?: number;\n readonly maxTextureDimension3D?: number;\n readonly maxTextureArrayLayers?: number;\n readonly maxBindGroups: number;\n readonly maxDynamicUniformBuffersPerPipelineLayout: number;\n readonly maxDynamicStorageBuffersPerPipelineLayout: number;\n readonly maxSampledTexturesPerShaderStage: number;\n readonly maxSamplersPerShaderStage: number;\n readonly maxStorageBuffersPerShaderStage: number;\n readonly maxStorageTexturesPerShaderStage: number;\n readonly maxUniformBuffersPerShaderStage: number;\n readonly maxUniformBufferBindingSize: number;\n readonly maxStorageBufferBindingSize?: number;\n readonly minUniformBufferOffsetAlignment?: number;\n readonly minStorageBufferOffsetAlignment?: number;\n readonly maxVertexBuffers?: number;\n readonly maxVertexAttributes: number;\n readonly maxVertexBufferArrayStride?: number;\n readonly maxInterStageShaderComponents?: number;\n readonly maxComputeWorkgroupStorageSize?: number;\n readonly maxComputeInvocationsPerWorkgroup?: number;\n readonly maxComputeWorkgroupSizeX?: number;\n readonly maxComputeWorkgroupSizeY?: number;\n readonly maxComputeWorkgroupSizeZ?: number;\n readonly maxComputeWorkgroupsPerDimension?: number;\n};\n\nexport type WebGPUDeviceFeature =\n | 'depth-clip-control'\n | 'depth24unorm-stencil8'\n | 'depth32float-stencil8'\n | 'timestamp-query'\n | 'indirect-first-instance'\n | 'texture-compression-bc'\n | 'texture-compression-etc2'\n | 'texture-compression-astc';\n\n// obsolete...\n// 'depth-clamping' |\n// 'depth24unorm-stencil8' |\n// 'depth32float-stencil8' |\n// 'pipeline-statistics-query' |\n// 'timestamp-query' |\n// 'texture-compression-bc'\n\nexport type WebGLDeviceFeature =\n | 'webgpu'\n | 'webgl2'\n | 'webgl'\n\n // api support (unify with WebGPU timestamp-query?)\n | 'timer-query-webgl'\n | 'uniform-buffers-webgl'\n | 'uniforms-webgl'\n\n // texture filtering\n | 'texture-filter-linear-float32-webgl'\n | 'texture-filter-linear-float16-webgl'\n | 'texture-filter-anisotropic-webgl'\n\n // texture rendering\n | 'texture-renderable-float32-webgl'\n | 'texture-renderable-float16-webgl'\n | 'texture-renderable-rgba32float-webgl' // TODO - remove\n\n // texture blending\n | 'texture-blend-float-webgl1'\n\n // texture format support\n | 'texture-formats-norm16-webgl'\n | 'texture-formats-srgb-webgl1'\n | 'texture-formats-depth-webgl1'\n | 'texture-formats-float32-webgl1'\n | 'texture-formats-float16-webgl1'\n\n // api support\n | 'vertex-array-object-webgl1'\n | 'instanced-rendering-webgl1'\n | 'multiple-render-targets-webgl1'\n | 'index-uint32-webgl1'\n | 'blend-minmax-webgl1'\n | 'transform-feedback-webgl2'\n\n // glsl extensions\n | 'glsl-frag-data'\n | 'glsl-frag-depth'\n | 'glsl-derivatives'\n | 'glsl-texture-lod';\n\ntype WebGLCompressedTextureFeatures =\n | 'texture-compression-bc5-webgl'\n | 'texture-compression-etc1-webgl'\n | 'texture-compression-pvrtc-webgl'\n | 'texture-compression-atc-webgl';\n\n/** Valid feature strings */\nexport type DeviceFeature =\n | WebGPUDeviceFeature\n | WebGLDeviceFeature\n | WebGLCompressedTextureFeatures;\n\n/**\n * WebGPU Device/WebGL context abstraction\n */\nexport abstract class Device {\n\n static defaultProps: Required<DeviceProps> = {\n id: null!,\n type: 'best-available',\n canvas: null,\n container: null,\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: Boolean(log.get('debug')), // Instrument context (at the expense of performance)\n break: [],\n \n // alpha: undefined,\n // depth: undefined,\n // stencil: undefined,\n // antialias: undefined,\n // premultipliedAlpha: undefined,\n // preserveDrawingBuffer: undefined,\n // failIfMajorPerformanceCaveat: undefined\n \n gl: null\n };\n \n\n get [Symbol.toStringTag](): string {\n return 'Device';\n }\n\n static VERSION = VERSION;\n\n constructor(props: DeviceProps) {\n this.props = {...Device.defaultProps, ...props};\n this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());\n }\n\n /** id of this device, primarily for debugging */\n readonly id: string;\n /** stats */\n readonly statsManager: StatsManager = lumaStats;\n /** A copy of the device props */\n readonly props: Required<DeviceProps>;\n /** Available for the application to store data on the device */\n userData: {[key: string]: unknown} = {};\n /** Used by other luma.gl modules to store data on the device */\n _lumaData: {[key: string]: unknown} = {};\n\n abstract destroy(): void;\n\n // Capabilities\n\n /** Information about the device (vendor, versions etc) */\n abstract info: DeviceInfo;\n\n /** Optional capability discovery */\n abstract get features(): Set<DeviceFeature>;\n\n /** WebGPU style device limits */\n abstract get limits(): DeviceLimits;\n\n /** Check if device supports a specific texture format (creation and `nearest` sampling) */\n abstract isTextureFormatSupported(format: TextureFormat): boolean;\n\n /** Check if linear filtering (sampler interpolation) is supported for a specific texture format */\n abstract isTextureFormatFilterable(format: TextureFormat): boolean;\n\n /** Check if device supports rendering to a specific texture format */\n abstract isTextureFormatRenderable(format: TextureFormat): boolean;\n\n // Device loss\n\n /** `true` if device is already lost */\n abstract get isLost(): boolean;\n\n /** Promise that resolves when device is lost */\n abstract readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n /**\n * Trigger device loss.\n * @returns `true` if context loss could actually be triggered.\n * @note primarily intended for testing how application reacts to device loss\n */\n loseDevice(): boolean {\n return false;\n }\n\n // Canvas context\n\n /** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */\n abstract canvasContext: CanvasContext | null;\n\n /** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */\n getCanvasContext(): CanvasContext {\n if (!this.canvasContext) {\n throw new Error('Device has no CanvasContext');\n }\n return this.canvasContext;\n }\n\n /** Creates a new CanvasContext (WebGPU only) */\n abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;\n\n /** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */\n abstract submit(): void;\n\n // Resource creation\n\n /** Create a buffer */\n abstract createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): Buffer;\n\n /** Create a texture */\n abstract _createTexture(props: TextureProps): Texture;\n createTexture(props: TextureProps): Texture;\n createTexture(data: Promise<TextureData>): Texture;\n createTexture(url: string): Texture;\n\n createTexture(props: TextureProps | Promise<TextureData> | string): Texture {\n // Signature: new Texture2D(gl, url | Promise)\n if (props instanceof Promise || typeof props === 'string') {\n props = {data: props};\n }\n return this._createTexture(props);\n }\n\n /** Create a temporary texture view of a video source */\n abstract createExternalTexture(props: ExternalTextureProps): ExternalTexture;\n\n /** Create a sampler */\n abstract createSampler(props: SamplerProps): Sampler;\n\n /** Create a Framebuffer. Must have at least one attachment. */\n abstract createFramebuffer(props: FramebufferProps): Framebuffer;\n\n /** Create a shader */\n abstract createShader(props: ShaderProps): Shader;\n\n /** Create a render pipeline (aka program) */\n abstract createRenderPipeline(props: RenderPipelineProps): RenderPipeline;\n\n /** Create a compute pipeline (aka program). WebGPU only. */\n abstract createComputePipeline(props: ComputePipelineProps): ComputePipeline;\n\n /** Create a vertex array */\n abstract createVertexArray(props: VertexArrayProps): VertexArray;\n\n /** Create a RenderPass */\n abstract beginRenderPass(props?: RenderPassProps): RenderPass;\n\n /** Create a ComputePass */\n abstract beginComputePass(props?: ComputePassProps): ComputePass;\n\n /** Get a renderpass that is set up to render to the primary CanvasContext */\n abstract getDefaultRenderPass(): RenderPass;\n\n /** Create a transform feedback (immutable set of output buffer bindings). WebGL 2 only. */\n abstract createTransformFeedback(props: TransformFeedbackProps): TransformFeedback;\n\n createCommandEncoder(props: CommandEncoderProps = {}): CommandEncoder {\n throw new Error('not implemented');\n }\n\n // WebGL specific HACKS - enables app to remove webgl import\n // Use until we have a better way to handle these\n\n /** @deprecated - will be removed - should use command encoder */\n readPixelsToArrayWebGL(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n sourceAttachment?: number;\n target?: Uint8Array | Uint16Array | Float32Array;\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Uint8Array | Uint16Array | Float32Array {\n throw new Error('not implemented');\n }\n \n /** @deprecated - will be removed - should use command encoder */\n readPixelsToBufferWebGL2(\n source: Framebuffer | Texture,\n options?: {\n sourceX?: number;\n sourceY?: number;\n sourceFormat?: number;\n target?: Buffer; // A new Buffer object is created when not provided.\n targetByteOffset?: number; // byte offset in buffer object\n // following parameters are auto deduced if not provided\n sourceWidth?: number;\n sourceHeight?: number;\n sourceType?: number;\n }\n ): Buffer {\n throw new Error('not implemented');\n }\n\n /** @deprecated - will be removed - should use WebGPU parameters (pipeline) */\n setParametersWebGL(parameters: any): void {\n throw new Error('not implemented');\n }\n\n /** @deprecated - will be removed - should use WebGPU parameters (pipeline) */\n withParametersWebGL(parameters: any, func: any): any {\n throw new Error('not implemented');\n }\n\n /** @deprecated - will be removed - should use clear arguments in RenderPass */\n clearWebGL(options?: {framebuffer?: Framebuffer; color?: any; depth?: any; stencil?: any}): void {\n throw new Error('not implemented');\n }\n\n // Implementation\n\n protected _getBufferProps(props: BufferProps | ArrayBuffer | ArrayBufferView): BufferProps {\n if (props instanceof ArrayBuffer || ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // TODO - fragile, as this is done before we merge with default options\n // inside the Buffer constructor\n\n const newProps = {...props};\n // Deduce indexType\n if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {\n if (props.data instanceof Uint32Array) {\n newProps.indexType = 'uint32';\n } else if (props.data instanceof Uint16Array) {\n newProps.indexType = 'uint16';\n } else {\n log.warn('indices buffer content must be of integer type')();\n }\n }\n return newProps;\n }\n}\n"],"mappings":";SACQA,OAAO;AAAA,SACOC,SAAS;AAAA,SACvBC,GAAG;AAAA,SACHC,GAAG;AAAA,SAIHC,MAAM;AAAAC,mBAAA,GAqNPC,MAAM,CAACC,WAAW;AA3BzB,OAAO,MAAeC,MAAM,CAAC;EA2B3B,KAAAH,mBAAA,IAAmC;IACjC,OAAO,QAAQ;EACjB;EAIAI,WAAWA,CAACC,KAAkB,EAAE;IAAA,KAMvBC,EAAE;IAAA,KAEFC,YAAY,GAAiBX,SAAS;IAAA,KAEtCS,KAAK;IAAA,KAEdG,QAAQ,GAA6B,CAAC,CAAC;IAAA,KAEvCC,SAAS,GAA6B,CAAC,CAAC;IAAA,KAO/BC,IAAI;IAAA,KAuBKC,IAAI;IAAA,KAcbC,aAAa;IAzDpB,IAAI,CAACP,KAAK,GAAG;MAAC,GAAGF,MAAM,CAACU,YAAY;MAAE,GAAGR;IAAK,CAAC;IAC/C,IAAI,CAACC,EAAE,GAAG,IAAI,CAACD,KAAK,CAACC,EAAE,IAAIR,GAAG,CAAC,IAAI,CAACG,MAAM,CAACC,WAAW,CAAC,CAACY,WAAW,CAAC,CAAC,CAAC;EACxE;EAgDAC,UAAUA,CAAA,EAAY;IACpB,OAAO,KAAK;EACd;EAQAC,gBAAgBA,CAAA,EAAkB;IAChC,IAAI,CAAC,IAAI,CAACJ,aAAa,EAAE;MACvB,MAAM,IAAIK,KAAK,CAAC,6BAA6B,CAAC;IAChD;IACA,OAA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IAAI,CAACnC,KAAK,CAACoC,SAAS,EAAE;MACzD,IAAIpC,KAAK,CAACe,IAAI,YAAYsB,WAAW,EAAE;QACrCJ,QAAQ,CAACG,SAAS,GAAG,QAAQ;MAC/B,CAAC,MAAM,IAAIpC,KAAK,CAACe,IAAI,YAAYuB,WAAW,EAAE;QAC5CL,QAAQ,CAACG,SAAS,GAAG,QAAQ;MAC/B,CAAC,MAAM;QACL5C,GAAG,CAAC+C,IAAI,CAAC,gDAAgD,CAAC,CAAC,CAAC;MAC9D;IACF;IACA,OAAON,QAAQ;EACjB;AACF;AAhPsBnC,MAAM,CAEnBU,YAAY,GAA0B;EAC3CP,EAAE,EAAE,IAAK;EACTuC,IAAI,EAAE,gBAAgB;EACtBC,MAAM,EAAE,IAAI;EACZC,SAAS,EAAE,IAAI;EACfC,MAAM,EAAE,IAAI;EACZC,MAAM,EAAE,IAAI;EACZC,WAAW,EAAE,IAAI;EACjBC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,GAAG;EACXC,KAAK,EAAEC,OAAO,CAACzD,GAAG,CAAC0D,GAAG,CAAC,OAAO,CAAC,CAAC;EAChCC,KAAK,EAAE,EAAE;EAUTC,EAAE,EAAE;AACN,CAAC;AAxBmBtD,MAAM,CA+BnBR,OAAO,GAAGA,OAAO"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Device } from '../device';
|
|
2
|
+
import { Resource, ResourceProps } from './resource';
|
|
3
|
+
export type BufferProps = ResourceProps & {
|
|
4
|
+
/** Supply a handle to connect to an existing device-specific buffer */
|
|
5
|
+
handle?: WebGLBuffer;
|
|
6
|
+
/** Specifies how this buffer can be used */
|
|
7
|
+
usage?: number;
|
|
8
|
+
/** Length in bytes of memory to be allocated. If not specified, `byteLength` of `props.data` will be used. */
|
|
9
|
+
byteLength?: number;
|
|
10
|
+
/** Data to initialize the buffer with. */
|
|
11
|
+
data?: ArrayBuffer | ArrayBufferView | null;
|
|
12
|
+
/** Byte offset into the newly created Buffer to store data at */
|
|
13
|
+
byteOffset?: number;
|
|
14
|
+
/** If props.usage includes Buffer.INDEX */
|
|
15
|
+
indexType?: 'uint16' | 'uint32';
|
|
16
|
+
mappedAtCreation?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Abstract GPU buffer */
|
|
19
|
+
export declare abstract class Buffer extends Resource<BufferProps> {
|
|
20
|
+
static defaultProps: Required<BufferProps>;
|
|
21
|
+
static MAP_READ: number;
|
|
22
|
+
static MAP_WRITE: number;
|
|
23
|
+
static COPY_SRC: number;
|
|
24
|
+
static COPY_DST: number;
|
|
25
|
+
/** Index buffer */
|
|
26
|
+
static INDEX: number;
|
|
27
|
+
/** Vertex buffer */
|
|
28
|
+
static VERTEX: number;
|
|
29
|
+
/** Uniform buffer */
|
|
30
|
+
static UNIFORM: number;
|
|
31
|
+
/** Storage buffer */
|
|
32
|
+
static STORAGE: number;
|
|
33
|
+
static INDIRECT: number;
|
|
34
|
+
static QUERY_RESOLVE: number;
|
|
35
|
+
get [Symbol.toStringTag](): string;
|
|
36
|
+
/** The usage with which this buffer was created */
|
|
37
|
+
readonly usage: number;
|
|
38
|
+
/** For index buffers, whether indices are 16 or 32 bit */
|
|
39
|
+
readonly indexType?: 'uint16' | 'uint32';
|
|
40
|
+
/** Length of buffer in bytes */
|
|
41
|
+
abstract byteLength: number;
|
|
42
|
+
constructor(device: Device, props: BufferProps);
|
|
43
|
+
/** Write data to buffer */
|
|
44
|
+
abstract write(data: ArrayBufferView, byteOffset?: number): void;
|
|
45
|
+
/** Read data asynchronoursly */
|
|
46
|
+
abstract readAsync(byteOffset?: number, byteLength?: number): Promise<Uint8Array>;
|
|
47
|
+
/** Read data synchronously. @note WebGL2 only */
|
|
48
|
+
readSyncWebGL2(byteOffset?: number, byteLength?: number): Uint8Array;
|
|
49
|
+
/** Max amount of debug data saved. Two vec4's */
|
|
50
|
+
static DEBUG_DATA_MAX_LENGTH: number;
|
|
51
|
+
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
52
|
+
debugData: ArrayBuffer;
|
|
53
|
+
/** This doesn't handle partial non-zero offset updates correctly */
|
|
54
|
+
protected _setDebugData(data: ArrayBufferView | ArrayBuffer | null, byteOffset: number, byteLength: number): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG;IACxC,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+GAA+G;IAC/G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAAC;IAC5C,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAGhC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAA;AAED,0BAA0B;AAC1B,8BAAsB,MAAO,SAAQ,QAAQ,CAAC,WAAW,CAAC;IACxD,OAAgB,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,CAQjD;IAGF,MAAM,CAAC,QAAQ,SAAQ;IACvB,MAAM,CAAC,SAAS,SAAQ;IACxB,MAAM,CAAC,QAAQ,SAAU;IACzB,MAAM,CAAC,QAAQ,SAAU;IACzB,mBAAmB;IACnB,MAAM,CAAC,KAAK,SAAU;IACtB,oBAAoB;IACpB,MAAM,CAAC,MAAM,SAAU;IACvB,qBAAqB;IACrB,MAAM,CAAC,OAAO,SAAU;IACxB,qBAAqB;IACrB,MAAM,CAAC,OAAO,SAAU;IACxB,MAAM,CAAC,QAAQ,SAAU;IACzB,MAAM,CAAC,aAAa,SAAU;IAE9B,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAqB;IAEhE,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACzC,gCAAgC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAkB9C,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAChE,gCAAgC;IAChC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAEjF,iDAAiD;IACjD,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU;IAIpE,iDAAiD;IACjD,MAAM,CAAC,qBAAqB,SAAM;IAClC,iFAAiF;IACjF,SAAS,EAAE,WAAW,CAAsB;IAE5C,oEAAoE;IACpE,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;CAWlH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
let _Symbol$toStringTag;
|
|
2
|
+
import { Resource } from "./resource.js";
|
|
3
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4
|
+
export class Buffer extends Resource {
|
|
5
|
+
get [_Symbol$toStringTag]() {
|
|
6
|
+
return 'Buffer';
|
|
7
|
+
}
|
|
8
|
+
constructor(device, props) {
|
|
9
|
+
const deducedProps = {
|
|
10
|
+
...props
|
|
11
|
+
};
|
|
12
|
+
if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {
|
|
13
|
+
if (props.data instanceof Uint32Array) {
|
|
14
|
+
deducedProps.indexType = 'uint32';
|
|
15
|
+
} else if (props.data instanceof Uint16Array) {
|
|
16
|
+
deducedProps.indexType = 'uint16';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
super(device, deducedProps, Buffer.defaultProps);
|
|
20
|
+
this.usage = void 0;
|
|
21
|
+
this.indexType = void 0;
|
|
22
|
+
this.byteLength = void 0;
|
|
23
|
+
this.debugData = new ArrayBuffer(0);
|
|
24
|
+
this.usage = props.usage || 0;
|
|
25
|
+
this.indexType = deducedProps.indexType;
|
|
26
|
+
}
|
|
27
|
+
readSyncWebGL2(byteOffset, byteLength) {
|
|
28
|
+
throw new Error('not implemented');
|
|
29
|
+
}
|
|
30
|
+
_setDebugData(data, byteOffset, byteLength) {
|
|
31
|
+
const buffer = ArrayBuffer.isView(data) ? data.buffer : data;
|
|
32
|
+
const debugDataLength = Math.min(data ? data.byteLength : byteLength, Buffer.DEBUG_DATA_MAX_LENGTH);
|
|
33
|
+
if (data === null) {
|
|
34
|
+
this.debugData = new ArrayBuffer(debugDataLength);
|
|
35
|
+
} else if (byteOffset === 0 && byteLength === data.byteLength) {
|
|
36
|
+
this.debugData = buffer.slice(0, debugDataLength);
|
|
37
|
+
} else {
|
|
38
|
+
this.debugData = buffer.slice(byteOffset, byteOffset + debugDataLength);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
Buffer.defaultProps = {
|
|
43
|
+
...Resource.defaultProps,
|
|
44
|
+
usage: 0,
|
|
45
|
+
byteLength: 0,
|
|
46
|
+
byteOffset: 0,
|
|
47
|
+
data: null,
|
|
48
|
+
indexType: 'uint16',
|
|
49
|
+
mappedAtCreation: false
|
|
50
|
+
};
|
|
51
|
+
Buffer.MAP_READ = 0x01;
|
|
52
|
+
Buffer.MAP_WRITE = 0x02;
|
|
53
|
+
Buffer.COPY_SRC = 0x0004;
|
|
54
|
+
Buffer.COPY_DST = 0x0008;
|
|
55
|
+
Buffer.INDEX = 0x0010;
|
|
56
|
+
Buffer.VERTEX = 0x0020;
|
|
57
|
+
Buffer.UNIFORM = 0x0040;
|
|
58
|
+
Buffer.STORAGE = 0x0080;
|
|
59
|
+
Buffer.INDIRECT = 0x0100;
|
|
60
|
+
Buffer.QUERY_RESOLVE = 0x0200;
|
|
61
|
+
Buffer.DEBUG_DATA_MAX_LENGTH = 32;
|
|
62
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","Buffer","constructor","device","props","deducedProps","usage","INDEX","indexType","data","Uint32Array","Uint16Array","defaultProps","byteLength","debugData","ArrayBuffer","readSyncWebGL2","byteOffset","Error","_setDebugData","buffer","isView","debugDataLength","Math","min","DEBUG_DATA_MAX_LENGTH","slice","mappedAtCreation","MAP_READ","MAP_WRITE","COPY_SRC","COPY_DST","VERTEX","UNIFORM","STORAGE","INDIRECT","QUERY_RESOLVE"],"sources":["../../../src/adapter/resources/buffer.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {Device} from '../device';\nimport {Resource, ResourceProps} from './resource';\n\nexport type BufferProps = ResourceProps & {\n /** Supply a handle to connect to an existing device-specific buffer */\n handle?: WebGLBuffer;\n /** Specifies how this buffer can be used */\n usage?: number;\n /** Length in bytes of memory to be allocated. If not specified, `byteLength` of `props.data` will be used. */\n byteLength?: number;\n /** Data to initialize the buffer with. */\n data?: ArrayBuffer | ArrayBufferView | null;\n /** Byte offset into the newly created Buffer to store data at */\n byteOffset?: number;\n /** If props.usage includes Buffer.INDEX */\n indexType?: 'uint16' | 'uint32';\n\n // TBD\n mappedAtCreation?: boolean;\n}\n\n/** Abstract GPU buffer */\nexport abstract class Buffer extends Resource<BufferProps> {\n static override defaultProps: Required<BufferProps> = {\n ...Resource.defaultProps,\n usage: 0, // Buffer.COPY_DST | Buffer.COPY_SRC\n byteLength: 0,\n byteOffset: 0,\n data: null,\n indexType: 'uint16',\n mappedAtCreation: false\n };\n\n // Usage Flags\n static MAP_READ = 0x01;\n static MAP_WRITE = 0x02;\n static COPY_SRC = 0x0004;\n static COPY_DST = 0x0008;\n /** Index buffer */\n static INDEX = 0x0010;\n /** Vertex buffer */\n static VERTEX = 0x0020;\n /** Uniform buffer */\n static UNIFORM = 0x0040;\n /** Storage buffer */\n static STORAGE = 0x0080;\n static INDIRECT = 0x0100;\n static QUERY_RESOLVE = 0x0200;\n\n override get [Symbol.toStringTag](): string { return 'Buffer'; }\n\n /** The usage with which this buffer was created */\n readonly usage: number;\n /** For index buffers, whether indices are 16 or 32 bit */\n readonly indexType?: 'uint16' | 'uint32';\n /** Length of buffer in bytes */\n abstract byteLength: number;\n\n constructor(device: Device, props: BufferProps) {\n const deducedProps = {...props};\n\n // Deduce indexType\n if ((props.usage || 0) & Buffer.INDEX && !props.indexType) {\n if (props.data instanceof Uint32Array) {\n deducedProps.indexType = 'uint32';\n } else if (props.data instanceof Uint16Array) {\n deducedProps.indexType = 'uint16';\n }\n }\n\n super(device, deducedProps, Buffer.defaultProps);\n\n this.usage = props.usage || 0;\n this.indexType = deducedProps.indexType;\n }\n\n /** Write data to buffer */\n abstract write(data: ArrayBufferView, byteOffset?: number): void;\n /** Read data asynchronoursly */\n abstract readAsync(byteOffset?: number, byteLength?: number): Promise<Uint8Array>;\n\n /** Read data synchronously. @note WebGL2 only */\n readSyncWebGL2(byteOffset?: number, byteLength?: number): Uint8Array { throw new Error('not implemented'); }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n /** Max amount of debug data saved. Two vec4's */\n static DEBUG_DATA_MAX_LENGTH = 32;\n /** A partial CPU-side copy of the data in this buffer, for debugging purposes */\n debugData: ArrayBuffer = new ArrayBuffer(0);\n\n /** This doesn't handle partial non-zero offset updates correctly */\n protected _setDebugData(data: ArrayBufferView | ArrayBuffer | null, byteOffset: number, byteLength: number): void {\n const buffer: ArrayBuffer | null = ArrayBuffer.isView(data) ? data.buffer : data;\n const debugDataLength = Math.min(data ? data.byteLength : byteLength, Buffer.DEBUG_DATA_MAX_LENGTH);\n if (data === null) {\n this.debugData = new ArrayBuffer(debugDataLength);\n } else if (byteOffset === 0 && byteLength === data.byteLength) {\n this.debugData = buffer.slice(0, debugDataLength);\n } else {\n this.debugData = buffer.slice(byteOffset, byteOffset + debugDataLength);\n }\n }\n}\n"],"mappings":";SAGQA,QAAQ;AAAAC,mBAAA,GAgDAC,MAAM,CAACC,WAAW;AA3BlC,OAAO,MAAeC,MAAM,SAASJ,QAAQ,CAAc;EA2BzD,KAAAC,mBAAA,IAA4C;IAAE,OAAO,QAAQ;EAAE;EAS/DI,WAAWA,CAACC,MAAc,EAAEC,KAAkB,EAAE;IAC9C,MAAMC,YAAY,GAAG;MAAC,GAAGD;IAAK,CAAC;IAG/B,IAAI,CAACA,KAAK,CAACE,KAAK,IAAI,CAAC,IAAIL,MAAM,CAACM,KAAK,IAAI,CAACH,KAAK,CAACI,SAAS,EAAE;MACzD,IAAIJ,KAAK,CAACK,IAAI,YAAYC,WAAW,EAAE;QACrCL,YAAY,CAACG,SAAS,GAAG,QAAQ;MACnC,CAAC,MAAM,IAAIJ,KAAK,CAACK,IAAI,YAAYE,WAAW,EAAE;QAC5CN,YAAY,CAACG,SAAS,GAAG,QAAQ;MACnC;IACF;IAEA,KAAK,CAACL,MAAM,EAAEE,YAAY,EAAEJ,MAAM,CAACW,YAAY,CAAC;IAAC,KAlB1CN,KAAK;IAAA,KAELE,SAAS;IAAA,KAETK,UAAU;IAAA,KAiCnBC,SAAS,GAAgB,IAAIC,WAAW,CAAC,CAAC,CAAC;IAjBzC,IAAI,CAACT,KAAK,GAAGF,KA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AG,MAAM;AAdJ7B,MAAM,CAenB8B,QAAQ,GAAG,MAAM;AAfJ9B,MAAM,CAiBnBM,KAAK,GAAG,MAAM;AAjBDN,MAAM,CAmBnB+B,MAAM,GAAG,MAAM;AAnBF/B,MAAM,CAqBnBgC,OAAO,GAAG,MAAM;AArBHhC,MAAM,CAuBnBiC,OAAO,GAAG,MAAM;AAvBHjC,MAAM,CAwBnBkC,QAAQ,GAAG,MAAM;AAxBJlC,MAAM,CAyBnBmC,aAAa,GAAG,MAAM;AAzBTnC,MAAM,CAiEnBwB,qBAAqB,GAAG,EAAE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Device } from '../device';
|
|
2
|
+
import { Resource, ResourceProps } from './resource';
|
|
3
|
+
export type CommandBufferProps = ResourceProps & {};
|
|
4
|
+
/**
|
|
5
|
+
* Encodes commands to queue that can be executed later
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class CommandBuffer extends Resource<CommandBufferProps> {
|
|
8
|
+
static defaultProps: Required<CommandBufferProps>;
|
|
9
|
+
get [Symbol.toStringTag](): string;
|
|
10
|
+
constructor(device: Device, props: CommandBufferProps);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=command-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/command-buffer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAiBnD,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,EAChD,CAAC;AAEF;;GAEG;AACH,8BAAsB,aAAc,SAAQ,QAAQ,CAAC,kBAAkB,CAAC;IACtE,OAAgB,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAExD;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;gBAEW,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB;CAGtD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
let _Symbol$toStringTag;
|
|
2
|
+
import { Resource } from "./resource.js";
|
|
3
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4
|
+
export class CommandBuffer extends Resource {
|
|
5
|
+
get [_Symbol$toStringTag]() {
|
|
6
|
+
return 'CommandBuffer';
|
|
7
|
+
}
|
|
8
|
+
constructor(device, props) {
|
|
9
|
+
super(device, props, CommandBuffer.defaultProps);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
CommandBuffer.defaultProps = {
|
|
13
|
+
...Resource.defaultProps
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=command-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-buffer.js","names":["Resource","_Symbol$toStringTag","Symbol","toStringTag","CommandBuffer","constructor","device","props","defaultProps"],"sources":["../../../src/adapter/resources/command-buffer.ts"],"sourcesContent":["// luma.gl, MIT license\nimport { Device } from '../device';\nimport {Resource, ResourceProps} from './resource';\n\n// interface Queue {\n// submit(commandBuffers);\n\n// // onSubmittedWorkDone(): Promise<undefined>;\n\n// writeBuffer(options: WriteBufferOptions): void;\n// writeTexture(options: WriteTextureOptions): void;\n\n// // copyExternalImageToTexture(\n// // GPUImageCopyExternalImage source,\n// // GPUImageCopyTextureTagged destination,\n// // GPUExtent3D copySize\n// // ): void;\n// }\n\nexport type CommandBufferProps = ResourceProps & {\n};\n\n/**\n * Encodes commands to queue that can be executed later\n */\nexport abstract class CommandBuffer extends Resource<CommandBufferProps> {\n static override defaultProps: Required<CommandBufferProps> = {\n ...Resource.defaultProps\n };\n \n override get [Symbol.toStringTag](): string {\n return 'CommandBuffer';\n }\n\n constructor(device: Device, props: CommandBufferProps) {\n super(device, props, CommandBuffer.defaultProps);\n }\n}\n"],"mappings":";SAEQA,QAAQ;AAAAC,mBAAA,GA4BAC,MAAM,CAACC,WAAW;AALlC,OAAO,MAAeC,aAAa,SAASJ,QAAQ,CAAqB;EAKvE,KAAAC,mBAAA,IAA4C;IAC1C,OAAO,eAAe;EACxB;EAEAI,WAAWA,CAACC,MAAc,EAAEC,KAAyB,EAAE;IACrD,KAAK,CAACD,MAAM,EAAEC,KAAK,EAAEH,aAAa,CAACI,YAAY,CAAC;EAClD;AACF;AAZsBJ,aAAa,CACjBI,YAAY,GAAiC;EAC3D,GAAGR,QAAQ,CAACQ;AACd,CAAC"}
|