Skip to content

feat(setup): expanded cache step + GPU encoding step (#153, #154)#198

Merged
samsoir merged 2 commits into
mainfrom
feat/153-154-setup-wizard-gpu-cache
May 11, 2026
Merged

feat(setup): expanded cache step + GPU encoding step (#153, #154)#198
samsoir merged 2 commits into
mainfrom
feat/153-154-setup-wizard-gpu-cache

Conversation

@samsoir

@samsoir samsoir commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

Restructures the xearthlayer setup wizard to expand the cache configuration step (#154) and add a new DDS encoding / GPU selection step (#153). Both issues touch the same module so they ship together.

Step 3 — Cache Configuration (expanded, #154)

Absorbs the old "system config" step. Now prompts in one place for:

Setting Default Notes
Cache directory ~/.xearthlayer/cache Detects storage type at chosen path
Disk cache size 25% of free space, floored to 10 GB (min 10 GB) Warns when user input exceeds free space
DDS disk ratio 0.6 Recommendation to keep default
Memory cache size RAM ÷ 12, clamped to [500 MB, RAM ÷ 4] Replaces previous tiered brackets that gave 8 GB cache on a 16 GB system
I/O profile Detected (NVMe/SSD/HDD) User can override

The new memory formula matches the documented intent of the memory cache as a small request absorber rather than a working set holder (the on-disk DDS cache is the working set).

Step 4 — DDS Encoding (new, #153)

  • Enumerates GPU adapters via wgpu with a spinner (10–30s on multi-adapter systems).
  • Single GPU or none: silently keeps ISPC (CPU) default.
  • Two or more GPUs: presents ISPC + each detected GPU with a warning against picking X-Plane's render GPU.
  • Maps selection to texture.compressor and texture.gpu_device, preferring the kind keyword (integrated/discrete) when unique, falling back to adapter name substring otherwise (handles dual-discrete setups).

Supporting refactors

  • New xearthlayer::system::gpu module wraps wgpu enumeration with a plain GpuAdapter type. Reusable by diagnostics report and future GUI consumers.
  • New MIN_MEMORY_CACHE_BYTES (500 MB) and MIN_DISK_CACHE_BYTES (10 GB) constants.
  • SystemInfo now carries cache_path_available_bytes (statvfs at detect time, walks up to existing ancestor when the cache dir doesn't exist yet).
  • RecommendedSettings::for_system signature gains available_disk: u64.
  • Bonus refactor: promoted KB / MB / GB from 5 inline private re-declarations to public xearthlayer::config::{KB, MB, GB}. SSOT for size constants.
  • Updated tests for new formulas (10 new/changed tests in system::recommendations, 5 new in system::gpu).
  • docs/configuration.md describes the new four-step wizard flow.

Test plan

  • cargo test — 2415 unit tests + 63 doctests pass
  • make pre-commit — fmt + clippy + tests clean
  • Wizard binary launches and renders Step 1 correctly
  • Interactive verification: operator confirmed full wizard flow works end-to-end including the new cache prompts and GPU detection step
  • In-sim: load X-Plane with the wizard-generated config and verify behavior matches the chosen settings (cache budgets respected, GPU encoding active if selected)

Fixes #153
Fixes #154

🤖 Generated with Claude Code

samsoir and others added 2 commits May 10, 2026 21:12
Restructures the setup wizard from 4 steps to 4 steps with new shape:

- Step 3 (Cache Configuration): absorbs the old "system config" step.
  Now prompts for cache directory, disk cache size, DDS disk ratio,
  memory cache size, and I/O profile in one place. Defaults derive
  from detected hardware:
    - Disk cache: 25% of available space, floored to 10 GB (min 10 GB)
    - Memory cache: RAM / 12, clamped to [500 MB, RAM / 4]
    - DDS ratio: 0.6
    - I/O profile: detected (NVMe / SSD / HDD), user can override

  Memory cache formula replaces the previous tiered brackets
  (8 GB cache @ 16 GB RAM was too large for an absorber-style cache).
  Disk formula replaces a fixed 40 GB recommendation that ignored
  free space.

- Step 4 (DDS Encoding): NEW. Enumerates GPU adapters via wgpu and:
    - Skips silently when 0 or 1 adapter is present (keeps ISPC default).
    - Presents ISPC + each detected GPU when 2+ adapters exist, with a
      warning against picking X-Plane's render GPU.
    - Maps the user's choice to texture.compressor + texture.gpu_device.
      The selector keyword "integrated"/"discrete" is preferred when
      the kind is unique; falls back to adapter name substring otherwise.
    - Shows a spinner during the 10-30s wgpu probe.

Supporting changes:

- New `xearthlayer::system::gpu` module wraps wgpu enumeration with a
  plain GpuAdapter type and config_value mapping. Used by the wizard;
  available to other consumers (diagnostics report, future GTK UI).
- New `MIN_MEMORY_CACHE_BYTES` and `MIN_DISK_CACHE_BYTES` constants
  in the recommendations module.
- `SystemInfo` now carries `cache_path_available_bytes` (statvfs at
  detect time, walks up to existing ancestor when the cache dir
  doesn't exist yet).
- `RecommendedSettings::for_system` signature gains `available_disk: u64`.
- Promote `KB / MB / GB` from inline private constants (5 redeclarations)
  to public `xearthlayer::config::{KB, MB, GB}` SSOT.
- Updated tests reflecting the new formulas.
- docs/configuration.md describes the new four-step wizard flow.

Fixes #153
Fixes #154

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull all wgpu enumeration and selection logic into system::gpu so the
wizard (writes config), encoder (reads config), and diagnostics report
(prints adapters) share one implementation.

Changes:

- system::gpu gains enumerate_raw() returning live wgpu::Adapter handles,
  find_adapter() returning a selected adapter by gpu_device string, and
  GpuSelectError as the typed error.
- GpuAdapter::from_wgpu factories the metadata-only record from a live
  wgpu::Adapter; enumerate() now delegates to enumerate_raw().mapped.
- New pure select_index() function operates on metadata-only [GpuAdapter]
  so the selection logic is testable without a real GPU.
- New round-trip test asserts that for every adapter in five realistic
  enumeration shapes, GpuAdapter::config_value(all) round-trips back to
  the same adapter via select_index(all, value). This locks the inverse-
  function relationship between the wizard's adapter→config-string
  mapping and the encoder's config-string→adapter mapping.
- dds/compressor.rs::create_gpu_resources now delegates enumeration and
  selection to system::gpu, dropping the duplicated wgpu instance setup
  and the now-dead select_adapter helper.
- diagnostics/report.rs renders "## GPU Compute Adapters" via the shared
  system::gpu::enumerate(), eliminating the third copy of the wgpu
  instance/enumerate boilerplate. Format shifts from "(DiscreteGpu, Vulkan)"
  to "(Discrete, vulkan)" — slightly cleaner human-readable output.

Net: -57 LOC of duplication removed, +95 LOC added in system::gpu (mostly
the 5-scenario round-trip test). Two duplicate wgpu instance setups
collapsed into one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samsoir

samsoir commented May 11, 2026

Copy link
Copy Markdown
Owner Author

:shipit:

@samsoir samsoir merged commit 9dda29f into main May 11, 2026
1 check passed
@samsoir samsoir deleted the feat/153-154-setup-wizard-gpu-cache branch May 11, 2026 04:34
@samsoir samsoir mentioned this pull request May 11, 2026
6 tasks
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.

feat: setup wizard expanded cache configuration feat: setup wizard GPU encoding configuration step

1 participant