Skip to content

Shaders: faster structurisation and live-pipeline-first compile order (upstream #1013) - #43

Merged
pablogonz12 merged 5 commits into
mainfrom
pr/1013
Nov 24, 2026
Merged

pablogonz12 merged 5 commits into
mainfrom
pr/1013

Conversation

@pablogonz12

@pablogonz12 pablogonz12 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Takes Marvisak/VIctory#1013 by @matheusfrta (Matheus), merged as-is with authorship kept (commits d60b7623, cbbb17ea, merge 7355d366).

What it fixes (BOARD B12): 48 % of producer dependencies were first-use compile latency. The PR

  • front-loads structurisation: memoised Bools::implies, a forced-atom analysis instead of repeated restrict calls, ite canonicalisation (f==g, f==h) and operand swaps, FxHash set membership in vars/meet;
  • splits pipeline work into an urgent/background queue, so pipelines a live draw needs jump ahead of pre-warmed ones (already-queued background entries are promoted).

Conflict: Bools::ite — kept both sides: our early overflow guard (and MAX_MEMO memo cap) plus upstream's f==g/f==h canonicalisation. make.rs merged cleanly (our "the title" wording kept alongside the new queue).

Numbers (RX 9070 XT, RADV, shaders-dump 751 programs):

  • cargo test -p victory-shader --lib: 150 passed, 0 failed, 2 ignored (same as main).
  • cargo xwin clippy --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.
  • offline check: 712/751 ok before and after (paired baseline on hub/main d12539f2 run the same hour: 712/751; the two report TSVs are identical line for line — no shader changed state). Earlier 692 figures were a stale corpus.
  • stage-1 translate 9.3 s both; whole check 13.6 s vs 15.3 s baseline.

Exe built: xcl-bin/bin-play/ab-i1013.exe (release, --features diagnostics). No game run (one live); enqueue a run if we want the runtime half measured.

Summary by CodeRabbit

  • Performance
    • Shader compilation now processes live pipelines before pre-warmed pipelines. In reported measurements, total processing time decreased from 15.3 seconds to 13.6 seconds, while stage-one translation remained at 9.3 seconds.
  • Documentation
    • Added benchmark results showing unchanged offline shader results: 712 of 751 shaders and identical report rows.

matheusfrta and others added 4 commits November 24, 2026 12:02
…tise live pipeline compiles)

Upstream PR Marvisak/VIctory#1013 by Matheus (matheusfrta), +395/-85.

- structure.rs: Bools::vars/ite/implies/restrict/forget/meet sped up
  (FxHash set membership, ite canonicalisation and swaps, memoised
  implies, forced-atom analysis replacing repeated restricts).
- make.rs: pipeline workers use an urgent/background work queue;
  first-use (live) pipelines are queued urgent and already-queued
  background entries are promoted.

Conflict in Bools::ite resolved keeping both: Scarlight's early
overflow guard (and MAX_MEMO cap) plus upstream's f==g / f==h
canonicalisation before the existing overflow check.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

Changes: Shader Boolean structure

Layer / File(s) Summary
Boolean decision operations
crates/victory-shader/src/structure.rs
Variable traversal uses sets. The ite, meet_in, implies, and forget operations add normalization, contradiction checks, memoization, and overflow handling.
Forced values and restriction
crates/victory-shader/src/structure.rs
forced identifies atoms fixed by a condition, and restrict_many substitutes them in one traversal. finish applies these values to guards and branch conditions. Tests cover forced values, implication, restriction, and contradictory constraints.
Block path worklist
crates/victory-shader/src/structure.rs
paths processes dirty blocks, marks successors dirty when block conditions change, and reuses a memo when forgetting loop-redefined atoms.

Merged-pull-request record

Layer / File(s) Summary
Comparison record
INTEGRATION.md
The table adds PR #1013 and records unchanged offline results for 712 of 751 shaders, identical report rows, equal 9.3-second stage-1 translation times, total times of 13.6 versus 15.3 seconds, and a B12 result.

Suggested reviewers: r4tedx

Change: Refactor

Security architecture risk: Low · up to 181eb

Live rendering gets priority over pre-warming, with no identified expansion of access or privileges. The main risk is recovery: if every compilation worker exits after startup, new pipelines can remain permanently pending, causing draws or dispatches that need them to be skipped.

Retained concerns

  • Low · reliability · inferred: If all compilation workers exit after a successful startup, the process-wide queue still accepts new pipelines but has no consumer. Pending entries remain latched as queued, so repeated use does not resubmit them, completion accounting does not drain, and dependent GPU operations can keep being skipped. The merge base instead attempted to compile new submissions on the caller thread after the channel disconnected; it did not guarantee recovery of already-failed work.
Security review details

Security Blast Radius

  • inferred — The scheduler shares failure across pipeline objects in the same Windows process. Already-completed pipelines do not need a worker on reuse; the loss-of-workers condition affects submissions that still need a build.

Trust Boundaries and Controls

  • observed — Title-provided shader bytes still enter through the existing pipeline creation path. Urgency is assigned by the existing live-use path, not by a new caller-supplied priority field, and both work lanes call the same host pipeline builder.

Hardening Proposals

  • proposed — Tie queue admission to current worker liveness. On total worker loss, restart workers or explicitly complete queued items as failed, with ownership and accounting settled exactly once, rather than leaving them pending or forcing compilation onto a latency-sensitive caller.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08bc73c1-ff02-4ca7-9eee-d018fb4abb52
Commits

Reviewing files that changed from the base of the PR and between 812fbdd and 181ebca.

Files selected for processing: 3

  • INTEGRATION.md
  • crates/victory-gpu/src/pipeline/make.rs
  • crates/victory-shader/src/structure.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

pipeline/make.rs: keep main's tiered demand/early queue, which already
generalises #1013's urgent-first ordering (and spawns its own workers via
work_queue(), so ensure_workers() was redundant).
@pablogonz12

Copy link
Copy Markdown
Owner Author

CodeRabbit's run on f0cd5d1 says "Skipped - No files to review" although the diff carries structure.rs (+287/-59), so the head has not actually been reviewed. CI is green and there are no threads. @coderabbitai please review the full diff (base main) — I will merge once it has.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Analysis chain

Script executed:

#!/bin/bash
set -euo pipefail
fd -HI '^structure\.rs$' .
file="crates/victory-shader/src/structure.rs"
if [ -f "$file" ]; then
  ast-grep outline "$file" --items all || true
  cat -n "$file" | sed -n '1,100p'
fi

Length of output: 6857


@pablogonz12 I’ll request a full review of the diff against main. The previous run reported “Skipped - No files to review” despite the changes to structure.rs.

Please wait for the review results before merging.

Action not completed

Pull request is closed.

@pablogonz12
pablogonz12 merged commit 8d0bf91 into main Nov 24, 2026
1 of 2 checks passed
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.

2 participants