@luma.gl/core 9.2.0-alpha.1 → 9.2.0-alpha.5
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/canvas-context.d.ts +19 -5
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +53 -3
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/device.d.ts +56 -11
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +78 -22
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/resources/buffer.d.ts +13 -7
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +1 -5
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +0 -1
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/framebuffer.d.ts +3 -3
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/pipeline-layout.d.ts +13 -0
- package/dist/adapter/resources/pipeline-layout.d.ts.map +1 -0
- package/dist/adapter/resources/pipeline-layout.js +21 -0
- package/dist/adapter/resources/pipeline-layout.js.map +1 -0
- package/dist/adapter/resources/render-pipeline.d.ts +4 -4
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/resource.d.ts +1 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +1 -1
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.js +1 -1
- package/dist/adapter/resources/vertex-array.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +3 -3
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/parameters.d.ts +2 -2
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +5 -6
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +3 -3
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +2 -2
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +430 -274
- package/dist/dist.min.js +5 -4
- package/dist/index.cjs +426 -273
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +18 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/portable/uniform-block.d.ts +1 -1
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-buffer-layout.d.ts +3 -3
- package/dist/portable/uniform-buffer-layout.d.ts.map +1 -1
- package/dist/portable/uniform-buffer-layout.js +8 -9
- package/dist/portable/uniform-buffer-layout.js.map +1 -1
- package/dist/portable/uniform-store.d.ts +2 -1
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/portable/uniform-store.js +1 -1
- package/dist/portable/uniform-store.js.map +1 -1
- package/dist/shadertypes/{data-types.d.ts → data-types/data-types.d.ts} +4 -0
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/data-types.js.map +1 -0
- package/dist/shadertypes/{utils → data-types}/decode-data-types.d.ts +4 -4
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/decode-data-types.js +74 -0
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -0
- package/dist/shadertypes/{utils → data-types}/decode-shader-types.d.ts +2 -2
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/decode-shader-types.js.map +1 -0
- package/dist/shadertypes/data-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/shader-types.js.map +1 -0
- package/dist/shadertypes/textures/pixel-utils.d.ts +112 -0
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/textures/pixel-utils.js +193 -0
- package/dist/shadertypes/textures/pixel-utils.js.map +1 -0
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +18 -0
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{utils/decode-texture-format.js → textures/texture-format-decoder.js} +48 -35
- package/dist/shadertypes/textures/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/textures/texture-format-generics.d.ts +33 -0
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +1 -0
- package/dist/shadertypes/{texture-formats.js → textures/texture-format-generics.js} +1 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +1 -0
- package/dist/shadertypes/{utils → textures}/texture-format-table.d.ts +2 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +1 -0
- package/dist/shadertypes/{utils → textures}/texture-format-table.js +41 -42
- package/dist/shadertypes/textures/texture-format-table.js.map +1 -0
- package/dist/shadertypes/textures/texture-formats.d.ts +90 -0
- package/dist/shadertypes/textures/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/textures/texture-formats.js +58 -0
- package/dist/shadertypes/textures/texture-formats.js.map +1 -0
- package/dist/shadertypes/{utils → vertex-arrays}/decode-vertex-format.d.ts +2 -2
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +1 -0
- package/dist/shadertypes/{utils → vertex-arrays}/decode-vertex-format.js +4 -4
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +1 -0
- package/dist/shadertypes/{vertex-formats.d.ts → vertex-arrays/vertex-formats.d.ts} +5 -3
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +1 -0
- package/package.json +2 -2
- package/src/adapter/canvas-context.ts +66 -8
- package/src/adapter/device.ts +132 -47
- package/src/adapter/resources/buffer.ts +30 -14
- package/src/adapter/resources/command-encoder.ts +0 -2
- package/src/adapter/resources/framebuffer.ts +5 -5
- package/src/adapter/resources/pipeline-layout.ts +30 -0
- package/src/adapter/resources/render-pipeline.ts +6 -6
- package/src/adapter/resources/resource.ts +1 -0
- package/src/adapter/resources/texture-view.ts +1 -1
- package/src/adapter/resources/texture.ts +1 -1
- package/src/adapter/resources/vertex-array.ts +1 -1
- package/src/adapter/types/attachments.ts +5 -5
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +2 -2
- package/src/adapter/types/shader-layout.ts +8 -5
- package/src/adapter-utils/get-attribute-from-layouts.ts +5 -5
- package/src/index.ts +60 -36
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-buffer-layout.ts +13 -12
- package/src/portable/uniform-store.ts +6 -2
- package/src/shadertypes/data-types/data-types.ts +96 -0
- package/src/shadertypes/data-types/decode-data-types.ts +91 -0
- package/src/shadertypes/{utils → data-types}/decode-shader-types.ts +2 -2
- package/src/shadertypes/textures/pixel-utils.ts +239 -0
- package/src/shadertypes/{utils/decode-texture-format.ts → textures/texture-format-decoder.ts} +63 -47
- package/src/shadertypes/textures/texture-format-generics.ts +190 -0
- package/src/shadertypes/{utils → textures}/texture-format-table.ts +62 -52
- package/src/shadertypes/{texture-formats.ts → textures/texture-formats.ts} +229 -147
- package/src/shadertypes/{utils → vertex-arrays}/decode-vertex-format.ts +6 -10
- package/src/shadertypes/{vertex-formats.ts → vertex-arrays/vertex-formats.ts} +20 -6
- package/dist/adapter-utils/buffer-layout-helper.d.ts +0 -11
- package/dist/adapter-utils/buffer-layout-helper.d.ts.map +0 -1
- package/dist/adapter-utils/buffer-layout-helper.js +0 -33
- package/dist/adapter-utils/buffer-layout-helper.js.map +0 -1
- package/dist/shadertypes/data-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types.js.map +0 -1
- package/dist/shadertypes/shader-types.d.ts.map +0 -1
- package/dist/shadertypes/shader-types.js.map +0 -1
- package/dist/shadertypes/texture-formats.d.ts +0 -74
- package/dist/shadertypes/texture-formats.d.ts.map +0 -1
- package/dist/shadertypes/texture-formats.js.map +0 -1
- package/dist/shadertypes/utils/decode-data-types.d.ts.map +0 -1
- package/dist/shadertypes/utils/decode-data-types.js +0 -114
- package/dist/shadertypes/utils/decode-data-types.js.map +0 -1
- package/dist/shadertypes/utils/decode-shader-types.d.ts.map +0 -1
- package/dist/shadertypes/utils/decode-shader-types.js.map +0 -1
- package/dist/shadertypes/utils/decode-texture-format.d.ts +0 -15
- package/dist/shadertypes/utils/decode-texture-format.d.ts.map +0 -1
- package/dist/shadertypes/utils/decode-texture-format.js.map +0 -1
- package/dist/shadertypes/utils/decode-vertex-format.d.ts.map +0 -1
- package/dist/shadertypes/utils/decode-vertex-format.js.map +0 -1
- package/dist/shadertypes/utils/texture-format-table.d.ts.map +0 -1
- package/dist/shadertypes/utils/texture-format-table.js.map +0 -1
- package/dist/shadertypes/vertex-formats.d.ts.map +0 -1
- package/dist/shadertypes/vertex-formats.js.map +0 -1
- package/src/adapter-utils/buffer-layout-helper.ts +0 -41
- package/src/shadertypes/data-types.ts +0 -42
- package/src/shadertypes/utils/decode-data-types.ts +0 -131
- /package/dist/shadertypes/{data-types.js → data-types/data-types.js} +0 -0
- /package/dist/shadertypes/{utils → data-types}/decode-shader-types.js +0 -0
- /package/dist/shadertypes/{shader-types.d.ts → data-types/shader-types.d.ts} +0 -0
- /package/dist/shadertypes/{shader-types.js → data-types/shader-types.js} +0 -0
- /package/dist/shadertypes/{vertex-formats.js → vertex-arrays/vertex-formats.js} +0 -0
- /package/src/shadertypes/{shader-types.ts → data-types/shader-types.ts} +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -44,6 +44,7 @@ var __exports__ = (() => {
|
|
|
44
44
|
DeviceLimits: () => DeviceLimits,
|
|
45
45
|
ExternalTexture: () => ExternalTexture,
|
|
46
46
|
Framebuffer: () => Framebuffer,
|
|
47
|
+
PipelineLayout: () => PipelineLayout,
|
|
47
48
|
QuerySet: () => QuerySet,
|
|
48
49
|
RenderPass: () => RenderPass,
|
|
49
50
|
RenderPipeline: () => RenderPipeline,
|
|
@@ -51,30 +52,31 @@ var __exports__ = (() => {
|
|
|
51
52
|
Sampler: () => Sampler,
|
|
52
53
|
Shader: () => Shader,
|
|
53
54
|
Texture: () => Texture,
|
|
55
|
+
TextureFormatDecoder: () => TextureFormatDecoder,
|
|
54
56
|
TextureView: () => TextureView,
|
|
55
57
|
TransformFeedback: () => TransformFeedback,
|
|
56
58
|
UniformBlock: () => UniformBlock,
|
|
57
59
|
UniformBufferLayout: () => UniformBufferLayout,
|
|
58
60
|
UniformStore: () => UniformStore,
|
|
59
61
|
VertexArray: () => VertexArray,
|
|
60
|
-
_BufferLayoutHelper: () => BufferLayoutHelper,
|
|
61
62
|
_getTextureFormatDefinition: () => getTextureFormatDefinition,
|
|
62
63
|
_getTextureFormatTable: () => getTextureFormatTable,
|
|
63
64
|
getAttributeInfosFromLayouts: () => getAttributeInfosFromLayouts,
|
|
64
65
|
getAttributeShaderTypeInfo: () => getAttributeShaderTypeInfo,
|
|
65
|
-
|
|
66
|
+
getDataType: () => getDataType,
|
|
66
67
|
getDataTypeInfo: () => getDataTypeInfo,
|
|
68
|
+
getNormalizedDataType: () => getNormalizedDataType,
|
|
67
69
|
getScratchArray: () => getScratchArray,
|
|
68
|
-
|
|
69
|
-
getTextureFormatInfo: () => getTextureFormatInfo,
|
|
70
|
-
getTypedArrayFromDataType: () => getTypedArrayFromDataType,
|
|
70
|
+
getTypedArrayConstructor: () => getTypedArrayConstructor,
|
|
71
71
|
getVariableShaderTypeInfo: () => getVariableShaderTypeInfo,
|
|
72
72
|
getVertexFormatFromAttribute: () => getVertexFormatFromAttribute,
|
|
73
73
|
getVertexFormatInfo: () => getVertexFormatInfo,
|
|
74
74
|
log: () => log,
|
|
75
75
|
luma: () => luma,
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
makeVertexFormat: () => makeVertexFormat,
|
|
77
|
+
readPixel: () => readPixel,
|
|
78
|
+
textureFormatDecoder: () => textureFormatDecoder,
|
|
79
|
+
writePixel: () => writePixel
|
|
78
80
|
});
|
|
79
81
|
|
|
80
82
|
// ../../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
|
|
@@ -315,7 +317,7 @@ var __exports__ = (() => {
|
|
|
315
317
|
}
|
|
316
318
|
|
|
317
319
|
// ../../node_modules/@probe.gl/env/dist/index.js
|
|
318
|
-
var VERSION = true ? "4.0
|
|
320
|
+
var VERSION = true ? "4.1.0" : "untranspiled source";
|
|
319
321
|
|
|
320
322
|
// ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
|
|
321
323
|
function getStorage(type) {
|
|
@@ -890,10 +892,6 @@ var __exports__ = (() => {
|
|
|
890
892
|
clone(props) {
|
|
891
893
|
return this.device.createBuffer({ ...this.props, ...props });
|
|
892
894
|
}
|
|
893
|
-
/** Read data synchronously. @note WebGL2 only */
|
|
894
|
-
readSyncWebGL(byteOffset, byteLength) {
|
|
895
|
-
throw new Error("not implemented");
|
|
896
|
-
}
|
|
897
895
|
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
898
896
|
debugData = new ArrayBuffer(0);
|
|
899
897
|
/** This doesn't handle partial non-zero offset updates correctly */
|
|
@@ -939,10 +937,10 @@ var __exports__ = (() => {
|
|
|
939
937
|
byteOffset: 0,
|
|
940
938
|
data: null,
|
|
941
939
|
indexType: "uint16",
|
|
942
|
-
|
|
940
|
+
onMapped: void 0
|
|
943
941
|
});
|
|
944
942
|
|
|
945
|
-
// src/shadertypes/
|
|
943
|
+
// src/shadertypes/data-types/decode-data-types.ts
|
|
946
944
|
function getDataTypeInfo(type) {
|
|
947
945
|
const [signedType, primitiveType, byteLength] = NORMALIZED_TYPE_MAP[type];
|
|
948
946
|
const normalized = type.includes("norm");
|
|
@@ -957,7 +955,7 @@ var __exports__ = (() => {
|
|
|
957
955
|
signed
|
|
958
956
|
};
|
|
959
957
|
}
|
|
960
|
-
function
|
|
958
|
+
function getNormalizedDataType(signedDataType) {
|
|
961
959
|
const dataType = signedDataType;
|
|
962
960
|
switch (dataType) {
|
|
963
961
|
case "uint8":
|
|
@@ -982,72 +980,117 @@ var __exports__ = (() => {
|
|
|
982
980
|
return size + (4 - size % 4) % 4;
|
|
983
981
|
}
|
|
984
982
|
}
|
|
985
|
-
function
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
return "uint32";
|
|
994
|
-
case Uint8Array:
|
|
995
|
-
case Uint8ClampedArray:
|
|
996
|
-
return "uint8";
|
|
997
|
-
case Int8Array:
|
|
998
|
-
return "sint8";
|
|
999
|
-
case Int16Array:
|
|
1000
|
-
return "sint16";
|
|
1001
|
-
case Int32Array:
|
|
1002
|
-
return "sint32";
|
|
1003
|
-
default:
|
|
1004
|
-
throw new Error(type.constructor.name);
|
|
983
|
+
function getDataType(arrayOrType) {
|
|
984
|
+
const Constructor = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
985
|
+
if (Constructor === Uint8ClampedArray) {
|
|
986
|
+
return "uint8";
|
|
987
|
+
}
|
|
988
|
+
const info = Object.values(NORMALIZED_TYPE_MAP).find((entry) => Constructor === entry[4]);
|
|
989
|
+
if (!info) {
|
|
990
|
+
throw new Error(Constructor.name);
|
|
1005
991
|
}
|
|
992
|
+
return info[0];
|
|
1006
993
|
}
|
|
1007
|
-
function
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
994
|
+
function getTypedArrayConstructor(type) {
|
|
995
|
+
const [, , , , Constructor] = NORMALIZED_TYPE_MAP[type];
|
|
996
|
+
return Constructor;
|
|
997
|
+
}
|
|
998
|
+
var NORMALIZED_TYPE_MAP = {
|
|
999
|
+
uint8: ["uint8", "u32", 1, false, Uint8Array],
|
|
1000
|
+
sint8: ["sint8", "i32", 1, false, Int8Array],
|
|
1001
|
+
unorm8: ["uint8", "f32", 1, true, Uint8Array],
|
|
1002
|
+
snorm8: ["sint8", "f32", 1, true, Int8Array],
|
|
1003
|
+
uint16: ["uint16", "u32", 2, false, Uint16Array],
|
|
1004
|
+
sint16: ["sint16", "i32", 2, false, Int16Array],
|
|
1005
|
+
unorm16: ["uint16", "u32", 2, true, Uint16Array],
|
|
1006
|
+
snorm16: ["sint16", "i32", 2, true, Int16Array],
|
|
1007
|
+
float16: ["float16", "f16", 2, false, Uint16Array],
|
|
1008
|
+
float32: ["float32", "f32", 4, false, Float32Array],
|
|
1009
|
+
uint32: ["uint32", "u32", 4, false, Uint32Array],
|
|
1010
|
+
sint32: ["sint32", "i32", 4, false, Int32Array]
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
// src/shadertypes/vertex-arrays/decode-vertex-format.ts
|
|
1014
|
+
function getVertexFormatInfo(format) {
|
|
1015
|
+
let webglOnly;
|
|
1016
|
+
if (format.endsWith("-webgl")) {
|
|
1017
|
+
format.replace("-webgl", "");
|
|
1018
|
+
webglOnly = true;
|
|
1019
|
+
}
|
|
1020
|
+
const [type_, count] = format.split("x");
|
|
1021
|
+
const type = type_;
|
|
1022
|
+
const components = count ? parseInt(count) : 1;
|
|
1023
|
+
const decodedType = getDataTypeInfo(type);
|
|
1024
|
+
const result = {
|
|
1025
|
+
type,
|
|
1026
|
+
components,
|
|
1027
|
+
byteLength: decodedType.byteLength * components,
|
|
1028
|
+
integer: decodedType.integer,
|
|
1029
|
+
signed: decodedType.signed,
|
|
1030
|
+
normalized: decodedType.normalized
|
|
1031
|
+
};
|
|
1032
|
+
if (webglOnly) {
|
|
1033
|
+
result.webglOnly = true;
|
|
1034
|
+
}
|
|
1035
|
+
return result;
|
|
1036
|
+
}
|
|
1037
|
+
function makeVertexFormat(signedDataType, components, normalized) {
|
|
1038
|
+
const dataType = normalized ? getNormalizedDataType(signedDataType) : signedDataType;
|
|
1039
|
+
switch (dataType) {
|
|
1040
|
+
case "unorm8":
|
|
1041
|
+
if (components === 1) {
|
|
1042
|
+
return "unorm8";
|
|
1043
|
+
}
|
|
1044
|
+
if (components === 3) {
|
|
1045
|
+
return "unorm8x3-webgl";
|
|
1046
|
+
}
|
|
1047
|
+
return `${dataType}x${components}`;
|
|
1048
|
+
case "snorm8":
|
|
1049
|
+
case "uint8":
|
|
1050
|
+
case "sint8":
|
|
1018
1051
|
case "uint16":
|
|
1019
|
-
case "unorm16":
|
|
1020
|
-
return Uint16Array;
|
|
1021
1052
|
case "sint16":
|
|
1053
|
+
case "unorm16":
|
|
1022
1054
|
case "snorm16":
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
case "snorm8":
|
|
1029
|
-
return Int8Array;
|
|
1030
|
-
case "f16":
|
|
1055
|
+
case "float16":
|
|
1056
|
+
if (components === 1 || components === 3) {
|
|
1057
|
+
throw new Error(`size: ${components}`);
|
|
1058
|
+
}
|
|
1059
|
+
return `${dataType}x${components}`;
|
|
1031
1060
|
default:
|
|
1032
|
-
|
|
1061
|
+
return components === 1 ? dataType : `${dataType}x${components}`;
|
|
1033
1062
|
}
|
|
1034
1063
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1064
|
+
function getVertexFormatFromAttribute(typedArray, size, normalized) {
|
|
1065
|
+
if (!size || size > 4) {
|
|
1066
|
+
throw new Error(`size ${size}`);
|
|
1067
|
+
}
|
|
1068
|
+
const components = size;
|
|
1069
|
+
const signedDataType = getDataType(typedArray);
|
|
1070
|
+
return makeVertexFormat(signedDataType, components, normalized);
|
|
1071
|
+
}
|
|
1072
|
+
function getCompatibleVertexFormat(opts) {
|
|
1073
|
+
let vertexType;
|
|
1074
|
+
switch (opts.primitiveType) {
|
|
1075
|
+
case "f32":
|
|
1076
|
+
vertexType = "float32";
|
|
1077
|
+
break;
|
|
1078
|
+
case "i32":
|
|
1079
|
+
vertexType = "sint32";
|
|
1080
|
+
break;
|
|
1081
|
+
case "u32":
|
|
1082
|
+
vertexType = "uint32";
|
|
1083
|
+
break;
|
|
1084
|
+
case "f16":
|
|
1085
|
+
return opts.components <= 2 ? "float16x2" : "float16x4";
|
|
1086
|
+
}
|
|
1087
|
+
if (opts.components === 1) {
|
|
1088
|
+
return vertexType;
|
|
1089
|
+
}
|
|
1090
|
+
return `${vertexType}x${opts.components}`;
|
|
1091
|
+
}
|
|
1049
1092
|
|
|
1050
|
-
// src/shadertypes/
|
|
1093
|
+
// src/shadertypes/textures/texture-format-table.ts
|
|
1051
1094
|
var texture_compression_bc = "texture-compression-bc";
|
|
1052
1095
|
var texture_compression_astc = "texture-compression-astc";
|
|
1053
1096
|
var texture_compression_etc2 = "texture-compression-etc2";
|
|
@@ -1072,73 +1115,65 @@ var __exports__ = (() => {
|
|
|
1072
1115
|
function getTextureFormatTable() {
|
|
1073
1116
|
return TEXTURE_FORMAT_TABLE;
|
|
1074
1117
|
}
|
|
1075
|
-
var
|
|
1118
|
+
var TEXTURE_FORMAT_COLOR_DEPTH_TABLE = {
|
|
1076
1119
|
// 8-bit formats
|
|
1077
1120
|
"r8unorm": {},
|
|
1078
|
-
"r8snorm": { render: snorm8_renderable },
|
|
1079
|
-
"r8uint": {},
|
|
1080
|
-
"r8sint": {},
|
|
1081
|
-
// 16-bit formats
|
|
1082
1121
|
"rg8unorm": {},
|
|
1083
|
-
"rg8snorm": { render: snorm8_renderable },
|
|
1084
|
-
"rg8uint": {},
|
|
1085
|
-
"rg8sint": {},
|
|
1086
|
-
"r16uint": {},
|
|
1087
|
-
"r16sint": {},
|
|
1088
|
-
"r16float": { render: float16_renderable, filter: "float16-filterable-webgl" },
|
|
1089
|
-
"r16unorm-webgl": { f: norm16_renderable },
|
|
1090
|
-
"r16snorm-webgl": { f: snorm16_renderable },
|
|
1091
|
-
// Packed 16-bit formats
|
|
1092
|
-
"rgba4unorm-webgl": { channels: "rgba", bitsPerChannel: [4, 4, 4, 4], packed: true },
|
|
1093
|
-
"rgb565unorm-webgl": { channels: "rgb", bitsPerChannel: [5, 6, 5, 0], packed: true },
|
|
1094
|
-
"rgb5a1unorm-webgl": { channels: "rgba", bitsPerChannel: [5, 5, 5, 1], packed: true },
|
|
1095
|
-
// 24-bit formats
|
|
1096
1122
|
"rgb8unorm-webgl": {},
|
|
1097
|
-
"rgb8snorm-webgl": {},
|
|
1098
|
-
// 32-bit formats
|
|
1099
1123
|
"rgba8unorm": {},
|
|
1100
1124
|
"rgba8unorm-srgb": {},
|
|
1125
|
+
"r8snorm": { render: snorm8_renderable },
|
|
1126
|
+
"rg8snorm": { render: snorm8_renderable },
|
|
1127
|
+
"rgb8snorm-webgl": {},
|
|
1101
1128
|
"rgba8snorm": { render: snorm8_renderable },
|
|
1129
|
+
"r8uint": {},
|
|
1130
|
+
"rg8uint": {},
|
|
1102
1131
|
"rgba8uint": {},
|
|
1132
|
+
"r8sint": {},
|
|
1133
|
+
"rg8sint": {},
|
|
1103
1134
|
"rgba8sint": {},
|
|
1104
|
-
// 32-bit, reverse colors, webgpu only
|
|
1105
1135
|
"bgra8unorm": {},
|
|
1106
1136
|
"bgra8unorm-srgb": {},
|
|
1137
|
+
"r16unorm": { f: norm16_renderable },
|
|
1138
|
+
"rg16unorm": { render: norm16_renderable },
|
|
1139
|
+
"rgb16unorm-webgl": { f: norm16_renderable },
|
|
1140
|
+
// rgb not renderable
|
|
1141
|
+
"rgba16unorm": { render: norm16_renderable },
|
|
1142
|
+
"r16snorm": { f: snorm16_renderable },
|
|
1143
|
+
"rg16snorm": { render: snorm16_renderable },
|
|
1144
|
+
"rgb16snorm-webgl": { f: norm16_renderable },
|
|
1145
|
+
// rgb not renderable
|
|
1146
|
+
"rgba16snorm": { render: snorm16_renderable },
|
|
1147
|
+
"r16uint": {},
|
|
1107
1148
|
"rg16uint": {},
|
|
1149
|
+
"rgba16uint": {},
|
|
1150
|
+
"r16sint": {},
|
|
1108
1151
|
"rg16sint": {},
|
|
1152
|
+
"rgba16sint": {},
|
|
1153
|
+
"r16float": { render: float16_renderable, filter: "float16-filterable-webgl" },
|
|
1109
1154
|
"rg16float": { render: float16_renderable, filter: float16_filterable },
|
|
1110
|
-
"
|
|
1111
|
-
"rg16snorm-webgl": { render: snorm16_renderable },
|
|
1155
|
+
"rgba16float": { render: float16_renderable, filter: float16_filterable },
|
|
1112
1156
|
"r32uint": {},
|
|
1157
|
+
"rg32uint": {},
|
|
1158
|
+
"rgba32uint": {},
|
|
1113
1159
|
"r32sint": {},
|
|
1160
|
+
"rg32sint": {},
|
|
1161
|
+
"rgba32sint": {},
|
|
1114
1162
|
"r32float": { render: float32_renderable, filter: float32_filterable },
|
|
1163
|
+
"rg32float": { render: false, filter: float32_filterable },
|
|
1164
|
+
"rgb32float-webgl": { render: float32_renderable, filter: float32_filterable },
|
|
1165
|
+
"rgba32float": { render: float32_renderable, filter: float32_filterable },
|
|
1166
|
+
// Packed 16-bit formats
|
|
1167
|
+
"rgba4unorm-webgl": { channels: "rgba", bitsPerChannel: [4, 4, 4, 4], packed: true },
|
|
1168
|
+
"rgb565unorm-webgl": { channels: "rgb", bitsPerChannel: [5, 6, 5, 0], packed: true },
|
|
1169
|
+
"rgb5a1unorm-webgl": { channels: "rgba", bitsPerChannel: [5, 5, 5, 1], packed: true },
|
|
1115
1170
|
// Packed 32 bit formats
|
|
1116
1171
|
"rgb9e5ufloat": { channels: "rgb", packed: true, render: rgb9e5ufloat_renderable },
|
|
1117
1172
|
// , filter: true},
|
|
1118
1173
|
"rg11b10ufloat": { channels: "rgb", bitsPerChannel: [11, 11, 10, 0], packed: true, p: 1, render: float32_renderable },
|
|
1119
1174
|
"rgb10a2unorm": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
|
|
1120
1175
|
"rgb10a2uint": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
|
|
1121
|
-
//
|
|
1122
|
-
"rgb16unorm-webgl": { f: norm16_renderable },
|
|
1123
|
-
// rgb not renderable
|
|
1124
|
-
"rgb16snorm-webgl": { f: norm16_renderable },
|
|
1125
|
-
// rgb not renderable
|
|
1126
|
-
// 64-bit formats
|
|
1127
|
-
"rg32uint": {},
|
|
1128
|
-
"rg32sint": {},
|
|
1129
|
-
"rg32float": { render: false, filter: float32_filterable },
|
|
1130
|
-
"rgba16uint": {},
|
|
1131
|
-
"rgba16sint": {},
|
|
1132
|
-
"rgba16float": { render: float16_renderable, filter: float16_filterable },
|
|
1133
|
-
"rgba16unorm-webgl": { render: norm16_renderable },
|
|
1134
|
-
"rgba16snorm-webgl": { render: snorm16_renderable },
|
|
1135
|
-
// 96-bit formats (deprecated!)
|
|
1136
|
-
"rgb32float-webgl": { render: float32_renderable, filter: float32_filterable },
|
|
1137
|
-
// 128-bit formats
|
|
1138
|
-
"rgba32uint": {},
|
|
1139
|
-
"rgba32sint": {},
|
|
1140
|
-
"rgba32float": { render: float32_renderable, filter: float32_filterable },
|
|
1141
|
-
// Depth/stencil
|
|
1176
|
+
// Depth/stencil Formats
|
|
1142
1177
|
// Depth and stencil formats
|
|
1143
1178
|
stencil8: { attachment: "stencil", bitsPerChannel: [8, 0, 0, 0], dataType: "uint8" },
|
|
1144
1179
|
"depth16unorm": { attachment: "depth", bitsPerChannel: [16, 0, 0, 0], dataType: "uint16" },
|
|
@@ -1147,7 +1182,9 @@ var __exports__ = (() => {
|
|
|
1147
1182
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
1148
1183
|
"depth24plus-stencil8": { attachment: "depth-stencil", bitsPerChannel: [24, 8, 0, 0], packed: true },
|
|
1149
1184
|
// "depth32float-stencil8" feature
|
|
1150
|
-
"depth32float-stencil8": { attachment: "depth-stencil", bitsPerChannel: [32, 8, 0, 0], packed: true }
|
|
1185
|
+
"depth32float-stencil8": { attachment: "depth-stencil", bitsPerChannel: [32, 8, 0, 0], packed: true }
|
|
1186
|
+
};
|
|
1187
|
+
var TEXTURE_FORMAT_COMPRESSED_TABLE = {
|
|
1151
1188
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
1152
1189
|
"bc1-rgb-unorm-webgl": { f: texture_compression_bc },
|
|
1153
1190
|
"bc1-rgb-unorm-srgb-webgl": { f: texture_compression_bc },
|
|
@@ -1218,8 +1255,12 @@ var __exports__ = (() => {
|
|
|
1218
1255
|
"atc-rgba-unorm-webgl": { f: texture_compression_atc_webgl },
|
|
1219
1256
|
"atc-rgbai-unorm-webgl": { f: texture_compression_atc_webgl }
|
|
1220
1257
|
};
|
|
1258
|
+
var TEXTURE_FORMAT_TABLE = {
|
|
1259
|
+
...TEXTURE_FORMAT_COLOR_DEPTH_TABLE,
|
|
1260
|
+
...TEXTURE_FORMAT_COMPRESSED_TABLE
|
|
1261
|
+
};
|
|
1221
1262
|
|
|
1222
|
-
// src/shadertypes/
|
|
1263
|
+
// src/shadertypes/textures/texture-format-decoder.ts
|
|
1223
1264
|
var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
|
|
1224
1265
|
"bc1",
|
|
1225
1266
|
"bc2",
|
|
@@ -1236,12 +1277,51 @@ var __exports__ = (() => {
|
|
|
1236
1277
|
"pvrtc"
|
|
1237
1278
|
];
|
|
1238
1279
|
var RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1280
|
+
var TextureFormatDecoder = class {
|
|
1281
|
+
/** Returns information about a texture format, e.g. attatchment type, components, byte length and flags (integer, signed, normalized) */
|
|
1282
|
+
getInfo(format) {
|
|
1283
|
+
return getTextureFormatInfo(format);
|
|
1284
|
+
}
|
|
1285
|
+
/** Checks if a texture format is color */
|
|
1286
|
+
isColor(format) {
|
|
1287
|
+
return format.startsWith("rgba") || format.startsWith("bgra") || format.startsWith("rgb");
|
|
1288
|
+
}
|
|
1289
|
+
/** Checks if a texture format is depth or stencil */
|
|
1290
|
+
isDepthStencil(format) {
|
|
1291
|
+
return format.startsWith("depth") || format.startsWith("stencil");
|
|
1292
|
+
}
|
|
1293
|
+
/** Checks if a texture format is compressed */
|
|
1294
|
+
isCompressed(format) {
|
|
1295
|
+
return COMPRESSED_TEXTURE_FORMAT_PREFIXES.some((prefix) => format.startsWith(prefix));
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Returns the "static" capabilities of a texture format.
|
|
1299
|
+
* @note Needs to be checked against current device
|
|
1300
|
+
*/
|
|
1301
|
+
getCapabilities(format) {
|
|
1302
|
+
const info = getTextureFormatDefinition(format);
|
|
1303
|
+
const formatCapabilities = {
|
|
1304
|
+
format,
|
|
1305
|
+
create: info.f ?? true,
|
|
1306
|
+
render: info.render ?? true,
|
|
1307
|
+
filter: info.filter ?? true,
|
|
1308
|
+
blend: info.blend ?? true,
|
|
1309
|
+
store: info.store ?? true
|
|
1310
|
+
};
|
|
1311
|
+
const formatInfo = getTextureFormatInfo(format);
|
|
1312
|
+
const isDepthStencil = format.startsWith("depth") || format.startsWith("stencil");
|
|
1313
|
+
const isSigned = formatInfo?.signed;
|
|
1314
|
+
const isInteger = formatInfo?.integer;
|
|
1315
|
+
const isWebGLSpecific = formatInfo?.webgl;
|
|
1316
|
+
formatCapabilities.render &&= !isSigned;
|
|
1317
|
+
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
1318
|
+
return formatCapabilities;
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
var textureFormatDecoder = new TextureFormatDecoder();
|
|
1242
1322
|
function getTextureFormatInfo(format) {
|
|
1243
1323
|
let formatInfo = getTextureFormatInfoUsingTable(format);
|
|
1244
|
-
if (
|
|
1324
|
+
if (textureFormatDecoder.isCompressed(format)) {
|
|
1245
1325
|
formatInfo.channels = "rgb";
|
|
1246
1326
|
formatInfo.components = 3;
|
|
1247
1327
|
formatInfo.bytesPerPixel = 1;
|
|
@@ -1295,25 +1375,6 @@ var __exports__ = (() => {
|
|
|
1295
1375
|
}
|
|
1296
1376
|
return formatInfo;
|
|
1297
1377
|
}
|
|
1298
|
-
function getTextureFormatCapabilities(format) {
|
|
1299
|
-
const info = getTextureFormatDefinition(format);
|
|
1300
|
-
const formatCapabilities = {
|
|
1301
|
-
format,
|
|
1302
|
-
create: info.f ?? true,
|
|
1303
|
-
render: info.render ?? true,
|
|
1304
|
-
filter: info.filter ?? true,
|
|
1305
|
-
blend: info.blend ?? true,
|
|
1306
|
-
store: info.store ?? true
|
|
1307
|
-
};
|
|
1308
|
-
const formatInfo = getTextureFormatInfo(format);
|
|
1309
|
-
const isDepthStencil = format.startsWith("depth") || format.startsWith("stencil");
|
|
1310
|
-
const isSigned = formatInfo?.signed;
|
|
1311
|
-
const isInteger = formatInfo?.integer;
|
|
1312
|
-
const isWebGLSpecific = formatInfo?.webgl;
|
|
1313
|
-
formatCapabilities.render &&= !isSigned;
|
|
1314
|
-
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
1315
|
-
return formatCapabilities;
|
|
1316
|
-
}
|
|
1317
1378
|
function getTextureFormatInfoUsingTable(format) {
|
|
1318
1379
|
const info = getTextureFormatDefinition(format);
|
|
1319
1380
|
const bytesPerPixel = info.bytesPerPixel || 1;
|
|
@@ -1395,9 +1456,8 @@ var __exports__ = (() => {
|
|
|
1395
1456
|
get [Symbol.toStringTag]() {
|
|
1396
1457
|
return "Device";
|
|
1397
1458
|
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
1459
|
+
toString() {
|
|
1460
|
+
return `Device(${this.id})`;
|
|
1401
1461
|
}
|
|
1402
1462
|
/** id of this device, primarily for debugging */
|
|
1403
1463
|
id;
|
|
@@ -1409,12 +1469,24 @@ var __exports__ = (() => {
|
|
|
1409
1469
|
statsManager = lumaStats;
|
|
1410
1470
|
/** An abstract timestamp used for change tracking */
|
|
1411
1471
|
timestamp = 0;
|
|
1472
|
+
/** True if this device has been reused during device creation (app has multiple references) */
|
|
1473
|
+
_reused = false;
|
|
1412
1474
|
/** Used by other luma.gl modules to store data on the device */
|
|
1413
1475
|
_lumaData = {};
|
|
1414
1476
|
_textureCaps = {};
|
|
1477
|
+
constructor(props) {
|
|
1478
|
+
this.props = { ..._Device.defaultProps, ...props };
|
|
1479
|
+
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
1480
|
+
}
|
|
1481
|
+
getVertexFormatInfo(format) {
|
|
1482
|
+
return getVertexFormatInfo(format);
|
|
1483
|
+
}
|
|
1484
|
+
isVertexFormatSupported(format) {
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1415
1487
|
/** Returns information about a texture format, such as data type, channels, bits per channel, compression etc */
|
|
1416
1488
|
getTextureFormatInfo(format) {
|
|
1417
|
-
return
|
|
1489
|
+
return textureFormatDecoder.getInfo(format);
|
|
1418
1490
|
}
|
|
1419
1491
|
/** Determines what operations are supported on a texture format on this particular device (checks against supported device features) */
|
|
1420
1492
|
getTextureFormatCapabilities(format) {
|
|
@@ -1453,7 +1525,7 @@ var __exports__ = (() => {
|
|
|
1453
1525
|
}
|
|
1454
1526
|
/** Check if a specific texture format is GPU compressed */
|
|
1455
1527
|
isTextureFormatCompressed(format) {
|
|
1456
|
-
return
|
|
1528
|
+
return textureFormatDecoder.isCompressed(format);
|
|
1457
1529
|
}
|
|
1458
1530
|
// DEBUG METHODS
|
|
1459
1531
|
pushDebugGroup(groupLabel) {
|
|
@@ -1477,12 +1549,40 @@ var __exports__ = (() => {
|
|
|
1477
1549
|
incrementTimestamp() {
|
|
1478
1550
|
return this.timestamp++;
|
|
1479
1551
|
}
|
|
1480
|
-
/**
|
|
1481
|
-
|
|
1552
|
+
/**
|
|
1553
|
+
* Reports Device errors in a way that optimizes for developer experience / debugging.
|
|
1554
|
+
* - Logs so that the console error links directly to the source code that generated the error.
|
|
1555
|
+
* - Includes the object that reported the error in the log message, even if the error is asynchronous.
|
|
1556
|
+
*
|
|
1557
|
+
* Conventions when calling reportError():
|
|
1558
|
+
* - Always call the returned function - to ensure error is logged, at the error site
|
|
1559
|
+
* - Follow with a call to device.debug() - to ensure that the debugger breaks at the error site
|
|
1560
|
+
*
|
|
1561
|
+
* @param error - the error to report. If needed, just create a new Error object with the appropriate message.
|
|
1562
|
+
* @param context - pass `this` as context, otherwise it may not be available in the debugger for async errors.
|
|
1563
|
+
* @returns the logger function returned by device.props.onError() so that it can be called from the error site.
|
|
1564
|
+
*
|
|
1565
|
+
* @example
|
|
1566
|
+
* device.reportError(new Error(...), this)();
|
|
1567
|
+
* device.debug();
|
|
1568
|
+
*/
|
|
1569
|
+
reportError(error, context, ...args) {
|
|
1570
|
+
const isHandled = this.props.onError(error, context);
|
|
1571
|
+
if (!isHandled) {
|
|
1572
|
+
return log.error(error.message, context, ...args);
|
|
1573
|
+
}
|
|
1574
|
+
return () => {
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
/** Break in the debugger - if device.props.debug is true */
|
|
1578
|
+
debug() {
|
|
1482
1579
|
if (this.props.debug) {
|
|
1483
1580
|
debugger;
|
|
1581
|
+
} else {
|
|
1582
|
+
const message = `'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
1583
|
+
or create a device with the 'debug: true' prop.`;
|
|
1584
|
+
log.once(0, message)();
|
|
1484
1585
|
}
|
|
1485
|
-
this.props.onError(error, context);
|
|
1486
1586
|
}
|
|
1487
1587
|
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
1488
1588
|
getDefaultCanvasContext() {
|
|
@@ -1535,8 +1635,12 @@ var __exports__ = (() => {
|
|
|
1535
1635
|
throw new Error("not implemented");
|
|
1536
1636
|
}
|
|
1537
1637
|
// IMPLEMENTATION
|
|
1638
|
+
/** Helper to get the canvas context props */
|
|
1639
|
+
static _getCanvasContextProps(props) {
|
|
1640
|
+
return props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
1641
|
+
}
|
|
1538
1642
|
_getDeviceTextureFormatCapabilities(format) {
|
|
1539
|
-
const genericCapabilities =
|
|
1643
|
+
const genericCapabilities = textureFormatDecoder.getCapabilities(format);
|
|
1540
1644
|
const checkFeature = (feature) => (typeof feature === "string" ? this.features.has(feature) : feature) ?? true;
|
|
1541
1645
|
const supported = checkFeature(genericCapabilities.create);
|
|
1542
1646
|
return {
|
|
@@ -1554,13 +1658,17 @@ var __exports__ = (() => {
|
|
|
1554
1658
|
props = { data: props };
|
|
1555
1659
|
}
|
|
1556
1660
|
const newProps = { ...props };
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1661
|
+
const usage = props.usage || 0;
|
|
1662
|
+
if (usage & Buffer2.INDEX) {
|
|
1663
|
+
if (!props.indexType) {
|
|
1664
|
+
if (props.data instanceof Uint32Array) {
|
|
1665
|
+
newProps.indexType = "uint32";
|
|
1666
|
+
} else if (props.data instanceof Uint16Array) {
|
|
1667
|
+
newProps.indexType = "uint16";
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
if (!newProps.indexType) {
|
|
1671
|
+
throw new Error("indices buffer content must be of type uint16 or uint32");
|
|
1564
1672
|
}
|
|
1565
1673
|
}
|
|
1566
1674
|
return newProps;
|
|
@@ -1575,11 +1683,16 @@ var __exports__ = (() => {
|
|
|
1575
1683
|
// WebGL specific
|
|
1576
1684
|
webgl: {},
|
|
1577
1685
|
// Callbacks
|
|
1578
|
-
|
|
1686
|
+
// eslint-disable-next-line handle-callback-err
|
|
1687
|
+
onError: (error, context) => {
|
|
1688
|
+
},
|
|
1579
1689
|
onResize: (context, info) => {
|
|
1580
1690
|
const [width, height] = context.getDevicePixelSize();
|
|
1581
|
-
|
|
1582
|
-
|
|
1691
|
+
log.log(1, `${context} resized => ${width}x${height}px`)();
|
|
1692
|
+
},
|
|
1693
|
+
onPositionChange: (context, info) => {
|
|
1694
|
+
const [left, top] = context.getPosition();
|
|
1695
|
+
log.log(1, `${context} repositioned => ${left},${top}`)();
|
|
1583
1696
|
},
|
|
1584
1697
|
onVisibilityChange: (context) => log.log(1, `${context} Visibility changed ${context.isVisible}`)(),
|
|
1585
1698
|
onDevicePixelRatioChange: (context, info) => log.log(1, `${context} DPR changed ${info.oldRatio} => ${context.devicePixelRatio}`)(),
|
|
@@ -1593,6 +1706,7 @@ var __exports__ = (() => {
|
|
|
1593
1706
|
// Note: log setting is queried by the spector.js code
|
|
1594
1707
|
debugSpectorJSUrl: void 0,
|
|
1595
1708
|
// Experimental
|
|
1709
|
+
_reuseDevices: false,
|
|
1596
1710
|
_requestMaxLimits: true,
|
|
1597
1711
|
_cacheShaders: false,
|
|
1598
1712
|
_cachePipelines: false,
|
|
@@ -1831,6 +1945,8 @@ var __exports__ = (() => {
|
|
|
1831
1945
|
_initializedResolvers = withResolvers();
|
|
1832
1946
|
_resizeObserver;
|
|
1833
1947
|
_intersectionObserver;
|
|
1948
|
+
_position;
|
|
1949
|
+
destroyed = false;
|
|
1834
1950
|
toString() {
|
|
1835
1951
|
return `${this[Symbol.toStringTag]}(${this.id})`;
|
|
1836
1952
|
}
|
|
@@ -1866,6 +1982,7 @@ var __exports__ = (() => {
|
|
|
1866
1982
|
this.drawingBufferWidth = this.canvas.width;
|
|
1867
1983
|
this.drawingBufferHeight = this.canvas.height;
|
|
1868
1984
|
this.devicePixelRatio = globalThis.devicePixelRatio || 1;
|
|
1985
|
+
this._position = [0, 0];
|
|
1869
1986
|
if (_CanvasContext.isHTMLCanvas(this.canvas)) {
|
|
1870
1987
|
this._intersectionObserver = new IntersectionObserver(
|
|
1871
1988
|
(entries) => this._handleIntersection(entries)
|
|
@@ -1878,8 +1995,14 @@ var __exports__ = (() => {
|
|
|
1878
1995
|
this._resizeObserver.observe(this.canvas, { box: "content-box" });
|
|
1879
1996
|
}
|
|
1880
1997
|
setTimeout(() => this._observeDevicePixelRatio(), 0);
|
|
1998
|
+
if (this.props.trackPosition) {
|
|
1999
|
+
this._trackPosition();
|
|
2000
|
+
}
|
|
1881
2001
|
}
|
|
1882
2002
|
}
|
|
2003
|
+
destroy() {
|
|
2004
|
+
this.destroyed = true;
|
|
2005
|
+
}
|
|
1883
2006
|
// SIZE METHODS
|
|
1884
2007
|
/**
|
|
1885
2008
|
* Returns the size covered by the canvas in CSS pixels
|
|
@@ -1889,6 +2012,9 @@ var __exports__ = (() => {
|
|
|
1889
2012
|
getCSSSize() {
|
|
1890
2013
|
return [this.cssWidth, this.cssHeight];
|
|
1891
2014
|
}
|
|
2015
|
+
getPosition() {
|
|
2016
|
+
return this._position;
|
|
2017
|
+
}
|
|
1892
2018
|
/**
|
|
1893
2019
|
* Returns the size covered by the canvas in actual device pixels.
|
|
1894
2020
|
* @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
|
|
@@ -1995,7 +2121,10 @@ var __exports__ = (() => {
|
|
|
1995
2121
|
this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
|
|
1996
2122
|
this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
|
|
1997
2123
|
if (this.props.autoResize) {
|
|
1998
|
-
if (this.props.useDevicePixels) {
|
|
2124
|
+
if (typeof this.props.useDevicePixels === "number") {
|
|
2125
|
+
const dpr = this.props.useDevicePixels;
|
|
2126
|
+
this.setDrawingBufferSize(this.cssWidth * dpr, this.cssHeight * dpr);
|
|
2127
|
+
} else if (this.props.useDevicePixels) {
|
|
1999
2128
|
this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);
|
|
2000
2129
|
} else {
|
|
2001
2130
|
this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
|
|
@@ -2004,12 +2133,14 @@ var __exports__ = (() => {
|
|
|
2004
2133
|
}
|
|
2005
2134
|
this._initializedResolvers.resolve();
|
|
2006
2135
|
this.isInitialized = true;
|
|
2136
|
+
this.updatePosition();
|
|
2007
2137
|
this.device.props.onResize(this, { oldPixelSize });
|
|
2008
2138
|
}
|
|
2009
2139
|
/** Monitor DPR changes */
|
|
2010
2140
|
_observeDevicePixelRatio() {
|
|
2011
2141
|
const oldRatio = this.devicePixelRatio;
|
|
2012
2142
|
this.devicePixelRatio = window.devicePixelRatio;
|
|
2143
|
+
this.updatePosition();
|
|
2013
2144
|
this.device.props.onDevicePixelRatioChange(this, { oldRatio });
|
|
2014
2145
|
matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener(
|
|
2015
2146
|
"change",
|
|
@@ -2017,6 +2148,34 @@ var __exports__ = (() => {
|
|
|
2017
2148
|
{ once: true }
|
|
2018
2149
|
);
|
|
2019
2150
|
}
|
|
2151
|
+
/** Start tracking positions with a timer */
|
|
2152
|
+
_trackPosition(intervalMs = 100) {
|
|
2153
|
+
const intervalId = setInterval(() => {
|
|
2154
|
+
if (this.destroyed) {
|
|
2155
|
+
clearInterval(intervalId);
|
|
2156
|
+
} else {
|
|
2157
|
+
this.updatePosition();
|
|
2158
|
+
}
|
|
2159
|
+
}, intervalMs);
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Calculated the absolute position of the canvas
|
|
2163
|
+
* @note - getBoundingClientRect() is normally cheap but can be expensive
|
|
2164
|
+
* if called before browser has finished a reflow. Should not be the case here.
|
|
2165
|
+
*/
|
|
2166
|
+
updatePosition() {
|
|
2167
|
+
const newRect = this.htmlCanvas?.getBoundingClientRect();
|
|
2168
|
+
if (newRect) {
|
|
2169
|
+
const position = [newRect.left, newRect.top];
|
|
2170
|
+
this._position ??= position;
|
|
2171
|
+
const positionChanged = position[0] !== this._position[0] || position[1] !== this._position[1];
|
|
2172
|
+
if (positionChanged) {
|
|
2173
|
+
const oldPosition = this._position;
|
|
2174
|
+
this._position = position;
|
|
2175
|
+
this.device.props.onPositionChange?.(this, { oldPosition });
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2020
2179
|
};
|
|
2021
2180
|
var CanvasContext = _CanvasContext;
|
|
2022
2181
|
__publicField(CanvasContext, "defaultProps", {
|
|
@@ -2029,7 +2188,8 @@ var __exports__ = (() => {
|
|
|
2029
2188
|
container: null,
|
|
2030
2189
|
visible: true,
|
|
2031
2190
|
alphaMode: "opaque",
|
|
2032
|
-
colorSpace: "srgb"
|
|
2191
|
+
colorSpace: "srgb",
|
|
2192
|
+
trackPosition: false
|
|
2033
2193
|
});
|
|
2034
2194
|
function getContainer(container) {
|
|
2035
2195
|
if (typeof container === "string") {
|
|
@@ -2817,7 +2977,7 @@ ${htmlLog}
|
|
|
2817
2977
|
...Resource.defaultProps
|
|
2818
2978
|
});
|
|
2819
2979
|
|
|
2820
|
-
// src/shadertypes/
|
|
2980
|
+
// src/shadertypes/data-types/decode-shader-types.ts
|
|
2821
2981
|
function getVariableShaderTypeInfo(format) {
|
|
2822
2982
|
const decoded = UNIFORM_FORMATS[format];
|
|
2823
2983
|
return decoded;
|
|
@@ -2970,86 +3130,6 @@ ${htmlLog}
|
|
|
2970
3130
|
mat4x4h: "mat4x4<f16>"
|
|
2971
3131
|
};
|
|
2972
3132
|
|
|
2973
|
-
// src/shadertypes/utils/decode-vertex-format.ts
|
|
2974
|
-
function getVertexFormatInfo(format) {
|
|
2975
|
-
let webglOnly;
|
|
2976
|
-
if (format.endsWith("-webgl")) {
|
|
2977
|
-
format.replace("-webgl", "");
|
|
2978
|
-
webglOnly = true;
|
|
2979
|
-
}
|
|
2980
|
-
const [type_, count] = format.split("x");
|
|
2981
|
-
const type = type_;
|
|
2982
|
-
const components = count ? parseInt(count) : 1;
|
|
2983
|
-
const decodedType = getDataTypeInfo(type);
|
|
2984
|
-
const result = {
|
|
2985
|
-
type,
|
|
2986
|
-
components,
|
|
2987
|
-
byteLength: decodedType.byteLength * components,
|
|
2988
|
-
integer: decodedType.integer,
|
|
2989
|
-
signed: decodedType.signed,
|
|
2990
|
-
normalized: decodedType.normalized
|
|
2991
|
-
};
|
|
2992
|
-
if (webglOnly) {
|
|
2993
|
-
result.webglOnly = true;
|
|
2994
|
-
}
|
|
2995
|
-
return result;
|
|
2996
|
-
}
|
|
2997
|
-
function makeVertexFormat(signedDataType, components, normalized) {
|
|
2998
|
-
const dataType = normalized ? makeNormalizedDataType(signedDataType) : signedDataType;
|
|
2999
|
-
switch (dataType) {
|
|
3000
|
-
case "unorm8":
|
|
3001
|
-
if (components === 1) {
|
|
3002
|
-
return "unorm8-webgl";
|
|
3003
|
-
}
|
|
3004
|
-
if (components === 3) {
|
|
3005
|
-
return "unorm8x3-webgl";
|
|
3006
|
-
}
|
|
3007
|
-
return `${dataType}x${components}`;
|
|
3008
|
-
case "snorm8":
|
|
3009
|
-
case "uint8":
|
|
3010
|
-
case "sint8":
|
|
3011
|
-
case "uint16":
|
|
3012
|
-
case "sint16":
|
|
3013
|
-
case "unorm16":
|
|
3014
|
-
case "snorm16":
|
|
3015
|
-
case "float16":
|
|
3016
|
-
if (components === 1 || components === 3) {
|
|
3017
|
-
throw new Error(`size: ${components}`);
|
|
3018
|
-
}
|
|
3019
|
-
return `${dataType}x${components}`;
|
|
3020
|
-
default:
|
|
3021
|
-
return components === 1 ? dataType : `${dataType}x${components}`;
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
function getVertexFormatFromAttribute(typedArray, size, normalized) {
|
|
3025
|
-
if (!size || size > 4) {
|
|
3026
|
-
throw new Error(`size ${size}`);
|
|
3027
|
-
}
|
|
3028
|
-
const components = size;
|
|
3029
|
-
const signedDataType = getDataTypeFromTypedArray(typedArray);
|
|
3030
|
-
return makeVertexFormat(signedDataType, components, normalized);
|
|
3031
|
-
}
|
|
3032
|
-
function getCompatibleVertexFormat(opts) {
|
|
3033
|
-
let vertexType;
|
|
3034
|
-
switch (opts.primitiveType) {
|
|
3035
|
-
case "f32":
|
|
3036
|
-
vertexType = "float32";
|
|
3037
|
-
break;
|
|
3038
|
-
case "i32":
|
|
3039
|
-
vertexType = "sint32";
|
|
3040
|
-
break;
|
|
3041
|
-
case "u32":
|
|
3042
|
-
vertexType = "uint32";
|
|
3043
|
-
break;
|
|
3044
|
-
case "f16":
|
|
3045
|
-
return opts.components <= 2 ? "float16x2" : "float16x4";
|
|
3046
|
-
}
|
|
3047
|
-
if (opts.components === 1) {
|
|
3048
|
-
return vertexType;
|
|
3049
|
-
}
|
|
3050
|
-
return `${vertexType}x${opts.components}`;
|
|
3051
|
-
}
|
|
3052
|
-
|
|
3053
3133
|
// src/adapter-utils/get-attribute-from-layouts.ts
|
|
3054
3134
|
function getAttributeInfosFromLayouts(shaderLayout, bufferLayout) {
|
|
3055
3135
|
const attributeInfos = {};
|
|
@@ -3195,7 +3275,7 @@ ${htmlLog}
|
|
|
3195
3275
|
// DEPRECATED METHODS
|
|
3196
3276
|
/** @deprecated Set constant attributes (WebGL only) */
|
|
3197
3277
|
setConstantWebGL(location, value) {
|
|
3198
|
-
|
|
3278
|
+
this.device.reportError(new Error("constant attributes not supported"), this)();
|
|
3199
3279
|
}
|
|
3200
3280
|
};
|
|
3201
3281
|
var VertexArray = _VertexArray;
|
|
@@ -3237,6 +3317,24 @@ ${htmlLog}
|
|
|
3237
3317
|
count: void 0
|
|
3238
3318
|
});
|
|
3239
3319
|
|
|
3320
|
+
// src/adapter/resources/pipeline-layout.ts
|
|
3321
|
+
var _PipelineLayout = class extends Resource {
|
|
3322
|
+
get [Symbol.toStringTag]() {
|
|
3323
|
+
return "PipelineLayout";
|
|
3324
|
+
}
|
|
3325
|
+
constructor(device, props) {
|
|
3326
|
+
super(device, props, _PipelineLayout.defaultProps);
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
var PipelineLayout = _PipelineLayout;
|
|
3330
|
+
__publicField(PipelineLayout, "defaultProps", {
|
|
3331
|
+
...Resource.defaultProps,
|
|
3332
|
+
shaderLayout: {
|
|
3333
|
+
attributes: [],
|
|
3334
|
+
bindings: []
|
|
3335
|
+
}
|
|
3336
|
+
});
|
|
3337
|
+
|
|
3240
3338
|
// src/utils/array-utils-flat.ts
|
|
3241
3339
|
var arrayBuffer;
|
|
3242
3340
|
function getScratchArrayBuffer(byteLength) {
|
|
@@ -3268,11 +3366,12 @@ ${htmlLog}
|
|
|
3268
3366
|
/** number of bytes needed for buffer allocation */
|
|
3269
3367
|
byteLength;
|
|
3270
3368
|
/** Create a new UniformBufferLayout given a map of attributes. */
|
|
3271
|
-
constructor(uniformTypes) {
|
|
3369
|
+
constructor(uniformTypes, uniformSizes = {}) {
|
|
3272
3370
|
let size = 0;
|
|
3273
3371
|
for (const [key, uniformType] of Object.entries(uniformTypes)) {
|
|
3274
3372
|
const typeAndComponents = getVariableShaderTypeInfo(uniformType);
|
|
3275
|
-
const { type, components
|
|
3373
|
+
const { type, components } = typeAndComponents;
|
|
3374
|
+
const count = components * (uniformSizes?.[key] ?? 1);
|
|
3276
3375
|
size = alignTo(size, count);
|
|
3277
3376
|
const offset = size;
|
|
3278
3377
|
size += count;
|
|
@@ -3284,8 +3383,7 @@ ${htmlLog}
|
|
|
3284
3383
|
}
|
|
3285
3384
|
/** Get the data for the complete buffer */
|
|
3286
3385
|
getData(uniformValues) {
|
|
3287
|
-
const
|
|
3288
|
-
const arrayBuffer2 = getScratchArrayBuffer(bufferSize);
|
|
3386
|
+
const arrayBuffer2 = getScratchArrayBuffer(this.byteLength);
|
|
3289
3387
|
const typedArrays = {
|
|
3290
3388
|
i32: new Int32Array(arrayBuffer2),
|
|
3291
3389
|
u32: new Uint32Array(arrayBuffer2),
|
|
@@ -3319,7 +3417,7 @@ ${htmlLog}
|
|
|
3319
3417
|
typedArray.set(value, offset);
|
|
3320
3418
|
}
|
|
3321
3419
|
}
|
|
3322
|
-
return new Uint8Array(arrayBuffer2);
|
|
3420
|
+
return new Uint8Array(arrayBuffer2, 0, this.byteLength);
|
|
3323
3421
|
}
|
|
3324
3422
|
/** Does this layout have a field with specified name */
|
|
3325
3423
|
has(name2) {
|
|
@@ -3425,7 +3523,10 @@ ${htmlLog}
|
|
|
3425
3523
|
constructor(blocks) {
|
|
3426
3524
|
for (const [bufferName, block] of Object.entries(blocks)) {
|
|
3427
3525
|
const uniformBufferName = bufferName;
|
|
3428
|
-
const uniformBufferLayout = new UniformBufferLayout(
|
|
3526
|
+
const uniformBufferLayout = new UniformBufferLayout(
|
|
3527
|
+
block.uniformTypes ?? {},
|
|
3528
|
+
block.uniformSizes ?? {}
|
|
3529
|
+
);
|
|
3429
3530
|
this.uniformBufferLayouts.set(uniformBufferName, uniformBufferLayout);
|
|
3430
3531
|
const uniformBlock = new UniformBlock({ name: bufferName });
|
|
3431
3532
|
uniformBlock.setUniforms(block.defaultUniforms || {});
|
|
@@ -3520,32 +3621,87 @@ ${htmlLog}
|
|
|
3520
3621
|
}
|
|
3521
3622
|
};
|
|
3522
3623
|
|
|
3523
|
-
// src/
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3624
|
+
// src/shadertypes/textures/pixel-utils.ts
|
|
3625
|
+
function readPixel(pixelData, x, y, bitsPerChannel) {
|
|
3626
|
+
if (x < 0 || x >= pixelData.width || y < 0 || y >= pixelData.height) {
|
|
3627
|
+
throw new Error("Coordinates out of bounds.");
|
|
3628
|
+
}
|
|
3629
|
+
const byteOffset = y * pixelData.bytesPerRow + x * pixelData.bytesPerPixel;
|
|
3630
|
+
const pixelDataView = new DataView(pixelData.arrayBuffer, byteOffset, pixelData.bytesPerPixel);
|
|
3631
|
+
let bitOffsetWithinPixel = 0;
|
|
3632
|
+
const channels = [];
|
|
3633
|
+
for (let i = 0; i < 4; i++) {
|
|
3634
|
+
const bits = bitsPerChannel[i];
|
|
3635
|
+
if (bits <= 0) {
|
|
3636
|
+
channels.push(0);
|
|
3637
|
+
} else {
|
|
3638
|
+
const channelValue = readBitsFromDataView(pixelDataView, bitOffsetWithinPixel, bits);
|
|
3639
|
+
channels.push(channelValue);
|
|
3640
|
+
bitOffsetWithinPixel += bits;
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
return [channels[0], channels[1], channels[2], channels[3]];
|
|
3644
|
+
}
|
|
3645
|
+
function writePixel(dataView, bitOffset, bitsPerChannel, pixel) {
|
|
3646
|
+
let currentBitOffset = bitOffset;
|
|
3647
|
+
for (let channel = 0; channel < 4; channel++) {
|
|
3648
|
+
const bits = bitsPerChannel[channel];
|
|
3649
|
+
const maxValue = (1 << bits) - 1;
|
|
3650
|
+
const channelValue = pixel[channel] & maxValue;
|
|
3651
|
+
writeBitsToDataView(dataView, currentBitOffset, bits, channelValue);
|
|
3652
|
+
currentBitOffset += bits;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
function readBitsFromDataView(dataView, bitOffset, bitCount) {
|
|
3656
|
+
if (bitOffset % 8 === 0) {
|
|
3657
|
+
const byteOffset = bitOffset / 8;
|
|
3658
|
+
if (bitCount === 8 && byteOffset + 1 <= dataView.byteLength) {
|
|
3659
|
+
return dataView.getUint8(byteOffset);
|
|
3660
|
+
} else if (bitCount === 16 && byteOffset + 2 <= dataView.byteLength) {
|
|
3661
|
+
return dataView.getUint16(byteOffset, false);
|
|
3662
|
+
} else if (bitCount === 32 && byteOffset + 4 <= dataView.byteLength) {
|
|
3663
|
+
return dataView.getUint32(byteOffset, false);
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
let value = 0;
|
|
3667
|
+
for (let i = 0; i < bitCount; i++) {
|
|
3668
|
+
const overallBitIndex = bitOffset + i;
|
|
3669
|
+
const byteIndex = Math.floor(overallBitIndex / 8);
|
|
3670
|
+
const bitIndex = overallBitIndex % 8;
|
|
3671
|
+
const byteValue = dataView.getUint8(byteIndex);
|
|
3672
|
+
const bit = byteValue >> 7 - bitIndex & 1;
|
|
3673
|
+
value = value << 1 | bit;
|
|
3674
|
+
}
|
|
3675
|
+
return value;
|
|
3676
|
+
}
|
|
3677
|
+
function writeBitsToDataView(dataView, bitOffset, bitCount, value) {
|
|
3678
|
+
if (bitOffset % 8 === 0) {
|
|
3679
|
+
const byteOffset = bitOffset / 8;
|
|
3680
|
+
if (bitCount === 8 && byteOffset + 1 <= dataView.byteLength) {
|
|
3681
|
+
dataView.setUint8(byteOffset, value & 255);
|
|
3682
|
+
return;
|
|
3683
|
+
} else if (bitCount === 16 && byteOffset + 2 <= dataView.byteLength) {
|
|
3684
|
+
dataView.setUint16(byteOffset, value & 65535, false);
|
|
3685
|
+
return;
|
|
3686
|
+
} else if (bitCount === 32 && byteOffset + 4 <= dataView.byteLength) {
|
|
3687
|
+
dataView.setUint32(byteOffset, value, false);
|
|
3688
|
+
return;
|
|
3545
3689
|
}
|
|
3546
|
-
return mergedLayouts;
|
|
3547
3690
|
}
|
|
3548
|
-
|
|
3691
|
+
for (let i = 0; i < bitCount; i++) {
|
|
3692
|
+
const overallBitIndex = bitOffset + i;
|
|
3693
|
+
const byteIndex = Math.floor(overallBitIndex / 8);
|
|
3694
|
+
const bitIndex = overallBitIndex % 8;
|
|
3695
|
+
const mask = 1 << 7 - bitIndex;
|
|
3696
|
+
const bitValue = value >> bitCount - 1 - i & 1;
|
|
3697
|
+
let currentByte = dataView.getUint8(byteIndex);
|
|
3698
|
+
currentByte &= ~mask;
|
|
3699
|
+
if (bitValue) {
|
|
3700
|
+
currentByte |= mask;
|
|
3701
|
+
}
|
|
3702
|
+
dataView.setUint8(byteIndex, currentByte);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3549
3705
|
return __toCommonJS(bundle_exports);
|
|
3550
3706
|
})();
|
|
3551
3707
|
return __exports__;
|