Skip to content

Keep parity-candidate shader bundles out of the published build #2

Description

@DennisSmolek

src/shaders/candidate{Filters,Inputs,Temporal,Debug}.ts — ~55 kB of source, mostly WGSL string literals that survive minification — is statically imported by Upscaler.ts and therefore ships in dist/index.js (currently 188.84 kB). These are parity-research bundles from the FSR 3.1.5 A/B program; no library consumer can reach them.

They are gated behind the private _candidateBundle config option, and the only thing that ever sets it is the bench (bench/src/benchmark/BenchmarkResolver.ts:43). Because the import is static and the branch is a runtime string compare, no bundler can drop them.

Why it isn't a one-liner: Upscaler.ts branches on _candidateBundle in ~15 places, selecting shader sources and pass structure (the structural bundle changes the graph, not just the WGSL). Removing the import means introducing a seam.

Approach options:

  1. Turn _candidateBundle into a shader/pass-source injection object the bench supplies, and move the candidate modules to bench/src/shaders/. The bench already aliases @pmndrs/upscaler../src/index.ts (bench/vite.config.ts:10), so it can inject without a published entry point.
  2. Ship them behind a secondary entry (@pmndrs/upscaler/candidates) that registers into the core. Keeps them installable but off the main path.
  3. Delete from src/ outright and keep the A/B rig reconstructable from git history (1b1be7b).

Option 1 is preferred — it keeps node scripts/run-benchmark.mjs --variant <A> --comparison <B> working, which the parity record depends on.

Acceptance:

  • dist/index.js contains no candidate WGSL (grep for a distinguishing candidate-only identifier); record the size delta.
  • Candidate A/B runs still work for all four bundle IDs.
  • npm test && npm run typecheck && npm run lint && npm run build clean; production capture output byte-identical (Q0/Q1/Q3) — this touches a core path, so it needs GPU re-verification, not just a green build.

Risk note: this edits the core pass-construction path. It was deliberately not bundled into the 0.2.0 PR (#1) for that reason. Do it early in a release cycle, not right before a publish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions