@luma.gl/test-utils 9.2.0-alpha.1 → 9.2.0-alpha.3
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/create-test-device.d.ts +2 -1
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +29 -17
- package/dist/create-test-device.js.map +1 -1
- package/dist/index.cjs +80 -19
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/null-device/null-device.d.ts +1 -0
- package/dist/null-device/null-device.d.ts.map +1 -1
- package/dist/null-device/null-device.js +4 -1
- package/dist/null-device/null-device.js.map +1 -1
- package/dist/null-device/resources/null-buffer.d.ts +8 -4
- package/dist/null-device/resources/null-buffer.d.ts.map +1 -1
- package/dist/null-device/resources/null-buffer.js +41 -4
- package/dist/null-device/resources/null-buffer.js.map +1 -1
- package/dist/null-device/resources/null-framebuffer.d.ts +1 -0
- package/dist/null-device/resources/null-framebuffer.d.ts.map +1 -1
- package/dist/null-device/resources/null-framebuffer.js +1 -0
- package/dist/null-device/resources/null-framebuffer.js.map +1 -1
- package/dist/null-device/resources/null-query-set.d.ts +1 -0
- package/dist/null-device/resources/null-query-set.d.ts.map +1 -1
- package/dist/null-device/resources/null-query-set.js +1 -0
- package/dist/null-device/resources/null-query-set.js.map +1 -1
- package/dist/null-device/resources/null-render-pass.d.ts +1 -0
- package/dist/null-device/resources/null-render-pass.d.ts.map +1 -1
- package/dist/null-device/resources/null-render-pass.js +1 -0
- package/dist/null-device/resources/null-render-pass.js.map +1 -1
- package/dist/null-device/resources/null-render-pipeline.d.ts +1 -0
- package/dist/null-device/resources/null-render-pipeline.d.ts.map +1 -1
- package/dist/null-device/resources/null-render-pipeline.js +1 -0
- package/dist/null-device/resources/null-render-pipeline.js.map +1 -1
- package/dist/null-device/resources/null-sampler.d.ts +1 -0
- package/dist/null-device/resources/null-sampler.d.ts.map +1 -1
- package/dist/null-device/resources/null-sampler.js +1 -0
- package/dist/null-device/resources/null-sampler.js.map +1 -1
- package/dist/null-device/resources/null-shader.d.ts +1 -0
- package/dist/null-device/resources/null-shader.d.ts.map +1 -1
- package/dist/null-device/resources/null-shader.js +1 -0
- package/dist/null-device/resources/null-shader.js.map +1 -1
- package/dist/null-device/resources/null-texture-view.d.ts +1 -0
- package/dist/null-device/resources/null-texture-view.d.ts.map +1 -1
- package/dist/null-device/resources/null-texture-view.js +1 -0
- package/dist/null-device/resources/null-texture-view.js.map +1 -1
- package/dist/null-device/resources/null-texture.d.ts +3 -1
- package/dist/null-device/resources/null-texture.d.ts.map +1 -1
- package/dist/null-device/resources/null-texture.js +4 -0
- package/dist/null-device/resources/null-texture.js.map +1 -1
- package/dist/null-device/resources/null-transform-feedback.d.ts +1 -0
- package/dist/null-device/resources/null-transform-feedback.d.ts.map +1 -1
- package/dist/null-device/resources/null-transform-feedback.js +1 -0
- package/dist/null-device/resources/null-transform-feedback.js.map +1 -1
- package/dist/null-device/resources/null-vertex-array.d.ts +1 -0
- package/dist/null-device/resources/null-vertex-array.d.ts.map +1 -1
- package/dist/null-device/resources/null-vertex-array.js +1 -0
- package/dist/null-device/resources/null-vertex-array.js.map +1 -1
- package/dist/performance-test-runner.js +1 -1
- package/dist/performance-test-runner.js.map +1 -1
- package/package.json +7 -7
- package/src/create-test-device.ts +42 -28
- package/src/index.ts +1 -0
- package/src/null-device/null-device.ts +5 -1
- package/src/null-device/resources/null-buffer.ts +60 -8
- package/src/null-device/resources/null-framebuffer.ts +1 -0
- package/src/null-device/resources/null-query-set.ts +1 -0
- package/src/null-device/resources/null-render-pass.ts +1 -0
- package/src/null-device/resources/null-render-pipeline.ts +2 -0
- package/src/null-device/resources/null-sampler.ts +1 -0
- package/src/null-device/resources/null-shader.ts +1 -0
- package/src/null-device/resources/null-texture-view.ts +2 -0
- package/src/null-device/resources/null-texture.ts +10 -3
- package/src/null-device/resources/null-transform-feedback.ts +1 -0
- package/src/null-device/resources/null-vertex-array.ts +1 -0
- package/src/performance-test-runner.ts +1 -1
|
@@ -61,7 +61,7 @@ export class NullDevice extends Device {
|
|
|
61
61
|
constructor(props: DeviceProps) {
|
|
62
62
|
super({...props, id: props.id || 'null-device'});
|
|
63
63
|
|
|
64
|
-
const canvasContextProps =
|
|
64
|
+
const canvasContextProps = Device._getCanvasContextProps(props);
|
|
65
65
|
this.canvasContext = new NullCanvasContext(this, canvasContextProps);
|
|
66
66
|
this.lost = new Promise(resolve => {});
|
|
67
67
|
this.commandEncoder = new NullCommandEncoder(this, {id: 'null-command-encoder'});
|
|
@@ -79,6 +79,10 @@ export class NullDevice extends Device {
|
|
|
79
79
|
|
|
80
80
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
81
81
|
|
|
82
|
+
getTextureByteAlignment(): number {
|
|
83
|
+
return 1;
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
createCanvasContext(props: CanvasContextProps): NullCanvasContext {
|
|
83
87
|
return new NullCanvasContext(this, props);
|
|
84
88
|
}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type
|
|
6
|
-
import {
|
|
7
|
-
import type {NullDevice} from '../null-device';
|
|
5
|
+
import {Buffer, type BufferProps, type BufferMapCallback} from '@luma.gl/core';
|
|
6
|
+
import {type NullDevice} from '../null-device';
|
|
8
7
|
|
|
9
8
|
export class NullBuffer extends Buffer {
|
|
10
9
|
device: NullDevice;
|
|
10
|
+
readonly handle: 'null' | null = 'null';
|
|
11
11
|
|
|
12
12
|
byteLength: number;
|
|
13
|
+
private _storage: ArrayBuffer;
|
|
13
14
|
|
|
14
15
|
constructor(device: NullDevice, props: BufferProps = {}) {
|
|
15
16
|
super(device, props);
|
|
@@ -18,9 +19,14 @@ export class NullBuffer extends Buffer {
|
|
|
18
19
|
const byteOffset = props.byteOffset || 0;
|
|
19
20
|
const byteLength = props.byteLength ?? (props.data ? props.data.byteLength + byteOffset : 0);
|
|
20
21
|
|
|
21
|
-
// assert(byteLength >= 0);
|
|
22
|
-
|
|
23
22
|
this.byteLength = byteLength;
|
|
23
|
+
this._storage = new ArrayBuffer(byteLength);
|
|
24
|
+
|
|
25
|
+
// If initial data is provided, copy it in
|
|
26
|
+
if (props.data) {
|
|
27
|
+
this.write(props.data, byteOffset);
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
this.trackAllocatedMemory(byteLength);
|
|
25
31
|
}
|
|
26
32
|
|
|
@@ -28,15 +34,61 @@ export class NullBuffer extends Buffer {
|
|
|
28
34
|
if (!this.destroyed) {
|
|
29
35
|
super.destroy();
|
|
30
36
|
this.trackDeallocatedMemory();
|
|
37
|
+
// @ts-expect-error
|
|
38
|
+
this.handle = null;
|
|
39
|
+
// Clear internal storage
|
|
40
|
+
this._storage = new ArrayBuffer(0);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
write(data: ArrayBufferLike | ArrayBufferView, byteOffset: number = 0): void {
|
|
45
|
+
const source = ArrayBuffer.isView(data)
|
|
46
|
+
? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)
|
|
47
|
+
: new Uint8Array(data);
|
|
48
|
+
const target = new Uint8Array(this._storage, byteOffset, source.byteLength);
|
|
49
|
+
|
|
50
|
+
if (byteOffset + source.byteLength > this.byteLength) {
|
|
51
|
+
throw new RangeError(`NullBuffer.write(): write would overflow buffer`);
|
|
31
52
|
}
|
|
53
|
+
|
|
54
|
+
target.set(source);
|
|
55
|
+
this._setDebugData(data, byteOffset, source.byteLength);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async mapAndWriteAsync(
|
|
59
|
+
callback: BufferMapCallback<void>,
|
|
60
|
+
byteOffset = 0,
|
|
61
|
+
byteLength = this.byteLength - byteOffset
|
|
62
|
+
): Promise<void> {
|
|
63
|
+
const view = new Uint8Array(this._storage, byteOffset, byteLength);
|
|
64
|
+
const tempBuffer = new Uint8Array(view.length); // safe scratch copy
|
|
65
|
+
callback(tempBuffer.buffer, 'copied');
|
|
66
|
+
view.set(tempBuffer);
|
|
67
|
+
this._setDebugData(view, byteOffset, byteLength);
|
|
32
68
|
}
|
|
33
69
|
|
|
34
70
|
async readAsync(byteOffset = 0, byteLength?: number): Promise<Uint8Array> {
|
|
35
71
|
byteLength = byteLength ?? this.byteLength - byteOffset;
|
|
36
|
-
|
|
72
|
+
|
|
73
|
+
if (byteOffset + byteLength > this.byteLength) {
|
|
74
|
+
throw new RangeError(`NullBuffer.readAsync(): read would overflow buffer`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const view = new Uint8Array(this._storage, byteOffset, byteLength);
|
|
78
|
+
return new Uint8Array(view); // return a copy
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async mapAndReadAsync<T>(
|
|
82
|
+
callback: BufferMapCallback<T>,
|
|
83
|
+
byteOffset = 0,
|
|
84
|
+
byteLength = this.byteLength - byteOffset
|
|
85
|
+
): Promise<T> {
|
|
86
|
+
const view = new Uint8Array(this._storage, byteOffset, byteLength);
|
|
87
|
+
const copy = new Uint8Array(view); // copy to protect memory
|
|
88
|
+
return callback(copy.buffer, 'copied');
|
|
37
89
|
}
|
|
38
90
|
|
|
39
|
-
|
|
40
|
-
|
|
91
|
+
readSyncWebGL(): Uint8Array {
|
|
92
|
+
throw new Error('NullBuffer.readSyncWebGL() not implemented');
|
|
41
93
|
}
|
|
42
94
|
}
|
|
@@ -9,6 +9,7 @@ import type {NullTextureView} from './null-texture-view';
|
|
|
9
9
|
|
|
10
10
|
export class NullFramebuffer extends Framebuffer {
|
|
11
11
|
device: NullDevice;
|
|
12
|
+
readonly handle = null;
|
|
12
13
|
|
|
13
14
|
colorAttachments: NullTextureView[] = [];
|
|
14
15
|
depthStencilAttachment: NullTextureView | null = null;
|
|
@@ -10,6 +10,8 @@ import type {NullTexture} from './null-texture';
|
|
|
10
10
|
|
|
11
11
|
export class NullTextureView extends TextureView {
|
|
12
12
|
readonly device: NullDevice;
|
|
13
|
+
readonly handle = null;
|
|
14
|
+
|
|
13
15
|
readonly texture: NullTexture;
|
|
14
16
|
|
|
15
17
|
constructor(device: NullDevice, props: TextureViewProps & {texture: NullTexture}) {
|
|
@@ -6,7 +6,9 @@ import type {
|
|
|
6
6
|
TextureProps,
|
|
7
7
|
TextureViewProps,
|
|
8
8
|
CopyExternalImageOptions,
|
|
9
|
-
CopyImageDataOptions
|
|
9
|
+
CopyImageDataOptions,
|
|
10
|
+
Sampler,
|
|
11
|
+
SamplerProps
|
|
10
12
|
} from '@luma.gl/core';
|
|
11
13
|
|
|
12
14
|
import {Texture} from '@luma.gl/core';
|
|
@@ -16,6 +18,7 @@ import {NullTextureView} from './null-texture-view';
|
|
|
16
18
|
|
|
17
19
|
export class NullTexture extends Texture {
|
|
18
20
|
readonly device: NullDevice;
|
|
21
|
+
readonly handle = null;
|
|
19
22
|
|
|
20
23
|
sampler: NullSampler;
|
|
21
24
|
view: NullTextureView;
|
|
@@ -76,11 +79,15 @@ export class NullTexture extends Texture {
|
|
|
76
79
|
return {width, height};
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
override
|
|
82
|
+
override setSampler(sampler?: Sampler | SamplerProps): void {
|
|
83
|
+
// ignore
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
copyImageData(options: CopyImageDataOptions): void {
|
|
80
87
|
throw new Error('copyImageData not implemented');
|
|
81
88
|
}
|
|
82
89
|
|
|
83
|
-
|
|
90
|
+
generateMipmapsWebGL(): void {
|
|
84
91
|
// ignore
|
|
85
92
|
}
|
|
86
93
|
}
|