shader_cache: zero-copy CacheKey::from_parts and get_or_convert_keyed #662

Open
Nyutt wants to merge 1 commit from nyutt/merge-shader-cache-key into post-merge AGit
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on Merge: read from crates/darner-gpu/src/shader_cache.rs and crates/darner-pipeline/src/cache.rs. shader_cache::cached() allocates and copies the entire shader container into [&build[..], ..., container].concat() on every cache lookup (hit or miss).

Add CacheKey::from_parts and Cache::get_or_convert_keyed to hash multi-slice cache keys directly with BLAKE3 without concatenating buffers, and pass container straight through to Translate::convert.

How it was tested

  • Tested revision: a251c17 (based on origin/Merge 28a9b42)
  • Commands and results: Verified hash equivalence with a new unit test and zero clippy warnings. Not yet benchmarked in-game on Merge.
  • Changes a default: yes (zero-copy cache key path; produces bit-identical cache keys, so existing shader caches remain valid).
  • A/B result: not yet measured in-game on Merge.
  • Checks run on that revision:
    • cargo test -p darner-pipeline --lib --locked -> 1 passed (from_parts_matches_new_on_concatenated_bytes), 0 failed
    • cargo clippy -p darner-pipeline -p darner-gpu --lib --locked -> 0 warnings in cache.rs; 0 new warnings in shader_cache.rs
  • Hardware dependence: general.
  • Coverage gaps: in-game preload/cache-lookup timing check on Merge.

Checklist

  • I ran this change in the game, or say below why it can't be (unit test + clippy verified; not yet timed in-game).
  • This PR contains one change based on Merge.
  • The diff contains no game files, code or assets.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #647, #649
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: <!-- paste your !myid here if wanted --> ## What it changes - The problem on `Merge`: read from `crates/darner-gpu/src/shader_cache.rs` and `crates/darner-pipeline/src/cache.rs`. `shader_cache::cached()` allocates and copies the entire shader container into `[&build[..], ..., container].concat()` on every cache lookup (hit or miss). Add `CacheKey::from_parts` and `Cache::get_or_convert_keyed` to hash multi-slice cache keys directly with BLAKE3 without concatenating buffers, and pass `container` straight through to `Translate::convert`. ## How it was tested - Tested revision: `a251c17` (based on `origin/Merge` `28a9b42`) - Commands and results: Verified hash equivalence with a new unit test and zero clippy warnings. Not yet benchmarked in-game on `Merge`. - Changes a default: yes (zero-copy cache key path; produces bit-identical cache keys, so existing shader caches remain valid). - A/B result: not yet measured in-game on `Merge`. - Checks run on that revision: - `cargo test -p darner-pipeline --lib --locked` -> 1 passed (`from_parts_matches_new_on_concatenated_bytes`), 0 failed - `cargo clippy -p darner-pipeline -p darner-gpu --lib --locked` -> 0 warnings in `cache.rs`; 0 new warnings in `shader_cache.rs` - Hardware dependence: general. - Coverage gaps: in-game preload/cache-lookup timing check on `Merge`. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (unit test + clippy verified; not yet timed in-game). - [x] This PR contains one change based on `Merge`. - [x] The diff contains no game files, code or assets. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #647, #649 - Replaces or overlaps: none found
TrustNo1 changed title from [pr-performance][shaders] shader_cache: zero-copy CacheKey::from_parts and get_or_convert_keyed to shader_cache: zero-copy CacheKey::from_parts and get_or_convert_keyed 2026-12-06 03:25:24 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/662/head:nyutt/merge-shader-cache-key'
git switch 'nyutt/merge-shader-cache-key'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'post-merge'
git merge --no-ff 'nyutt/merge-shader-cache-key'
git switch 'nyutt/merge-shader-cache-key'
git rebase 'post-merge'
git switch 'post-merge'
git merge --ff-only 'nyutt/merge-shader-cache-key'
git switch 'nyutt/merge-shader-cache-key'
git rebase 'post-merge'
git switch 'post-merge'
git merge --no-ff 'nyutt/merge-shader-cache-key'
git switch 'post-merge'
git merge --squash 'nyutt/merge-shader-cache-key'
git switch 'post-merge'
git merge --ff-only 'nyutt/merge-shader-cache-key'
git switch 'post-merge'
git merge 'nyutt/merge-shader-cache-key'
git push origin 'post-merge'
Sign in to join this conversation.
No reviewers
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!662
No description provided.