GPU Detection API
Utilities for checking WebGPU availability.
isWebGPUAvailable
Async boolean indicating if WebGPU is supported.
ts
const isWebGPUAvailable: Promise<boolean>;1
Example
ts
import { isWebGPUAvailable } from 'webgpu-fft';
if (await isWebGPUAvailable) {
console.log('WebGPU is available!');
}1
2
3
4
5
2
3
4
5
hasWebGPUSupport()
Synchronous check for basic WebGPU API availability.
ts
function hasWebGPUSupport(): boolean;1
This checks if navigator.gpu exists but does not verify that a GPU adapter is available.
Example
ts
import { hasWebGPUSupport } from 'webgpu-fft';
if (!hasWebGPUSupport()) {
console.log('WebGPU API not available in this browser.');
}1
2
3
4
5
2
3
4
5
Recommendation
Always use isWebGPUAvailable for the most accurate check:
ts
import { createFFTEngine, isWebGPUAvailable } from 'webgpu-fft';
if (await isWebGPUAvailable) {
const engine = await createFFTEngine();
// Use GPU engine
} else {
// Fall back to cpuFFT
}1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Related
- Browser Support — WebGPU compatibility matrix
- FFTEngine — GPU-accelerated FFT engine