@luma.gl/webgl 9.1.9 → 9.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.js +14 -9
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +13 -2
- package/dist/adapter/converters/sampler-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 +122 -0
- package/dist/adapter/converters/webgl-shadertypes.js.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -1
- package/dist/adapter/converters/webgl-texture-table.js +17 -13
- 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} +2 -3
- 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 -242
- 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 +7 -7
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +29 -18
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts +4 -3
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +5 -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.d.ts +2 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.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 +2 -2
- 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 +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +16 -13
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +5 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +28 -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 +152 -320
- 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 +43 -30
- 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 +19 -20
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +44 -31
- 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 +1 -0
- 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 +4788 -4801
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +3906 -3960
- 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/sampler-parameters.ts +13 -2
- package/src/adapter/converters/shader-formats.ts +50 -24
- package/src/adapter/converters/webgl-shadertypes.ts +151 -0
- package/src/adapter/converters/webgl-texture-table.ts +21 -15
- package/src/adapter/converters/{vertex-formats.ts → webgl-vertex-formats.ts} +4 -5
- 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 -348
- package/src/adapter/resources/webgl-buffer.ts +43 -23
- package/src/adapter/resources/webgl-command-buffer.ts +9 -8
- package/src/adapter/resources/webgl-command-encoder.ts +18 -9
- package/src/adapter/resources/webgl-framebuffer.ts +4 -4
- package/src/adapter/resources/webgl-query-set.ts +7 -3
- package/src/adapter/resources/webgl-render-pass.ts +20 -17
- package/src/adapter/resources/webgl-render-pipeline.ts +38 -37
- 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 +184 -394
- 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 +46 -33
- package/src/adapter/webgl-canvas-context.ts +7 -47
- package/src/adapter/webgl-device.ts +64 -44
- 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 +9 -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
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
21
|
-
//# sourceMappingURL=split-uniforms-and-bindings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"split-uniforms-and-bindings.js","sourceRoot":"","sources":["../../src/utils/split-uniforms-and-bindings.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;AACnG,CAAC;AAOD,MAAM,UAAU,wBAAwB,CACtC,QAAgD;IAEhD,MAAM,MAAM,GAAwB,EAAC,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAC,CAAC;IACjE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;QAClC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {ShaderUniformType, ShaderAttributeType, VertexFormat} from '@luma.gl/core';
|
|
6
|
-
import {GL, GLUniformType, GLSamplerType, GLCompositeType, GLDataType} from '@luma.gl/constants';
|
|
7
|
-
|
|
8
|
-
/** Check is uniform is of sampler type */
|
|
9
|
-
export function isSamplerUniform(type: GLUniformType): boolean {
|
|
10
|
-
return SAMPLER_TYPES.includes(type as GLSamplerType);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const SAMPLER_TYPES: GLSamplerType[] = [
|
|
14
|
-
GL.SAMPLER_2D,
|
|
15
|
-
GL.SAMPLER_CUBE,
|
|
16
|
-
GL.SAMPLER_3D,
|
|
17
|
-
GL.SAMPLER_2D_SHADOW,
|
|
18
|
-
GL.SAMPLER_2D_ARRAY,
|
|
19
|
-
GL.SAMPLER_2D_ARRAY_SHADOW,
|
|
20
|
-
GL.SAMPLER_CUBE_SHADOW,
|
|
21
|
-
GL.INT_SAMPLER_2D,
|
|
22
|
-
GL.INT_SAMPLER_3D,
|
|
23
|
-
GL.INT_SAMPLER_CUBE,
|
|
24
|
-
GL.INT_SAMPLER_2D_ARRAY,
|
|
25
|
-
GL.UNSIGNED_INT_SAMPLER_2D,
|
|
26
|
-
GL.UNSIGNED_INT_SAMPLER_3D,
|
|
27
|
-
GL.UNSIGNED_INT_SAMPLER_CUBE,
|
|
28
|
-
GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
// Composite types table
|
|
32
|
-
const COMPOSITE_GL_TYPES: Record<
|
|
33
|
-
GLCompositeType,
|
|
34
|
-
[GLDataType, number, string, ShaderUniformType, VertexFormat?]
|
|
35
|
-
> = {
|
|
36
|
-
[GL.FLOAT]: [GL.FLOAT, 1, 'float', 'f32', 'float32'],
|
|
37
|
-
[GL.FLOAT_VEC2]: [GL.FLOAT, 2, 'vec2', 'vec2<f32>', 'float32x2'],
|
|
38
|
-
[GL.FLOAT_VEC3]: [GL.FLOAT, 3, 'vec3', 'vec3<f32>', 'float32x3'],
|
|
39
|
-
[GL.FLOAT_VEC4]: [GL.FLOAT, 4, 'vec4', 'vec4<f32>', 'float32x4'],
|
|
40
|
-
|
|
41
|
-
[GL.INT]: [GL.INT, 1, 'int', 'i32', 'sint32'],
|
|
42
|
-
[GL.INT_VEC2]: [GL.INT, 2, 'ivec2', 'vec2<i32>', 'sint32x2'],
|
|
43
|
-
[GL.INT_VEC3]: [GL.INT, 3, 'ivec3', 'vec3<i32>', 'sint32x3'],
|
|
44
|
-
[GL.INT_VEC4]: [GL.INT, 4, 'ivec4', 'vec4<i32>', 'sint32x4'],
|
|
45
|
-
|
|
46
|
-
[GL.UNSIGNED_INT]: [GL.UNSIGNED_INT, 1, 'uint', 'u32', 'uint32'],
|
|
47
|
-
[GL.UNSIGNED_INT_VEC2]: [GL.UNSIGNED_INT, 2, 'uvec2', 'vec2<u32>', 'uint32x2'],
|
|
48
|
-
[GL.UNSIGNED_INT_VEC3]: [GL.UNSIGNED_INT, 3, 'uvec3', 'vec3<u32>', 'uint32x3'],
|
|
49
|
-
[GL.UNSIGNED_INT_VEC4]: [GL.UNSIGNED_INT, 4, 'uvec4', 'vec4<u32>', 'uint32x4'],
|
|
50
|
-
|
|
51
|
-
[GL.BOOL]: [GL.FLOAT, 1, 'bool', 'f32', 'float32'],
|
|
52
|
-
[GL.BOOL_VEC2]: [GL.FLOAT, 2, 'bvec2', 'vec2<f32>', 'float32x2'],
|
|
53
|
-
[GL.BOOL_VEC3]: [GL.FLOAT, 3, 'bvec3', 'vec3<f32>', 'float32x3'],
|
|
54
|
-
[GL.BOOL_VEC4]: [GL.FLOAT, 4, 'bvec4', 'vec4<f32>', 'float32x4'],
|
|
55
|
-
|
|
56
|
-
// TODO - are sizes/components below correct?
|
|
57
|
-
[GL.FLOAT_MAT2]: [GL.FLOAT, 8, 'mat2', 'mat2x2<f32>'], // 4
|
|
58
|
-
[GL.FLOAT_MAT2x3]: [GL.FLOAT, 8, 'mat2x3', 'mat2x3<f32>'], // 6
|
|
59
|
-
[GL.FLOAT_MAT2x4]: [GL.FLOAT, 8, 'mat2x4', 'mat2x4<f32>'], // 8
|
|
60
|
-
|
|
61
|
-
[GL.FLOAT_MAT3x2]: [GL.FLOAT, 12, 'mat3x2', 'mat3x2<f32>'], // 6
|
|
62
|
-
[GL.FLOAT_MAT3]: [GL.FLOAT, 12, 'mat3', 'mat3x3<f32>'], // 9
|
|
63
|
-
[GL.FLOAT_MAT3x4]: [GL.FLOAT, 12, 'mat3x4', 'mat3x4<f32>'], // 12
|
|
64
|
-
|
|
65
|
-
[GL.FLOAT_MAT4x2]: [GL.FLOAT, 16, 'mat4x2', 'mat4x2<f32>'], // 8
|
|
66
|
-
[GL.FLOAT_MAT4x3]: [GL.FLOAT, 16, 'mat4x3', 'mat4x3<f32>'], // 12
|
|
67
|
-
[GL.FLOAT_MAT4]: [GL.FLOAT, 16, 'mat4', 'mat4x4<f32>'] // 16
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
|
|
71
|
-
export function decodeGLUniformType(glUniformType: GL): {
|
|
72
|
-
format: ShaderUniformType;
|
|
73
|
-
components: number;
|
|
74
|
-
glType: GLDataType;
|
|
75
|
-
} {
|
|
76
|
-
const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
|
|
77
|
-
if (!typeAndSize) {
|
|
78
|
-
throw new Error('uniform');
|
|
79
|
-
}
|
|
80
|
-
const [glType, components, , format] = typeAndSize;
|
|
81
|
-
return {format, components, glType};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Decomposes a composite type (GL.VEC3) into a basic type (GL.FLOAT) and components (3) */
|
|
85
|
-
export function decodeGLAttributeType(glAttributeType: GL): {
|
|
86
|
-
attributeType: ShaderAttributeType;
|
|
87
|
-
vertexFormat: VertexFormat;
|
|
88
|
-
components: number;
|
|
89
|
-
// glType: GLDataType;
|
|
90
|
-
} {
|
|
91
|
-
const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
|
|
92
|
-
if (!typeAndSize) {
|
|
93
|
-
throw new Error('attribute');
|
|
94
|
-
}
|
|
95
|
-
const [, components, , shaderType, vertexFormat] = typeAndSize;
|
|
96
|
-
// TODO sanity - if (shaderType.startsWith('mat' ...))
|
|
97
|
-
const attributeType = shaderType as unknown as ShaderAttributeType;
|
|
98
|
-
return {attributeType, vertexFormat, components}; // , glType};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Decomposes a composite type GL.VEC3 into a basic type (GL.FLOAT) and components (3) */
|
|
102
|
-
export function decomposeCompositeGLDataType(
|
|
103
|
-
compositeGLDataType: GLCompositeType
|
|
104
|
-
): {type: GLDataType; components: number} | null {
|
|
105
|
-
const typeAndSize = COMPOSITE_GL_TYPES[compositeGLDataType];
|
|
106
|
-
if (!typeAndSize) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const [type, components] = typeAndSize;
|
|
110
|
-
return {type, components};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function getCompositeGLDataType(
|
|
114
|
-
type: GL,
|
|
115
|
-
components
|
|
116
|
-
): {glType: GLDataType; name: string} | null {
|
|
117
|
-
switch (type) {
|
|
118
|
-
case GL.BYTE:
|
|
119
|
-
case GL.UNSIGNED_BYTE:
|
|
120
|
-
case GL.SHORT:
|
|
121
|
-
case GL.UNSIGNED_SHORT:
|
|
122
|
-
type = GL.FLOAT;
|
|
123
|
-
break;
|
|
124
|
-
default:
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
for (const glType in COMPOSITE_GL_TYPES) {
|
|
128
|
-
const [compType, compComponents, name] = COMPOSITE_GL_TYPES[glType];
|
|
129
|
-
if (compType === type && compComponents === components) {
|
|
130
|
-
return {glType: Number(glType), name};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {TypedArray, TypedArrayConstructor} from '@math.gl/types';
|
|
6
|
-
import {GL, GLDataType, GLPixelType} from '@luma.gl/constants';
|
|
7
|
-
|
|
8
|
-
const ERR_TYPE_DEDUCTION = 'Failed to deduce GL constant from typed array';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Converts TYPED ARRAYS to corresponding GL constant
|
|
12
|
-
* Used to auto deduce gl parameter types
|
|
13
|
-
* @deprecated Use getDataTypeFromTypedArray
|
|
14
|
-
* @param arrayOrType
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export function getGLTypeFromTypedArray(arrayOrType: TypedArray): GLDataType {
|
|
18
|
-
// If typed array, look up constructor
|
|
19
|
-
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
20
|
-
switch (type) {
|
|
21
|
-
case Float32Array:
|
|
22
|
-
return GL.FLOAT;
|
|
23
|
-
case Uint16Array:
|
|
24
|
-
return GL.UNSIGNED_SHORT;
|
|
25
|
-
case Uint32Array:
|
|
26
|
-
return GL.UNSIGNED_INT;
|
|
27
|
-
case Uint8Array:
|
|
28
|
-
return GL.UNSIGNED_BYTE;
|
|
29
|
-
case Uint8ClampedArray:
|
|
30
|
-
return GL.UNSIGNED_BYTE;
|
|
31
|
-
case Int8Array:
|
|
32
|
-
return GL.BYTE;
|
|
33
|
-
case Int16Array:
|
|
34
|
-
return GL.SHORT;
|
|
35
|
-
case Int32Array:
|
|
36
|
-
return GL.INT;
|
|
37
|
-
default:
|
|
38
|
-
throw new Error(ERR_TYPE_DEDUCTION);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Converts GL constant to corresponding TYPED ARRAY
|
|
44
|
-
* Used to auto deduce gl parameter types
|
|
45
|
-
* @deprecated Use getTypedArrayFromDataType
|
|
46
|
-
* @param glType
|
|
47
|
-
* @param param1
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
// eslint-disable-next-line complexity
|
|
51
|
-
export function getTypedArrayFromGLType(
|
|
52
|
-
glType: GLDataType | GLPixelType,
|
|
53
|
-
options?: {
|
|
54
|
-
clamped?: boolean;
|
|
55
|
-
}
|
|
56
|
-
): TypedArrayConstructor {
|
|
57
|
-
const {clamped = true} = options || {};
|
|
58
|
-
// Sorted in some order of likelihood to reduce amount of comparisons
|
|
59
|
-
switch (glType) {
|
|
60
|
-
case GL.FLOAT:
|
|
61
|
-
return Float32Array;
|
|
62
|
-
case GL.UNSIGNED_SHORT:
|
|
63
|
-
case GL.UNSIGNED_SHORT_5_6_5:
|
|
64
|
-
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
65
|
-
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
66
|
-
return Uint16Array;
|
|
67
|
-
case GL.UNSIGNED_INT:
|
|
68
|
-
return Uint32Array;
|
|
69
|
-
case GL.UNSIGNED_BYTE:
|
|
70
|
-
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
71
|
-
case GL.BYTE:
|
|
72
|
-
return Int8Array;
|
|
73
|
-
case GL.SHORT:
|
|
74
|
-
return Int16Array;
|
|
75
|
-
case GL.INT:
|
|
76
|
-
return Int32Array;
|
|
77
|
-
default:
|
|
78
|
-
throw new Error('Failed to deduce typed array type from GL constant');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Flip rows (can be used on arrays returned from `Framebuffer.readPixels`)
|
|
84
|
-
* https: *stackoverflow.com/questions/41969562/
|
|
85
|
-
* how-can-i-flip-the-result-of-webglrenderingcontext-readpixels
|
|
86
|
-
* @param param0
|
|
87
|
-
*/
|
|
88
|
-
export function flipRows(options: {
|
|
89
|
-
data: TypedArray;
|
|
90
|
-
width: number;
|
|
91
|
-
height: number;
|
|
92
|
-
bytesPerPixel?: number;
|
|
93
|
-
temp?: Uint8Array;
|
|
94
|
-
}): void {
|
|
95
|
-
const {data, width, height, bytesPerPixel = 4, temp} = options;
|
|
96
|
-
const bytesPerRow = width * bytesPerPixel;
|
|
97
|
-
|
|
98
|
-
// make a temp buffer to hold one row
|
|
99
|
-
const tempBuffer = temp || new Uint8Array(bytesPerRow);
|
|
100
|
-
for (let y = 0; y < height / 2; ++y) {
|
|
101
|
-
const topOffset = y * bytesPerRow;
|
|
102
|
-
const bottomOffset = (height - y - 1) * bytesPerRow;
|
|
103
|
-
// make copy of a row on the top half
|
|
104
|
-
tempBuffer.set(data.subarray(topOffset, topOffset + bytesPerRow));
|
|
105
|
-
// copy a row from the bottom half to the top
|
|
106
|
-
data.copyWithin(topOffset, bottomOffset, bottomOffset + bytesPerRow);
|
|
107
|
-
// copy the copy of the top half row to the bottom half
|
|
108
|
-
data.set(tempBuffer, bottomOffset);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function scalePixels(options: {data: TypedArray; width: number; height: number}): {
|
|
113
|
-
data: Uint8Array;
|
|
114
|
-
width: number;
|
|
115
|
-
height: number;
|
|
116
|
-
} {
|
|
117
|
-
const {data, width, height} = options;
|
|
118
|
-
const newWidth = Math.round(width / 2);
|
|
119
|
-
const newHeight = Math.round(height / 2);
|
|
120
|
-
const newData = new Uint8Array(newWidth * newHeight * 4);
|
|
121
|
-
for (let y = 0; y < newHeight; y++) {
|
|
122
|
-
for (let x = 0; x < newWidth; x++) {
|
|
123
|
-
for (let c = 0; c < 4; c++) {
|
|
124
|
-
newData[(y * newWidth + x) * 4 + c] = data[(y * 2 * width + x * 2) * 4 + c];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return {data: newData, width: newWidth, height: newHeight};
|
|
129
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {Buffer, log} from '@luma.gl/core';
|
|
6
|
-
import {GL, GLDataType, GLPixelType} from '@luma.gl/constants';
|
|
7
|
-
import {TypedArrayConstructor} from '@math.gl/types';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Attribute descriptor object
|
|
11
|
-
* @deprecated Use ShaderLayout
|
|
12
|
-
*/
|
|
13
|
-
export interface AccessorObject {
|
|
14
|
-
buffer?: Buffer;
|
|
15
|
-
// format: VertexFormat;
|
|
16
|
-
offset?: number;
|
|
17
|
-
// can now be described with single WebGPU-style `format` string
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
stride?: number;
|
|
21
|
-
|
|
22
|
-
/** @deprecated - Use accessor.stepMode */
|
|
23
|
-
divisor?: number;
|
|
24
|
-
|
|
25
|
-
/** @deprecated - Infer from format */
|
|
26
|
-
type?: number;
|
|
27
|
-
/** @deprecated - Infer from format */
|
|
28
|
-
size?: number;
|
|
29
|
-
/** @deprecated - Infer from format */
|
|
30
|
-
normalized?: boolean;
|
|
31
|
-
/** @deprecated - Infer from format */
|
|
32
|
-
integer?: boolean;
|
|
33
|
-
|
|
34
|
-
/** @deprecated */
|
|
35
|
-
index?: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const DEFAULT_ACCESSOR_VALUES = {
|
|
39
|
-
offset: 0,
|
|
40
|
-
stride: 0,
|
|
41
|
-
type: GL.FLOAT,
|
|
42
|
-
size: 1,
|
|
43
|
-
divisor: 0,
|
|
44
|
-
normalized: false,
|
|
45
|
-
integer: false
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export class Accessor implements AccessorObject {
|
|
49
|
-
offset?: number;
|
|
50
|
-
stride?: number;
|
|
51
|
-
type?: number;
|
|
52
|
-
size?: number;
|
|
53
|
-
divisor?: number;
|
|
54
|
-
normalized?: boolean;
|
|
55
|
-
integer?: boolean;
|
|
56
|
-
|
|
57
|
-
buffer?: Buffer;
|
|
58
|
-
index?: number;
|
|
59
|
-
|
|
60
|
-
static getBytesPerElement(accessor: Accessor | AccessorObject): number {
|
|
61
|
-
// TODO: using `FLOAT` when type is not specified,
|
|
62
|
-
// ensure this assumption is valid or force API to specify type.
|
|
63
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);
|
|
64
|
-
return ArrayType.BYTES_PER_ELEMENT;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static getBytesPerVertex(accessor: AccessorObject): number {
|
|
68
|
-
// assert(accessor.size);
|
|
69
|
-
// TODO: using `FLOAT` when type is not specified,
|
|
70
|
-
// ensure this assumption is valid or force API to specify type.
|
|
71
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type || GL.FLOAT);
|
|
72
|
-
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Combines (merges) a list of accessors. On top of default values
|
|
76
|
-
// Usually [programAccessor, bufferAccessor, appAccessor]
|
|
77
|
-
// All props will be set in the returned object.
|
|
78
|
-
// TODO check for conflicts between values in the supplied accessors
|
|
79
|
-
static resolve(...accessors: AccessorObject[]): Accessor {
|
|
80
|
-
return new Accessor(...[DEFAULT_ACCESSOR_VALUES, ...accessors]); // Default values
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
constructor(...accessors: AccessorObject[]) {
|
|
84
|
-
log.warn('Accessor will be removed in next minor release');
|
|
85
|
-
accessors.forEach(accessor => this._assign(accessor)); // Merge in sequence
|
|
86
|
-
Object.freeze(this);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
toString(): string {
|
|
90
|
-
return JSON.stringify(this);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ACCESSORS
|
|
94
|
-
|
|
95
|
-
// TODO - remove>
|
|
96
|
-
get BYTES_PER_ELEMENT(): number {
|
|
97
|
-
return Accessor.getBytesPerElement(this);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
get BYTES_PER_VERTEX(): number {
|
|
101
|
-
return Accessor.getBytesPerVertex(this);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// PRIVATE
|
|
105
|
-
|
|
106
|
-
// eslint-disable-next-line complexity, max-statements
|
|
107
|
-
_assign(props: AccessorObject = {}): this {
|
|
108
|
-
if (props.type !== undefined) {
|
|
109
|
-
this.type = props.type;
|
|
110
|
-
|
|
111
|
-
// Auto-deduce integer type?
|
|
112
|
-
if ((props.type as GL) === GL.INT || (props.type as GL) === GL.UNSIGNED_INT) {
|
|
113
|
-
this.integer = true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (props.size !== undefined) {
|
|
117
|
-
this.size = props.size;
|
|
118
|
-
}
|
|
119
|
-
if (props.offset !== undefined) {
|
|
120
|
-
this.offset = props.offset;
|
|
121
|
-
}
|
|
122
|
-
if (props.stride !== undefined) {
|
|
123
|
-
this.stride = props.stride;
|
|
124
|
-
}
|
|
125
|
-
// @ts-expect-error
|
|
126
|
-
if (props.normalize !== undefined) {
|
|
127
|
-
// @ts-expect-error
|
|
128
|
-
this.normalized = props.normalize;
|
|
129
|
-
}
|
|
130
|
-
if (props.normalized !== undefined) {
|
|
131
|
-
this.normalized = props.normalized;
|
|
132
|
-
}
|
|
133
|
-
if (props.integer !== undefined) {
|
|
134
|
-
this.integer = props.integer;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// INSTANCE DIVISOR
|
|
138
|
-
if (props.divisor !== undefined) {
|
|
139
|
-
this.divisor = props.divisor;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Buffer is optional
|
|
143
|
-
if (props.buffer !== undefined) {
|
|
144
|
-
this.buffer = props.buffer;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// The binding index (for binding e.g. Transform feedbacks and Uniform buffers)
|
|
148
|
-
// TODO - should this be part of accessor?
|
|
149
|
-
if (props.index !== undefined) {
|
|
150
|
-
if (typeof props.index === 'boolean') {
|
|
151
|
-
this.index = props.index ? 1 : 0;
|
|
152
|
-
} else {
|
|
153
|
-
this.index = props.index;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// DEPRECATED
|
|
158
|
-
// @ts-expect-error
|
|
159
|
-
if (props.instanced !== undefined) {
|
|
160
|
-
// @ts-expect-error
|
|
161
|
-
this.divisor = props.instanced ? 1 : 0;
|
|
162
|
-
}
|
|
163
|
-
// @ts-expect-error
|
|
164
|
-
if (props.isInstanced !== undefined) {
|
|
165
|
-
// @ts-expect-error
|
|
166
|
-
this.divisor = props.isInstanced ? 1 : 0;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (this.offset === undefined) delete this.offset;
|
|
170
|
-
if (this.stride === undefined) delete this.stride;
|
|
171
|
-
if (this.type === undefined) delete this.type;
|
|
172
|
-
if (this.size === undefined) delete this.size;
|
|
173
|
-
if (this.divisor === undefined) delete this.divisor;
|
|
174
|
-
if (this.normalized === undefined) delete this.normalized;
|
|
175
|
-
if (this.integer === undefined) delete this.integer;
|
|
176
|
-
|
|
177
|
-
if (this.buffer === undefined) delete this.buffer;
|
|
178
|
-
if (this.index === undefined) delete this.index;
|
|
179
|
-
|
|
180
|
-
return this;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Converts GL constant to corresponding TYPED ARRAY
|
|
186
|
-
* Used to auto deduce gl parameter types
|
|
187
|
-
* @deprecated Use getTypedArrayFromDataType
|
|
188
|
-
* @param glType
|
|
189
|
-
* @param param1
|
|
190
|
-
* @returns
|
|
191
|
-
*/
|
|
192
|
-
// eslint-disable-next-line complexity
|
|
193
|
-
function getTypedArrayFromGLType(
|
|
194
|
-
glType: GLDataType | GLPixelType,
|
|
195
|
-
options?: {
|
|
196
|
-
clamped?: boolean;
|
|
197
|
-
}
|
|
198
|
-
): TypedArrayConstructor {
|
|
199
|
-
const {clamped = true} = options || {};
|
|
200
|
-
// Sorted in some order of likelihood to reduce amount of comparisons
|
|
201
|
-
switch (glType) {
|
|
202
|
-
case GL.FLOAT:
|
|
203
|
-
return Float32Array;
|
|
204
|
-
case GL.UNSIGNED_SHORT:
|
|
205
|
-
case GL.UNSIGNED_SHORT_5_6_5:
|
|
206
|
-
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
207
|
-
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
208
|
-
return Uint16Array;
|
|
209
|
-
case GL.UNSIGNED_INT:
|
|
210
|
-
return Uint32Array;
|
|
211
|
-
case GL.UNSIGNED_BYTE:
|
|
212
|
-
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
213
|
-
case GL.BYTE:
|
|
214
|
-
return Int8Array;
|
|
215
|
-
case GL.SHORT:
|
|
216
|
-
return Int16Array;
|
|
217
|
-
case GL.INT:
|
|
218
|
-
return Int32Array;
|
|
219
|
-
default:
|
|
220
|
-
throw new Error('Failed to deduce typed array type from GL constant');
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// TEST EXPORTS
|
|
225
|
-
export {DEFAULT_ACCESSOR_VALUES};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {UniformValue, Binding} from '@luma.gl/core';
|
|
6
|
-
import {isNumericArray} from '@math.gl/types';
|
|
7
|
-
|
|
8
|
-
export function isUniformValue(value: unknown): value is UniformValue {
|
|
9
|
-
return isNumericArray(value) !== null || typeof value === 'number' || typeof value === 'boolean';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type UniformsAndBindings = {
|
|
13
|
-
bindings: Record<string, Binding>;
|
|
14
|
-
uniforms: Record<string, UniformValue>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function splitUniformsAndBindings(
|
|
18
|
-
uniforms: Record<string, Binding | UniformValue>
|
|
19
|
-
): UniformsAndBindings {
|
|
20
|
-
const result: UniformsAndBindings = {bindings: {}, uniforms: {}};
|
|
21
|
-
Object.keys(uniforms).forEach(name => {
|
|
22
|
-
const uniform = uniforms[name];
|
|
23
|
-
if (isUniformValue(uniform)) {
|
|
24
|
-
result.uniforms[name] = uniform;
|
|
25
|
-
} else {
|
|
26
|
-
result.bindings[name] = uniform;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return result;
|
|
31
|
-
}
|