Skip to content

refactor: split emberwave-wgpu out of emberwave-core (D75, steps 1 and 2) - #175

Merged
with-developer merged 2 commits into
mainfrom
refactor/emberwave-wgpu
Nov 24, 2026
Merged

with-developer merged 2 commits into
mainfrom
refactor/emberwave-wgpu

Conversation

@with-developer

Copy link
Copy Markdown
Owner

What changes for a client, and how to revert

  • C, Swift and CLI users: nothing. The C API, the library's exports and name, the CLI and their behaviour are the same.
  • Rust users of the GPU decoder and encoder: the types move from emberwave_core::gpu:: to the new crate emberwave_wgpu:: (same names), and emberwave_core::wgpu becomes emberwave_wgpu::wgpu. emberwave-core no longer has a gpu feature or depends on wgpu. emberwave-wgpu is publish = false until the maintainer takes the name on crates.io; until then the next emberwave-core and emberwave-cli cannot be published as they are (the cli depends on emberwave-wgpu), which D75 states. The published 0.19.0 crates are unaffected.
  • To revert, revert the merge: the move is renames plus path rewrites.

Purpose

Decision D75, choice 2 (issue #165): about thirty public items of emberwave-core took or returned wgpu's types, which every wgpu major would break, so the core could not promise a stable Rust API at 1.0. The GPU code moves to emberwave-wgpu, whose version follows wgpu's; the core keeps the bitstream, the CPU decoder and encoder and the colour code, with no wgpu.

Changes

  • crates/emberwave-core/src/gpu → crates/emberwave-wgpu/src by git mv (mod.rs → lib.rs), with the GPU tests; paths rewritten. The shared test helpers are included from the core's tests by #[path], the GPU's own beside them.
  • The core opens what the GPU encoder shares with the CPU one as #[doc(hidden)] pub: encode::{fdwt, quant, rate}, Bands, Block32, the header and plane-check helpers, the CPU encoder's transform and quantise, color::check_rgb. The compiler named them (D75's search found six; the list is now in D75).
  • An RGB order the GPU code does not know (RgbOrder is non_exhaustive) returns GpuError::InvalidArgument; tests build the core's non-exhaustive structs field by field or with ColorParams::new.
  • emberwave-cli, emberwave-ffi, emberwave-web use emberwave_wgpu. The workspace takes emberwave-core and emberwave-wgpu at their exact version.
  • CI: a step fails if the core depends on wgpu or naga; the browser lint covers the new crate; the adapter report runs from its tests. CONTRIBUTING, the READMEs' layout tables and D75 follow. ARCHITECTURE's other sections, the C API README and the changelog are the next step of D75.

Testing

cargo test --workspace: every binary passes, with the same counts as before (the core's 141 unit tests are 109 in the core and 32 in emberwave-wgpu; gpu 32 + 1 ignored, gpu_encoder 18, gpu_hooks 1, shaders 6). cargo clippy --workspace --all-targets -D warnings, the wasm32 clippy of web, wgpu and core, cargo fmt. A reviewer agent is reading it.

…d 2)

The core's public API showed about thirty wgpu types, which a new major
version of wgpu would break, so a 1.0 of the core could not promise a stable
Rust API (#165). D75 decided to move the GPU code into a crate of its own.

- `crates/emberwave-core/src/gpu` moves to `crates/emberwave-wgpu/src` with git
  mv (`mod.rs` becomes `lib.rs`), with the GPU tests (`gpu.rs`,
  `gpu_encoder.rs`, `gpu_hooks.rs`, `shaders.rs`); the shared test helpers are
  included from the core's tests by `#[path]`, with the GPU's own beside them.
- The core loses its `gpu` feature, `pub use wgpu` and its wgpu, pollster and
  bytemuck dependencies. `emberwave-wgpu` re-exports wgpu and takes the core
  at its exact version.
- The core opens, as `#[doc(hidden)] pub`, what the GPU encoder shares with
  the CPU one: the modules `encode::{fdwt, quant, rate}`, `Bands`, `Block32`,
  the helpers of the stream's headers and of the planes' checks, the CPU
  encoder's `transform` and `quantise`, and `color::check_rgb`. The compiler
  named them; D75's search had found six.
- The GPU code handles an RGB order it does not know (`RgbOrder` is
  non_exhaustive) with `GpuError::InvalidArgument`; its tests build the core's
  non_exhaustive structs field by field.
- `emberwave-cli`, `emberwave-ffi` and `emberwave-web` take the GPU types from
  `emberwave_wgpu`; the C API does not change.
- CI checks that the core does not depend on wgpu, lints the new crate for the
  browser, and reports the adapter from its tests; CONTRIBUTING, the README's
  layout tables and D75 follow. The rest of the docs is the next step.

The workspace's tests pass in the same numbers as before.

Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42
…ow the docs

A review of the split found it sound and six small things, all taken:
- The core had made all 27 items of `encode::{fdwt, quant, rate}` public; 18
  of them are not used by emberwave-wgpu and are crate-private again. What
  stays open: `fdwt::sample_level`, `quant::{DROP_STEPS, BandQuant::{new,
  max_drop}, Block8, Blocks8}` and `rate::{BlockCost, choose}`.
- The CI check that the core does not depend on wgpu matched only `wgpu` and
  `naga` and passed when `cargo tree` failed; it now reads the tree first, for
  every target, and matches the whole family (`wgpu-types` holds the API types).
- The browser build of the docs links to calls it leaves out: the allow that
  the core had for it moves to emberwave-wgpu.
- The soak test's command names emberwave-wgpu; two comments name the right
  crate.
- CONTRIBUTING's release step: emberwave-cli cannot be published until
  emberwave-wgpu has a name on crates.io, the order then, and that the next
  release is a minor version.
- The docs: ARCHITECTURE's status line, its table of modules and the GPU
  paths of its other sections, the README's 1.0 checklist in both languages,
  and an Unreleased entry in the CHANGELOG for the change of the Rust paths.

Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42
@with-developer
with-developer merged commit c00ac15 into main Nov 24, 2026
15 of 16 checks passed
@with-developer
with-developer deleted the refactor/emberwave-wgpu branch November 24, 2026 13:41
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