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

visgl / luma.gl / 23357312823

20 Mar 2026 06:35PM UTC coverage: 58.158% (+5.9%) from 52.213%
23357312823

Pull #2555

github

web-flow
Merge 71b78bbe2 into fc5791b65
Pull Request #2555: chore: Run tests on src instead of dist

3021 of 6029 branches covered (50.11%)

Branch coverage included in aggregate %.

7102 of 11377 relevant lines covered (62.42%)

243.33 hits per line

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

20.75
/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';
56✔
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) {
26!
35
      throw new Error('WebGPU not available. Recent Chrome browsers should work.');
×
36
    }
37

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

43
    if (!adapter) {
26!
44
      throw new Error('Failed to request WebGPU adapter');
26✔
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 ||
×
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[]));
×
60

61
      // Require all limits
62
      // Filter out chrome specific keys (avoid crash)
63
      const limits = Object.keys(adapter.limits).filter(
×
64
        key => !['minSubgroupSize', 'maxSubgroupSize'].includes(key)
×
65
      );
66
      for (const key of limits) {
×
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({
×
76
      requiredFeatures,
77
      requiredLimits
78
    });
79

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

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

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