New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@domgell/webgpu-arraybuffer-writer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domgell/webgpu-arraybuffer-writer

Utility for writing data to an ArrayBuffer with correct WebGPU/WGSL alignment

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

WebGPU ArrayBuffer Writer

WGSL structs and arrays have specific alignment rules which can make it inconvenient to write data to WebGPU buffers.

This is a utility to make it easier to write correctly aligned data to ArrayBuffers. These can then be written directly to GPUBuffers.

Example

struct Particle {
    position: vec3f,
    velocity: vec3f,
    friction: f32,
}
const particle = {
    position: {x: 10, y: 5},
    velocity: {x: 0, y: 0},
    friction: 0.5,
}

// Create an ArrayBufferWriter with a given size or provide an existing ArrayBuffer
const particleWriter = ArrayBufferWriter(particleByteSize);

// Write each struct member
particleWriter
    .vec3f(particle.position)
    .vec3f(particle.velocity)
    .f32(particle.friction);

// Write the ArrayBuffer to an existing GPUBuffer
device.queue.writeBuffer(particleGPUBuffer, 0, particleWriter.arrayBuffer);

Keywords

webgpu

FAQs

Package last updated on 17 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts