You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**`useGPUContext()`** — create a shared `GPUAdapter` + `GPUDevice` + `PipelineCache` for multi-chart dashboards; see [`docs/api/hooks.md#usegpucontext`](./api/hooks.md#usegpucontext)
Creates a shared `GPUAdapter`, `GPUDevice`, and `PipelineCache` for multi-chart dashboards. Call this once in a parent component and pass the result to each `<ChartGPU gpuContext={...} />` (or to `useChartGPU`'s third argument). This avoids each chart requesting its own GPU device and compiling duplicate shader pipelines.
- On mount, requests a `GPUAdapter` (high-performance preference) and `GPUDevice`, then creates a `PipelineCache`.
114
+
- All fields are `null` until initialization completes. `isReady` becomes `true` once both `adapter` and `device` are available.
115
+
- If WebGPU is not supported or adapter/device acquisition fails, `error` is set and other fields remain `null`.
116
+
- Safe in React 18 StrictMode dev (uses a ref guard to prevent double-initialization).
117
+
- Initialization runs once on mount and cannot be re-triggered.
118
+
119
+
### Usage with `<ChartGPU>`
120
+
121
+
The `gpuContext` prop on `<ChartGPU>` accepts `{ adapter, device, pipelineCache }` which maps to the `ChartGPUCreateContext` type. This prop is **init-only** -- it is captured in a `useRef` at mount and only read during `ChartGPU.create(...)`. Changing it after mount has no effect.
For multi-chart dashboards, combine `useGPUContext` (shared GPU resources) with `useConnectCharts` (synced interaction). This avoids duplicate GPU device allocation and keeps crosshair/zoom in sync across all charts.
137
+
138
+
See also: [`useGPUContext` hook docs](../api/hooks.md#usegpucontext)
0 commit comments