@luma.gl/webgl 9.1.0-beta.9 → 9.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.js +14 -9
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/shader-formats.d.ts +67 -8
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +82 -52
- package/dist/adapter/converters/shader-formats.js.map +1 -1
- package/dist/adapter/converters/webgl-shadertypes.d.ts +20 -0
- package/dist/adapter/converters/webgl-shadertypes.d.ts.map +1 -0
- package/dist/adapter/converters/webgl-shadertypes.js +123 -0
- package/dist/adapter/converters/webgl-shadertypes.js.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.js +6 -6
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
- package/dist/adapter/converters/{vertex-formats.d.ts → webgl-vertex-formats.d.ts} +4 -4
- package/dist/adapter/converters/webgl-vertex-formats.d.ts.map +1 -0
- package/dist/adapter/converters/{vertex-formats.js → webgl-vertex-formats.js} +1 -1
- package/dist/adapter/converters/webgl-vertex-formats.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -1
- package/dist/adapter/helpers/format-utils.d.ts +3 -2
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/format-utils.js.map +1 -1
- package/dist/adapter/helpers/{get-shader-layout.d.ts → get-shader-layout-from-glsl.d.ts} +1 -1
- package/dist/adapter/helpers/get-shader-layout-from-glsl.d.ts.map +1 -0
- package/dist/adapter/helpers/{get-shader-layout.js → get-shader-layout-from-glsl.js} +12 -35
- package/dist/adapter/helpers/get-shader-layout-from-glsl.js.map +1 -0
- package/dist/adapter/helpers/set-uniform.d.ts +2 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +2 -25
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +10 -99
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +5 -3
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +4 -4
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts +6 -2
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +9 -4
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-external-texture.js +1 -0
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +2 -2
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-query-set.js +5 -1
- package/dist/adapter/resources/webgl-query-set.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +11 -6
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +3 -3
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +27 -24
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +9 -2
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture-view.js +1 -1
- package/dist/adapter/resources/webgl-texture-view.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +21 -66
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +148 -319
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +3 -2
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts +4 -3
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +16 -7
- package/dist/adapter/webgl-adapter.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +3 -24
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +5 -44
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +17 -20
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +30 -28
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/context/debug/spector-types.d.ts.map +1 -1
- package/dist/context/debug/spector-types.js +3 -0
- package/dist/context/debug/spector-types.js.map +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -1
- package/dist/context/helpers/webgl-extensions.js +3 -0
- package/dist/context/helpers/webgl-extensions.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -0
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +1 -0
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -1
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.d.ts +2 -1
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +4 -5
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -1
- package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -1
- package/dist/context/state-tracker/webgl-state-tracker.js +4 -1
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/dist.dev.js +4720 -4771
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +3849 -3938
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +19 -9
- package/src/adapter/converters/shader-formats.ts +50 -24
- package/src/adapter/converters/webgl-shadertypes.ts +152 -0
- package/src/adapter/converters/webgl-texture-table.ts +9 -9
- package/src/adapter/converters/{vertex-formats.ts → webgl-vertex-formats.ts} +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +1 -1
- package/src/adapter/device-helpers/webgl-device-limits.ts +1 -1
- package/src/adapter/helpers/format-utils.ts +2 -2
- package/src/adapter/helpers/{get-shader-layout.ts → get-shader-layout-from-glsl.ts} +20 -50
- package/src/adapter/helpers/set-uniform.ts +2 -2
- package/src/adapter/helpers/webgl-texture-utils.ts +12 -127
- package/src/adapter/resources/webgl-buffer.ts +5 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +17 -8
- package/src/adapter/resources/webgl-framebuffer.ts +2 -2
- package/src/adapter/resources/webgl-query-set.ts +5 -1
- package/src/adapter/resources/webgl-render-pass.ts +15 -9
- package/src/adapter/resources/webgl-render-pipeline.ts +32 -35
- package/src/adapter/resources/webgl-sampler.ts +1 -1
- package/src/adapter/resources/webgl-shader.ts +11 -2
- package/src/adapter/resources/webgl-texture-view.ts +1 -1
- package/src/adapter/resources/webgl-texture.ts +180 -393
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -2
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-adapter.ts +20 -8
- package/src/adapter/webgl-canvas-context.ts +7 -47
- package/src/adapter/webgl-device.ts +46 -41
- package/src/context/debug/spector-types.ts +5 -0
- package/src/context/debug/spector.ts +1 -1
- package/src/context/debug/webgl-developer-tools.ts +8 -3
- package/src/context/helpers/webgl-extensions.ts +3 -0
- package/src/context/parameters/unified-parameter-api.ts +9 -2
- package/src/context/parameters/webgl-parameter-tables.ts +2 -0
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +1 -0
- package/src/context/state-tracker/deep-array-equal.ts +11 -6
- package/src/context/state-tracker/webgl-state-tracker.ts +5 -1
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +1 -5
- package/dist/adapter/converters/vertex-formats.d.ts.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.d.ts +0 -26
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js +0 -102
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/typed-array-utils.d.ts +0 -44
- package/dist/adapter/helpers/typed-array-utils.d.ts.map +0 -1
- package/dist/adapter/helpers/typed-array-utils.js +0 -107
- package/dist/adapter/helpers/typed-array-utils.js.map +0 -1
- package/dist/deprecated/accessor.d.ts +0 -53
- package/dist/deprecated/accessor.d.ts.map +0 -1
- package/dist/deprecated/accessor.js +0 -177
- package/dist/deprecated/accessor.js.map +0 -1
- package/dist/utils/split-uniforms-and-bindings.d.ts +0 -9
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +0 -1
- package/dist/utils/split-uniforms-and-bindings.js +0 -21
- package/dist/utils/split-uniforms-and-bindings.js.map +0 -1
- package/src/adapter/helpers/decode-webgl-types.ts +0 -134
- package/src/adapter/helpers/typed-array-utils.ts +0 -129
- package/src/deprecated/accessor.ts +0 -225
- package/src/utils/split-uniforms-and-bindings.ts +0 -31
package/dist/index.d.ts
CHANGED
|
@@ -13,10 +13,8 @@ export { WEBGLCommandEncoder } from "./adapter/resources/webgl-command-encoder.j
|
|
|
13
13
|
export { WEBGLRenderPass } from "./adapter/resources/webgl-render-pass.js";
|
|
14
14
|
export { WEBGLVertexArray } from "./adapter/resources/webgl-vertex-array.js";
|
|
15
15
|
export { WEBGLTransformFeedback } from "./adapter/resources/webgl-transform-feedback.js";
|
|
16
|
-
export { Accessor } from "./deprecated/accessor.js";
|
|
17
|
-
export type { AccessorObject } from "./types.js";
|
|
18
16
|
export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
|
|
19
|
-
export { getShaderLayoutFromGLSL } from "./adapter/helpers/get-shader-layout.js";
|
|
17
|
+
export { getShaderLayoutFromGLSL } from "./adapter/helpers/get-shader-layout-from-glsl.js";
|
|
20
18
|
export { WebGLStateTracker } from "./context/state-tracker/webgl-state-tracker.js";
|
|
21
19
|
export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.js";
|
|
22
20
|
export { withGLParameters } from "./context/state-tracker/with-parameters.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,aAAa,EAAC,mCAAgC;AACtD,YAAY,EAAC,YAAY,EAAC,mCAAgC;AAG1D,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAGlE,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAE/D,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAE9E,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,OAAO,EAAC,aAAa,EAAC,mCAAgC;AACtD,YAAY,EAAC,YAAY,EAAC,mCAAgC;AAG1D,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAGlE,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAE/D,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAE9E,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AAEtE,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAGxE,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAIpF,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAGjG,OAAO,EAAC,uBAAuB,EAAC,yDAAsD;AACtF,OAAO,EAAC,iBAAiB,EAAC,uDAAoD;AAG9E,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
|
package/dist/index.js
CHANGED
|
@@ -21,12 +21,10 @@ export { WEBGLRenderPass } from "./adapter/resources/webgl-render-pass.js";
|
|
|
21
21
|
export { WEBGLVertexArray } from "./adapter/resources/webgl-vertex-array.js";
|
|
22
22
|
// WebGL adapter classes
|
|
23
23
|
export { WEBGLTransformFeedback } from "./adapter/resources/webgl-transform-feedback.js";
|
|
24
|
-
// WebGL adapter classes
|
|
25
|
-
export { Accessor } from "./deprecated/accessor.js";
|
|
26
24
|
// Unified parameter API
|
|
27
25
|
export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
|
|
28
26
|
// HELPERS - EXPERIMENTAL
|
|
29
|
-
export { getShaderLayoutFromGLSL } from "./adapter/helpers/get-shader-layout.js";
|
|
27
|
+
export { getShaderLayoutFromGLSL } from "./adapter/helpers/get-shader-layout-from-glsl.js";
|
|
30
28
|
export { WebGLStateTracker } from "./context/state-tracker/webgl-state-tracker.js";
|
|
31
29
|
// DEPRECATED TEST EXPORTS
|
|
32
30
|
export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAWpC,wBAAwB;AACxB,OAAO,EAAC,aAAa,EAAC,mCAAgC;AAGtD,uBAAuB;AACvB,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAElE,yBAAyB;AACzB,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,mFAAmF;AACnF,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,mFAAmF;AACnF,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AACtE,2EAA2E;AAC3E,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAExE,wBAAwB;AACxB,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAEpF,wBAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAWpC,wBAAwB;AACxB,OAAO,EAAC,aAAa,EAAC,mCAAgC;AAGtD,uBAAuB;AACvB,OAAO,EAAC,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAElE,yBAAyB;AACzB,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,mFAAmF;AACnF,OAAO,EAAC,WAAW,EAAC,4CAAyC;AAC7D,OAAO,EAAC,YAAY,EAAC,6CAA0C;AAC/D,OAAO,EAAC,gBAAgB,EAAC,iDAA8C;AAEvE,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,mFAAmF;AACnF,OAAO,EAAC,mBAAmB,EAAC,qDAAkD;AAC9E,OAAO,EAAC,eAAe,EAAC,iDAA8C;AACtE,2EAA2E;AAC3E,OAAO,EAAC,gBAAgB,EAAC,kDAA+C;AAExE,wBAAwB;AACxB,OAAO,EAAC,sBAAsB,EAAC,wDAAqD;AAEpF,wBAAwB;AAExB,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAEjG,yBAAyB;AACzB,OAAO,EAAC,uBAAuB,EAAC,yDAAsD;AACtF,OAAO,EAAC,iBAAiB,EAAC,uDAAoD;AAE9E,0BAA0B;AAC1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0-alpha.1",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "
|
|
43
|
+
"@luma.gl/core": "9.2.0-alpha.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.
|
|
46
|
+
"@luma.gl/constants": "9.2.0-alpha.1",
|
|
47
47
|
"@math.gl/types": "^4.1.0",
|
|
48
48
|
"@probe.gl/env": "^4.0.8"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "d6d2f791f2ce96f4b5acb68e05faea62c35440fb"
|
|
51
51
|
}
|
|
@@ -395,23 +395,33 @@ function convertBlendOperationToEquation(
|
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
function convertBlendFactorToFunction(
|
|
398
|
+
function convertBlendFactorToFunction(
|
|
399
|
+
parameter: string,
|
|
400
|
+
value: BlendFactor,
|
|
401
|
+
type: 'color' | 'alpha' = 'color'
|
|
402
|
+
): GLBlendFunction {
|
|
399
403
|
return map<BlendFactor, GLBlendFunction>(parameter, value, {
|
|
400
404
|
one: GL.ONE,
|
|
401
405
|
zero: GL.ZERO,
|
|
402
|
-
|
|
403
|
-
'one-minus-src
|
|
404
|
-
|
|
405
|
-
'one-minus-dst
|
|
406
|
+
src: GL.SRC_COLOR,
|
|
407
|
+
'one-minus-src': GL.ONE_MINUS_SRC_COLOR,
|
|
408
|
+
dst: GL.DST_COLOR,
|
|
409
|
+
'one-minus-dst': GL.ONE_MINUS_DST_COLOR,
|
|
406
410
|
'src-alpha': GL.SRC_ALPHA,
|
|
407
411
|
'one-minus-src-alpha': GL.ONE_MINUS_SRC_ALPHA,
|
|
408
412
|
'dst-alpha': GL.DST_ALPHA,
|
|
409
413
|
'one-minus-dst-alpha': GL.ONE_MINUS_DST_ALPHA,
|
|
410
414
|
'src-alpha-saturated': GL.SRC_ALPHA_SATURATE,
|
|
411
|
-
'
|
|
412
|
-
'one-minus-constant
|
|
413
|
-
|
|
414
|
-
'
|
|
415
|
+
constant: type === 'color' ? GL.CONSTANT_COLOR : GL.CONSTANT_ALPHA,
|
|
416
|
+
'one-minus-constant':
|
|
417
|
+
type === 'color' ? GL.ONE_MINUS_CONSTANT_COLOR : GL.ONE_MINUS_CONSTANT_ALPHA,
|
|
418
|
+
// 'constant-alpha': GL.CONSTANT_ALPHA,
|
|
419
|
+
// 'one-minus-constant-alpha': GL.ONE_MINUS_CONSTANT_ALPHA,
|
|
420
|
+
// TODO not supported in WebGL2
|
|
421
|
+
src1: GL.SRC_COLOR,
|
|
422
|
+
'one-minus-src1': GL.ONE_MINUS_SRC_COLOR,
|
|
423
|
+
'src1-alpha': GL.SRC_ALPHA,
|
|
424
|
+
'one-minus-src1-alpha': GL.ONE_MINUS_SRC_ALPHA
|
|
415
425
|
});
|
|
416
426
|
}
|
|
417
427
|
|
|
@@ -2,31 +2,35 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {GL} from '@luma.gl/constants';
|
|
6
|
-
import {
|
|
5
|
+
import {GL, GLDataType, GLPixelType} from '@luma.gl/constants';
|
|
6
|
+
import {SignedDataType} from '@luma.gl/core';
|
|
7
7
|
|
|
8
|
-
/** Get
|
|
9
|
-
export function
|
|
10
|
-
type
|
|
11
|
-
components: 1 | 2 | 3 | 4
|
|
12
|
-
): ShaderAttributeType {
|
|
13
|
-
const dataType = getShaderDataTypeFromGL(type);
|
|
14
|
-
switch (components) {
|
|
15
|
-
case 1:
|
|
16
|
-
return dataType;
|
|
17
|
-
case 2:
|
|
18
|
-
return `vec2<${dataType}>`;
|
|
19
|
-
case 3:
|
|
20
|
-
return `vec2<${dataType}>`;
|
|
21
|
-
case 4:
|
|
22
|
-
return `vec2<${dataType}>`;
|
|
23
|
-
default:
|
|
24
|
-
throw new Error(String(components));
|
|
25
|
-
}
|
|
8
|
+
/** Get shadertypes data type from GL constants */
|
|
9
|
+
export function convertGLDataTypeToDataType(type: GLDataType | GLPixelType): SignedDataType {
|
|
10
|
+
return GL_DATA_TYPE_MAP[type];
|
|
26
11
|
}
|
|
27
12
|
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const GL_DATA_TYPE_MAP: Record<GLDataType | GLPixelType, SignedDataType> = {
|
|
14
|
+
[GL.INT]: 'sint32',
|
|
15
|
+
[GL.UNSIGNED_INT]: 'uint32',
|
|
16
|
+
[GL.SHORT]: 'sint16',
|
|
17
|
+
[GL.UNSIGNED_SHORT]: 'uint16',
|
|
18
|
+
[GL.BYTE]: 'sint8',
|
|
19
|
+
[GL.UNSIGNED_BYTE]: 'uint8',
|
|
20
|
+
[GL.FLOAT]: 'float32',
|
|
21
|
+
[GL.HALF_FLOAT]: 'float16',
|
|
22
|
+
[GL.UNSIGNED_SHORT_5_6_5]: 'uint16',
|
|
23
|
+
[GL.UNSIGNED_SHORT_4_4_4_4]: 'uint16',
|
|
24
|
+
[GL.UNSIGNED_SHORT_5_5_5_1]: 'uint16',
|
|
25
|
+
[GL.UNSIGNED_INT_2_10_10_10_REV]: 'uint32',
|
|
26
|
+
[GL.UNSIGNED_INT_10F_11F_11F_REV]: 'uint32',
|
|
27
|
+
[GL.UNSIGNED_INT_5_9_9_9_REV]: 'uint32',
|
|
28
|
+
[GL.UNSIGNED_INT_24_8]: 'uint32',
|
|
29
|
+
[GL.FLOAT_32_UNSIGNED_INT_24_8_REV]: 'uint32'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Get shader data type from GL constants *
|
|
33
|
+
export function getPrimitiveTypeFromGL(type: GL): PrimitiveDataType {
|
|
30
34
|
switch (type) {
|
|
31
35
|
case GL.INT:
|
|
32
36
|
return 'i32';
|
|
@@ -49,9 +53,30 @@ export function getShaderDataTypeFromGL(type: GL): ShaderDataType {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
/**
|
|
56
|
+
/** Get shader attribute type from GL constants *
|
|
57
|
+
export function getShaderAttributeTypeFromGL(
|
|
58
|
+
type: GL,
|
|
59
|
+
components: 1 | 2 | 3 | 4
|
|
60
|
+
): AttributeShaderType {
|
|
61
|
+
const dataType = getPrimitiveTypeFromGL(type);
|
|
62
|
+
switch (components) {
|
|
63
|
+
case 1:
|
|
64
|
+
return dataType;
|
|
65
|
+
case 2:
|
|
66
|
+
return `vec2<${dataType}>`;
|
|
67
|
+
case 3:
|
|
68
|
+
return `vec2<${dataType}>`;
|
|
69
|
+
case 4:
|
|
70
|
+
return `vec2<${dataType}>`;
|
|
71
|
+
default:
|
|
72
|
+
throw new Error(String(components));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/** GetGL constant from shader data type
|
|
53
78
|
export function getGLFromShaderDataType(
|
|
54
|
-
type:
|
|
79
|
+
type: PrimitiveDataType
|
|
55
80
|
): GL.INT | GL.UNSIGNED_INT | GL.FLOAT | GL.HALF_FLOAT {
|
|
56
81
|
switch (type) {
|
|
57
82
|
// TODO
|
|
@@ -67,3 +92,4 @@ export function getGLFromShaderDataType(
|
|
|
67
92
|
throw new Error(String(type));
|
|
68
93
|
}
|
|
69
94
|
}
|
|
95
|
+
*/
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {VariableShaderType, SignedDataType, VertexFormat, NormalizedDataType} from '@luma.gl/core';
|
|
6
|
+
import {GL, GLUniformType, GLSamplerType, GLDataType} from '@luma.gl/constants';
|
|
7
|
+
|
|
8
|
+
export type TextureBindingInfo = {
|
|
9
|
+
viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
10
|
+
sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Converts to a luma shadertype to a GL data type (GL.BYTE, GL.FLOAT32 etc) */
|
|
14
|
+
export function convertDataTypeToGLDataType(normalizedType: NormalizedDataType): GLDataType {
|
|
15
|
+
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Converts to a luma shadertype to a GL data type (GL.BYTE, GL.FLOAT32 etc) */
|
|
19
|
+
export function convertShaderVariableTypeToGLDataType(
|
|
20
|
+
normalizedType: VariableShaderType
|
|
21
|
+
): GLDataType {
|
|
22
|
+
// @ts-ignore TODO
|
|
23
|
+
return NORMALIZED_SHADER_TYPE_TO_WEBGL[normalizedType];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Convert a WebGL "compisite type (e.g. GL.VEC3) into the corresponding luma shader uniform type */
|
|
27
|
+
export function convertGLUniformTypeToShaderVariableType(
|
|
28
|
+
glUniformType: GLUniformType
|
|
29
|
+
): VariableShaderType {
|
|
30
|
+
return WEBGL_SHADER_TYPES[glUniformType];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Check if a WebGL "uniform:" is a texture binding */
|
|
34
|
+
export function isGLSamplerType(type: GLUniformType | GLSamplerType): type is GLSamplerType {
|
|
35
|
+
// @ts-ignore TODO
|
|
36
|
+
return Boolean(WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[type]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Get luma texture binding info (viewDimension and sampleType) from a WebGL "sampler" binding */
|
|
40
|
+
export function getTextureBindingFromGLSamplerType(
|
|
41
|
+
glSamplerType: GLSamplerType
|
|
42
|
+
): TextureBindingInfo {
|
|
43
|
+
return WEBGL_SAMPLER_TO_TEXTURE_BINDINGS[glSamplerType];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Get vertex format from GL constants */
|
|
47
|
+
export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 | 4): VertexFormat {
|
|
48
|
+
const base = getVertexTypeFromGL(type);
|
|
49
|
+
// prettier-ignore
|
|
50
|
+
switch (components) {
|
|
51
|
+
// @ts-expect-error TODO deal with lack of formats
|
|
52
|
+
case 1: return base;
|
|
53
|
+
case 2: return `${base}x2`;
|
|
54
|
+
// @ts-expect-error TODO deal with lack of formats
|
|
55
|
+
case 3: return `${base}x3`;
|
|
56
|
+
case 4: return `${base}x4`;
|
|
57
|
+
}
|
|
58
|
+
// @ts-ignore unreachable
|
|
59
|
+
throw new Error(String(components));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Get data type from GL constants */
|
|
63
|
+
export function getVertexTypeFromGL(glType: GLDataType, normalized = false): NormalizedDataType {
|
|
64
|
+
const index = normalized ? 1 : 0;
|
|
65
|
+
return WEBGL_TO_NORMALIZED_DATA_TYPE[glType][index];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Composite types table
|
|
69
|
+
// @ts-ignore TODO - fix the type confusion here
|
|
70
|
+
const WEBGL_SHADER_TYPES: Record<GLUniformType, VariableShaderType> = {
|
|
71
|
+
[GL.FLOAT]: 'f32',
|
|
72
|
+
[GL.FLOAT_VEC2]: 'vec2<f32>',
|
|
73
|
+
[GL.FLOAT_VEC3]: 'vec3<f32>',
|
|
74
|
+
[GL.FLOAT_VEC4]: 'vec4<f32>',
|
|
75
|
+
|
|
76
|
+
[GL.INT]: 'i32',
|
|
77
|
+
[GL.INT_VEC2]: 'vec2<i32>',
|
|
78
|
+
[GL.INT_VEC3]: 'vec3<i32>',
|
|
79
|
+
[GL.INT_VEC4]: 'vec4<i32>',
|
|
80
|
+
|
|
81
|
+
[GL.UNSIGNED_INT]: 'u32',
|
|
82
|
+
[GL.UNSIGNED_INT_VEC2]: 'vec2<u32>',
|
|
83
|
+
[GL.UNSIGNED_INT_VEC3]: 'vec3<u32>',
|
|
84
|
+
[GL.UNSIGNED_INT_VEC4]: 'vec4<u32>',
|
|
85
|
+
|
|
86
|
+
[GL.BOOL]: 'f32',
|
|
87
|
+
[GL.BOOL_VEC2]: 'vec2<f32>',
|
|
88
|
+
[GL.BOOL_VEC3]: 'vec3<f32>',
|
|
89
|
+
[GL.BOOL_VEC4]: 'vec4<f32>',
|
|
90
|
+
|
|
91
|
+
// TODO - are sizes/components below correct?
|
|
92
|
+
[GL.FLOAT_MAT2]: 'mat2x2<f32>',
|
|
93
|
+
[GL.FLOAT_MAT2x3]: 'mat2x3<f32>',
|
|
94
|
+
[GL.FLOAT_MAT2x4]: 'mat2x4<f32>',
|
|
95
|
+
|
|
96
|
+
[GL.FLOAT_MAT3x2]: 'mat3x2<f32>',
|
|
97
|
+
[GL.FLOAT_MAT3]: 'mat3x3<f32>',
|
|
98
|
+
[GL.FLOAT_MAT3x4]: 'mat3x4<f32>',
|
|
99
|
+
|
|
100
|
+
[GL.FLOAT_MAT4x2]: 'mat4x2<f32>',
|
|
101
|
+
[GL.FLOAT_MAT4x3]: 'mat4x3<f32>',
|
|
102
|
+
[GL.FLOAT_MAT4]: 'mat4x4<f32>'
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const WEBGL_SAMPLER_TO_TEXTURE_BINDINGS: Record<GLSamplerType, TextureBindingInfo> = {
|
|
106
|
+
[GL.SAMPLER_2D]: {viewDimension: '2d', sampleType: 'float'},
|
|
107
|
+
[GL.SAMPLER_CUBE]: {viewDimension: 'cube', sampleType: 'float'},
|
|
108
|
+
[GL.SAMPLER_3D]: {viewDimension: '3d', sampleType: 'float'},
|
|
109
|
+
[GL.SAMPLER_2D_SHADOW]: {viewDimension: '3d', sampleType: 'depth'},
|
|
110
|
+
[GL.SAMPLER_2D_ARRAY]: {viewDimension: '2d-array', sampleType: 'float'},
|
|
111
|
+
[GL.SAMPLER_2D_ARRAY_SHADOW]: {viewDimension: '2d-array', sampleType: 'depth'},
|
|
112
|
+
[GL.SAMPLER_CUBE_SHADOW]: {viewDimension: 'cube', sampleType: 'float'},
|
|
113
|
+
[GL.INT_SAMPLER_2D]: {viewDimension: '2d', sampleType: 'sint'},
|
|
114
|
+
[GL.INT_SAMPLER_3D]: {viewDimension: '3d', sampleType: 'sint'},
|
|
115
|
+
[GL.INT_SAMPLER_CUBE]: {viewDimension: 'cube', sampleType: 'sint'},
|
|
116
|
+
[GL.INT_SAMPLER_2D_ARRAY]: {viewDimension: '2d-array', sampleType: 'uint'},
|
|
117
|
+
[GL.UNSIGNED_INT_SAMPLER_2D]: {viewDimension: '2d', sampleType: 'uint'},
|
|
118
|
+
[GL.UNSIGNED_INT_SAMPLER_3D]: {viewDimension: '3d', sampleType: 'uint'},
|
|
119
|
+
[GL.UNSIGNED_INT_SAMPLER_CUBE]: {viewDimension: 'cube', sampleType: 'uint'},
|
|
120
|
+
[GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: {viewDimension: '2d-array', sampleType: 'uint'}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** Map from WebGL normalized types to WebGL */
|
|
124
|
+
const NORMALIZED_SHADER_TYPE_TO_WEBGL: Record<NormalizedDataType, GLDataType> = {
|
|
125
|
+
uint8: GL.UNSIGNED_BYTE,
|
|
126
|
+
sint8: GL.BYTE,
|
|
127
|
+
unorm8: GL.UNSIGNED_BYTE,
|
|
128
|
+
snorm8: GL.BYTE,
|
|
129
|
+
uint16: GL.UNSIGNED_SHORT,
|
|
130
|
+
sint16: GL.SHORT,
|
|
131
|
+
unorm16: GL.UNSIGNED_SHORT,
|
|
132
|
+
snorm16: GL.SHORT,
|
|
133
|
+
uint32: GL.UNSIGNED_INT,
|
|
134
|
+
sint32: GL.INT,
|
|
135
|
+
// WebGPU does not support normalized 32 bit integer attributes
|
|
136
|
+
// 'unorm32': GL.UNSIGNED_INT,
|
|
137
|
+
// 'snorm32': GL.INT,
|
|
138
|
+
float16: GL.HALF_FLOAT,
|
|
139
|
+
float32: GL.FLOAT
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/* Map from WebGL types to webgpu normalized types */
|
|
143
|
+
const WEBGL_TO_NORMALIZED_DATA_TYPE: Record<GLDataType, [SignedDataType, NormalizedDataType]> = {
|
|
144
|
+
[GL.BYTE]: ['sint8', 'snorm16'],
|
|
145
|
+
[GL.UNSIGNED_BYTE]: ['uint8', 'unorm8'],
|
|
146
|
+
[GL.SHORT]: ['sint16', 'unorm16'],
|
|
147
|
+
[GL.UNSIGNED_SHORT]: ['uint16', 'unorm16'],
|
|
148
|
+
[GL.INT]: ['sint32', 'sint32'],
|
|
149
|
+
[GL.UNSIGNED_INT]: ['uint32', 'uint32'],
|
|
150
|
+
[GL.FLOAT]: ['float32', 'float32'],
|
|
151
|
+
[GL.HALF_FLOAT]: ['float16', 'float16']
|
|
152
|
+
};
|
|
@@ -8,10 +8,10 @@ import type {
|
|
|
8
8
|
TextureFormatCapabilities,
|
|
9
9
|
DeviceTextureFormatCapabilities
|
|
10
10
|
} from '@luma.gl/core';
|
|
11
|
-
import {
|
|
11
|
+
import {getTextureFormatInfo} from '@luma.gl/core';
|
|
12
12
|
import {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/constants';
|
|
13
13
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
14
|
-
import {getGLFromVertexType} from './vertex-formats';
|
|
14
|
+
import {getGLFromVertexType} from './webgl-vertex-formats';
|
|
15
15
|
|
|
16
16
|
/* eslint-disable camelcase */
|
|
17
17
|
|
|
@@ -148,8 +148,8 @@ export const WEBGL_TEXTURE_FORMATS: Record<TextureFormat, WebGLFormatInfo> = {
|
|
|
148
148
|
'rgb9e5ufloat': {gl: GL.RGB9_E5}, // , filter: true},
|
|
149
149
|
'rg11b10ufloat': {gl: GL.R11F_G11F_B10F, rb: true},
|
|
150
150
|
'rgb10a2unorm': {gl: GL.RGB10_A2, rb: true},
|
|
151
|
-
'rgb10a2uint
|
|
152
|
-
|
|
151
|
+
'rgb10a2uint': {gl: GL.RGB10_A2UI, rb: true},
|
|
152
|
+
|
|
153
153
|
// 48-bit formats
|
|
154
154
|
'rgb16unorm-webgl': {gl: GL.RGB16_EXT}, // rgb not renderable
|
|
155
155
|
'rgb16snorm-webgl': {gl: GL.RGB16_SNORM_EXT}, // rgb not renderable
|
|
@@ -332,7 +332,7 @@ export function getTextureFormatWebGL(format: TextureFormat): {
|
|
|
332
332
|
} {
|
|
333
333
|
const formatData = WEBGL_TEXTURE_FORMATS[format];
|
|
334
334
|
const webglFormat = convertTextureFormatToGL(format);
|
|
335
|
-
const decoded =
|
|
335
|
+
const decoded = getTextureFormatInfo(format);
|
|
336
336
|
return {
|
|
337
337
|
internalFormat: webglFormat,
|
|
338
338
|
format:
|
|
@@ -349,7 +349,7 @@ export function getTextureFormatWebGL(format: TextureFormat): {
|
|
|
349
349
|
export function getDepthStencilAttachmentWebGL(
|
|
350
350
|
format: TextureFormat
|
|
351
351
|
): GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT {
|
|
352
|
-
const formatInfo =
|
|
352
|
+
const formatInfo = getTextureFormatInfo(format);
|
|
353
353
|
switch (formatInfo.attachment) {
|
|
354
354
|
case 'depth':
|
|
355
355
|
return GL.DEPTH_ATTACHMENT;
|
|
@@ -364,8 +364,8 @@ export function getDepthStencilAttachmentWebGL(
|
|
|
364
364
|
|
|
365
365
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
366
366
|
export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
|
|
367
|
-
const formatInfo =
|
|
368
|
-
return formatInfo.bytesPerPixel;
|
|
367
|
+
const formatInfo = getTextureFormatInfo(format);
|
|
368
|
+
return formatInfo.bytesPerPixel as number;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
// DATA TYPE HELPERS
|
|
@@ -394,7 +394,7 @@ export function getWebGLPixelDataFormat(
|
|
|
394
394
|
/**
|
|
395
395
|
* Map WebGPU style texture format strings to GL constants
|
|
396
396
|
*/
|
|
397
|
-
function convertTextureFormatToGL(format: TextureFormat): GL
|
|
397
|
+
function convertTextureFormatToGL(format: TextureFormat): GL {
|
|
398
398
|
const formatInfo = WEBGL_TEXTURE_FORMATS[format];
|
|
399
399
|
const webglFormat = formatInfo?.gl;
|
|
400
400
|
if (webglFormat === undefined) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {GL} from '@luma.gl/constants';
|
|
6
|
-
import {VertexFormat,
|
|
6
|
+
import {VertexFormat, NormalizedDataType} from '@luma.gl/core';
|
|
7
7
|
|
|
8
8
|
type GLDataType =
|
|
9
9
|
| GL.UNSIGNED_BYTE
|
|
@@ -32,7 +32,7 @@ export function getVertexFormatFromGL(type: GLDataType, components: 1 | 2 | 3 |
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** Get data type from GL constants */
|
|
35
|
-
export function getVertexTypeFromGL(type: GLDataType, normalized = false):
|
|
35
|
+
export function getVertexTypeFromGL(type: GLDataType, normalized = false): NormalizedDataType {
|
|
36
36
|
// prettier-ignore
|
|
37
37
|
switch (type) {
|
|
38
38
|
// WebGPU does not support normalized 32 bit integer attributes
|
|
@@ -50,7 +50,7 @@ export function getVertexTypeFromGL(type: GLDataType, normalized = false): Verte
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function getGLFromVertexType(
|
|
53
|
-
dataType:
|
|
53
|
+
dataType: NormalizedDataType
|
|
54
54
|
):
|
|
55
55
|
| GL.UNSIGNED_BYTE
|
|
56
56
|
| GL.BYTE
|
|
@@ -62,7 +62,7 @@ export class WebGLDeviceFeatures extends DeviceFeatures {
|
|
|
62
62
|
getWebGLExtension(gl, 'EXT_color_buffer_float', extensions);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
*[Symbol.iterator](): IterableIterator<DeviceFeature> {
|
|
65
|
+
override *[Symbol.iterator](): IterableIterator<DeviceFeature> {
|
|
66
66
|
const features = this.getFeatures();
|
|
67
67
|
for (const feature of features) {
|
|
68
68
|
if (this.has(feature)) {
|
|
@@ -26,7 +26,7 @@ export class WebGLDeviceLimits extends DeviceLimits {
|
|
|
26
26
|
get maxVertexBuffers() { return 16; } // WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
|
|
27
27
|
get maxVertexAttributes() { return this.getParameter(GL.MAX_VERTEX_ATTRIBS); }
|
|
28
28
|
get maxVertexBufferArrayStride() { return 2048; } // TBD, this is just the default value from WebGPU
|
|
29
|
-
get
|
|
29
|
+
get maxInterStageShaderVariables() { return this.getParameter(GL.MAX_VARYING_COMPONENTS); }
|
|
30
30
|
get maxComputeWorkgroupStorageSize() { return 0; } // WebGL does not support compute shaders
|
|
31
31
|
get maxComputeInvocationsPerWorkgroup() { return 0; } // WebGL does not support compute shaders
|
|
32
32
|
get maxComputeWorkgroupSizeX() { return 0; } // WebGL does not support compute shaders
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {GL} from '@luma.gl/constants';
|
|
6
6
|
|
|
7
7
|
// Returns number of components in a specific readPixels WebGL format
|
|
8
|
-
export function glFormatToComponents(format) {
|
|
8
|
+
export function glFormatToComponents(format: GL): 0 | 1 | 2 | 3 | 4 {
|
|
9
9
|
switch (format) {
|
|
10
10
|
case GL.ALPHA:
|
|
11
11
|
case GL.R32F:
|
|
@@ -33,7 +33,7 @@ export function glFormatToComponents(format) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Return byte count for given readPixels WebGL type
|
|
36
|
-
export function glTypeToBytes(type) {
|
|
36
|
+
export function glTypeToBytes(type: GL): 0 | 1 | 2 | 4 {
|
|
37
37
|
switch (type) {
|
|
38
38
|
case GL.UNSIGNED_BYTE:
|
|
39
39
|
return 1;
|
|
@@ -7,11 +7,17 @@ import type {
|
|
|
7
7
|
UniformBinding,
|
|
8
8
|
UniformBlockBinding,
|
|
9
9
|
AttributeDeclaration,
|
|
10
|
-
VaryingBinding
|
|
10
|
+
VaryingBinding,
|
|
11
|
+
AttributeShaderType
|
|
11
12
|
} from '@luma.gl/core';
|
|
13
|
+
import {getVariableShaderTypeInfo} from '@luma.gl/core';
|
|
12
14
|
|
|
13
|
-
import {GL} from '@luma.gl/constants';
|
|
14
|
-
import {
|
|
15
|
+
import {GL, GLUniformType} from '@luma.gl/constants';
|
|
16
|
+
import {
|
|
17
|
+
isGLSamplerType,
|
|
18
|
+
getTextureBindingFromGLSamplerType,
|
|
19
|
+
convertGLUniformTypeToShaderVariableType
|
|
20
|
+
} from '../converters/webgl-shadertypes';
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* Extract metadata describing binding information for a program's shaders
|
|
@@ -53,8 +59,8 @@ export function getShaderLayoutFromGLSL(
|
|
|
53
59
|
const uniforms: UniformBinding[] = readUniformBindings(gl, program);
|
|
54
60
|
let textureUnit = 0;
|
|
55
61
|
for (const uniform of uniforms) {
|
|
56
|
-
if (
|
|
57
|
-
const {viewDimension, sampleType} =
|
|
62
|
+
if (isGLSamplerType(uniform.type)) {
|
|
63
|
+
const {viewDimension, sampleType} = getTextureBindingFromGLSamplerType(uniform.type);
|
|
58
64
|
shaderLayout.bindings.push({
|
|
59
65
|
type: 'texture',
|
|
60
66
|
name: uniform.name,
|
|
@@ -108,7 +114,7 @@ function readAttributeDeclarations(
|
|
|
108
114
|
const location = gl.getAttribLocation(program, name);
|
|
109
115
|
// Add only user provided attributes, for built-in attributes like `gl_InstanceID` location will be < 0
|
|
110
116
|
if (location >= 0) {
|
|
111
|
-
const
|
|
117
|
+
const attributeType = convertGLUniformTypeToShaderVariableType(compositeType);
|
|
112
118
|
|
|
113
119
|
// Whether an attribute is instanced is essentially fixed by the structure of the shader code,
|
|
114
120
|
// so it is arguably a static property of the shader.
|
|
@@ -120,7 +126,7 @@ function readAttributeDeclarations(
|
|
|
120
126
|
name,
|
|
121
127
|
location,
|
|
122
128
|
stepMode,
|
|
123
|
-
type: attributeType
|
|
129
|
+
type: attributeType as AttributeShaderType
|
|
124
130
|
// size - for arrays, size is the number of elements in the array
|
|
125
131
|
});
|
|
126
132
|
}
|
|
@@ -145,10 +151,10 @@ function readVaryings(gl: WebGL2RenderingContext, program: WebGLProgram): Varyin
|
|
|
145
151
|
if (!activeInfo) {
|
|
146
152
|
throw new Error('activeInfo');
|
|
147
153
|
}
|
|
148
|
-
const {name, type:
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
varyings.push(
|
|
154
|
+
const {name, type: glUniformType, size} = activeInfo;
|
|
155
|
+
const uniformType = convertGLUniformTypeToShaderVariableType(glUniformType as GLUniformType);
|
|
156
|
+
const {type, components} = getVariableShaderTypeInfo(uniformType);
|
|
157
|
+
varyings.push({location, name, type, size: size * components});
|
|
152
158
|
}
|
|
153
159
|
|
|
154
160
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -251,9 +257,11 @@ function readUniformBlocks(
|
|
|
251
257
|
throw new Error('activeInfo');
|
|
252
258
|
}
|
|
253
259
|
|
|
260
|
+
const format = convertGLUniformTypeToShaderVariableType(uniformType[i]);
|
|
261
|
+
|
|
254
262
|
blockInfo.uniforms.push({
|
|
255
263
|
name: activeInfo.name,
|
|
256
|
-
format
|
|
264
|
+
format,
|
|
257
265
|
type: uniformType[i],
|
|
258
266
|
arrayLength: uniformArrayLength[i],
|
|
259
267
|
byteOffset: uniformOffset[i],
|
|
@@ -291,44 +299,6 @@ function readUniformBlocks(
|
|
|
291
299
|
}
|
|
292
300
|
*/
|
|
293
301
|
|
|
294
|
-
const SAMPLER_UNIFORMS_GL_TO_GPU: Record<
|
|
295
|
-
number,
|
|
296
|
-
[
|
|
297
|
-
'1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d',
|
|
298
|
-
'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint'
|
|
299
|
-
]
|
|
300
|
-
> = {
|
|
301
|
-
[GL.SAMPLER_2D]: ['2d', 'float'],
|
|
302
|
-
[GL.SAMPLER_CUBE]: ['cube', 'float'],
|
|
303
|
-
[GL.SAMPLER_3D]: ['3d', 'float'],
|
|
304
|
-
[GL.SAMPLER_2D_SHADOW]: ['3d', 'depth'],
|
|
305
|
-
[GL.SAMPLER_2D_ARRAY]: ['2d-array', 'float'],
|
|
306
|
-
[GL.SAMPLER_2D_ARRAY_SHADOW]: ['2d-array', 'depth'],
|
|
307
|
-
[GL.SAMPLER_CUBE_SHADOW]: ['cube', 'float'],
|
|
308
|
-
[GL.INT_SAMPLER_2D]: ['2d', 'sint'],
|
|
309
|
-
[GL.INT_SAMPLER_3D]: ['3d', 'sint'],
|
|
310
|
-
[GL.INT_SAMPLER_CUBE]: ['cube', 'sint'],
|
|
311
|
-
[GL.INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint'],
|
|
312
|
-
[GL.UNSIGNED_INT_SAMPLER_2D]: ['2d', 'uint'],
|
|
313
|
-
[GL.UNSIGNED_INT_SAMPLER_3D]: ['3d', 'uint'],
|
|
314
|
-
[GL.UNSIGNED_INT_SAMPLER_CUBE]: ['cube', 'uint'],
|
|
315
|
-
[GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ['2d-array', 'uint']
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
type SamplerInfo = {
|
|
319
|
-
viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
320
|
-
sampleType: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
function getSamplerInfo(type: GL): SamplerInfo {
|
|
324
|
-
const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
325
|
-
if (!sampler) {
|
|
326
|
-
throw new Error('sampler');
|
|
327
|
-
}
|
|
328
|
-
const [viewDimension, sampleType] = sampler;
|
|
329
|
-
return {viewDimension, sampleType};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
302
|
// HELPERS
|
|
333
303
|
|
|
334
304
|
function parseUniformName(name: string): {name: string; length: number; isArray: boolean} {
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
// Uniforms
|
|
8
8
|
import type {UniformValue} from '@luma.gl/core';
|
|
9
|
-
import {GL,
|
|
9
|
+
import {GL, GLUniformType, GLSamplerType} from '@luma.gl/constants';
|
|
10
10
|
|
|
11
11
|
/** Set a raw uniform (without type conversion and caching) */
|
|
12
12
|
/* eslint-disable max-len */
|
|
13
13
|
export function setUniform(
|
|
14
14
|
gl: WebGL2RenderingContext,
|
|
15
15
|
location: WebGLUniformLocation,
|
|
16
|
-
type:
|
|
16
|
+
type: GLUniformType | GLSamplerType,
|
|
17
17
|
value: UniformValue
|
|
18
18
|
): void {
|
|
19
19
|
const gl2 = gl as WebGL2RenderingContext;
|