Skip to content

GPU: preserve successful shader translations on cache I/O failure - #447

Open
VlREX wants to merge 1 commit into
fxceless:mainfrom
VlREX:virex/shader-cache-resilience
Open

VlREX wants to merge 1 commit into
fxceless:mainfrom
VlREX:virex/shader-cache-resilience

Conversation

@VlREX

@VlREX VlREX commented Nov 25, 2026

Copy link
Copy Markdown

Problem

cached() currently propagates Cache::get_or_convert errors even when translation succeeded and only publishing the optional cache entry failed. This can discard usable shaders.

Change

Retain the conversion result for the current request. Return successful in-memory translations even when writing or renaming the cache entry fails; do not retry a genuine translation failure. Cache hits and damaged-entry recovery remain unchanged. No cache key, format or shader semantics change.

Validation

Added two focused Rust regression tests for a blocked cache publication and a translator failure, each asserting one translation call. Native Rust/Windows and game tests have not been run. No measured performance or rendering claim. Based on a803c87. AI-assisted (ChatGPT).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T00:55:59.109669Z fe4e274 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

RecompLive pushed a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
Shaders: a signed 64-bit operand sign-extends its 32-bit literal
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
Shaders: a signed 64-bit operand sign-extends its 32-bit literal
(cherry picked from commit 1134418)
PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…witch, its lowerings of instructions the title does not run, and 16-bit results by MODE

Ported from Marvisak/VIctory into emit/official.rs, a child module of the
lowering; lower.rs and the instruction modules (valu, valu16, salu, buffer,
interp, image, export) only call it (lower.rs: 129 bytes more, for the module
and the round-mode state).

On by default, `VICTORY_<NAME>=0` gives the translation as before (each is
part of the shader cache key):
- VICTORY_MESH_EDGE_FLAGS (#1718, c0228d9): a mesh primitive's corners are
  9-bit indices, the edge flag above each (bits 9, 19, 29) no part of it.
  Ours took 10 bits, so a flagged corner named vertex 512+ and the triangle
  was culled as naming a vertex past the program's count. Every mesh
  program's DXIL (the mask constant).
- VICTORY_NORM_ENDS (fxceless#169, 645391b): a normalized buffer format's ends load
  as exactly 1.0 and -1.0 whatever the host's division gives there (vertex
  fetch, typed-format loads of compute programs): 9,764 programs.
- VICTORY_CUBE_GRAD_LEVEL (4f57f46; the same fix as 9ee9adf of
  fxceless#767, flagged by amdsh): a cube sample with gradients takes log2
  of the longer gradient in texels (DXIL's Log is base 2, ours multiplied it
  by log2(e) again: 1.44 times the level, blurrier cube reads), at least the
  _cl clamp: 29 pixel programs.
- VICTORY_SMINMAX_SCC (77053a0's scalar part): s_min/s_max set SCC to
  whether the first operand was chosen (RDNA2 ISA); ours set result != 0.
- VICTORY_INTERP_F16_MODIFIERS (#1696, e29391f): v_interp_p2_f16 honours
  op_sel[3] (the high half), omod and clamp; only an instruction that has
  one of them translates differently (the title's have none).
- VICTORY_DEAD_PHI_LATCHES (#1471, be3202d): an empty loop latch whose phis
  are all unread folds as an empty one does.
- VICTORY_BRANCH_FALLTHROUGH (#1282, 1ed26e5): a conditional branch to the
  next instruction is a jump. As a branch it gave its block the same
  successor twice, and the join's phi the wrong value (the official test
  fails on ours without it, on WARP).

Off by default:
- VICTORY_OMOD_ZERO=1 (77053a0): an output multiplier reads a denormal
  operand as a zero of its sign and gives +0 for a zero product, as RDNA2
  measured with IEEE mode off. Compilers fold every x2, x4, x0.5 into one:
  12,276 programs would gain its eight instructions, for the sign of a zero.
- 16-bit results by MODE (77053a0), under our VICTORY_F16_NEAREST=1: every
  f32 to f16 result of a VALU operation (v_cvt_f16_f32, v_fma_mixlo/hi_f16,
  packed and scalar f16 arithmetic, f16 interpolation) rounds as the
  console's MODE says where it is: toward zero after
  `s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 3` (the title writes it
  6,694 times, around its 16-bit interpolation), to nearest even elsewhere;
  the switch covered 16-bit arithmetic only, at nearest even everywhere.

Without switches (no program of the title runs them): s_quadmask_b32/b64
(#1443), v_cvt_off_f32_i4 (#1391), v_sad_u8/hi_u8/u16/u32 and v_msad_u8
(fxceless#162), v_mul_hi_u32_u24/i32_i24 (fxceless#156), tbuffer_load_format_d16_* packed two
channels a VGPR (fxceless#169, c430b1d), a signed 64-bit operand's literal
sign-extended (fxceless#447, 7d04943), v_cndmask_b32 on an inline constant mask or a
mask the structurisation keeps among its other masks (#1221, 67c4f53;
Structured::other exported), and v_cmp_f/tru as constants (`fcmp false/true`
removed the WARP device; 77053a0). format_load and write_half became
pub(super), for official.rs.

Tests: the official ones of these (valu_tests on the hardware adapter and
WARP: quad masks, cvt_off, tbuffer d16, normalized ends, i64 literals,
branch to fallthrough), its instruction tests fxceless#1052, fxceless#1050 and fxceless#990 (they
pass on ours unchanged), CPU models of the SAD, 24-bit high multiply and
s_min/s_max SCC results, and the MODE rounding under VICTORY_F16_NEAREST.

Census (CPU, against wave5's own): with every switch off, every program's
DXIL is byte for byte as before; with the defaults, 10,711 programs change
(Ms 8,765, Cs 1,077, Vs 840, Ps 29) and none is lost or gained (25,953 of
25,953 pass either way).
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.

1 participant