Skip to content

refactor(rendering,particles): generalize WebGPU compute SDK primitives, migrate ParticleGpuState onto them#418

Merged
Exoridus merged 2 commits into
mainfrom
refactor/webgpu-compute-sdk-particles
Jul 26, 2026
Merged

refactor(rendering,particles): generalize WebGPU compute SDK primitives, migrate ParticleGpuState onto them#418
Exoridus merged 2 commits into
mainfrom
refactor/webgpu-compute-sdk-particles

Conversation

@Exoridus

Copy link
Copy Markdown
Owner

Summary

  • WebGpuComputePipeline gains multi-group bind groups, texture/sampler/storage-texture bindings, and dedicated dispatchWorkgroups (2D/3D) and dispatchIndirect methods alongside the existing item-count dispatch.
  • New WebGpuUniformBuffer mirrors WebGpuStorageBuffer for the uniform-buffer case (kept as a separate class rather than merged — different real-world usage shape: storage buffers get read back, uniform buffers essentially never do).
  • New reflectComputeBindings(wgsl, options?) derives bindingGroups directly from a compute shader's own @group/@binding declarations via a small set of targeted regexes, instead of a hand-written parallel binding list that has to be kept in sync with the shader text by hand.
  • ParticleGpuState (exojs-particles) is migrated fully onto these primitives — all 8 storage buffers, all 3 uniform buffers, the compute pipeline, and both bind-group layouts (the second one now reflected, not hand-written). ~50 lines of binding-list bookkeeping removed.

No public API change to ParticleSystem or any engine-facing surface — internal-only, plus new SDK-only exports on @codexo/exojs/renderer-sdk (WebGpuUniformBuffer, reflectComputeBindings, extended WebGpuComputePipeline/ComputeBinding).

Test plan

  • pnpm typecheck (root) clean
  • pnpm --filter @codexo/exojs-particles typecheck clean
  • eslint clean on all touched files
  • packages/exojs-particles/test/particle-gpu.test.ts — all 27 tests pass unmodified, proving the reflected bind-group layout matches the previously hand-written one bit-for-bit (including the module-uniforms-present/absent branch and the r32float non-filtering texture/sampler case)
  • pnpm verify:quick (full local pre-push gate: typecheck across all projects, guides, examples, type-tests, packages, lint, format, API-doc sync) — all green

Exoridus added 2 commits July 26, 2026 14:08
…es, migrate ParticleGpuState onto them

WebGpuComputePipeline gains multi-group bind groups, texture/sampler/storage-texture
bindings, dedicated 2D/3D and indirect dispatch methods. New WebGpuUniformBuffer
mirrors WebGpuStorageBuffer for the uniform-buffer case. New reflectComputeBindings
derives bindingGroups directly from a compute shader's own @group/@binding
declarations instead of a hand-written parallel binding list.

ParticleGpuState now builds entirely on these primitives (buffers, pipeline,
bind-group layouts via reflection) instead of raw WebGPU calls duplicated
alongside the SDK surface, removing ~50 lines of binding-list bookkeeping that
had to be kept in sync with the shader text by hand.

No public API change to ParticleSystem; internal-only. Verified against the
existing 27-test particle-gpu.test.ts suite (unmodified) plus typecheck/lint.
@Exoridus
Exoridus enabled auto-merge (squash) July 26, 2026 12:18
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 24.55kB (0.1%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
exo-esm-modules-esm 3.96MB 16.71kB (0.42%) ⬆️
exojs-particles-esm 202.84kB -1.76kB (-0.86%) ⬇️
exo-full-iife-Exo-iife 2.81MB 9.6kB (0.34%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: exo-esm-modules-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
rendering/webgpu/compute/WebGpuComputePipeline.js 2.47kB 5.82kB 73.96% ⚠️
rendering/webgpu/compute/WebGpuComputePipeline.d.ts 3.51kB 5.62kB 166.64% ⚠️
rendering/webgpu/compute/reflectComputeBindings.js (New) 5.57kB 5.57kB 100.0% 🚀
rendering/webgpu/compute/WebGpuStorageBuffer.js 210 bytes 3.43kB 6.52% ⚠️
renderer-*.d.ts 68 bytes 2.92kB 2.39%
renderer-*.js 184 bytes 2.2kB 9.15% ⚠️
rendering/webgpu/compute/reflectComputeBindings.d.ts (New) 1.99kB 1.99kB 100.0% 🚀
rendering/webgpu/compute/WebGpuStorageBuffer.d.ts 215 bytes 1.98kB 12.17% ⚠️
rendering/webgpu/compute/WebGpuUniformBuffer.js (New) 1.35kB 1.35kB 100.0% 🚀
rendering/webgpu/compute/WebGpuUniformBuffer.d.ts (New) 985 bytes 985 bytes 100.0% 🚀
rendering/webgpu/compute/index.d.ts 151 bytes 375 bytes 67.41% ⚠️

Files in rendering/webgpu/compute/WebGpuComputePipeline.js:

  • ./src/rendering/webgpu/compute/WebGpuComputePipeline.ts → Total Size: 5.72kB

Files in rendering/webgpu/compute/reflectComputeBindings.js:

  • ./src/rendering/webgpu/compute/reflectComputeBindings.ts → Total Size: 5.47kB

Files in rendering/webgpu/compute/WebGpuStorageBuffer.js:

  • ./src/rendering/webgpu/compute/WebGpuStorageBuffer.ts → Total Size: 3.35kB

Files in renderer-*.js:

  • ./src/renderer-sdk.ts → Total Size: 0 bytes

Files in rendering/webgpu/compute/WebGpuUniformBuffer.js:

  • ./src/rendering/webgpu/compute/WebGpuUniformBuffer.ts → Total Size: 1.26kB
view changes for bundle: exojs-particles-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
gpu/ParticleGpuState.js -2.57kB 20.84kB -10.98%
gpu/ParticleGpuState.d.ts 806 bytes 3.27kB 32.76% ⚠️

Files in gpu/ParticleGpuState.js:

  • ./src/gpu/ParticleGpuState.ts → Total Size: 20.53kB
view changes for bundle: exo-full-iife-Exo-iife

Assets Changed:

Asset Name Size Change Total Size Change (%)
exo.full.iife.js 9.6kB 2.81MB 0.34%

Files in exo.full.iife.js:

  • ./packages/exojs-particles/src/gpu/ParticleGpuState.ts → Total Size: 16.26kB

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 18 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../rendering/webgpu/compute/WebGpuComputePipeline.ts 72.22% 9 Missing and 1 partial ⚠️
...rendering/webgpu/compute/reflectComputeBindings.ts 86.04% 6 Missing ⚠️
...rc/rendering/webgpu/compute/WebGpuStorageBuffer.ts 0.00% 0 Missing and 1 partial ⚠️
...rc/rendering/webgpu/compute/WebGpuUniformBuffer.ts 87.50% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Exoridus
Exoridus merged commit d7bb647 into main Jul 26, 2026
17 of 18 checks passed
@Exoridus
Exoridus deleted the refactor/webgpu-compute-sdk-particles branch July 26, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant