Skip to content

Code-first video & image, rendered natively on WebGPU.

fix(webgpu-renderers): request the adapter's buffer limits for shared vision models

okanasl48643d5f8118
diff --git a/.changeset/vision-depth-relief.md b/.changeset/vision-depth-relief.md
index 0bdacd21..b9f108cf 100644
--- a/.changeset/vision-depth-relief.md
+++ b/.changeset/vision-depth-relief.md
@@ -8,3 +8,4 @@ Depth and relief: footage as a 3D surface.
- `withVision({ mode: "depth" })` draws a clip's depth as gray (white = near), always for the frame on screen; it makes its depth clip when there is none.
- `layer.withRelief(heightLayer, { amount })` lifts a 3D layer into a surface by another layer's brightness, along the default camera's rays: from that lens it is the flat layer, pixel for pixel; a moving camera sees it in 3D, lit by the scene and hiding what passes behind it. With a depth layer, footage joins the 3D scene.
- Layers inside a `matte` or `relief` now link to their `comp.vision` clips too.
+- The render GPU device now requests the adapter's full buffer limits. Vision models share that device, and one whose intermediates exceed the 128 MiB default binding (Depth Anything's attention) computed on truncated data instead of failing.
diff --git a/packages/webgpu-renderers/src/device.test.ts b/packages/webgpu-renderers/src/device.test.ts
index 8204a317..ed116bf3 100644
--- a/packages/webgpu-renderers/src/device.test.ts
+++ b/packages/webgpu-renderers/src/device.test.ts
@@ -73,6 +73,23 @@ describe("device management", () => {
expect(device).toBe(mockDevice);
});
+ it("requests the adapter's full buffer limits, which shared vision models need", async () => {
+ mockAdapter.limits = {
+ maxTextureDimension2D: 16384,
+ maxStorageBufferBindingSize: 4_294_967_292,
+ maxBufferSize: 4_294_967_296,
+ };
+ await acquireDevice();
+ expect(mockAdapter.requestDevice).toHaveBeenCalledWith(
+ expect.objectContaining({
+ requiredLimits: expect.objectContaining({
+ maxStorageBufferBindingSize: 4_294_967_292,
+ maxBufferSize: 4_294_967_296,
+ }),
+ }),
+ );
+ });
+
it("should cache device instance on ensureDevice", async () => {
const promise1 = ensureDevice();
const promise2 = ensureDevice();
diff --git a/packages/webgpu-renderers/src/device.ts b/packages/webgpu-renderers/src/device.ts
index 4c496ce9..befe30f4 100644
--- a/packages/webgpu-renderers/src/device.ts
+++ b/packages/webgpu-renderers/src/device.ts
@@ -113,6 +113,13 @@ export async function acquireDevice(
adapter.limits.maxStorageBuffersPerPipelineLayout,
);
}
+ // Vision models share this device; their large intermediates (Depth Anything's
+ // attention is ~140 MB at 518 px) exceed the 128 MiB / 256 MiB defaults, and
+ // an undersized binding computes on truncated data instead of failing.
+ for (const limit of ["maxStorageBufferBindingSize", "maxBufferSize"]) {
+ const max = adapter.limits?.[limit];
+ if (Number.isFinite(max)) requiredLimits[limit] = max;
+ }
return adapter.requestDevice({
requiredFeatures: requiredFeatures as unknown as GPUFeatureName[],