[enhancement] Switch helpers in darner-core, so every crate reads DARNER_* switches one way #398

Open
opened 2026-12-04 19:52:04 +00:00 by iBooM72 · 0 comments
Contributor

What you would like

AGENTS.md says to read switches only through toggled! (on unless 0) and asked_for! (on only at 1) in crates/darner-gpu/src/switch.rs. On main f3840d73, about 300 reads outside darner-gpu go to the environment directly, with at least three meanings of "on" (counts are approximate):

  • darner-hle, about 105: it depends on darner-gpu and can use the helpers today. One read already does (darner_gpu::asked_for!("DARNER_WHEEL_HOLD"), gameinput.rs:2750).
  • apps/darner, about 80: it reaches darner-gpu only through darner-hle's re-exports, and the two macros aren't among them.
  • darner-shader (about 95), darner-loader (about 14) and darner-core (about 6): they don't depend on darner-gpu, so they can't reach the helpers at all.

What that causes, read from the code:

  • DARNER_STRICT_JOINS and DARNER_MESH_OUTPUT_STRICT are read with .is_some(), while the README documents them as 1 = on. So =0 turns them on, and because both are in the shader cache key, it also re-translates every shader.
  • DARNER_SOFT_VIEWS is parsed two different ways inside xmem.rs (:3982 and :4972).

Proposal:

  1. Move the two helpers and their read-once cache into darner-core (for example darner_core::switch), and re-export them from darner-gpu, so none of its call sites change. One thing to keep in mind: the diagnostics/ab cfgs inside the macros are evaluated in the calling crate, so DARNER_AB switching works only where that crate has those features (darner-shader, darner-loader and darner-core have diagnostics but no ab).
  2. Convert the other crates' reads in small later PRs, one crate or area at a time. darner-shader doesn't depend on darner-core yet, and any darner-shader change re-keys every user's shader cache, so its part (the new dependency and its reads) should ride with a translator change that ships anyway.

Is that the direction you want before anyone starts, or would you rather keep the direct reads?

Checked with AI assistance (Claude Code).

Are you working on a fix?

I'd like to, with some pointers

### What you would like AGENTS.md says to read switches only through `toggled!` (on unless `0`) and `asked_for!` (on only at `1`) in `crates/darner-gpu/src/switch.rs`. On `main` `f3840d73`, about 300 reads outside darner-gpu go to the environment directly, with at least three meanings of "on" (counts are approximate): - darner-hle, about 105: it depends on darner-gpu and can use the helpers today. One read already does (`darner_gpu::asked_for!("DARNER_WHEEL_HOLD")`, `gameinput.rs:2750`). - apps/darner, about 80: it reaches darner-gpu only through darner-hle's re-exports, and the two macros aren't among them. - darner-shader (about 95), darner-loader (about 14) and darner-core (about 6): they don't depend on darner-gpu, so they can't reach the helpers at all. What that causes, read from the code: - `DARNER_STRICT_JOINS` and `DARNER_MESH_OUTPUT_STRICT` are read with `.is_some()`, while the README documents them as `1 = on`. So `=0` turns them on, and because both are in the shader cache key, it also re-translates every shader. - `DARNER_SOFT_VIEWS` is parsed two different ways inside `xmem.rs` (`:3982` and `:4972`). Proposal: 1. Move the two helpers and their read-once cache into darner-core (for example `darner_core::switch`), and re-export them from darner-gpu, so none of its call sites change. One thing to keep in mind: the `diagnostics`/`ab` cfgs inside the macros are evaluated in the calling crate, so `DARNER_AB` switching works only where that crate has those features (darner-shader, darner-loader and darner-core have `diagnostics` but no `ab`). 2. Convert the other crates' reads in small later PRs, one crate or area at a time. darner-shader doesn't depend on darner-core yet, and any darner-shader change re-keys every user's shader cache, so its part (the new dependency and its reads) should ride with a translator change that ships anyway. Is that the direction you want before anyone starts, or would you rather keep the direct reads? Checked with AI assistance (Claude Code). ### Are you working on a fix? I'd like to, with some pointers
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner#398
No description provided.