@luma.gl/test-utils 9.3.0-alpha.4 → 9.3.0-alpha.8
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 +19 -0
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +83 -14
- package/dist/create-test-device.js.map +1 -1
- package/dist/deprecated/classic-animation-loop.d.ts.map +1 -1
- package/dist/deprecated/classic-animation-loop.js +2 -10
- package/dist/deprecated/classic-animation-loop.js.map +1 -1
- package/dist/deprecated/sync-test-device.d.ts +0 -5
- package/dist/deprecated/sync-test-device.d.ts.map +1 -1
- package/dist/deprecated/sync-test-device.js +11 -1
- package/dist/deprecated/sync-test-device.js.map +1 -1
- package/dist/index.cjs +185 -74
- package/dist/index.cjs.map +4 -4
- 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-canvas-context.d.ts.map +1 -1
- package/dist/null-device/null-canvas-context.js +1 -0
- package/dist/null-device/null-canvas-context.js.map +1 -1
- package/dist/null-device/null-device.d.ts +5 -3
- package/dist/null-device/null-device.d.ts.map +1 -1
- package/dist/null-device/null-device.js +16 -4
- package/dist/null-device/null-device.js.map +1 -1
- package/dist/null-device/resources/null-command-buffer.d.ts +8 -8
- package/dist/null-device/resources/null-command-buffer.d.ts.map +1 -1
- package/dist/null-device/resources/null-command-buffer.js +16 -6
- package/dist/null-device/resources/null-command-buffer.js.map +1 -1
- package/dist/null-device/resources/null-command-encoder.d.ts +8 -7
- package/dist/null-device/resources/null-command-encoder.d.ts.map +1 -1
- package/dist/null-device/resources/null-command-encoder.js +24 -9
- package/dist/null-device/resources/null-command-encoder.js.map +1 -1
- package/dist/null-device/resources/null-query-set.d.ts +6 -0
- package/dist/null-device/resources/null-query-set.d.ts.map +1 -1
- package/dist/null-device/resources/null-query-set.js +11 -0
- package/dist/null-device/resources/null-query-set.js.map +1 -1
- package/dist/null-device/resources/null-render-pass.d.ts.map +1 -1
- package/dist/null-device/resources/null-render-pass.js +6 -1
- package/dist/null-device/resources/null-render-pass.js.map +1 -1
- package/dist/null-device/resources/null-render-pipeline.d.ts +3 -4
- package/dist/null-device/resources/null-render-pipeline.d.ts.map +1 -1
- package/dist/null-device/resources/null-render-pipeline.js +0 -5
- package/dist/null-device/resources/null-render-pipeline.js.map +1 -1
- package/dist/null-device/resources/null-texture.d.ts +3 -3
- package/dist/null-device/resources/null-texture.d.ts.map +1 -1
- package/dist/null-device/resources/null-texture.js +9 -13
- package/dist/null-device/resources/null-texture.js.map +1 -1
- package/dist/test-runner.d.ts +1 -1
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +2 -1
- package/dist/test-runner.js.map +1 -1
- package/dist/utils/resource-tracker.js +1 -1
- package/dist/utils/resource-tracker.js.map +1 -1
- package/package.json +7 -7
- package/src/create-test-device.ts +113 -14
- package/src/deprecated/classic-animation-loop.ts +2 -10
- package/src/deprecated/sync-test-device.ts +16 -1
- package/src/index.ts +1 -0
- package/src/null-device/null-canvas-context.ts +1 -0
- package/src/null-device/null-device.ts +21 -4
- package/src/null-device/resources/null-command-buffer.ts +18 -8
- package/src/null-device/resources/null-command-encoder.ts +25 -9
- package/src/null-device/resources/null-query-set.ts +14 -0
- package/src/null-device/resources/null-render-pass.ts +6 -1
- package/src/null-device/resources/null-render-pipeline.ts +3 -14
- package/src/null-device/resources/null-texture.ts +17 -17
- package/src/test-runner.ts +2 -1
- package/src/utils/resource-tracker.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -29,13 +29,14 @@ __export(dist_exports, {
|
|
|
29
29
|
deepCopy: () => deepCopy,
|
|
30
30
|
getLeakedResources: () => getLeakedResources,
|
|
31
31
|
getNullTestDevice: () => getNullTestDevice,
|
|
32
|
+
getPresentationWebGLTestDevice: () => getPresentationWebGLTestDevice,
|
|
32
33
|
getResourceCounts: () => getResourceCounts,
|
|
33
34
|
getTestDevice: () => getTestDevice,
|
|
34
35
|
getTestDevices: () => getTestDevices,
|
|
35
36
|
getWebGLTestDevice: () => getWebGLTestDevice,
|
|
36
37
|
getWebGPUTestDevice: () => getWebGPUTestDevice,
|
|
37
38
|
nullAdapter: () => nullAdapter,
|
|
38
|
-
webglDevice: () =>
|
|
39
|
+
webglDevice: () => webglDevice
|
|
39
40
|
});
|
|
40
41
|
module.exports = __toCommonJS(dist_exports);
|
|
41
42
|
|
|
@@ -132,6 +133,7 @@ var NullCanvasContext = class extends import_core4.CanvasContext {
|
|
|
132
133
|
this.device = device;
|
|
133
134
|
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
134
135
|
this._configureDevice();
|
|
136
|
+
this._startObservers();
|
|
135
137
|
}
|
|
136
138
|
_getCurrentFramebuffer() {
|
|
137
139
|
this._framebuffer = this._framebuffer || new NullFramebuffer(this.device, { handle: null });
|
|
@@ -231,21 +233,26 @@ var NullCommandBuffer = class extends import_core7.CommandBuffer {
|
|
|
231
233
|
super(device, props);
|
|
232
234
|
this.device = device;
|
|
233
235
|
}
|
|
234
|
-
copyBufferToBuffer(
|
|
236
|
+
copyBufferToBuffer(_options) {
|
|
237
|
+
throw new Error("copyBufferToBuffer is not supported on NullDevice");
|
|
235
238
|
}
|
|
236
|
-
copyBufferToTexture(
|
|
239
|
+
copyBufferToTexture(_options) {
|
|
240
|
+
throw new Error("copyBufferToTexture is not supported on NullDevice");
|
|
237
241
|
}
|
|
238
|
-
copyTextureToBuffer(
|
|
242
|
+
copyTextureToBuffer(_options) {
|
|
243
|
+
throw new Error("copyTextureToBuffer is not supported on NullDevice");
|
|
239
244
|
}
|
|
240
|
-
copyTextureToTexture(
|
|
245
|
+
copyTextureToTexture(_options) {
|
|
246
|
+
throw new Error("copyTextureToTexture is not supported on NullDevice");
|
|
241
247
|
}
|
|
242
248
|
pushDebugGroup(groupLabel) {
|
|
243
249
|
}
|
|
244
250
|
popDebugGroup() {
|
|
245
251
|
}
|
|
246
|
-
insertDebugMarker(
|
|
252
|
+
insertDebugMarker(_markerLabel) {
|
|
247
253
|
}
|
|
248
|
-
resolveQuerySet(
|
|
254
|
+
resolveQuerySet(_querySet) {
|
|
255
|
+
throw new Error("resolveQuerySet is not supported on NullDevice");
|
|
249
256
|
}
|
|
250
257
|
};
|
|
251
258
|
|
|
@@ -259,6 +266,10 @@ var NullRenderPass = class extends import_core8.RenderPass {
|
|
|
259
266
|
this.device = device;
|
|
260
267
|
}
|
|
261
268
|
end() {
|
|
269
|
+
if (this.destroyed) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this.destroy();
|
|
262
273
|
}
|
|
263
274
|
pushDebugGroup(groupLabel) {
|
|
264
275
|
}
|
|
@@ -282,24 +293,34 @@ var NullCommandEncoder = class extends import_core9.CommandEncoder {
|
|
|
282
293
|
super(device, props);
|
|
283
294
|
this.device = device;
|
|
284
295
|
}
|
|
285
|
-
|
|
286
|
-
|
|
296
|
+
destroy() {
|
|
297
|
+
this.destroyResource();
|
|
298
|
+
}
|
|
299
|
+
finish(props = {}) {
|
|
300
|
+
const commandBuffer = new NullCommandBuffer(this.device, props);
|
|
301
|
+
this.destroy();
|
|
302
|
+
return commandBuffer;
|
|
287
303
|
}
|
|
288
304
|
beginRenderPass(props) {
|
|
289
305
|
return new NullRenderPass(this.device, props);
|
|
290
306
|
}
|
|
291
|
-
beginComputePass(
|
|
292
|
-
throw new Error("ComputePass not supported
|
|
307
|
+
beginComputePass(_props) {
|
|
308
|
+
throw new Error("ComputePass is not supported on NullDevice");
|
|
293
309
|
}
|
|
294
|
-
copyBufferToBuffer(
|
|
310
|
+
copyBufferToBuffer(_options) {
|
|
311
|
+
throw new Error("copyBufferToBuffer is not supported on NullDevice");
|
|
295
312
|
}
|
|
296
|
-
copyBufferToTexture(
|
|
313
|
+
copyBufferToTexture(_options) {
|
|
314
|
+
throw new Error("copyBufferToTexture is not supported on NullDevice");
|
|
297
315
|
}
|
|
298
|
-
copyTextureToBuffer(
|
|
316
|
+
copyTextureToBuffer(_options) {
|
|
317
|
+
throw new Error("copyTextureToBuffer is not supported on NullDevice");
|
|
299
318
|
}
|
|
300
|
-
copyTextureToTexture(
|
|
319
|
+
copyTextureToTexture(_options) {
|
|
320
|
+
throw new Error("copyTextureToTexture is not supported on NullDevice");
|
|
301
321
|
}
|
|
302
|
-
resolveQuerySet(
|
|
322
|
+
resolveQuerySet(_querySet) {
|
|
323
|
+
throw new Error("resolveQuerySet is not supported on NullDevice");
|
|
303
324
|
}
|
|
304
325
|
pushDebugGroup(groupLabel) {
|
|
305
326
|
}
|
|
@@ -355,6 +376,7 @@ var NullTexture = class extends import_core12.Texture {
|
|
|
355
376
|
mipLevelCount: 1,
|
|
356
377
|
arrayLayerCount: 1
|
|
357
378
|
});
|
|
379
|
+
this.trackAllocatedMemory(this.getAllocatedByteLength(), "Texture");
|
|
358
380
|
Object.seal(this);
|
|
359
381
|
}
|
|
360
382
|
destroy() {
|
|
@@ -367,21 +389,21 @@ var NullTexture = class extends import_core12.Texture {
|
|
|
367
389
|
return new NullTextureView(this.device, { ...props, texture: this });
|
|
368
390
|
}
|
|
369
391
|
copyExternalImage(options) {
|
|
370
|
-
this.trackDeallocatedMemory("Texture");
|
|
371
|
-
const bytesPerPixel = 4;
|
|
372
|
-
this.trackAllocatedMemory(this.width * this.height * bytesPerPixel, "Texture");
|
|
373
392
|
return { width: this.width, height: this.height };
|
|
374
393
|
}
|
|
375
394
|
setSampler(sampler) {
|
|
376
395
|
}
|
|
377
396
|
copyImageData(options) {
|
|
378
|
-
|
|
397
|
+
super.copyImageData(options);
|
|
379
398
|
}
|
|
380
|
-
readBuffer(
|
|
381
|
-
|
|
399
|
+
readBuffer(_options = {}, buffer) {
|
|
400
|
+
if (!buffer) {
|
|
401
|
+
throw new Error("buffer required");
|
|
402
|
+
}
|
|
403
|
+
return buffer;
|
|
382
404
|
}
|
|
383
|
-
async readDataAsync(
|
|
384
|
-
|
|
405
|
+
async readDataAsync(_options = {}) {
|
|
406
|
+
throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`);
|
|
385
407
|
}
|
|
386
408
|
writeBuffer(buffer, options = {}) {
|
|
387
409
|
}
|
|
@@ -396,8 +418,6 @@ var NullRenderPipeline = class extends import_core13.RenderPipeline {
|
|
|
396
418
|
handle = null;
|
|
397
419
|
vs;
|
|
398
420
|
fs;
|
|
399
|
-
uniforms = {};
|
|
400
|
-
bindings = {};
|
|
401
421
|
constructor(device, props) {
|
|
402
422
|
super(device, props);
|
|
403
423
|
this.device = device;
|
|
@@ -409,9 +429,6 @@ var NullRenderPipeline = class extends import_core13.RenderPipeline {
|
|
|
409
429
|
uniforms: []
|
|
410
430
|
};
|
|
411
431
|
}
|
|
412
|
-
setBindings(bindings) {
|
|
413
|
-
Object.assign(this.bindings, bindings);
|
|
414
|
-
}
|
|
415
432
|
draw(options) {
|
|
416
433
|
const { renderPass, vertexArray } = options;
|
|
417
434
|
vertexArray.bindBeforeRender(renderPass);
|
|
@@ -492,6 +509,17 @@ var NullQuerySet = class extends import_core16.QuerySet {
|
|
|
492
509
|
super(device, props);
|
|
493
510
|
this.device = device;
|
|
494
511
|
}
|
|
512
|
+
isResultAvailable(_queryIndex) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
async readResults(options) {
|
|
516
|
+
const firstQuery = (options == null ? void 0 : options.firstQuery) || 0;
|
|
517
|
+
const queryCount = (options == null ? void 0 : options.queryCount) || this.props.count - firstQuery;
|
|
518
|
+
return new Array(queryCount).fill(0n);
|
|
519
|
+
}
|
|
520
|
+
async readTimestampDuration(_beginIndex, _endIndex) {
|
|
521
|
+
return 0;
|
|
522
|
+
}
|
|
495
523
|
};
|
|
496
524
|
|
|
497
525
|
// dist/null-device/resources/null-fence.js
|
|
@@ -539,6 +567,8 @@ var NullDevice = class extends import_core18.Device {
|
|
|
539
567
|
* @note Has no effect for null contexts
|
|
540
568
|
*/
|
|
541
569
|
destroy() {
|
|
570
|
+
var _a;
|
|
571
|
+
(_a = this.commandEncoder) == null ? void 0 : _a.destroy();
|
|
542
572
|
}
|
|
543
573
|
get isLost() {
|
|
544
574
|
return false;
|
|
@@ -547,6 +577,9 @@ var NullDevice = class extends import_core18.Device {
|
|
|
547
577
|
createCanvasContext(props) {
|
|
548
578
|
return new NullCanvasContext(this, props);
|
|
549
579
|
}
|
|
580
|
+
createPresentationContext(_props) {
|
|
581
|
+
throw new Error("PresentationContext is not supported on NullDevice");
|
|
582
|
+
}
|
|
550
583
|
createBuffer(props) {
|
|
551
584
|
const newProps = this._normalizeBufferProps(props);
|
|
552
585
|
return new NullBuffer(this, newProps);
|
|
@@ -584,13 +617,19 @@ var NullDevice = class extends import_core18.Device {
|
|
|
584
617
|
createRenderPipeline(props) {
|
|
585
618
|
return new NullRenderPipeline(this, props);
|
|
586
619
|
}
|
|
587
|
-
createComputePipeline(
|
|
588
|
-
throw new Error("ComputePipeline not supported
|
|
620
|
+
createComputePipeline(_props) {
|
|
621
|
+
throw new Error("ComputePipeline is not supported on NullDevice");
|
|
589
622
|
}
|
|
590
623
|
createCommandEncoder(props = {}) {
|
|
591
624
|
return new NullCommandEncoder(this, props);
|
|
592
625
|
}
|
|
593
|
-
submit() {
|
|
626
|
+
submit(commandBuffer) {
|
|
627
|
+
if (!commandBuffer) {
|
|
628
|
+
commandBuffer = this.commandEncoder.finish({ id: `${this.id}-default-command-buffer` });
|
|
629
|
+
this.commandEncoder.destroy();
|
|
630
|
+
this.commandEncoder = this.createCommandEncoder({ id: `${this.id}-default-command-encoder` });
|
|
631
|
+
}
|
|
632
|
+
commandBuffer.destroy();
|
|
594
633
|
}
|
|
595
634
|
setParametersWebGL(parameters) {
|
|
596
635
|
}
|
|
@@ -638,9 +677,8 @@ var nullAdapter = new NullAdapter();
|
|
|
638
677
|
|
|
639
678
|
// dist/create-test-device.js
|
|
640
679
|
var DEFAULT_CANVAS_CONTEXT_PROPS = { width: 1, height: 1 };
|
|
641
|
-
var
|
|
642
|
-
var
|
|
643
|
-
var webgpuDevicePromise = makeWebGPUTestDevice();
|
|
680
|
+
var TEST_DEVICE_CACHE_KEY = "__lumaTestDeviceCache";
|
|
681
|
+
var testDeviceCache = getOrCreateTestDeviceCache();
|
|
644
682
|
async function getTestDevices(types = ["webgl", "webgpu"]) {
|
|
645
683
|
const promises = types.map((type) => getTestDevice(type));
|
|
646
684
|
const devices = await Promise.all(promises);
|
|
@@ -649,23 +687,49 @@ async function getTestDevices(types = ["webgl", "webgpu"]) {
|
|
|
649
687
|
async function getTestDevice(type) {
|
|
650
688
|
switch (type) {
|
|
651
689
|
case "webgl":
|
|
652
|
-
return
|
|
690
|
+
return getOrCreateWebGLTestDevicePromise();
|
|
653
691
|
case "webgpu":
|
|
654
|
-
return
|
|
692
|
+
return getWebGPUTestDevice();
|
|
655
693
|
case "null":
|
|
656
|
-
return
|
|
694
|
+
return getOrCreateNullTestDevicePromise();
|
|
657
695
|
case "unknown":
|
|
658
696
|
return null;
|
|
659
697
|
}
|
|
660
698
|
}
|
|
661
|
-
function getWebGPUTestDevice() {
|
|
662
|
-
|
|
699
|
+
async function getWebGPUTestDevice() {
|
|
700
|
+
const webgpuDevice = await getOrCreateWebGPUTestDevicePromise();
|
|
701
|
+
if (webgpuDevice == null ? void 0 : webgpuDevice.isLost) {
|
|
702
|
+
if (testDeviceCache.webgpuDevicePromise) {
|
|
703
|
+
testDeviceCache.webgpuDevicePromise = null;
|
|
704
|
+
}
|
|
705
|
+
return getOrCreateWebGPUTestDevicePromise();
|
|
706
|
+
}
|
|
707
|
+
return webgpuDevice;
|
|
663
708
|
}
|
|
664
709
|
async function getWebGLTestDevice() {
|
|
665
|
-
return
|
|
710
|
+
return getOrCreateWebGLTestDevicePromise();
|
|
711
|
+
}
|
|
712
|
+
async function getPresentationWebGLTestDevice() {
|
|
713
|
+
return getOrCreatePresentationWebGLTestDevicePromise();
|
|
666
714
|
}
|
|
667
715
|
async function getNullTestDevice() {
|
|
668
|
-
return
|
|
716
|
+
return getOrCreateNullTestDevicePromise();
|
|
717
|
+
}
|
|
718
|
+
function getOrCreateWebGPUTestDevicePromise() {
|
|
719
|
+
testDeviceCache.webgpuDevicePromise ||= makeWebGPUTestDevice();
|
|
720
|
+
return testDeviceCache.webgpuDevicePromise;
|
|
721
|
+
}
|
|
722
|
+
function getOrCreateWebGLTestDevicePromise() {
|
|
723
|
+
testDeviceCache.webglDevicePromise ||= makeWebGLTestDevice();
|
|
724
|
+
return testDeviceCache.webglDevicePromise;
|
|
725
|
+
}
|
|
726
|
+
function getOrCreatePresentationWebGLTestDevicePromise() {
|
|
727
|
+
testDeviceCache.presentationWebglDevicePromise ||= makePresentationWebGLTestDevice();
|
|
728
|
+
return testDeviceCache.presentationWebglDevicePromise;
|
|
729
|
+
}
|
|
730
|
+
function getOrCreateNullTestDevicePromise() {
|
|
731
|
+
testDeviceCache.nullDevicePromise ||= makeNullTestDevice();
|
|
732
|
+
return testDeviceCache.nullDevicePromise;
|
|
669
733
|
}
|
|
670
734
|
async function makeWebGPUTestDevice() {
|
|
671
735
|
const webgpuDeviceResolvers = withResolvers();
|
|
@@ -677,6 +741,11 @@ async function makeWebGPUTestDevice() {
|
|
|
677
741
|
createCanvasContext: DEFAULT_CANVAS_CONTEXT_PROPS,
|
|
678
742
|
debug: true
|
|
679
743
|
});
|
|
744
|
+
webgpuDevice.lost.finally(() => {
|
|
745
|
+
if (testDeviceCache.webgpuDevicePromise === webgpuDeviceResolvers.promise) {
|
|
746
|
+
testDeviceCache.webgpuDevicePromise = null;
|
|
747
|
+
}
|
|
748
|
+
});
|
|
680
749
|
webgpuDeviceResolvers.resolve(webgpuDevice);
|
|
681
750
|
} catch (error) {
|
|
682
751
|
import_core20.log.error(String(error))();
|
|
@@ -687,20 +756,50 @@ async function makeWebGPUTestDevice() {
|
|
|
687
756
|
async function makeWebGLTestDevice() {
|
|
688
757
|
const webglDeviceResolvers = withResolvers();
|
|
689
758
|
try {
|
|
690
|
-
const
|
|
759
|
+
const webglDevice2 = await import_core20.luma.createDevice({
|
|
691
760
|
id: "webgl-test-device",
|
|
692
761
|
type: "webgl",
|
|
693
762
|
adapters: [import_webgl2.webgl2Adapter],
|
|
694
763
|
createCanvasContext: DEFAULT_CANVAS_CONTEXT_PROPS,
|
|
695
764
|
debug: true
|
|
696
765
|
});
|
|
697
|
-
|
|
766
|
+
webglDevice2.lost.finally(() => {
|
|
767
|
+
if (testDeviceCache.webglDevicePromise === webglDeviceResolvers.promise) {
|
|
768
|
+
testDeviceCache.webglDevicePromise = null;
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
webglDeviceResolvers.resolve(webglDevice2);
|
|
698
772
|
} catch (error) {
|
|
699
773
|
import_core20.log.error(String(error))();
|
|
700
774
|
webglDeviceResolvers.resolve(null);
|
|
701
775
|
}
|
|
702
776
|
return webglDeviceResolvers.promise;
|
|
703
777
|
}
|
|
778
|
+
async function makePresentationWebGLTestDevice() {
|
|
779
|
+
if (typeof OffscreenCanvas === "undefined") {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
const presentationWebGLDeviceResolvers = withResolvers();
|
|
783
|
+
try {
|
|
784
|
+
const webglDevice2 = await import_core20.luma.createDevice({
|
|
785
|
+
id: "webgl-presentation-context-test-device",
|
|
786
|
+
type: "webgl",
|
|
787
|
+
adapters: [import_webgl2.webgl2Adapter],
|
|
788
|
+
createCanvasContext: { canvas: new OffscreenCanvas(4, 4) },
|
|
789
|
+
debug: true
|
|
790
|
+
});
|
|
791
|
+
webglDevice2.lost.finally(() => {
|
|
792
|
+
if (testDeviceCache.presentationWebglDevicePromise === presentationWebGLDeviceResolvers.promise) {
|
|
793
|
+
testDeviceCache.presentationWebglDevicePromise = null;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
presentationWebGLDeviceResolvers.resolve(webglDevice2);
|
|
797
|
+
} catch (error) {
|
|
798
|
+
import_core20.log.error(String(error))();
|
|
799
|
+
presentationWebGLDeviceResolvers.resolve(null);
|
|
800
|
+
}
|
|
801
|
+
return presentationWebGLDeviceResolvers.promise;
|
|
802
|
+
}
|
|
704
803
|
async function makeNullTestDevice() {
|
|
705
804
|
const nullDeviceResolvers = withResolvers();
|
|
706
805
|
try {
|
|
@@ -714,10 +813,20 @@ async function makeNullTestDevice() {
|
|
|
714
813
|
nullDeviceResolvers.resolve(nullDevice);
|
|
715
814
|
} catch (error) {
|
|
716
815
|
import_core20.log.error(String(error))();
|
|
717
|
-
nullDevicePromise = Promise.resolve(null);
|
|
816
|
+
testDeviceCache.nullDevicePromise = Promise.resolve(null);
|
|
718
817
|
}
|
|
719
818
|
return nullDeviceResolvers.promise;
|
|
720
819
|
}
|
|
820
|
+
function getOrCreateTestDeviceCache() {
|
|
821
|
+
const rootObject = globalThis;
|
|
822
|
+
rootObject[TEST_DEVICE_CACHE_KEY] ||= {
|
|
823
|
+
nullDevicePromise: null,
|
|
824
|
+
webglDevicePromise: null,
|
|
825
|
+
presentationWebglDevicePromise: null,
|
|
826
|
+
webgpuDevicePromise: null
|
|
827
|
+
};
|
|
828
|
+
return rootObject[TEST_DEVICE_CACHE_KEY];
|
|
829
|
+
}
|
|
721
830
|
function withResolvers() {
|
|
722
831
|
let resolve;
|
|
723
832
|
let reject;
|
|
@@ -728,11 +837,36 @@ function withResolvers() {
|
|
|
728
837
|
return { promise, resolve, reject };
|
|
729
838
|
}
|
|
730
839
|
|
|
840
|
+
// dist/deprecated/sync-test-device.js
|
|
841
|
+
var import_webgl3 = require("@luma.gl/webgl");
|
|
842
|
+
var DEFAULT_CANVAS_CONTEXT_PROPS2 = {
|
|
843
|
+
width: 1,
|
|
844
|
+
height: 1
|
|
845
|
+
};
|
|
846
|
+
function createTestDevice() {
|
|
847
|
+
if (cachedWebglDevice) {
|
|
848
|
+
return cachedWebglDevice;
|
|
849
|
+
}
|
|
850
|
+
if (typeof navigator === "undefined" || typeof document === "undefined" || typeof HTMLCanvasElement === "undefined") {
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
853
|
+
try {
|
|
854
|
+
cachedWebglDevice = new import_webgl3.WebGLDevice({ createCanvasContext: DEFAULT_CANVAS_CONTEXT_PROPS2 });
|
|
855
|
+
return cachedWebglDevice;
|
|
856
|
+
} catch (error) {
|
|
857
|
+
console.error(`Failed to created device: ${error.message}`);
|
|
858
|
+
debugger;
|
|
859
|
+
return null;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
var cachedWebglDevice = null;
|
|
863
|
+
var webglDevice = createTestDevice();
|
|
864
|
+
|
|
731
865
|
// dist/deprecated/classic-animation-loop.js
|
|
732
866
|
var import_core21 = require("@luma.gl/core");
|
|
733
867
|
var import_engine = require("@luma.gl/engine");
|
|
734
868
|
var import_env = require("@probe.gl/env");
|
|
735
|
-
var
|
|
869
|
+
var import_webgl4 = require("@luma.gl/webgl");
|
|
736
870
|
var isPage = (0, import_env.isBrowser)() && typeof document !== "undefined";
|
|
737
871
|
function getHTMLCanvasElement(canvas) {
|
|
738
872
|
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement ? canvas : null;
|
|
@@ -798,9 +932,9 @@ var ClassicAnimationLoop = class {
|
|
|
798
932
|
this.device = props.device;
|
|
799
933
|
this.gl = this.device && this.device.gl || props.gl;
|
|
800
934
|
this.stats = props.stats;
|
|
935
|
+
this.frameRate = this.stats.get("Frame Rate");
|
|
801
936
|
this.cpuTime = this.stats.get("CPU Time");
|
|
802
937
|
this.gpuTime = this.stats.get("GPU Time");
|
|
803
|
-
this.frameRate = this.stats.get("Frame Rate");
|
|
804
938
|
this.setProps({
|
|
805
939
|
autoResizeViewport: props.autoResizeViewport,
|
|
806
940
|
autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,
|
|
@@ -1091,7 +1225,7 @@ var ClassicAnimationLoop = class {
|
|
|
1091
1225
|
const deviceProps = { ...this.props, ...props, ...this.props.glOptions };
|
|
1092
1226
|
this.device = await this.onCreateDevice(deviceProps);
|
|
1093
1227
|
this.gl = this.device.gl;
|
|
1094
|
-
(0,
|
|
1228
|
+
(0, import_webgl4.resetGLParameters)(this.gl);
|
|
1095
1229
|
this._createInfoDiv();
|
|
1096
1230
|
}
|
|
1097
1231
|
_createInfoDiv() {
|
|
@@ -1119,13 +1253,7 @@ var ClassicAnimationLoop = class {
|
|
|
1119
1253
|
_getSizeAndAspect() {
|
|
1120
1254
|
const width = this.gl.drawingBufferWidth;
|
|
1121
1255
|
const height = this.gl.drawingBufferHeight;
|
|
1122
|
-
|
|
1123
|
-
const canvas = getHTMLCanvasElement(this.gl.canvas);
|
|
1124
|
-
if (canvas && canvas.clientHeight) {
|
|
1125
|
-
aspect = canvas.clientWidth / canvas.clientHeight;
|
|
1126
|
-
} else if (width > 0 && height > 0) {
|
|
1127
|
-
aspect = width / height;
|
|
1128
|
-
}
|
|
1256
|
+
const aspect = width > 0 && height > 0 ? width / height : 1;
|
|
1129
1257
|
return { width, height, aspect };
|
|
1130
1258
|
}
|
|
1131
1259
|
/** Default viewport setup */
|
|
@@ -1198,7 +1326,7 @@ var DEFAULT_TEST_PROPS = {
|
|
|
1198
1326
|
imageDiffOptions: void 0
|
|
1199
1327
|
};
|
|
1200
1328
|
var TestRunner = class {
|
|
1201
|
-
device =
|
|
1329
|
+
device = createTestDevice();
|
|
1202
1330
|
props;
|
|
1203
1331
|
isRunning = false;
|
|
1204
1332
|
testOptions = { ...DEFAULT_TEST_PROPS };
|
|
@@ -1470,7 +1598,7 @@ function deepCopy(object) {
|
|
|
1470
1598
|
|
|
1471
1599
|
// dist/utils/resource-tracker.js
|
|
1472
1600
|
function getResourceCounts() {
|
|
1473
|
-
const resourceStats = luma.stats.get("Resource Counts");
|
|
1601
|
+
const resourceStats = luma.stats.get("GPU Resource Counts");
|
|
1474
1602
|
return {
|
|
1475
1603
|
Texture2D: resourceStats.get("Texture2Ds Active").count,
|
|
1476
1604
|
Buffer: resourceStats.get("Buffers Active").count
|
|
@@ -1490,21 +1618,4 @@ function getLeakedResources(startCounts, endCounts) {
|
|
|
1490
1618
|
}
|
|
1491
1619
|
return leakedResources;
|
|
1492
1620
|
}
|
|
1493
|
-
|
|
1494
|
-
// dist/deprecated/sync-test-device.js
|
|
1495
|
-
var import_webgl4 = require("@luma.gl/webgl");
|
|
1496
|
-
var DEFAULT_CANVAS_CONTEXT_PROPS2 = {
|
|
1497
|
-
width: 1,
|
|
1498
|
-
height: 1
|
|
1499
|
-
};
|
|
1500
|
-
function createTestDevice() {
|
|
1501
|
-
try {
|
|
1502
|
-
return new import_webgl4.WebGLDevice({ createCanvasContext: DEFAULT_CANVAS_CONTEXT_PROPS2 });
|
|
1503
|
-
} catch (error) {
|
|
1504
|
-
console.error(`Failed to created device: ${error.message}`);
|
|
1505
|
-
debugger;
|
|
1506
|
-
return null;
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
var webglDevice2 = createTestDevice();
|
|
1510
1621
|
//# sourceMappingURL=index.cjs.map
|