Files
workinf_Blender_Wasm/tools/web/headed/fixtures/webgpu-control/control-combined.html
mes123456 5976c3dd7c fix(web): stop the transfer-FBO leak and the canvas-freeze resize churn
- renderer: release_transfer_images() deletes the transfer framebuffer instead
  of only zeroing the name; the leak exhausted VRAM and killed the GPU process
  under Vulkan after ~3-7 minutes
- canvas: status notices are absolute overlays, so they no longer resize the
  native surface (each show/hide freed and recreated region draw buffers and
  eventually froze the main regions)
- compute: bounded shader/layout/pipeline caches, staging pool, device-lost
  error propagation, dev-only ?glStats / ?computeFault / ?compute hooks
- headed tools: soak/probe/smoke assets and docs
- evidence: 20-minute Vulkan soak STABLE (GPU-SOAK-20261205-161007),
  SwiftShader control STABLE (GPU-SOAK-20261205-162105), Clip 28/28
  NOT_CLAIMED (CLIP-HEADED-20261205-162214)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-05 16:29:26 +08:00

58 lines
2.2 KiB
HTML

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>webgl2+webgpu control</title></head>
<body style="margin:0;background:#111">
<canvas id="gl" width="800" height="600"></canvas>
<script id="compute" type="text/x-wgsl">
@group(0) @binding(0) var<storage, read_write> data: array<f32>;
@compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id: vec3<u32>) {
let i = id.x;
if (i < arrayLength(&data)) { data[i] = sin(data[i] + 0.01); }
}
</script>
<script type="module">
/* Both stacks the engine uses at once: a WebGL2 raster context and a WebGPU
* compute device in the same page/GPU process. */
const glCanvas = document.getElementById("gl");
const gl = glCanvas.getContext("webgl2");
let glOk = false;
if (gl) {
glOk = true;
gl.clearColor(0.1, 0.2, 0.5, 1);
}
const adapter = await navigator.gpu?.requestAdapter().catch(() => null);
let computeOk = false;
let device = null;
if (adapter) {
device = await adapter.requestDevice();
const data = new Float32Array(100000).map((_, index) => Math.sin(index));
const buffer = device.createBuffer({ size: data.byteLength, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC });
device.queue.writeBuffer(buffer, 0, data);
const module = device.createShaderModule({ code: document.getElementById("compute").textContent });
const pipeline = device.createComputePipeline({ layout: "auto", compute: { module, entryPoint: "main" } });
const bind = device.createBindGroup({ layout: pipeline.getBindGroupLayout(0), entries: [{ binding: 0, resource: { buffer } }] });
const encoder = device.createCommandEncoder();
const pass = encoder.beginComputePass();
pass.setPipeline(pipeline);
pass.setBindGroup(0, bind);
pass.dispatchWorkgroups(Math.ceil(100000 / 64));
pass.end();
device.queue.submit([encoder.finish()]);
computeOk = true;
}
document.title = `combined gl=${glOk} compute=${computeOk}`;
let frame = 0;
function tick() {
if (gl) {
gl.clearColor(0.1 + 0.05 * Math.sin(frame / 30), 0.2, 0.5, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
}
frame += 1;
document.body.dataset.frames = String(frame);
requestAnimationFrame(tick);
}
tick();
</script>
</body>
</html>