WasmGPU.frameArena.allocF32¶
Summary¶
WasmGPU.frameArena.allocF32 allocates contiguous float32 storage in the global frame arena.
It returns a raw pointer; use WasmGPU.driver.view(Float32Array, ptr, len) to access values.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
len |
number |
Yes | Number of float32 elements to allocate. |
Returns¶
number - Pointer to the first float32 element.
Notes¶
- This method is a convenience for transient
float32storage, but it still returns a raw pointer. - Use
wgpu.driver.frame.allocF32(...)instead when you want aWasmSlice<Float32Array>with epoch-awareisAlive()andassertAlive()checks.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const ptr = wgpu.frameArena.allocF32(16);
const m = wgpu.driver.view(Float32Array, ptr, 16);
m.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);