@luma.gl/webgl 9.0.11 → 9.1.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/LICENSE +34 -0
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +12 -1
- package/dist/adapter/converters/texture-formats.d.ts +22 -16
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +31 -32
- package/dist/adapter/device-helpers/webgl-device-features.js +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +300 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.js +368 -0
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +0 -4
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +2 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +6 -9
- package/dist/adapter/resources/webgl-framebuffer.d.ts +32 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +42 -60
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -2
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +1 -3
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +45 -20
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +2 -2
- package/dist/adapter/resources/webgl-texture-view.d.ts +1 -1
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture-view.js +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +58 -172
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +402 -510
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -2
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts +3 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +2 -0
- package/dist/adapter/webgl-device.d.ts +4 -3
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +6 -5
- package/dist/classic/accessor.d.ts +22 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -9
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +2 -5
- package/dist/classic/copy-and-blit.d.ts +2 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +11 -9
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +0 -3
- package/dist/classic/typed-array-utils.d.ts +1 -1
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +2 -5
- package/dist/context/parameters/webgl-parameter-tables.js +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -6
- package/dist/dist.dev.js +870 -1261
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +859 -1137
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/utils/fill-array.d.ts +8 -0
- package/dist/utils/fill-array.d.ts.map +1 -0
- package/dist/utils/fill-array.js +26 -0
- package/dist/utils/load-script.d.ts +8 -0
- package/dist/utils/load-script.d.ts.map +1 -0
- package/dist/utils/load-script.js +26 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts +9 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -0
- package/dist/utils/split-uniforms-and-bindings.js +20 -0
- package/package.json +6 -5
- package/src/adapter/converters/device-parameters.ts +13 -1
- package/src/adapter/converters/texture-formats.ts +45 -42
- 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/webgl-texture-utils.ts +481 -0
- package/src/adapter/helpers/webgl-topology-utils.ts +0 -4
- package/src/adapter/resources/webgl-buffer.ts +2 -2
- package/src/adapter/resources/webgl-command-buffer.ts +8 -10
- package/src/adapter/resources/webgl-framebuffer.ts +22 -56
- package/src/adapter/resources/webgl-render-pass.ts +4 -5
- package/src/adapter/resources/webgl-render-pipeline.ts +48 -23
- package/src/adapter/resources/webgl-shader.ts +3 -3
- package/src/adapter/resources/webgl-texture-view.ts +1 -3
- package/src/adapter/resources/webgl-texture.ts +432 -784
- package/src/adapter/resources/webgl-vertex-array.ts +8 -7
- package/src/adapter/webgl-canvas-context.ts +4 -1
- package/src/adapter/webgl-device.ts +10 -18
- package/src/classic/accessor.ts +31 -11
- package/src/classic/clear.ts +3 -6
- package/src/classic/copy-and-blit.ts +19 -19
- package/src/classic/format-utils.ts +0 -3
- package/src/classic/typed-array-utils.ts +1 -1
- package/src/context/debug/spector.ts +2 -1
- package/src/context/debug/webgl-developer-tools.ts +3 -7
- package/src/context/parameters/webgl-parameter-tables.ts +3 -3
- package/src/context/state-tracker/track-context-state.ts +5 -6
- package/src/index.ts +0 -6
- package/src/utils/fill-array.ts +35 -0
- package/src/utils/load-script.ts +30 -0
- package/src/utils/split-uniforms-and-bindings.ts +31 -0
- package/dist/adapter/objects/constants-to-keys.d.ts +0 -3
- package/dist/adapter/objects/constants-to-keys.d.ts.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js +0 -22
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +0 -43
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +0 -95
- package/dist/adapter/objects/webgl-resource.d.ts +0 -32
- package/dist/adapter/objects/webgl-resource.d.ts.map +0 -1
- package/dist/adapter/objects/webgl-resource.js +0 -114
- package/src/adapter/objects/constants-to-keys.ts +0 -27
- package/src/adapter/objects/webgl-renderbuffer.ts +0 -132
- package/src/adapter/objects/webgl-resource.ts +0 -183
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export type { WebGLDeviceLimits } from "./adapter/device-helpers/webgl-device-limits.js";
|
|
2
2
|
export { WebGLDevice } from "./adapter/webgl-device.js";
|
|
3
3
|
export { WebGLCanvasContext } from "./adapter/webgl-canvas-context.js";
|
|
4
|
-
export { WebGLResource, WebGLResource as WEBGLResource } from "./adapter/objects/webgl-resource.js";
|
|
5
4
|
export { WEBGLBuffer } from "./adapter/resources/webgl-buffer.js";
|
|
6
5
|
export { WEBGLTexture } from "./adapter/resources/webgl-texture.js";
|
|
7
6
|
export { WEBGLShader } from "./adapter/resources/webgl-shader.js";
|
|
@@ -16,9 +15,6 @@ export { Accessor } from "./classic/accessor.js";
|
|
|
16
15
|
export type { AccessorObject } from "./types.js";
|
|
17
16
|
export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
|
|
18
17
|
export { getShaderLayout } from "./adapter/helpers/get-shader-layout.js";
|
|
19
|
-
export { convertGLToTextureFormat } from "./adapter/converters/texture-formats.js";
|
|
20
|
-
export type { RenderbufferProps as _RenderbufferProps } from "./adapter/objects/webgl-renderbuffer.js";
|
|
21
|
-
export { WEBGLRenderbuffer as _WEBGLRenderbuffer } from "./adapter/objects/webgl-renderbuffer.js";
|
|
22
18
|
export { TEXTURE_FORMATS as _TEXTURE_FORMATS } from "./adapter/converters/texture-formats.js";
|
|
23
19
|
export { trackContextState, pushContextState, popContextState } from "./context/state-tracker/track-context-state.js";
|
|
24
20
|
export { resetGLParameters, setGLParameters, getGLParameters } from "./context/parameters/unified-parameter-api.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,WAAW,EAAC,kCAA+B;AACnD,OAAO,EAAC,kBAAkB,EAAC,0CAAuC;AAGlE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,YAAY,EAAC,iBAAiB,EAAC,wDAAqD;AAGpF,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;AAGpF,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,YAAY,EAAC,cAAc,EAAC,mBAAgB;AAI5C,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,kDAA+C;AAGjG,OAAO,EAAC,eAAe,EAAC,+CAA4C;AAGpE,OAAO,EAAC,eAAe,IAAI,gBAAgB,EAAC,gDAA6C;AAIzF,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,uDAAoD;AAErD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,sDAAmD;AAEpD,OAAO,EAAC,gBAAgB,EAAC,mDAAgD"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
export { WebGLDevice } from "./adapter/webgl-device.js";
|
|
6
6
|
export { WebGLCanvasContext } from "./adapter/webgl-canvas-context.js";
|
|
7
7
|
// WebGL Resource classes
|
|
8
|
-
export { WebGLResource, WebGLResource as WEBGLResource } from "./adapter/objects/webgl-resource.js";
|
|
9
8
|
export { WEBGLBuffer } from "./adapter/resources/webgl-buffer.js";
|
|
10
9
|
export { WEBGLTexture } from "./adapter/resources/webgl-texture.js";
|
|
11
10
|
// export {WEBGLExternalTexture} from './adapter/resources/webgl-external-texture';
|
|
@@ -26,8 +25,6 @@ export { Accessor } from "./classic/accessor.js";
|
|
|
26
25
|
export { setDeviceParameters, withDeviceParameters } from "./adapter/converters/device-parameters.js";
|
|
27
26
|
// HELPERS - EXPERIMENTAL
|
|
28
27
|
export { getShaderLayout } from "./adapter/helpers/get-shader-layout.js";
|
|
29
|
-
export { convertGLToTextureFormat } from "./adapter/converters/texture-formats.js";
|
|
30
|
-
export { WEBGLRenderbuffer as _WEBGLRenderbuffer } from "./adapter/objects/webgl-renderbuffer.js";
|
|
31
28
|
// TEST EXPORTS
|
|
32
29
|
export { TEXTURE_FORMATS as _TEXTURE_FORMATS } from "./adapter/converters/texture-formats.js";
|
|
33
30
|
// DEPRECATED TEST EXPORTS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-array.d.ts","sourceRoot":"","sources":["../../src/utils/fill-array.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAGhD,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,WAAW,CAsBd"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Uses copyWithin to significantly speed up typed array value filling
|
|
5
|
+
export function fillArray(options) {
|
|
6
|
+
const { target, source, start = 0, count = 1 } = options;
|
|
7
|
+
const length = source.length;
|
|
8
|
+
const total = count * length;
|
|
9
|
+
let copied = 0;
|
|
10
|
+
for (let i = start; copied < length; copied++) {
|
|
11
|
+
target[i++] = source[copied];
|
|
12
|
+
}
|
|
13
|
+
while (copied < total) {
|
|
14
|
+
// If we have copied less than half, copy everything we got
|
|
15
|
+
// else copy remaining in one operation
|
|
16
|
+
if (copied < total - copied) {
|
|
17
|
+
target.copyWithin(start + copied, start, start + copied);
|
|
18
|
+
copied *= 2;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
target.copyWithin(start + copied, start, start + total - copied);
|
|
22
|
+
copied = total;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return options.target;
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load a script (identified by an url). When the url returns, the
|
|
3
|
+
* content of this file is added into a new script element, attached to the DOM (body element)
|
|
4
|
+
* @param scriptUrl defines the url of the script to laod
|
|
5
|
+
* @param scriptId defines the id of the script element
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadScript(scriptUrl: string, scriptId?: string): Promise<Event>;
|
|
8
|
+
//# sourceMappingURL=load-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-script.d.ts","sourceRoot":"","sources":["../../src/utils/load-script.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAmBrF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* Load a script (identified by an url). When the url returns, the
|
|
6
|
+
* content of this file is added into a new script element, attached to the DOM (body element)
|
|
7
|
+
* @param scriptUrl defines the url of the script to laod
|
|
8
|
+
* @param scriptId defines the id of the script element
|
|
9
|
+
*/
|
|
10
|
+
export async function loadScript(scriptUrl, scriptId) {
|
|
11
|
+
const head = document.getElementsByTagName('head')[0];
|
|
12
|
+
if (!head) {
|
|
13
|
+
throw new Error('loadScript');
|
|
14
|
+
}
|
|
15
|
+
const script = document.createElement('script');
|
|
16
|
+
script.setAttribute('type', 'text/javascript');
|
|
17
|
+
script.setAttribute('src', scriptUrl);
|
|
18
|
+
if (scriptId) {
|
|
19
|
+
script.id = scriptId;
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
script.onload = resolve;
|
|
23
|
+
script.onerror = error => reject(new Error(`Unable to load script '${scriptUrl}': ${error}`));
|
|
24
|
+
head.appendChild(script);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UniformValue, Binding } from '@luma.gl/core';
|
|
2
|
+
export declare function isUniformValue(value: unknown): boolean;
|
|
3
|
+
type UniformsAndBindings = {
|
|
4
|
+
bindings: Record<string, Binding>;
|
|
5
|
+
uniforms: Record<string, UniformValue>;
|
|
6
|
+
};
|
|
7
|
+
export declare function splitUniformsAndBindings(uniforms: Record<string, Binding | UniformValue>): UniformsAndBindings;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=split-uniforms-and-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-uniforms-and-bindings.d.ts","sourceRoot":"","sources":["../../src/utils/split-uniforms-and-bindings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAGzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,GAC/C,mBAAmB,CAYrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { isNumericArray } from '@math.gl/types';
|
|
5
|
+
export function isUniformValue(value) {
|
|
6
|
+
return isNumericArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';
|
|
7
|
+
}
|
|
8
|
+
export function splitUniformsAndBindings(uniforms) {
|
|
9
|
+
const result = { bindings: {}, uniforms: {} };
|
|
10
|
+
Object.keys(uniforms).forEach(name => {
|
|
11
|
+
const uniform = uniforms[name];
|
|
12
|
+
if (isUniformValue(uniform)) {
|
|
13
|
+
result.uniforms[name] = uniform;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
result.bindings[name] = uniform;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.1.0-alpha.1",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "^9.0.0"
|
|
43
|
+
"@luma.gl/core": "^9.0.0-beta"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.0.
|
|
47
|
-
"@
|
|
46
|
+
"@luma.gl/constants": "9.1.0-alpha.1",
|
|
47
|
+
"@math.gl/types": "^4.0.0",
|
|
48
|
+
"@probe.gl/env": "^4.0.8"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "bc5c11c87f1e4db857e701688ca1410d7f51fd0f"
|
|
50
51
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {CompareFunction, StencilOperation, BlendOperation, BlendFactor} from '@luma.gl/core';
|
|
6
|
-
import {Device, log,
|
|
6
|
+
import {Device, log, Parameters, PolygonMode, ProvokingVertex} from '@luma.gl/core';
|
|
7
7
|
import {GL} from '@luma.gl/constants';
|
|
8
8
|
import type {
|
|
9
9
|
GLBlendEquation,
|
|
@@ -423,3 +423,15 @@ function map<K extends string | number, V>(parameter: string, value: K, valueMap
|
|
|
423
423
|
function mapBoolean(parameter: string, value: boolean): boolean {
|
|
424
424
|
return value;
|
|
425
425
|
}
|
|
426
|
+
|
|
427
|
+
/** Returns true if given object is empty, false otherwise. */
|
|
428
|
+
function isObjectEmpty(obj: object): boolean {
|
|
429
|
+
let isEmpty = true;
|
|
430
|
+
// @ts-ignore key is unused
|
|
431
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
432
|
+
for (const key in obj) {
|
|
433
|
+
isEmpty = false;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
return isEmpty;
|
|
437
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {TextureFormat, DeviceFeature} from '@luma.gl/core';
|
|
6
6
|
import {decodeTextureFormat} from '@luma.gl/core';
|
|
7
|
-
import {GL, GLExtensions} from '@luma.gl/constants';
|
|
7
|
+
import {GL, GLPixelType, GLExtensions, GLTexelDataFormat} from '@luma.gl/constants';
|
|
8
8
|
import {getWebGLExtension} from '../../context/helpers/webgl-extensions';
|
|
9
9
|
import {getGLFromVertexType} from './vertex-formats';
|
|
10
10
|
|
|
@@ -123,9 +123,8 @@ type Format = {
|
|
|
123
123
|
/** If not supported on WebGPU */
|
|
124
124
|
wgpu?: false;
|
|
125
125
|
|
|
126
|
-
types?:
|
|
127
|
-
|
|
128
|
-
dataFormat?: GL;
|
|
126
|
+
types?: GLPixelType[];
|
|
127
|
+
dataFormat?: GLTexelDataFormat;
|
|
129
128
|
/** Depth and stencil format attachment points. If set, needs to be a Renderbuffer unless depthTexture is set */
|
|
130
129
|
attachment?: GL.DEPTH_ATTACHMENT | GL.STENCIL_ATTACHMENT | GL.DEPTH_STENCIL_ATTACHMENT;
|
|
131
130
|
/** if depthTexture is set this is a depth/stencil format that can be set to a texture */
|
|
@@ -190,7 +189,6 @@ export const TEXTURE_FORMATS: Record<TextureFormat, Format> = {
|
|
|
190
189
|
|
|
191
190
|
'rg16uint': {gl: GL.RG16UI, b: 4, c: 1, bpp: 4},
|
|
192
191
|
'rg16sint': {gl: GL.RG16I, b: 4, c: 2, bpp: 4},
|
|
193
|
-
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
194
192
|
'rg16float': {gl: GL.RG16F, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true},
|
|
195
193
|
'rg16unorm-webgl': {gl: GL.RG16_EXT, b:2, c:2, render: norm16_renderable},
|
|
196
194
|
'rg16snorm-webgl': {gl: GL.RG16_SNORM_EXT, b:2, c:2, render: snorm16_renderable},
|
|
@@ -485,33 +483,7 @@ export function isRenderbufferFormatSupported(
|
|
|
485
483
|
extensions: GLExtensions
|
|
486
484
|
): boolean {
|
|
487
485
|
// Note: Order is important since the function call initializes extensions.
|
|
488
|
-
return isTextureFormatSupported(gl, format, extensions) && TEXTURE_FORMATS[format]?.rb;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
493
|
-
*/
|
|
494
|
-
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
495
|
-
if (typeof format === 'string') {
|
|
496
|
-
return format;
|
|
497
|
-
}
|
|
498
|
-
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
499
|
-
if (!entry) {
|
|
500
|
-
throw new Error(`Unknown texture format ${format}`);
|
|
501
|
-
}
|
|
502
|
-
return entry[0] as TextureFormat;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Map WebGPU style texture format strings to GL constants
|
|
507
|
-
*/
|
|
508
|
-
export function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
509
|
-
const formatInfo = TEXTURE_FORMATS[format];
|
|
510
|
-
const webglFormat = formatInfo?.gl;
|
|
511
|
-
if (webglFormat === undefined) {
|
|
512
|
-
throw new Error(`Unsupported texture format ${format}`);
|
|
513
|
-
}
|
|
514
|
-
return webglFormat;
|
|
486
|
+
return isTextureFormatSupported(gl, format, extensions) && Boolean(TEXTURE_FORMATS[format]?.rb);
|
|
515
487
|
}
|
|
516
488
|
|
|
517
489
|
/** Checks if a texture format is supported */
|
|
@@ -537,7 +509,7 @@ export function getTextureFormatSupport(
|
|
|
537
509
|
|
|
538
510
|
// Support Check that we have a GL constant
|
|
539
511
|
let supported = info.gl === undefined;
|
|
540
|
-
supported = supported && checkTextureFeature(gl, info.f, extensions);
|
|
512
|
+
supported = supported && checkTextureFeature(gl, info.f as DeviceFeature, extensions);
|
|
541
513
|
|
|
542
514
|
// Filtering
|
|
543
515
|
// const filterable = info.filter
|
|
@@ -549,8 +521,8 @@ export function getTextureFormatSupport(
|
|
|
549
521
|
|
|
550
522
|
return {
|
|
551
523
|
supported,
|
|
552
|
-
renderable: supported && checkTextureFeature(gl, info.render, extensions),
|
|
553
|
-
filterable: supported && checkTextureFeature(gl, info.filter, extensions),
|
|
524
|
+
renderable: supported && checkTextureFeature(gl, info.render as DeviceFeature, extensions),
|
|
525
|
+
filterable: supported && checkTextureFeature(gl, info.filter as DeviceFeature, extensions),
|
|
554
526
|
blendable: false, // tod,
|
|
555
527
|
storable: false
|
|
556
528
|
};
|
|
@@ -601,13 +573,18 @@ export function isTextureFormatRenderable(
|
|
|
601
573
|
}
|
|
602
574
|
|
|
603
575
|
/** Get parameters necessary to work with format in WebGL: internalFormat, dataFormat, type, compressed, */
|
|
604
|
-
export function
|
|
576
|
+
export function getTextureFormatWebGL(format: TextureFormat): {
|
|
577
|
+
internalFormat: GL;
|
|
578
|
+
format: GLTexelDataFormat;
|
|
579
|
+
type: GLPixelType;
|
|
580
|
+
compressed: boolean;
|
|
581
|
+
} {
|
|
605
582
|
const formatData = TEXTURE_FORMATS[format];
|
|
606
583
|
const webglFormat = convertTextureFormatToGL(format);
|
|
607
584
|
const decoded = decodeTextureFormat(format);
|
|
608
585
|
return {
|
|
609
|
-
|
|
610
|
-
|
|
586
|
+
internalFormat: webglFormat,
|
|
587
|
+
format:
|
|
611
588
|
formatData?.dataFormat ||
|
|
612
589
|
getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
613
590
|
// depth formats don't have a type
|
|
@@ -632,21 +609,21 @@ export function getDepthStencilAttachmentWebGL(
|
|
|
632
609
|
/** TODO - VERY roundabout legacy way of calculating bytes per pixel */
|
|
633
610
|
export function getTextureFormatBytesPerPixel(format: TextureFormat): number {
|
|
634
611
|
// TODO remove webgl1 support
|
|
635
|
-
const params =
|
|
612
|
+
const params = getTextureFormatWebGL(format);
|
|
636
613
|
// NOTE(Tarek): Default to RGBA bytes
|
|
637
|
-
const channels = DATA_FORMAT_CHANNELS[params.
|
|
614
|
+
const channels = DATA_FORMAT_CHANNELS[params.format] || 4;
|
|
638
615
|
const channelSize = TYPE_SIZES[params.type] || 1;
|
|
639
616
|
return channels * channelSize;
|
|
640
617
|
}
|
|
641
618
|
|
|
642
619
|
// DATA TYPE HELPERS
|
|
643
620
|
|
|
644
|
-
function getWebGLPixelDataFormat(
|
|
621
|
+
export function getWebGLPixelDataFormat(
|
|
645
622
|
dataFormat: string,
|
|
646
623
|
integer: boolean,
|
|
647
624
|
normalized: boolean,
|
|
648
625
|
format: GL
|
|
649
|
-
):
|
|
626
|
+
): GLTexelDataFormat {
|
|
650
627
|
// WebGL1 formats use same internalFormat
|
|
651
628
|
if (format === GL.RGBA || format === GL.RGB) {
|
|
652
629
|
return format;
|
|
@@ -660,3 +637,29 @@ function getWebGLPixelDataFormat(
|
|
|
660
637
|
default: return GL.RGBA;
|
|
661
638
|
}
|
|
662
639
|
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Map WebGPU style texture format strings to GL constants
|
|
643
|
+
*/
|
|
644
|
+
function convertTextureFormatToGL(format: TextureFormat): GL | undefined {
|
|
645
|
+
const formatInfo = TEXTURE_FORMATS[format];
|
|
646
|
+
const webglFormat = formatInfo?.gl;
|
|
647
|
+
if (webglFormat === undefined) {
|
|
648
|
+
throw new Error(`Unsupported texture format ${format}`);
|
|
649
|
+
}
|
|
650
|
+
return webglFormat;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Map WebGL texture formats (GL constants) to WebGPU-style TextureFormat strings
|
|
655
|
+
export function convertGLToTextureFormat(format: GL | TextureFormat): TextureFormat {
|
|
656
|
+
if (typeof format === 'string') {
|
|
657
|
+
return format;
|
|
658
|
+
}
|
|
659
|
+
const entry = Object.entries(TEXTURE_FORMATS).find(([, entry]) => entry.gl === format);
|
|
660
|
+
if (!entry) {
|
|
661
|
+
throw new Error(`Unknown texture format ${format}`);
|
|
662
|
+
}
|
|
663
|
+
return entry[0] as TextureFormat;
|
|
664
|
+
}
|
|
665
|
+
*/
|