Skip to content

createSplatField#markDataDirty

Summary

createSplatField#markDataDirty tells the renderer that caller-supplied GPU buffers contain updated splat data. Call it after GPU writes and before drawing so the next render uses a depth order for the updated data.

Syntax

SplatField.markDataDirty(): void
field.markDataDirty();

Returns

void - Invalidates the cached depth order for the field. The call requires caller-supplied GPU buffers. For a WebAssembly source, call refreshFromWasm() instead.

Example

const wgpu = await WasmGPU.create(document.querySelector("canvas"));
const { device, queue } = wgpu.gpu;
const makeChannel = () => device.createBuffer({ size: 16, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST });
const centerOpacityBuffer = makeChannel();
const rotationBuffer = makeChannel();
const scaleBuffer = makeChannel();
queue.writeBuffer(rotationBuffer, 0, new Float32Array([0, 0, 0, 1]));
queue.writeBuffer(scaleBuffer, 0, new Float32Array([1, 1, 1, 0]));
const field = wgpu.createSplatField({ centerOpacityBuffer, rotationBuffer, scaleBuffer, splatCount: 1, ownBuffers: true });
queue.writeBuffer(centerOpacityBuffer, 0, new Float32Array([1, 0, 0, 1]));
field.markDataDirty();
// Render the field here, then destroy it when finished.
field.destroy();
wgpu.destroy();

Notes

Submit recorded writes before the render that consumes them. Update splatCount when the active prefix changes and maintain explicit bounds for GPU-backed data as needed. Marking data dirty does not change the count, upload bytes, or calculate bounds.

See Also