npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pex-gpu

v0.0.1

Published

Modern WebGPU wrapper for PEX: allocate GPU resources (textures, buffers), reflect WGSL shaders, cache pipelines, and optionally describe render and compute work as plain command objects.

Readme

pex-gpu

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Modern WebGPU wrapper for PEX: describe render and compute work as plain command objects, backed by automatic WGSL reflection, pipeline caching, and GPU resource allocation.

[!NOTE] pex-gpu is WebGPU only and written in TypeScript. Shaders are written in WGSL and all enum-like values are raw WebGPU strings ("rgba8unorm", "triangle-list", ...). For the WebGL 1/2 version, see pex-context.

Installation

npm install pex-gpu

Usage

Everything is a free function behind one import — import * as gpu from "pex-gpu" — typed, tree-shakeable, and discoverable by autocompleting gpu..

Describe draws, compute dispatches and render bundles as plain objects and gpu.submit() them inside a gpu.frame() loop. Vertex layouts, bind groups, pipelines and uniform buffers are derived from your WGSL and cached automatically: you write a shader and a command, pex-gpu does the WebGPU.

When something is slow or leaking, always-on gpu.debugStats(ctx) counters and opt-in gpu.debug(ctx) logging show resource pressure, cache behavior and the submit stream at any time.

Advanced users who need to drive GPUCommandEncoders directly can reach for the core helpers underneath — context/canvas setup, buffers, textures, samplers, readback, timestamp queries, render bundles — which every command is itself built on. Options follow WebGPU naming and derive from WebGPU descriptor types, so raw-WebGPU knowledge transfers 1:1, and hand-built pipelines/bind groups/encoders plug into declarative passes. See the API docs below. The machinery itself — WGSL reflection, uniform struct packing, the pipeline cache, allocators, byte math — is importable from "pex-gpu/internals" for the same purpose.

import * as gpu from "pex-gpu";

import { mat4 } from "pex-math";
import { cube } from "primitive-geometry";

const ctx = await gpu.createContext();

const geometry = cube();

const shader = /* wgsl */ `
struct Uniforms {
  projection: mat4x4f,
  view: mat4x4f,
  model: mat4x4f,
}
@group(0) @binding(0) var<uniform> uniforms: Uniforms;

struct VertexIn {
  @location(0) position: vec3f,
  @location(1) normal: vec3f,
}
struct VertexOut {
  @builtin(position) position: vec4f,
  @location(0) color: vec4f,
}

@vertex
fn vertexMain(input: VertexIn) -> VertexOut {
  var output: VertexOut;
  output.color = vec4f(input.normal * 0.5 + 0.5, 1.0);
  output.position =
    uniforms.projection * uniforms.view * uniforms.model * vec4f(input.position, 1.0);
  return output;
}

@fragment
fn fragmentMain(input: VertexOut) -> @location(0) vec4f {
  return input.color;
}
`;

// defineCommand is a typed identity helper: the command stays a plain object
const drawCmd = gpu.defineCommand({
  // depthClearValue implies a context-managed, canvas-sized depth texture
  pass: { clearValue: [0.2, 0.2, 0.2, 1], depthClearValue: 1 },
  pipeline: { vertex: shader, fragment: shader, depthWriteEnabled: true, cullMode: "back" },
  attributes: {
    position: gpu.createBuffer(ctx, { usage: "vertex", data: geometry.positions }),
    normal: gpu.createBuffer(ctx, { usage: "vertex", data: geometry.normals }),
  },
  indices: gpu.createBuffer(ctx, { usage: "index", data: geometry.cells }),
  uniforms: {
    // WebGPU clip-space depth is [0, 1]: use the ZO projection variants
    projection: mat4.perspectiveZO(mat4.create(), Math.PI / 4, ctx.width / ctx.height, 0.1, 100),
    view: mat4.lookAt(mat4.create(), [2, 2, 3], [0, 0, 0], [0, 1, 0]),
    model: mat4.create(),
  },
});

gpu.frame(ctx, () => {
  gpu.submit(ctx, drawCmd);
});

Every WebGPU feature has a dedicated example: MRT, MSAA resolve, compute + storage buffers, indirect draws, async picking, timestamp queries and render bundles — including hand-built pipelines and bind groups replayed inside a declarative pass (examples/render-bundles.js).

API

License

MIT. See license file.