• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / luma.gl / 23412316304

22 Mar 2026 08:56PM UTC coverage: 73.59% (-0.6%) from 74.227%
23412316304

push

github

web-flow
feat(engine): add async texture buffer read (#2439)

4597 of 7074 branches covered (64.98%)

Branch coverage included in aggregate %.

111 of 213 new or added lines in 20 files covered. (52.11%)

40 existing lines in 8 files now uncovered.

10525 of 13475 relevant lines covered (78.11%)

263.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.08
/modules/webgpu/src/adapter/webgpu-adapter.ts
1
// luma.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
// prettier-ignore
6
// / <reference types="@webgpu/types" />
7

8
import {Adapter, DeviceProps, log} from '@luma.gl/core';
9
import type {WebGPUDevice} from './webgpu-device';
10

11
export class WebGPUAdapter extends Adapter {
12
  /** type of device's created by this adapter */
13
  readonly type: WebGPUDevice['type'] = 'webgpu';
61✔
14

15
  isSupported(): boolean {
16
    // Check if WebGPU is available
17
    return Boolean(typeof navigator !== 'undefined' && navigator.gpu);
2✔
18
  }
19

20
  isDeviceHandle(handle: unknown): boolean {
21
    if (typeof GPUDevice !== 'undefined' && handle instanceof GPUDevice) {
×
22
      return true;
×
23
    }
24

25
    // TODO - WebGPU does not yet seem to have a stable in-browser API, so we "sniff" for members instead
26
    if ((handle as any)?.queue) {
×
27
      return true;
×
28
    }
29

30
    return false;
×
31
  }
32

33
  async create(props: DeviceProps): Promise<WebGPUDevice> {
34
    if (!navigator.gpu) {
25!
35
      throw new Error('WebGPU not available. Recent Chrome browsers should work.');
×
36
    }
37

38
    const adapter = await navigator.gpu.requestAdapter({
25✔
39
      powerPreference: 'high-performance'
40
      // forceSoftware: false
41
    });
42

43
    if (!adapter) {
25!
UNCOV
44
      throw new Error('Failed to request WebGPU adapter');
×
45
    }
46

47
    //  Note: adapter.requestAdapterInfo() has been replaced with adapter.info. Fall back in case adapter.info is not available
48
    const adapterInfo =
49
      adapter.info ||
25!
50
      // @ts-ignore
51
      (await adapter.requestAdapterInfo?.());
52
    // log.probe(2, 'Adapter available', adapterInfo)();
53

54
    const requiredFeatures: GPUFeatureName[] = [];
×
55
    const requiredLimits: Record<string, number> = {};
×
56

57
    if (props._requestMaxLimits) {
✔
58
      // Require all features
59
      requiredFeatures.push(...(Array.from(adapter.features) as GPUFeatureName[]));
25✔
60

61
      // Require all limits
62
      // Filter out chrome specific keys (avoid crash)
63
      const limits = Object.keys(adapter.limits).filter(
25✔
64
        key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key)
×
65
      );
66
      for (const key of limits) {
25✔
67
        const limit = key as keyof GPUSupportedLimits;
×
68
        const value = adapter.limits[limit];
×
69
        if (typeof value === 'number') {
×
70
          requiredLimits[limit] = value;
×
71
        }
72
      }
73
    }
74

75
    const gpuDevice = await adapter.requestDevice({
25✔
76
      requiredFeatures,
77
      requiredLimits
78
    });
79

80
    // log.probe(1, 'GPUDevice available')();
81

82
    const {WebGPUDevice} = await import('./webgpu-device');
25✔
83

84
    log.groupCollapsed(1, 'WebGPUDevice created')();
25✔
85
    try {
25✔
86
      const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
25✔
87
      log.probe(
25✔
88
        1,
89
        'Device created. For more info, set chrome://flags/#enable-webgpu-developer-features'
90
      )();
91
      log.table(1, device.info)();
25✔
92
      return device;
25✔
93
    } finally {
94
      log.groupEnd(1)();
25✔
95
    }
96
  }
97

98
  async attach(handle: GPUDevice): Promise<WebGPUDevice> {
99
    throw new Error('WebGPUAdapter.attach() not implemented');
×
100
  }
101
}
102

103
export const webgpuAdapter = new WebGPUAdapter();
61✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc