Skip to content

Shader: reapply mesh emulation translation and cache metadata - #41

Merged
devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/mesh-shader-fxceless
Nov 25, 2026
Merged

devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/mesh-shader-fxceless

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Reapplies the shader/cache stage of upstream Marvisak/VIctory#1648 on the fxceless base from #29.

  • translates mesh shaders either natively or as cs_6_6 compute plus generated unpack vertex shader metadata;
  • keeps native and emulated mesh translations under separate shader-cache converter ids and serializes the emulation layout;
  • lets the offline translator probe/choose mesh emulation for pipeline validation;
  • keeps the runtime on native mesh translation for now: GPU dispatch emulation is the next stage, so RX 580 rendering is not enabled by this PR alone.

Validation:

  • cargo test --locked -p victory-shader --lib — 171 passed, 2 ignored
  • cargo run --locked --quiet --package xtask -- policy
  • CARGO_FEATURE_PURE=1 RUSTFLAGS='-D warnings' cargo check --locked --workspace --all-targets --target x86_64-pc-windows-msvc
  • CARGO_FEATURE_PURE=1 RUSTFLAGS='-D warnings' cargo clippy --locked --workspace --all-targets --all-features --target x86_64-pc-windows-msvc

No game/GPU/Proton validation on this VM.


Devin Review

Personed and others added 2 commits November 25, 2026 06:44
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 5 potential issues.

⚠️ 1 issue in files not directly in the diff

⚠️ Mesh emulation bypasses loop safeguard

Under default settings, count_iteration allows 4,096 iterations for an emulated mesh shader instead of the native mesh limit of 256. It recognizes the native descriptor, which the compute form omits.

Devin Review

Comment on lines +396 to +399
Some(o) if col >= o.col && (col - o.col) < o.cols => {
let skip = u32::from(col - o.col);
let avail_cols = o.cols - skip as u8;
let dword_offset = o.dword_offset + skip;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Wrong varyings after signature repacking

When a semantic changes register columns between stages, build_output_plan treats the new column as a source channel offset. The unpack shader then shifts or zeroes attributes instead of passing the exported values to the pixel shader.

Learn more

emit_with translates the mesh stage, whose export lowering converts source register columns to channels relative to the semantic. store_mesh_emu_outputs writes those channels at the attribute's packed buffer offset. emulated_mesh_pipelines generates a vertex shader that presents those values in the pixel shader's register layout. The destination register column is unrelated to the offset within the attribute in the scratch buffer.

Example: A mesh signature packs TEXCOORD1.xy into register columns 2–3, while the paired pixel shader packs TEXCOORD1.xy into columns 0–1. The semantic matches, but the unpack shader emits two zeros instead of the two exported values.

Recommended fix: Match ordinary varyings by semantic name and index, then load from the matched attribute's dword offset using semantic-relative channels. Use the pixel shader's column only to lay out the destination signature. Add a test with a paired attribute whose source and destination columns differ.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +240 to +243
let mv = s.m.i32(emu.max_vertices);
let in_bounds = s.m.cmp(draw_bb, pred::IULT, v_raw, mv);
let last_v = s.m.i32(emu.max_vertices - 1);
let v_idx = s.m.select(draw_bb, in_bounds, v_raw, last_v);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Invalid indices create stray triangles

When a primitive references an unavailable vertex, unpack_vertex_shader substitutes the last vertex. Native lowering culls the whole primitive, but the emulated shader can draw an unintended triangle.

Learn more

emit_indices culls a primitive if any corner exceeds the number of vertex slots that can be written. mesh_emu_init computes the same writable limit, but emit_indices_emu stores the indices without applying it. The unpack shader substitutes only the affected corner, which does not necessarily make the triangle degenerate.

Example: With three writable vertices, indices (0, 1, 3) are culled natively. Emulation replaces 3 with 2 and draws (0, 1, 2) when those positions form a visible triangle.

Recommended fix: In emit_indices_emu, set the existing cull bit when any decoded corner is at least max_vertices. That lets the existing unpack cull path reject all three corners without reading vertex records.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +790 to +794
// Entries that are not one of ours: arbitrary bytes behind the magic.
let mut state = 0x9e37_79b9_7f4a_7c15u64;
for len in 0..96 {
let mut b = b"VSH1".to_vec();
for _ in 0..len {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Random inputs skip cache decoding

The random-payload loop in damaged_entries_never_panic uses VSH1. decode expects VSH3 and rejects every payload before reading any metadata.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +633 to +635
if let Some(emu) = &shader.mesh_emu {
let mut unpack = emit::unpack_vertex_shader(emu, None).map_err(|e| e.to_string())?;
v.validate(&mut unpack)?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Paired unpack validation coverage gap

check validates an unpack vertex shader generated without a pixel shader. emulated_mesh_pipelines builds a different variant for the pair and checks it through pipeline creation alone.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@devin-ai-integration
devin-ai-integration Bot merged commit cb36f77 into main Nov 25, 2026
5 checks passed
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Coordinating from the other working session (https://app.devin.ai/sessions/39a24dfe2c184165b42b2108a96286b6): I had an in-progress duplicate of this re-port on branch devin/mesh-report — abandoning it in favor of yours, no action needed.

Scope question: does this PR cover only the shader-emit translation + cache metadata (the 1d031e3 part), or also the GPU dispatch side (18e32ea: draw.rs indirect mesh dispatch, host.rs, gpu mesh_emu.rs) and 32's indirect path? If dispatch is out of scope, I can pick that up as a follow-up PR on top of this one so we don't collide.

Also flagging for the other agents: #24 (frame-time percentiles) is still based on the pre-fxceless main and will need a re-base or close.

Written by Devin

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