@luma.gl/webgl 8.6.0-alpha.5 → 9.0.0-alpha.11
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/README.md +3 -67
- package/dist/adapter/converters/device-parameters.d.ts +27 -0
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -0
- package/dist/adapter/converters/{set-device-parameters.js → device-parameters.js} +50 -6
- package/dist/adapter/converters/device-parameters.js.map +1 -0
- package/dist/{classes → adapter/converters}/renderbuffer-formats.d.ts +0 -0
- package/dist/adapter/converters/renderbuffer-formats.d.ts.map +1 -0
- package/dist/{classes → adapter/converters}/renderbuffer-formats.js +1 -1
- package/dist/adapter/converters/renderbuffer-formats.js.map +1 -0
- package/dist/adapter/converters/sampler-parameters.d.ts +19 -0
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -0
- package/dist/adapter/converters/sampler-parameters.js +227 -0
- package/dist/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +93 -0
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -0
- package/dist/adapter/converters/texture-formats.js +954 -0
- package/dist/adapter/converters/texture-formats.js.map +1 -0
- package/dist/adapter/converters/vertex-formats.d.ts +4 -0
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -0
- package/dist/adapter/converters/vertex-formats.js +35 -0
- package/dist/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/adapter/device-helpers/device-features.d.ts +3 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +39 -50
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +1 -0
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +1 -0
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +7 -7
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.d.ts +11 -0
- package/dist/adapter/helpers/attribute-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/attribute-utils.js +81 -0
- package/dist/adapter/helpers/attribute-utils.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +55 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.js +330 -0
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/{webgl-utils → adapter/helpers}/parse-shader-compiler-log.d.ts +0 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → adapter/helpers}/parse-shader-compiler-log.js +0 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/adapter/helpers/set-uniform.d.ts +4 -0
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -0
- package/dist/adapter/helpers/set-uniform.js +115 -0
- package/dist/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/adapter/helpers/uniforms.d.ts +26 -0
- package/dist/adapter/helpers/uniforms.d.ts.map +1 -0
- package/dist/adapter/helpers/uniforms.js +99 -0
- package/dist/adapter/helpers/uniforms.js.map +1 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +5 -0
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → adapter/objects}/constants-to-keys.js +1 -0
- package/dist/adapter/objects/constants-to-keys.js.map +1 -0
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +40 -0
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -0
- package/dist/{esm/classes/renderbuffer.js → adapter/objects/webgl-renderbuffer.js} +38 -72
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -0
- package/dist/{classes → adapter/objects}/webgl-resource.d.ts +15 -14
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -0
- package/dist/{classes → adapter/objects}/webgl-resource.js +7 -3
- package/dist/adapter/objects/webgl-resource.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +27 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.js +84 -0
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -0
- package/dist/adapter/resources/webgl-buffer.d.ts +27 -0
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-buffer.js +164 -0
- package/dist/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts +25 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.js +65 -0
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts +18 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.js +53 -0
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.d.ts +1 -0
- package/dist/adapter/resources/webgl-external-texture.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.js +2 -0
- package/dist/{es5/helpers/program-bindings.js.map → adapter/resources/webgl-external-texture.js.map} +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +41 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.js +267 -0
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +11 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.js +21 -0
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +55 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.js +428 -0
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-sampler.d.ts +20 -0
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-sampler.js +50 -0
- package/dist/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/adapter/{webgl-shader.d.ts → resources/webgl-shader.d.ts} +3 -6
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -0
- package/dist/{esm/adapter → adapter/resources}/webgl-shader.js +17 -23
- package/dist/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +193 -0
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -0
- package/dist/{classes/texture.js → adapter/resources/webgl-texture.js} +280 -232
- package/dist/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +36 -0
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -0
- package/dist/adapter/webgl-canvas-context.js +52 -0
- package/dist/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/adapter/webgl-device.d.ts +77 -83
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +253 -115
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +32 -0
- package/dist/classic/accessor.d.ts.map +1 -0
- package/dist/{classes → classic}/accessor.js +33 -1
- package/dist/classic/accessor.js.map +1 -0
- package/dist/{classes/webgl-buffer.d.ts → classic/buffer.d.ts} +28 -33
- package/dist/classic/buffer.d.ts.map +1 -0
- package/dist/{classes/webgl-buffer.js → classic/buffer.js} +67 -57
- package/dist/classic/buffer.js.map +1 -0
- package/dist/{webgl-utils → classic}/typed-array-utils.d.ts +3 -2
- package/dist/classic/typed-array-utils.d.ts.map +1 -0
- package/dist/{esm/webgl-utils → classic}/typed-array-utils.js +0 -0
- package/dist/classic/typed-array-utils.js.map +1 -0
- package/dist/context/context/context-state.d.ts +0 -5
- package/dist/context/context/context-state.d.ts.map +1 -1
- package/dist/context/context/context-state.js +1 -6
- package/dist/context/context/context-state.js.map +1 -1
- package/dist/context/context/{create-context.d.ts → create-browser-context.d.ts} +2 -1
- package/dist/context/context/create-browser-context.d.ts.map +1 -0
- package/dist/{esm/context/context/create-context.js → context/context/create-browser-context.js} +27 -3
- package/dist/context/context/create-browser-context.js.map +1 -0
- package/dist/context/context/create-headless-context.d.ts +9 -0
- package/dist/context/context/create-headless-context.d.ts.map +1 -0
- package/dist/context/context/create-headless-context.js +43 -0
- package/dist/context/context/create-headless-context.js.map +1 -0
- package/dist/context/debug/spector.d.ts +18 -0
- package/dist/context/debug/spector.d.ts.map +1 -0
- package/dist/context/debug/spector.js +76 -0
- package/dist/context/debug/spector.js.map +1 -0
- package/dist/context/debug/webgl-developer-tools.d.ts +19 -0
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -0
- package/dist/context/debug/webgl-developer-tools.js +121 -0
- package/dist/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/context/parameters/unified-parameter-api.d.ts +9 -7
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +9 -8
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +40 -36
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +3 -3
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +26 -12
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts +2 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -2
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/{set-device-parameters.js → device-parameters.js} +53 -6
- package/dist/es5/adapter/converters/device-parameters.js.map +1 -0
- package/dist/es5/{classes → adapter/converters}/renderbuffer-formats.js +1 -1
- package/dist/es5/adapter/converters/renderbuffer-formats.js.map +1 -0
- package/dist/es5/adapter/converters/sampler-parameters.js +245 -0
- package/dist/es5/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/es5/adapter/converters/texture-formats.js +1031 -0
- package/dist/es5/adapter/converters/texture-formats.js.map +1 -0
- package/dist/es5/adapter/converters/vertex-formats.js +45 -0
- package/dist/es5/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/es5/adapter/device-helpers/device-features.js +61 -58
- package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js +1 -1
- package/dist/es5/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/es5/adapter/device-helpers/get-device-info.js +7 -7
- package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/es5/adapter/helpers/attribute-utils.js +91 -0
- package/dist/es5/adapter/helpers/attribute-utils.js.map +1 -0
- package/dist/es5/{helpers/get-program-bindings.js → adapter/helpers/get-shader-layout.js} +211 -94
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/es5/{webgl-utils → adapter/helpers}/parse-shader-compiler-log.js +0 -0
- package/dist/es5/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/es5/adapter/helpers/set-uniform.js +125 -0
- package/dist/es5/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/es5/adapter/helpers/uniforms.js +112 -0
- package/dist/es5/adapter/helpers/uniforms.js.map +1 -0
- package/dist/es5/{webgl-utils → adapter/objects}/constants-to-keys.js +1 -0
- package/dist/es5/adapter/objects/constants-to-keys.js.map +1 -0
- package/dist/es5/{classes/renderbuffer.js → adapter/objects/webgl-renderbuffer.js} +48 -98
- package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +1 -0
- package/dist/es5/{classes → adapter/objects}/webgl-resource.js +8 -3
- package/dist/es5/adapter/objects/webgl-resource.js.map +1 -0
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js +137 -0
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-buffer.js +243 -0
- package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-command-buffer.js +96 -0
- package/dist/es5/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-command-encoder.js +98 -0
- package/dist/es5/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-external-texture.js +2 -0
- package/dist/{esm/helpers/program-bindings.js.map → es5/adapter/resources/webgl-external-texture.js.map} +1 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +346 -0
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/es5/{classes/texture-2d.js → adapter/resources/webgl-render-pass.js} +26 -45
- package/dist/es5/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +530 -0
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/es5/adapter/resources/webgl-sampler.js +96 -0
- package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/es5/adapter/{webgl-shader.js → resources/webgl-shader.js} +16 -21
- package/dist/es5/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/es5/{classes/texture.js → adapter/resources/webgl-texture.js} +374 -298
- package/dist/es5/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/es5/adapter/webgl-canvas-context.js +94 -0
- package/dist/es5/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/es5/adapter/webgl-device.js +325 -131
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/{classes → classic}/accessor.js +25 -1
- package/dist/es5/classic/accessor.js.map +1 -0
- package/dist/es5/{classes/webgl-buffer.js → classic/buffer.js} +88 -72
- package/dist/es5/classic/buffer.js.map +1 -0
- package/dist/es5/{webgl-utils → classic}/typed-array-utils.js +0 -0
- package/dist/es5/classic/typed-array-utils.js.map +1 -0
- package/dist/es5/context/context/context-state.js +1 -6
- package/dist/es5/context/context/context-state.js.map +1 -1
- package/dist/es5/context/context/{create-context.js → create-browser-context.js} +29 -3
- package/dist/es5/context/context/create-browser-context.js.map +1 -0
- package/dist/es5/context/context/create-headless-context.js +60 -0
- package/dist/es5/context/context/create-headless-context.js.map +1 -0
- package/dist/es5/context/debug/spector.js +133 -0
- package/dist/es5/context/debug/spector.js.map +1 -0
- package/dist/es5/context/debug/webgl-developer-tools.js +198 -0
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/es5/context/parameters/unified-parameter-api.js +15 -9
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-context.js +3 -3
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/es5/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/es5/context/state-tracker/track-context-state.js +39 -24
- package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/context/state-tracker/with-parameters.js +8 -2
- package/dist/es5/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/es5/index.js +63 -305
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/init.js +1 -41
- package/dist/es5/init.js.map +1 -1
- package/dist/es5/{context/parameters/webgl-parameters.js → types/webgl.js} +1 -1
- package/dist/es5/types/webgl.js.map +1 -0
- package/dist/esm/adapter/converters/{set-device-parameters.js → device-parameters.js} +50 -6
- package/dist/esm/adapter/converters/device-parameters.js.map +1 -0
- package/dist/esm/{classes → adapter/converters}/renderbuffer-formats.js +1 -1
- package/dist/esm/adapter/converters/renderbuffer-formats.js.map +1 -0
- package/dist/esm/adapter/converters/sampler-parameters.js +227 -0
- package/dist/esm/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/esm/adapter/converters/texture-formats.js +954 -0
- package/dist/esm/adapter/converters/texture-formats.js.map +1 -0
- package/dist/esm/adapter/converters/vertex-formats.js +35 -0
- package/dist/esm/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/esm/adapter/device-helpers/device-features.js +39 -50
- package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-limits.js +1 -0
- package/dist/esm/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/esm/adapter/device-helpers/get-device-info.js +7 -7
- package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/esm/adapter/helpers/attribute-utils.js +81 -0
- package/dist/esm/adapter/helpers/attribute-utils.js.map +1 -0
- package/dist/esm/adapter/helpers/get-shader-layout.js +330 -0
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/{webgl-utils → esm/adapter/helpers}/parse-shader-compiler-log.js +0 -0
- package/dist/esm/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/esm/adapter/helpers/set-uniform.js +115 -0
- package/dist/esm/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/esm/adapter/helpers/uniforms.js +99 -0
- package/dist/esm/adapter/helpers/uniforms.js.map +1 -0
- package/dist/{webgl-utils → esm/adapter/objects}/constants-to-keys.js +1 -0
- package/dist/esm/adapter/objects/constants-to-keys.js.map +1 -0
- package/dist/{classes/renderbuffer.js → esm/adapter/objects/webgl-renderbuffer.js} +38 -72
- package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +1 -0
- package/dist/esm/{classes → adapter/objects}/webgl-resource.js +7 -3
- package/dist/esm/adapter/objects/webgl-resource.js.map +1 -0
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js +84 -0
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-buffer.js +164 -0
- package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-command-buffer.js +65 -0
- package/dist/esm/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-command-encoder.js +53 -0
- package/dist/esm/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-external-texture.js +2 -0
- package/dist/{helpers/program-bindings.js.map → esm/adapter/resources/webgl-external-texture.js.map} +1 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +267 -0
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-render-pass.js +21 -0
- package/dist/esm/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +428 -0
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/esm/adapter/resources/webgl-sampler.js +50 -0
- package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/{adapter → esm/adapter/resources}/webgl-shader.js +17 -23
- package/dist/esm/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/esm/{classes/texture.js → adapter/resources/webgl-texture.js} +280 -232
- package/dist/esm/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/esm/adapter/webgl-canvas-context.js +52 -0
- package/dist/esm/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/esm/adapter/webgl-device.js +253 -115
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/{classes → classic}/accessor.js +33 -1
- package/dist/esm/classic/accessor.js.map +1 -0
- package/dist/esm/{classes/webgl-buffer.js → classic/buffer.js} +67 -57
- package/dist/esm/classic/buffer.js.map +1 -0
- package/dist/{webgl-utils → esm/classic}/typed-array-utils.js +0 -0
- package/dist/esm/classic/typed-array-utils.js.map +1 -0
- package/dist/esm/context/context/context-state.js +1 -6
- package/dist/esm/context/context/context-state.js.map +1 -1
- package/dist/{context/context/create-context.js → esm/context/context/create-browser-context.js} +27 -3
- package/dist/esm/context/context/create-browser-context.js.map +1 -0
- package/dist/esm/context/context/create-headless-context.js +43 -0
- package/dist/esm/context/context/create-headless-context.js.map +1 -0
- package/dist/esm/context/debug/spector.js +76 -0
- package/dist/esm/context/debug/spector.js.map +1 -0
- package/dist/esm/context/debug/webgl-developer-tools.js +121 -0
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/esm/context/parameters/unified-parameter-api.js +9 -8
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-context.js +3 -3
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/esm/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js +26 -12
- package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/esm/context/state-tracker/with-parameters.js +6 -2
- package/dist/esm/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/esm/index.js +20 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.js +2 -31
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/types/webgl.js +2 -0
- package/dist/esm/types/webgl.js.map +1 -0
- package/dist/index.d.ts +25 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -32
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +2 -31
- package/dist/init.js.map +1 -1
- package/dist/types/webgl.d.ts +145 -0
- package/dist/types/webgl.d.ts.map +1 -0
- package/dist/types/webgl.js +2 -0
- package/dist/types/webgl.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/{set-device-parameters.ts → device-parameters.ts} +81 -12
- package/src/{classes → adapter/converters}/renderbuffer-formats.ts +1 -1
- package/src/adapter/converters/sampler-parameters.ts +184 -0
- package/src/adapter/converters/texture-formats.ts +633 -0
- package/src/adapter/converters/vertex-formats.ts +22 -0
- package/src/adapter/device-helpers/device-features.ts +55 -124
- package/src/adapter/device-helpers/device-limits.ts +6 -3
- package/src/adapter/device-helpers/get-device-info.ts +8 -8
- package/src/adapter/helpers/attribute-utils.ts +61 -0
- package/src/adapter/helpers/get-shader-layout.ts +407 -0
- package/src/{webgl-utils → adapter/helpers}/parse-shader-compiler-log.ts +0 -0
- package/src/adapter/helpers/set-uniform.ts +87 -0
- package/src/adapter/helpers/uniforms.ts +121 -0
- package/src/{webgl-utils → adapter/objects}/constants-to-keys.ts +6 -3
- package/src/adapter/objects/webgl-renderbuffer.ts +104 -0
- package/src/{classes → adapter/objects}/webgl-resource.ts +23 -17
- package/src/adapter/objects/webgl-vertex-array-object.ts +111 -0
- package/src/adapter/resources/webgl-buffer.ts +219 -0
- package/src/adapter/resources/webgl-command-buffer.ts +94 -0
- package/src/adapter/resources/webgl-command-encoder.ts +58 -0
- package/src/adapter/resources/webgl-external-texture.ts +92 -0
- package/src/adapter/resources/webgl-framebuffer.ts +282 -0
- package/src/adapter/resources/webgl-render-pass.ts +24 -0
- package/src/adapter/resources/webgl-render-pipeline.ts +425 -0
- package/src/adapter/resources/webgl-sampler.ts +56 -0
- package/src/adapter/{webgl-shader.ts → resources/webgl-shader.ts} +19 -24
- package/src/adapter/resources/webgl-texture.ts +1036 -0
- package/src/adapter/webgl-canvas-context.ts +72 -0
- package/src/adapter/webgl-device.ts +312 -285
- package/{dist/esm/classes/accessor.ts.disabled → src/classic/accessor.ts} +38 -37
- package/src/{classes/webgl-buffer.ts → classic/buffer.ts} +76 -84
- package/src/{webgl-utils → classic}/typed-array-utils.ts +5 -1
- package/src/context/context/context-state.ts +4 -12
- package/src/context/context/{create-context.ts → create-browser-context.ts} +41 -6
- package/src/context/context/create-headless-context.ts +48 -0
- package/src/context/debug/spector.ts +92 -0
- package/src/context/debug/webgl-developer-tools.ts +162 -0
- package/src/context/parameters/unified-parameter-api.ts +21 -13
- package/src/context/parameters/webgl-parameter-tables.ts +38 -36
- package/src/context/polyfill/get-parameter-polyfill.ts +1 -1
- package/src/context/polyfill/polyfill-context.ts +4 -5
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/context/state-tracker/deep-array-equal.ts +1 -1
- package/src/context/state-tracker/track-context-state.ts +34 -26
- package/src/context/state-tracker/with-parameters.ts +7 -2
- package/src/index.ts +42 -105
- package/src/init.ts +2 -46
- package/src/types/webgl.ts +284 -0
- package/dist/_deprecated/context-api.d.ts +0 -85
- package/dist/_deprecated/context-api.d.ts.map +0 -1
- package/dist/_deprecated/context-api.js +0 -76
- package/dist/_deprecated/context-api.js.map +0 -1
- package/dist/_deprecated/features.d.ts +0 -27
- package/dist/_deprecated/features.d.ts.map +0 -1
- package/dist/_deprecated/features.js +0 -111
- package/dist/_deprecated/features.js.map +0 -1
- package/dist/adapter/converters/set-device-parameters.d.ts +0 -5
- package/dist/adapter/converters/set-device-parameters.d.ts.map +0 -1
- package/dist/adapter/converters/set-device-parameters.js.map +0 -1
- package/dist/adapter/converters/webgpu-texture-formats.d.ts +0 -281
- package/dist/adapter/converters/webgpu-texture-formats.d.ts.map +0 -1
- package/dist/adapter/converters/webgpu-texture-formats.js +0 -285
- package/dist/adapter/converters/webgpu-texture-formats.js.map +0 -1
- package/dist/adapter/webgl-shader.d.ts.map +0 -1
- package/dist/adapter/webgl-shader.js.map +0 -1
- package/dist/classes/accessor.d.ts +0 -28
- package/dist/classes/accessor.d.ts.map +0 -1
- package/dist/classes/accessor.js.map +0 -1
- package/dist/classes/accessor.ts.disabled +0 -159
- package/dist/classes/clear.d.ts +0 -17
- package/dist/classes/clear.d.ts.map +0 -1
- package/dist/classes/clear.js +0 -105
- package/dist/classes/clear.js.map +0 -1
- package/dist/classes/copy-and-blit.d.ts +0 -86
- package/dist/classes/copy-and-blit.d.ts.map +0 -1
- package/dist/classes/copy-and-blit.js +0 -338
- package/dist/classes/copy-and-blit.js.map +0 -1
- package/dist/classes/framebuffer.d.ts +0 -139
- package/dist/classes/framebuffer.d.ts.map +0 -1
- package/dist/classes/framebuffer.js +0 -656
- package/dist/classes/framebuffer.js.map +0 -1
- package/dist/classes/program-configuration.d.ts +0 -24
- package/dist/classes/program-configuration.d.ts.map +0 -1
- package/dist/classes/program-configuration.js +0 -73
- package/dist/classes/program-configuration.js.map +0 -1
- package/dist/classes/program.d.ts +0 -66
- package/dist/classes/program.d.ts.map +0 -1
- package/dist/classes/program.js +0 -379
- package/dist/classes/program.js.map +0 -1
- package/dist/classes/query.d.ts +0 -27
- package/dist/classes/query.d.ts.map +0 -1
- package/dist/classes/query.js +0 -145
- package/dist/classes/query.js.map +0 -1
- package/dist/classes/renderbuffer-formats.d.ts.map +0 -1
- package/dist/classes/renderbuffer-formats.js.map +0 -1
- package/dist/classes/renderbuffer.d.ts +0 -60
- package/dist/classes/renderbuffer.d.ts.map +0 -1
- package/dist/classes/renderbuffer.js.map +0 -1
- package/dist/classes/shader.d.ts +0 -42
- package/dist/classes/shader.d.ts.map +0 -1
- package/dist/classes/shader.js +0 -118
- package/dist/classes/shader.js.map +0 -1
- package/dist/classes/texture-2d.d.ts +0 -9
- package/dist/classes/texture-2d.d.ts.map +0 -1
- package/dist/classes/texture-2d.js +0 -36
- package/dist/classes/texture-2d.js.map +0 -1
- package/dist/classes/texture-3d.d.ts +0 -29
- package/dist/classes/texture-3d.d.ts.map +0 -1
- package/dist/classes/texture-3d.js +0 -76
- package/dist/classes/texture-3d.js.map +0 -1
- package/dist/classes/texture-cube.d.ts +0 -28
- package/dist/classes/texture-cube.d.ts.map +0 -1
- package/dist/classes/texture-cube.js +0 -130
- package/dist/classes/texture-cube.js.map +0 -1
- package/dist/classes/texture-formats.d.ts +0 -37
- package/dist/classes/texture-formats.d.ts.map +0 -1
- package/dist/classes/texture-formats.js +0 -98
- package/dist/classes/texture-formats.js.map +0 -1
- package/dist/classes/texture.d.ts +0 -123
- package/dist/classes/texture.d.ts.map +0 -1
- package/dist/classes/texture.js.map +0 -1
- package/dist/classes/transform-feedback.d.ts +0 -33
- package/dist/classes/transform-feedback.d.ts.map +0 -1
- package/dist/classes/transform-feedback.js +0 -198
- package/dist/classes/transform-feedback.js.map +0 -1
- package/dist/classes/uniform-buffer-layout.d.ts +0 -17
- package/dist/classes/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/classes/uniform-buffer-layout.js +0 -104
- package/dist/classes/uniform-buffer-layout.js.map +0 -1
- package/dist/classes/uniforms.d.ts +0 -37
- package/dist/classes/uniforms.d.ts.map +0 -1
- package/dist/classes/uniforms.js +0 -250
- package/dist/classes/uniforms.js.map +0 -1
- package/dist/classes/vertex-array-object.d.ts +0 -76
- package/dist/classes/vertex-array-object.d.ts.map +0 -1
- package/dist/classes/vertex-array-object.js +0 -261
- package/dist/classes/vertex-array-object.js.map +0 -1
- package/dist/classes/vertex-array.d.ts +0 -75
- package/dist/classes/vertex-array.d.ts.map +0 -1
- package/dist/classes/vertex-array.js +0 -408
- package/dist/classes/vertex-array.js.map +0 -1
- package/dist/classes/webgl-buffer.d.ts.map +0 -1
- package/dist/classes/webgl-buffer.js.map +0 -1
- package/dist/classes/webgl-resource.d.ts.map +0 -1
- package/dist/classes/webgl-resource.js.map +0 -1
- package/dist/context/context/create-context.d.ts.map +0 -1
- package/dist/context/context/create-context.js.map +0 -1
- package/dist/context/context/device-pixels.d.ts +0 -25
- package/dist/context/context/device-pixels.d.ts.map +0 -1
- package/dist/context/context/device-pixels.js +0 -98
- package/dist/context/context/device-pixels.js.map +0 -1
- package/dist/context/context/get-canvas.d.ts +0 -13
- package/dist/context/context/get-canvas.d.ts.map +0 -1
- package/dist/context/context/get-canvas.js +0 -31
- package/dist/context/context/get-canvas.js.map +0 -1
- package/dist/context/context/resize-context.d.ts +0 -20
- package/dist/context/context/resize-context.d.ts.map +0 -1
- package/dist/context/context/resize-context.js +0 -15
- package/dist/context/context/resize-context.js.map +0 -1
- package/dist/context/parameters/webgl-parameters.d.ts +0 -144
- package/dist/context/parameters/webgl-parameters.d.ts.map +0 -1
- package/dist/context/parameters/webgl-parameters.js +0 -2
- package/dist/context/parameters/webgl-parameters.js.map +0 -1
- package/dist/debug/debug-program-configuration.d.ts +0 -2
- package/dist/debug/debug-program-configuration.d.ts.map +0 -1
- package/dist/debug/debug-program-configuration.js +0 -40
- package/dist/debug/debug-program-configuration.js.map +0 -1
- package/dist/debug/debug-uniforms.d.ts +0 -12
- package/dist/debug/debug-uniforms.d.ts.map +0 -1
- package/dist/debug/debug-uniforms.js +0 -108
- package/dist/debug/debug-uniforms.js.map +0 -1
- package/dist/debug/debug-vertex-array.d.ts +0 -5
- package/dist/debug/debug-vertex-array.d.ts.map +0 -1
- package/dist/debug/debug-vertex-array.js +0 -118
- package/dist/debug/debug-vertex-array.js.map +0 -1
- package/dist/es5/_deprecated/context-api.js +0 -116
- package/dist/es5/_deprecated/context-api.js.map +0 -1
- package/dist/es5/_deprecated/features.js +0 -118
- package/dist/es5/_deprecated/features.js.map +0 -1
- package/dist/es5/adapter/converters/set-device-parameters.js.map +0 -1
- package/dist/es5/adapter/converters/webgpu-texture-formats.js +0 -296
- package/dist/es5/adapter/converters/webgpu-texture-formats.js.map +0 -1
- package/dist/es5/adapter/webgl-shader.js.map +0 -1
- package/dist/es5/classes/accessor.d.ts +0 -28
- package/dist/es5/classes/accessor.js.map +0 -1
- package/dist/es5/classes/accessor.ts.disabled +0 -159
- package/dist/es5/classes/clear.js +0 -135
- package/dist/es5/classes/clear.js.map +0 -1
- package/dist/es5/classes/copy-and-blit.js +0 -382
- package/dist/es5/classes/copy-and-blit.js.map +0 -1
- package/dist/es5/classes/framebuffer.js +0 -807
- package/dist/es5/classes/framebuffer.js.map +0 -1
- package/dist/es5/classes/program-configuration.js +0 -119
- package/dist/es5/classes/program-configuration.js.map +0 -1
- package/dist/es5/classes/program.js +0 -471
- package/dist/es5/classes/program.js.map +0 -1
- package/dist/es5/classes/query.js +0 -222
- package/dist/es5/classes/query.js.map +0 -1
- package/dist/es5/classes/renderbuffer-formats.js.map +0 -1
- package/dist/es5/classes/renderbuffer.js.map +0 -1
- package/dist/es5/classes/shader.js +0 -195
- package/dist/es5/classes/shader.js.map +0 -1
- package/dist/es5/classes/texture-2d.js.map +0 -1
- package/dist/es5/classes/texture-3d.js +0 -142
- package/dist/es5/classes/texture-3d.js.map +0 -1
- package/dist/es5/classes/texture-cube.js +0 -202
- package/dist/es5/classes/texture-cube.js.map +0 -1
- package/dist/es5/classes/texture-formats.js +0 -87
- package/dist/es5/classes/texture-formats.js.map +0 -1
- package/dist/es5/classes/texture.js.map +0 -1
- package/dist/es5/classes/transform-feedback.js +0 -267
- package/dist/es5/classes/transform-feedback.js.map +0 -1
- package/dist/es5/classes/uniform-buffer-layout.js +0 -130
- package/dist/es5/classes/uniform-buffer-layout.js.map +0 -1
- package/dist/es5/classes/uniforms.js +0 -232
- package/dist/es5/classes/uniforms.js.map +0 -1
- package/dist/es5/classes/vertex-array-object.js +0 -337
- package/dist/es5/classes/vertex-array-object.js.map +0 -1
- package/dist/es5/classes/vertex-array.js +0 -465
- package/dist/es5/classes/vertex-array.js.map +0 -1
- package/dist/es5/classes/webgl-buffer.js.map +0 -1
- package/dist/es5/classes/webgl-resource.js.map +0 -1
- package/dist/es5/context/context/create-context.js.map +0 -1
- package/dist/es5/context/context/device-pixels.js +0 -115
- package/dist/es5/context/context/device-pixels.js.map +0 -1
- package/dist/es5/context/context/get-canvas.js +0 -40
- package/dist/es5/context/context/get-canvas.js.map +0 -1
- package/dist/es5/context/context/resize-context.js +0 -23
- package/dist/es5/context/context/resize-context.js.map +0 -1
- package/dist/es5/context/parameters/webgl-parameters.js.map +0 -1
- package/dist/es5/debug/debug-program-configuration.js +0 -76
- package/dist/es5/debug/debug-program-configuration.js.map +0 -1
- package/dist/es5/debug/debug-uniforms.js +0 -156
- package/dist/es5/debug/debug-uniforms.js.map +0 -1
- package/dist/es5/debug/debug-vertex-array.js +0 -126
- package/dist/es5/debug/debug-vertex-array.js.map +0 -1
- package/dist/es5/helpers/get-program-bindings.js.map +0 -1
- package/dist/es5/helpers/program-bindings.js +0 -2
- package/dist/es5/types/accessor.d.ts +0 -29
- package/dist/es5/webgl-utils/attribute-utils.js +0 -186
- package/dist/es5/webgl-utils/attribute-utils.js.map +0 -1
- package/dist/es5/webgl-utils/constants-to-keys.js.map +0 -1
- package/dist/es5/webgl-utils/format-utils.js +0 -58
- package/dist/es5/webgl-utils/format-utils.js.map +0 -1
- package/dist/es5/webgl-utils/get-error.js +0 -49
- package/dist/es5/webgl-utils/get-error.js.map +0 -1
- package/dist/es5/webgl-utils/index.js +0 -74
- package/dist/es5/webgl-utils/index.js.map +0 -1
- package/dist/es5/webgl-utils/parse-shader-compiler-log.js.map +0 -1
- package/dist/es5/webgl-utils/request-animation-frame.js +0 -16
- package/dist/es5/webgl-utils/request-animation-frame.js.map +0 -1
- package/dist/es5/webgl-utils/texture-utils.js +0 -61
- package/dist/es5/webgl-utils/texture-utils.js.map +0 -1
- package/dist/es5/webgl-utils/typed-array-utils.js.map +0 -1
- package/dist/esm/_deprecated/context-api.js +0 -76
- package/dist/esm/_deprecated/context-api.js.map +0 -1
- package/dist/esm/_deprecated/features.js +0 -111
- package/dist/esm/_deprecated/features.js.map +0 -1
- package/dist/esm/adapter/converters/set-device-parameters.js.map +0 -1
- package/dist/esm/adapter/converters/webgpu-texture-formats.js +0 -285
- package/dist/esm/adapter/converters/webgpu-texture-formats.js.map +0 -1
- package/dist/esm/adapter/webgl-shader.js.map +0 -1
- package/dist/esm/classes/accessor.d.ts +0 -28
- package/dist/esm/classes/accessor.js.map +0 -1
- package/dist/esm/classes/clear.js +0 -105
- package/dist/esm/classes/clear.js.map +0 -1
- package/dist/esm/classes/copy-and-blit.js +0 -338
- package/dist/esm/classes/copy-and-blit.js.map +0 -1
- package/dist/esm/classes/framebuffer.js +0 -656
- package/dist/esm/classes/framebuffer.js.map +0 -1
- package/dist/esm/classes/program-configuration.js +0 -73
- package/dist/esm/classes/program-configuration.js.map +0 -1
- package/dist/esm/classes/program.js +0 -379
- package/dist/esm/classes/program.js.map +0 -1
- package/dist/esm/classes/query.js +0 -145
- package/dist/esm/classes/query.js.map +0 -1
- package/dist/esm/classes/renderbuffer-formats.js.map +0 -1
- package/dist/esm/classes/renderbuffer.js.map +0 -1
- package/dist/esm/classes/shader.js +0 -118
- package/dist/esm/classes/shader.js.map +0 -1
- package/dist/esm/classes/texture-2d.js +0 -36
- package/dist/esm/classes/texture-2d.js.map +0 -1
- package/dist/esm/classes/texture-3d.js +0 -76
- package/dist/esm/classes/texture-3d.js.map +0 -1
- package/dist/esm/classes/texture-cube.js +0 -130
- package/dist/esm/classes/texture-cube.js.map +0 -1
- package/dist/esm/classes/texture-formats.js +0 -98
- package/dist/esm/classes/texture-formats.js.map +0 -1
- package/dist/esm/classes/texture.js.map +0 -1
- package/dist/esm/classes/transform-feedback.js +0 -198
- package/dist/esm/classes/transform-feedback.js.map +0 -1
- package/dist/esm/classes/uniform-buffer-layout.js +0 -104
- package/dist/esm/classes/uniform-buffer-layout.js.map +0 -1
- package/dist/esm/classes/uniforms.js +0 -250
- package/dist/esm/classes/uniforms.js.map +0 -1
- package/dist/esm/classes/vertex-array-object.js +0 -261
- package/dist/esm/classes/vertex-array-object.js.map +0 -1
- package/dist/esm/classes/vertex-array.js +0 -408
- package/dist/esm/classes/vertex-array.js.map +0 -1
- package/dist/esm/classes/webgl-buffer.js.map +0 -1
- package/dist/esm/classes/webgl-resource.js.map +0 -1
- package/dist/esm/context/context/create-context.js.map +0 -1
- package/dist/esm/context/context/device-pixels.js +0 -98
- package/dist/esm/context/context/device-pixels.js.map +0 -1
- package/dist/esm/context/context/get-canvas.js +0 -31
- package/dist/esm/context/context/get-canvas.js.map +0 -1
- package/dist/esm/context/context/resize-context.js +0 -15
- package/dist/esm/context/context/resize-context.js.map +0 -1
- package/dist/esm/context/parameters/webgl-parameters.js +0 -2
- package/dist/esm/context/parameters/webgl-parameters.js.map +0 -1
- package/dist/esm/debug/debug-program-configuration.js +0 -40
- package/dist/esm/debug/debug-program-configuration.js.map +0 -1
- package/dist/esm/debug/debug-uniforms.js +0 -108
- package/dist/esm/debug/debug-uniforms.js.map +0 -1
- package/dist/esm/debug/debug-vertex-array.js +0 -118
- package/dist/esm/debug/debug-vertex-array.js.map +0 -1
- package/dist/esm/helpers/get-program-bindings.js +0 -228
- package/dist/esm/helpers/get-program-bindings.js.map +0 -1
- package/dist/esm/helpers/program-bindings.js +0 -2
- package/dist/esm/types/accessor.d.ts +0 -29
- package/dist/esm/webgl-utils/attribute-utils.js +0 -182
- package/dist/esm/webgl-utils/attribute-utils.js.map +0 -1
- package/dist/esm/webgl-utils/constants-to-keys.js.map +0 -1
- package/dist/esm/webgl-utils/format-utils.js +0 -45
- package/dist/esm/webgl-utils/format-utils.js.map +0 -1
- package/dist/esm/webgl-utils/get-error.js +0 -41
- package/dist/esm/webgl-utils/get-error.js.map +0 -1
- package/dist/esm/webgl-utils/index.js +0 -5
- package/dist/esm/webgl-utils/index.js.map +0 -1
- package/dist/esm/webgl-utils/parse-shader-compiler-log.js.map +0 -1
- package/dist/esm/webgl-utils/request-animation-frame.js +0 -7
- package/dist/esm/webgl-utils/request-animation-frame.js.map +0 -1
- package/dist/esm/webgl-utils/texture-utils.js +0 -48
- package/dist/esm/webgl-utils/texture-utils.js.map +0 -1
- package/dist/esm/webgl-utils/typed-array-utils.js.map +0 -1
- package/dist/helpers/get-program-bindings.d.ts +0 -8
- package/dist/helpers/get-program-bindings.d.ts.map +0 -1
- package/dist/helpers/get-program-bindings.js +0 -228
- package/dist/helpers/get-program-bindings.js.map +0 -1
- package/dist/helpers/program-bindings.d.ts +0 -41
- package/dist/helpers/program-bindings.d.ts.map +0 -1
- package/dist/helpers/program-bindings.js +0 -2
- package/dist/types/accessor.d.ts +0 -29
- package/dist/webgl-utils/attribute-utils.d.ts +0 -18
- package/dist/webgl-utils/attribute-utils.d.ts.map +0 -1
- package/dist/webgl-utils/attribute-utils.js +0 -182
- package/dist/webgl-utils/attribute-utils.js.map +0 -1
- package/dist/webgl-utils/constants-to-keys.d.ts +0 -4
- package/dist/webgl-utils/constants-to-keys.d.ts.map +0 -1
- package/dist/webgl-utils/constants-to-keys.js.map +0 -1
- package/dist/webgl-utils/format-utils.d.ts +0 -3
- package/dist/webgl-utils/format-utils.d.ts.map +0 -1
- package/dist/webgl-utils/format-utils.js +0 -45
- package/dist/webgl-utils/format-utils.js.map +0 -1
- package/dist/webgl-utils/get-error.d.ts +0 -3
- package/dist/webgl-utils/get-error.d.ts.map +0 -1
- package/dist/webgl-utils/get-error.js +0 -41
- package/dist/webgl-utils/get-error.js.map +0 -1
- package/dist/webgl-utils/index.d.ts +0 -5
- package/dist/webgl-utils/index.d.ts.map +0 -1
- package/dist/webgl-utils/index.js +0 -5
- package/dist/webgl-utils/index.js.map +0 -1
- package/dist/webgl-utils/parse-shader-compiler-log.d.ts.map +0 -1
- package/dist/webgl-utils/parse-shader-compiler-log.js.map +0 -1
- package/dist/webgl-utils/request-animation-frame.d.ts +0 -4
- package/dist/webgl-utils/request-animation-frame.d.ts.map +0 -1
- package/dist/webgl-utils/request-animation-frame.js +0 -7
- package/dist/webgl-utils/request-animation-frame.js.map +0 -1
- package/dist/webgl-utils/texture-utils.d.ts +0 -15
- package/dist/webgl-utils/texture-utils.d.ts.map +0 -1
- package/dist/webgl-utils/texture-utils.js +0 -48
- package/dist/webgl-utils/texture-utils.js.map +0 -1
- package/dist/webgl-utils/typed-array-utils.d.ts.map +0 -1
- package/dist/webgl-utils/typed-array-utils.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/_deprecated/context-api.ts +0 -146
- package/src/_deprecated/features.ts +0 -159
- package/src/adapter/converters/webgpu-texture-formats.ts +0 -167
- package/src/classes/accessor.d.ts +0 -28
- package/src/classes/accessor.js +0 -129
- package/src/classes/accessor.ts.disabled +0 -159
- package/src/classes/clear.ts +0 -108
- package/src/classes/copy-and-blit.ts +0 -460
- package/src/classes/framebuffer.ts +0 -763
- package/src/classes/program-configuration.ts +0 -77
- package/src/classes/program.ts +0 -431
- package/src/classes/query.ts +0 -171
- package/src/classes/renderbuffer.ts +0 -154
- package/src/classes/shader.ts +0 -129
- package/src/classes/texture-2d.ts +0 -35
- package/src/classes/texture-3d.ts +0 -123
- package/src/classes/texture-cube.ts +0 -162
- package/src/classes/texture-formats.ts +0 -171
- package/src/classes/texture.ts +0 -965
- package/src/classes/transform-feedback.ts +0 -191
- package/src/classes/uniform-buffer-layout.ts +0 -113
- package/src/classes/uniforms.ts +0 -394
- package/src/classes/vertex-array-object.ts +0 -339
- package/src/classes/vertex-array.ts +0 -484
- package/src/context/context/device-pixels.ts +0 -147
- package/src/context/context/get-canvas.ts +0 -37
- package/src/context/context/resize-context.ts +0 -37
- package/src/context/parameters/webgl-parameters.ts +0 -197
- package/src/debug/debug-program-configuration.ts +0 -32
- package/src/debug/debug-uniforms.ts +0 -100
- package/src/debug/debug-vertex-array.ts +0 -123
- package/src/helpers/get-program-bindings.ts +0 -244
- package/src/helpers/program-bindings.ts +0 -46
- package/src/types/accessor.d.ts +0 -29
- package/src/webgl-utils/attribute-utils.ts +0 -171
- package/src/webgl-utils/format-utils.ts +0 -43
- package/src/webgl-utils/get-error.ts +0 -56
- package/src/webgl-utils/index.ts +0 -12
- package/src/webgl-utils/request-animation-frame.ts +0 -14
- package/src/webgl-utils/texture-utils.ts +0 -60
|
@@ -1,94 +1,113 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Device, log } from '@luma.gl/api';
|
|
2
|
+
import { Device, CanvasContext, log } from '@luma.gl/api';
|
|
3
|
+
import { isBrowser } from '@probe.gl/env';
|
|
3
4
|
import { polyfillContext } from '../context/polyfill/polyfill-context';
|
|
4
|
-
import { trackContextState } from '../context/state-tracker/track-context-state';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getCanvas } from '../context/context/get-canvas';
|
|
8
|
-
import { isWebGL, isWebGL2 } from '../context/context/webgl-checks';
|
|
5
|
+
import { popContextState, pushContextState, trackContextState } from '../context/state-tracker/track-context-state';
|
|
6
|
+
import { createBrowserContext } from '../context/context/create-browser-context';
|
|
7
|
+
import { createHeadlessContext, isHeadlessGLRegistered } from '../context/context/create-headless-context';
|
|
9
8
|
import { getDeviceInfo } from './device-helpers/get-device-info';
|
|
10
9
|
import { getDeviceFeatures } from './device-helpers/device-features';
|
|
11
10
|
import { getDeviceLimits, getWebGLLimits } from './device-helpers/device-limits';
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
debug: false,
|
|
24
|
-
break: undefined,
|
|
25
|
-
onContextLost: () => console.error('WebGL context lost'),
|
|
26
|
-
onContextRestored: () => console.info('WebGL context restored'),
|
|
27
|
-
alpha: undefined,
|
|
28
|
-
depth: undefined,
|
|
29
|
-
stencil: undefined,
|
|
30
|
-
antialias: undefined,
|
|
31
|
-
premultipliedAlpha: undefined,
|
|
32
|
-
preserveDrawingBuffer: undefined,
|
|
33
|
-
failIfMajorPerformanceCaveat: undefined
|
|
34
|
-
};
|
|
11
|
+
import WebGLCanvasContext from './webgl-canvas-context';
|
|
12
|
+
import { loadSpectorJS, initializeSpectorJS } from '../context/debug/spector';
|
|
13
|
+
import { loadWebGLDeveloperTools, makeDebugContext } from '../context/debug/webgl-developer-tools';
|
|
14
|
+
import { isTextureFormatSupported, isTextureFormatRenderable, isTextureFormatFilterable } from './converters/texture-formats';
|
|
15
|
+
import ClassicBuffer from '../classic/buffer';
|
|
16
|
+
import WEBGLShader from './resources/webgl-shader';
|
|
17
|
+
import WEBGLSampler from './resources/webgl-sampler';
|
|
18
|
+
import WEBGLTexture from './resources/webgl-texture';
|
|
19
|
+
import WEBGLFramebuffer from './resources/webgl-framebuffer';
|
|
20
|
+
import WEBGLRenderPass from './resources/webgl-render-pass';
|
|
21
|
+
import WEBGLRenderPipeline from './resources/webgl-render-pipeline';
|
|
35
22
|
const LOG_LEVEL = 1;
|
|
36
|
-
const glToContextMap = new WeakMap();
|
|
37
|
-
export function getWebGLDevice(gl) {
|
|
38
|
-
return glToContextMap.get(gl);
|
|
39
|
-
}
|
|
40
23
|
let counter = 0;
|
|
41
24
|
export default class WebGLDevice extends Device {
|
|
42
|
-
static
|
|
43
|
-
return
|
|
25
|
+
static isSupported() {
|
|
26
|
+
return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get features() {
|
|
30
|
+
this._features = this._features || getDeviceFeatures(this.gl);
|
|
31
|
+
return this._features;
|
|
44
32
|
}
|
|
45
33
|
|
|
46
|
-
|
|
34
|
+
get limits() {
|
|
35
|
+
this._limits = this._limits || getDeviceLimits(this.gl);
|
|
36
|
+
return this._limits;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static attach(gl) {
|
|
47
40
|
if (gl instanceof WebGLDevice) {
|
|
48
41
|
return gl;
|
|
49
42
|
}
|
|
50
43
|
|
|
44
|
+
if ((gl === null || gl === void 0 ? void 0 : gl.device) instanceof Device) {
|
|
45
|
+
return gl.device;
|
|
46
|
+
}
|
|
47
|
+
|
|
51
48
|
if (!isWebGL(gl)) {
|
|
52
49
|
throw new Error('Invalid WebGLRenderingContext');
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
return new WebGLDevice({
|
|
52
|
+
return new WebGLDevice({
|
|
56
53
|
gl: gl
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
static async create(props = {}) {
|
|
58
|
+
log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');
|
|
59
|
+
|
|
60
|
+
if (typeof props.canvas === 'string') {
|
|
61
|
+
await CanvasContext.pageLoaded;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (props.debug) {
|
|
65
|
+
await loadWebGLDeveloperTools();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (props.spector) {
|
|
69
|
+
await loadSpectorJS();
|
|
70
|
+
}
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
log.probe(LOG_LEVEL + 1, 'DOM is loaded')();
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
if (props.gl && props.gl.device) {
|
|
75
|
+
return WebGLDevice.attach(props.gl);
|
|
76
|
+
}
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
return new WebGLDevice(props);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
constructor(props) {
|
|
82
|
+
var _props$gl;
|
|
83
|
+
|
|
84
|
+
super(props);
|
|
68
85
|
|
|
69
86
|
_defineProperty(this, "info", void 0);
|
|
70
87
|
|
|
71
|
-
_defineProperty(this, "
|
|
88
|
+
_defineProperty(this, "canvasContext", void 0);
|
|
72
89
|
|
|
73
|
-
_defineProperty(this, "
|
|
90
|
+
_defineProperty(this, "handle", void 0);
|
|
74
91
|
|
|
75
|
-
_defineProperty(this, "
|
|
92
|
+
_defineProperty(this, "lost", void 0);
|
|
76
93
|
|
|
77
|
-
_defineProperty(this, "
|
|
94
|
+
_defineProperty(this, "_resolveContextLost", void 0);
|
|
78
95
|
|
|
79
|
-
_defineProperty(this, "
|
|
96
|
+
_defineProperty(this, "_features", void 0);
|
|
80
97
|
|
|
81
|
-
_defineProperty(this, "
|
|
98
|
+
_defineProperty(this, "_limits", void 0);
|
|
82
99
|
|
|
83
|
-
_defineProperty(this, "
|
|
100
|
+
_defineProperty(this, "renderPass", null);
|
|
84
101
|
|
|
85
|
-
_defineProperty(this, "
|
|
102
|
+
_defineProperty(this, "gl", void 0);
|
|
103
|
+
|
|
104
|
+
_defineProperty(this, "gl2", null);
|
|
86
105
|
|
|
87
|
-
_defineProperty(this, "
|
|
106
|
+
_defineProperty(this, "debug", false);
|
|
88
107
|
|
|
89
|
-
_defineProperty(this, "
|
|
108
|
+
_defineProperty(this, "isWebGL1", void 0);
|
|
90
109
|
|
|
91
|
-
_defineProperty(this, "
|
|
110
|
+
_defineProperty(this, "isWebGL2", void 0);
|
|
92
111
|
|
|
93
112
|
_defineProperty(this, "_canvasSizeInfo", {
|
|
94
113
|
clientWidth: 0,
|
|
@@ -100,108 +119,227 @@ export default class WebGLDevice extends Device {
|
|
|
100
119
|
|
|
101
120
|
_defineProperty(this, "_polyfilled", false);
|
|
102
121
|
|
|
103
|
-
this
|
|
104
|
-
...props
|
|
105
|
-
};
|
|
106
|
-
const device = (_this$props$gl = this.props.gl) === null || _this$props$gl === void 0 ? void 0 : _this$props$gl.device;
|
|
122
|
+
_defineProperty(this, "spector", void 0);
|
|
107
123
|
|
|
108
|
-
|
|
109
|
-
if (device._state !== 'initialized') {
|
|
110
|
-
log.error('recursive context');
|
|
111
|
-
throw new Error('recursive context');
|
|
112
|
-
}
|
|
124
|
+
_defineProperty(this, "_webglLimits", void 0);
|
|
113
125
|
|
|
114
|
-
|
|
126
|
+
const device = (_props$gl = props.gl) === null || _props$gl === void 0 ? void 0 : _props$gl.device;
|
|
127
|
+
|
|
128
|
+
if (device) {
|
|
129
|
+
throw new Error("WebGL context already attached to device ".concat(device.id));
|
|
115
130
|
}
|
|
116
131
|
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this._state = 'initializing';
|
|
132
|
+
this.canvasContext = new WebGLCanvasContext(this, props);
|
|
133
|
+
this.lost = new Promise(resolve => {
|
|
134
|
+
this._resolveContextLost = resolve;
|
|
135
|
+
});
|
|
122
136
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
const onContextLost = event => {
|
|
138
|
+
var _this$_resolveContext;
|
|
139
|
+
|
|
140
|
+
return (_this$_resolveContext = this._resolveContextLost) === null || _this$_resolveContext === void 0 ? void 0 : _this$_resolveContext.call(this, {
|
|
141
|
+
reason: 'destroyed',
|
|
142
|
+
message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
let gl = props.gl;
|
|
147
|
+
gl = gl || (isBrowser() ? createBrowserContext(this.canvasContext.canvas, { ...props,
|
|
148
|
+
onContextLost
|
|
149
|
+
}) : null);
|
|
150
|
+
gl = gl || (!isBrowser() ? createHeadlessContext({ ...props,
|
|
151
|
+
onContextLost
|
|
152
|
+
}) : null);
|
|
153
|
+
|
|
154
|
+
if (!gl) {
|
|
155
|
+
throw new Error('WebGL context creation failed');
|
|
126
156
|
}
|
|
127
157
|
|
|
128
|
-
this.
|
|
129
|
-
this.gl
|
|
130
|
-
|
|
158
|
+
this.handle = gl;
|
|
159
|
+
this.gl = this.handle;
|
|
160
|
+
this.gl2 = this.gl;
|
|
161
|
+
this.isWebGL2 = isWebGL2(this.gl);
|
|
162
|
+
this.isWebGL1 = !this.isWebGL2;
|
|
131
163
|
this.info = getDeviceInfo(this.gl);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
log.groupCollapsed(LOG_LEVEL, "".concat(webGL).concat(debug, " context: ").concat(this.info.vendor, ", ").concat(this.info.renderer))();
|
|
164
|
+
this.gl.device = this;
|
|
165
|
+
this.gl._version = this.isWebGL2 ? 2 : 1;
|
|
135
166
|
polyfillContext(this.gl);
|
|
136
|
-
|
|
167
|
+
const {
|
|
168
|
+
enable = true,
|
|
169
|
+
copyState = false
|
|
170
|
+
} = props;
|
|
137
171
|
trackContextState(this.gl, {
|
|
138
|
-
|
|
172
|
+
enable,
|
|
173
|
+
copyState,
|
|
139
174
|
log: (...args) => log.log(1, ...args)()
|
|
140
175
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
176
|
+
|
|
177
|
+
if (isBrowser() && props.debug) {
|
|
178
|
+
this.gl = makeDebugContext(this.gl, { ...props,
|
|
179
|
+
webgl2: this.isWebGL2,
|
|
180
|
+
throwOnError: true
|
|
181
|
+
});
|
|
182
|
+
this.gl2 = this.gl;
|
|
183
|
+
this.debug = true;
|
|
184
|
+
log.level = Math.max(log.level, 1);
|
|
185
|
+
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (isBrowser() && props.spector) {
|
|
189
|
+
const canvas = this.handle.canvas || props.canvas;
|
|
190
|
+
this.spector = initializeSpectorJS({ ...this.props,
|
|
191
|
+
canvas
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const message = "Created ".concat(this.info.type).concat(this.debug ? ' debug' : '', " context: ").concat(this.info.vendor, ", ").concat(this.info.renderer, " for canvas: ").concat(this.canvasContext.id);
|
|
196
|
+
log.probe(LOG_LEVEL, message)();
|
|
148
197
|
log.groupEnd(LOG_LEVEL)();
|
|
149
|
-
this._state = 'initialized';
|
|
150
198
|
}
|
|
151
199
|
|
|
152
200
|
destroy() {
|
|
153
|
-
|
|
201
|
+
const ext = this.gl.getExtension('STACKGL_destroy_context');
|
|
154
202
|
|
|
155
203
|
if (ext) {
|
|
156
204
|
ext.destroy();
|
|
157
205
|
}
|
|
158
206
|
}
|
|
159
207
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
setDevicePixelRatio(this.gl, devicePixelRatio, options);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
208
|
+
get isLost() {
|
|
209
|
+
return this.gl.isContextLost();
|
|
210
|
+
}
|
|
166
211
|
|
|
167
|
-
|
|
212
|
+
getSize() {
|
|
213
|
+
return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
|
|
214
|
+
}
|
|
168
215
|
|
|
169
|
-
|
|
170
|
-
|
|
216
|
+
isTextureFormatSupported(format) {
|
|
217
|
+
return isTextureFormatSupported(this.gl, format);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
isTextureFormatFilterable(format) {
|
|
221
|
+
return isTextureFormatFilterable(this.gl, format);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
isTextureFormatRenderable(format) {
|
|
225
|
+
return isTextureFormatRenderable(this.gl, format);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
assertWebGL2() {
|
|
229
|
+
if (!this.gl2) {
|
|
230
|
+
throw new Error('Requires WebGL2');
|
|
171
231
|
}
|
|
232
|
+
|
|
233
|
+
return this.gl2;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
createCanvasContext(props) {
|
|
237
|
+
throw new Error('WebGL only supports a single canvas');
|
|
172
238
|
}
|
|
173
239
|
|
|
174
240
|
_createBuffer(props) {
|
|
175
|
-
return new
|
|
241
|
+
return new ClassicBuffer(this, props);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
_createTexture(props) {
|
|
245
|
+
return new WEBGLTexture(this, props);
|
|
176
246
|
}
|
|
177
247
|
|
|
178
|
-
|
|
179
|
-
|
|
248
|
+
createExternalTexture(props) {
|
|
249
|
+
throw new Error('createExternalTexture() not implemented');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
createSampler(props) {
|
|
253
|
+
return new WEBGLSampler(this, props);
|
|
180
254
|
}
|
|
181
255
|
|
|
182
256
|
createShader(props) {
|
|
183
257
|
return new WEBGLShader(this, props);
|
|
184
258
|
}
|
|
185
259
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
this.gl.commit();
|
|
189
|
-
}
|
|
260
|
+
createFramebuffer(props) {
|
|
261
|
+
return new WEBGLFramebuffer(this, props);
|
|
190
262
|
}
|
|
191
263
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
264
|
+
createRenderPipeline(props) {
|
|
265
|
+
return new WEBGLRenderPipeline(this, props);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
beginRenderPass(props) {
|
|
269
|
+
return new WEBGLRenderPass(this, props);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
createComputePipeline(props) {
|
|
273
|
+
throw new Error('ComputePipeline not supported in WebGL');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
beginComputePass(props) {
|
|
277
|
+
throw new Error('compute shaders not supported in WebGL');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
getDefaultRenderPass() {
|
|
281
|
+
this.renderPass = this.renderPass || this.beginRenderPass({
|
|
282
|
+
framebuffer: this.canvasContext.getCurrentFramebuffer()
|
|
283
|
+
});
|
|
284
|
+
return this.renderPass;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
submit() {
|
|
288
|
+
var _this$renderPass;
|
|
289
|
+
|
|
290
|
+
(_this$renderPass = this.renderPass) === null || _this$renderPass === void 0 ? void 0 : _this$renderPass.endPass();
|
|
291
|
+
this.renderPass = null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
get webglLimits() {
|
|
295
|
+
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
296
|
+
return this._webglLimits;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
loseDevice() {
|
|
300
|
+
var _this$_resolveContext2;
|
|
301
|
+
|
|
302
|
+
const ext = this.gl.getExtension('WEBGL_lose_context');
|
|
303
|
+
|
|
304
|
+
if (ext) {
|
|
305
|
+
ext.loseContext();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
(_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
|
|
309
|
+
reason: 'destroyed',
|
|
310
|
+
message: 'Application triggered context loss'
|
|
202
311
|
});
|
|
203
|
-
return createBrowserContext(targetCanvas, options);
|
|
204
312
|
}
|
|
205
313
|
|
|
314
|
+
pushState() {
|
|
315
|
+
pushContextState(this.gl);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
popState() {
|
|
319
|
+
popContextState(this.gl);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
_defineProperty(WebGLDevice, "type", 'webgl');
|
|
325
|
+
|
|
326
|
+
function isWebGL(gl) {
|
|
327
|
+
if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return Boolean(gl && Number.isFinite(gl._version));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function isWebGL2(gl) {
|
|
339
|
+
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return Boolean(gl && gl._version === 2);
|
|
206
344
|
}
|
|
207
345
|
//# sourceMappingURL=webgl-device.js.map
|
|
@@ -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","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,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;A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C,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"}
|
|
1
|
+
{"version":3,"sources":["../../src/adapter/webgl-device.ts"],"names":["Device","CanvasContext","log","isBrowser","polyfillContext","popContextState","pushContextState","trackContextState","createBrowserContext","createHeadlessContext","isHeadlessGLRegistered","getDeviceInfo","getDeviceFeatures","getDeviceLimits","getWebGLLimits","WebGLCanvasContext","loadSpectorJS","initializeSpectorJS","loadWebGLDeveloperTools","makeDebugContext","isTextureFormatSupported","isTextureFormatRenderable","isTextureFormatFilterable","ClassicBuffer","WEBGLShader","WEBGLSampler","WEBGLTexture","WEBGLFramebuffer","WEBGLRenderPass","WEBGLRenderPipeline","LOG_LEVEL","counter","WebGLDevice","isSupported","WebGLRenderingContext","features","_features","gl","limits","_limits","attach","device","isWebGL","Error","create","props","groupCollapsed","canvas","pageLoaded","debug","spector","probe","constructor","clientWidth","clientHeight","devicePixelRatio","id","canvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","args","webgl2","throwOnError","level","Math","max","warn","type","vendor","renderer","groupEnd","destroy","ext","getExtension","isLost","isContextLost","getSize","drawingBufferWidth","drawingBufferHeight","format","assertWebGL2","createCanvasContext","_createBuffer","_createTexture","createExternalTexture","createSampler","createShader","createFramebuffer","createRenderPipeline","beginRenderPass","createComputePipeline","beginComputePass","getDefaultRenderPass","renderPass","framebuffer","getCurrentFramebuffer","submit","endPass","webglLimits","_webglLimits","loseDevice","loseContext","pushState","popState","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";AASA,SAAQA,MAAR,EAAgBC,aAAhB,EAA+BC,GAA/B,QAAiD,cAAjD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,eAAR,QAA8B,sCAA9B;AACA,SAAQC,eAAR,EAAyBC,gBAAzB,EAA2CC,iBAA3C,QAAmE,8CAAnE;AAEA,SAAQC,oBAAR,QAAmC,2CAAnC;AACA,SACEC,qBADF,EAEEC,sBAFF,QAGO,4CAHP;AAIA,SAAQC,aAAR,QAA4B,kCAA5B;AACA,SAAQC,iBAAR,QAAgC,kCAAhC;AACA,SAAQC,eAAR,EAAyBC,cAAzB,QAA2D,gCAA3D;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;AACA,SAAQC,aAAR,EAAuBC,mBAAvB,QAAiD,0BAAjD;AACA,SAAQC,uBAAR,EAAiCC,gBAAjC,QAAwD,wCAAxD;AACA,SACEC,wBADF,EAEEC,yBAFF,EAGEC,yBAHF,QAIO,8BAJP;AA0BA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AACA,OAAOC,eAAP,MAA4B,+BAA5B;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AAEA,MAAMC,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;AAGA,eAAe,MAAMC,WAAN,SAA0BhC,MAA1B,CAAyD;AAOpD,SAAXiC,WAAW,GAAY;AAC5B,WAAO,OAAOC,qBAAP,KAAiC,WAAj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C,MAAAA,OAAO,EAAE;AAFgB,KAA3B;AAID;;AAGDmD,EAAAA,SAAS,GAAS;AAChB9G,IAAAA,gBAAgB,CAAC,KAAK+B,EAAN,CAAhB;AACD;;AAGDgF,EAAAA,QAAQ,GAAS;AACfhH,IAAAA,eAAe,CAAC,KAAKgC,EAAN,CAAf;AACD;;AAlVqE;;gBAAnDL,W,UAKG,O;;AAiVxB,SAASU,OAAT,CAAiBL,EAAjB,EAAmC;AACjC,MAAI,OAAOH,qBAAP,KAAiC,WAAjC,IAAgDG,EAAE,YAAYH,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOoF,sBAAP,KAAkC,WAAlC,IAAiDjF,EAAE,YAAYiF,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAClF,EAAE,IAAImF,MAAM,CAACC,QAAP,CAAgBpF,EAAE,CAACkC,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkB/B,EAAlB,EAAoC;AAClC,MAAI,OAAOiF,sBAAP,KAAkC,WAAlC,IAAiDjF,EAAE,YAAYiF,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAAClF,EAAE,IAAIA,EAAE,CAACkC,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {popContextState, pushContextState, trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport WebGLCanvasContext from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps\n} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\nimport WEBGLBuffer from './resources/webgl-buffer';\nimport WEBGLShader from './resources/webgl-shader';\nimport WEBGLSampler from './resources/webgl-sampler';\nimport WEBGLTexture from './resources/webgl-texture';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\nimport WEBGLRenderPass from './resources/webgl-render-pass';\nimport WEBGLRenderPipeline from './resources/webgl-render-pipeline';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>((resolve) => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy() {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new ClassicBuffer(this, props);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits() : WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n * @todo Promote to `Device` API?\n */\n loseDevice(): void {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n"],"file":"webgl-device.js"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Buffer, AccessorObject } from '@luma.gl/api';
|
|
2
|
+
import GL from '@luma.gl/constants';
|
|
3
|
+
declare const DEFAULT_ACCESSOR_VALUES: {
|
|
4
|
+
offset: number;
|
|
5
|
+
stride: number;
|
|
6
|
+
type: GL;
|
|
7
|
+
size: number;
|
|
8
|
+
divisor: number;
|
|
9
|
+
normalized: boolean;
|
|
10
|
+
integer: boolean;
|
|
11
|
+
};
|
|
12
|
+
export default class Accessor implements AccessorObject {
|
|
13
|
+
offset?: number;
|
|
14
|
+
stride?: number;
|
|
15
|
+
type?: number;
|
|
16
|
+
size?: number;
|
|
17
|
+
divisor?: number;
|
|
18
|
+
normalized?: boolean;
|
|
19
|
+
integer?: boolean;
|
|
20
|
+
buffer?: Buffer;
|
|
21
|
+
index?: number;
|
|
22
|
+
static getBytesPerElement(accessor: Accessor | AccessorObject): number;
|
|
23
|
+
static getBytesPerVertex(accessor: AccessorObject): number;
|
|
24
|
+
static resolve(...accessors: AccessorObject[]): Accessor;
|
|
25
|
+
constructor(...accessors: AccessorObject[]);
|
|
26
|
+
toString(): string;
|
|
27
|
+
get BYTES_PER_ELEMENT(): number;
|
|
28
|
+
get BYTES_PER_VERTEX(): number;
|
|
29
|
+
_assign(props?: AccessorObject): this;
|
|
30
|
+
}
|
|
31
|
+
export { DEFAULT_ACCESSOR_VALUES };
|
|
32
|
+
//# sourceMappingURL=accessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../src/classic/accessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGpC,QAAA,MAAM,uBAAuB;;;;;;;;CAQ5B,CAAC;AASF,MAAM,CAAC,OAAO,OAAO,QAAS,YAAW,cAAc;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,MAAM;IAOtE,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAY1D,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,GAAG,QAAQ;gBAI5C,GAAG,SAAS,EAAE,cAAc,EAAE;IAK1C,QAAQ,IAAI,MAAM;IAOlB,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAKD,OAAO,CAAC,KAAK,GAAE,cAAmB,GAAG,IAAI;CA6E1C;AAGD,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
|