Performance recipe: dropped draws, dark faces and other visual defects in the Series S intro #17

Open
opened 2026-11-27 14:01:21 +00:00 by github-bot · 3 comments
Owner

@⁠jgrizon on GitHub · 2026-11-27 14:01 UTC · original

Findings from the performance recipe (runtime-preview/build.sh --perf) on the Series S intro, from release and diagnostics builds. Setup: Apple M5 Pro, 24 GB, macOS 27.3, CrossOver 26.3.0.39832, D3DMetal 3.0. Posting so others can pick them up.

1. Draws dropped for want of a host pipeline

  • Size: the world frames ask for 2,500 to 4,400 draws, and the frame report says 78 to 984 of them are dropped, 1,650 at worst. The shader and pipeline caches were warm, and no pipelines are compiled in steady play.
  • The reason is no longer printed. Since some point the per-reason drop map prints nothing, even in diagnostics builds. Also, note_drop records nothing when a pipeline exists but binding it fails. The last runs that still printed reasons named being made and indirect kind N: no host pipeline.
  • A suspect: pipeline/make.rs (around lines 195 and 272-290) gives each title frame a single 500 ms wait, shared by every thread. One slow driver compile can use it all up. That explains drops during loading, but not steady drops once the caches are warm.
  • A first step anyone can take: record a reason at every drop site, including bind failures, and print the top reasons in release builds too.

2. Faces and skin render nearly black

Diagnostics captures show people as dark silhouettes in front of lit buildings, and car occupants almost black. This looks like the dark geometry the checkpoint's wave64 work fixed on the M3 Pro (VICTORY_WAVE64_REDUCE, checkpoint patches 0013-0015). The performance recipe does not have those patches. #14's tester also reported better faces with VICTORY_AMBIENT=1.0. We are trying a port of the checkpoint's wave64 patches onto the performance recipe.

3. No depth bounds test under Wine

host.rs (around lines 352-364) turns depth bounds off under Wine. As a result, pipelines are built without it, and OMSetDepthBounds is never called. Every draw that relies on it renders more pixels than the title intended. An idea: emulate it with a pixel-shader clip, the way mesh clipping is emulated.

4. SW_64KB_R_X (Swizzle 27) textures are never copied back

a texture of a kind copied back is not: its layout (Swizzle(27)) cannot be tiled. Three kinds of texture are affected (1x1 f41, 256x256 f41, 10x12 f42), so the GPU keeps reading stale results. The fix would be the R_X XOR swizzle in victory-formats, plus enabling it in the copy-back path.

5. Not a bug: the mesh shader output warning

mesh shader outputs exceed Metal's limit measures the mesh program alone (33,792 to 34,816 B). Linked with its pixel shader, the pair is 28,160 B, under the limit. The real refusal line never appears in about 475 run logs. So no draws are lost to it; only the warning is misleading.

6. Still open: the green credits panel

The opening credits show a flat green panel where a video should play. The video planes read as near zero with the credits text on top. We have not found the cause.

A false lead worth knowing about

host pipeline refused error=Call failed. (0x80004005) in large numbers means Wine loaded vkd3d instead of D3DMetal. That happens with a rebuilt ntdll.so that is not the CrossOver one. vkd3d ignores the root-signature flags for directly indexed heaps (0xc00, 0xc01), so every such pipeline fails. With D3DMetal loaded, no pipelines are refused.

**@⁠jgrizon** on GitHub · 2026-11-27 14:01 UTC · [original](https://github.com/paveledits/ScarlettMac/issues/17) Findings from the performance recipe (`runtime-preview/build.sh --perf`) on the Series S intro, from release and diagnostics builds. Setup: Apple M5 Pro, 24 GB, macOS 27.3, CrossOver 26.3.0.39832, D3DMetal 3.0. Posting so others can pick them up. ## 1. Draws dropped for want of a host pipeline - **Size:** the world frames ask for 2,500 to 4,400 draws, and the frame report says 78 to 984 of them are dropped, 1,650 at worst. The shader and pipeline caches were warm, and no pipelines are compiled in steady play. - **The reason is no longer printed.** Since some point the per-reason drop map prints nothing, even in diagnostics builds. Also, `note_drop` records nothing when a pipeline exists but binding it fails. The last runs that still printed reasons named `being made` and `indirect kind N: no host pipeline`. - **A suspect:** `pipeline/make.rs` (around lines 195 and 272-290) gives each title frame a single 500 ms wait, shared by every thread. One slow driver compile can use it all up. That explains drops during loading, but not steady drops once the caches are warm. - **A first step anyone can take:** record a reason at every drop site, including bind failures, and print the top reasons in release builds too. ## 2. Faces and skin render nearly black Diagnostics captures show people as dark silhouettes in front of lit buildings, and car occupants almost black. This looks like the dark geometry the checkpoint's wave64 work fixed on the M3 Pro (`VICTORY_WAVE64_REDUCE`, checkpoint patches 0013-0015). The performance recipe does not have those patches. #14's tester also reported better faces with `VICTORY_AMBIENT=1.0`. We are trying a port of the checkpoint's wave64 patches onto the performance recipe. ## 3. No depth bounds test under Wine `host.rs` (around lines 352-364) turns depth bounds off under Wine. As a result, pipelines are built without it, and `OMSetDepthBounds` is never called. Every draw that relies on it renders more pixels than the title intended. An idea: emulate it with a pixel-shader clip, the way mesh clipping is emulated. ## 4. `SW_64KB_R_X` (Swizzle 27) textures are never copied back `a texture of a kind copied back is not: its layout (Swizzle(27)) cannot be tiled`. Three kinds of texture are affected (`1x1 f41`, `256x256 f41`, `10x12 f42`), so the GPU keeps reading stale results. The fix would be the R_X XOR swizzle in victory-formats, plus enabling it in the copy-back path. ## 5. Not a bug: the mesh shader output warning `mesh shader outputs exceed Metal's limit` measures the mesh program alone (33,792 to 34,816 B). Linked with its pixel shader, the pair is 28,160 B, under the limit. The real refusal line never appears in about 475 run logs. So no draws are lost to it; only the warning is misleading. ## 6. Still open: the green credits panel The opening credits show a flat green panel where a video should play. The video planes read as near zero with the credits text on top. We have not found the cause. ## A false lead worth knowing about `host pipeline refused error=Call failed. (0x80004005)` in large numbers means Wine loaded vkd3d instead of D3DMetal. That happens with a rebuilt `ntdll.so` that is not the CrossOver one. vkd3d ignores the root-signature flags for directly indexed heaps (`0xc00`, `0xc01`), so every such pipeline fails. With D3DMetal loaded, no pipelines are refused.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:01:21 +00:00
Author
Owner

@⁠jgrizon on GitHub · 2026-11-27 15:48 UTC · original

Update on item 1 (dropped draws) and item 2 (dark faces): they have the same cause.

What the dropped draws are. We made every dropped call record its reason, in release builds too. In steady world play, 100% of drops are dispatch: the BVH builder held back, 72 to 169 per frame. XboxBvhBuilder.dll is the title's own compute builder for its ray-tracing structure (the BVH, a tree of bounding boxes), 53 compute pipelines. It is not DXR. pipeline/builder.rs opens it only when !halves && all_made. With VICTORY_HALVES_LOCAL=1/VICTORY_HALVES_SHARED_LDS=1, which the play preset sets, halves is always true, so the builder never runs:

BVH builder held back: its 64-lane programs would run as 32-lane halves on their own (VICTORY_HALVES_LOCAL, VICTORY_HALVES_SHARED_LDS) frame=1593 pipelines=53 made=53 refused=0

The guard is there because approximate halves in the builder hung GPUs.

Why faces are black. The probe resolve then traces against a structure that was never built. As ambient.rs says, it "leaves next to nothing, and whatever the sun does not reach directly is black". The preset's VICTORY_AMBIENT=estimate replaces that output, but its floor is about 0.04, so 99 to 100% of sampled points stay under it. Raising the floor (VICTORY_AMBIENT_FLOOR=1) still left faces black.

What fixes it today. VICTORY_AMBIENT=1.0, the constant stand-in that #14's tester also liked. In the same intro scene, a character who was a black silhouette shows a lit face, cap, skin and clothing colours, with some small dotted artifacts on skin and beard. It costs nothing measurable: 431 world frames in the first 120 s in a diagnostics build, against 386 for the preset's estimate. Release timing runs are queued.

What did not help. Upstream's checkpoint wave64 patches (0005 to 0015), ported onto the perf recipe with VICTORY_WAVE64_REDUCE=1, gave speckled hair and faces and green blobs on this M5 Pro with D3DMetal 3.0. They cost no speed (525 frames), but the picture was worse.

The real fix still to do. Let the builder run when every one of its 53 programs translates exactly across the two halves, i.e. with no approximate half-local answers. We are working on a per-pipeline "exact" mark and a VICTORY_BUILDER_EXACT=1 gate. Anyone who knows the builder's cross-lane ops well is welcome to jump in.

Also: the mesh shader outputs exceed Metal's limit warning (item 5) and the 10% of profile samples in mmdevapi are both phantoms. The audio threads are parked in one Unix call that the profiler's wait list does not know about, and turning audio off gave no gain.

**@⁠jgrizon** on GitHub · 2026-11-27 15:48 UTC · [original](https://github.com/paveledits/ScarlettMac/issues/17#issuecomment-7222497113) Update on item 1 (dropped draws) and item 2 (dark faces): they have the same cause. **What the dropped draws are.** We made every dropped call record its reason, in release builds too. In steady world play, 100% of drops are `dispatch: the BVH builder held back`, 72 to 169 per frame. `XboxBvhBuilder.dll` is the title's own compute builder for its ray-tracing structure (the BVH, a tree of bounding boxes), 53 compute pipelines. It is not DXR. `pipeline/builder.rs` opens it only when `!halves && all_made`. With `VICTORY_HALVES_LOCAL=1`/`VICTORY_HALVES_SHARED_LDS=1`, which the play preset sets, `halves` is always true, so the builder never runs: ``` BVH builder held back: its 64-lane programs would run as 32-lane halves on their own (VICTORY_HALVES_LOCAL, VICTORY_HALVES_SHARED_LDS) frame=1593 pipelines=53 made=53 refused=0 ``` The guard is there because approximate halves in the builder hung GPUs. **Why faces are black.** The probe resolve then traces against a structure that was never built. As `ambient.rs` says, it "leaves next to nothing, and whatever the sun does not reach directly is black". The preset's `VICTORY_AMBIENT=estimate` replaces that output, but its floor is about 0.04, so 99 to 100% of sampled points stay under it. Raising the floor (`VICTORY_AMBIENT_FLOOR=1`) still left faces black. **What fixes it today.** `VICTORY_AMBIENT=1.0`, the constant stand-in that #14's tester also liked. In the same intro scene, a character who was a black silhouette shows a lit face, cap, skin and clothing colours, with some small dotted artifacts on skin and beard. It costs nothing measurable: 431 world frames in the first 120 s in a diagnostics build, against 386 for the preset's `estimate`. Release timing runs are queued. **What did not help.** Upstream's checkpoint wave64 patches (0005 to 0015), ported onto the perf recipe with `VICTORY_WAVE64_REDUCE=1`, gave speckled hair and faces and green blobs on this M5 Pro with D3DMetal 3.0. They cost no speed (525 frames), but the picture was worse. **The real fix still to do.** Let the builder run when every one of its 53 programs translates exactly across the two halves, i.e. with no approximate half-local answers. We are working on a per-pipeline "exact" mark and a `VICTORY_BUILDER_EXACT=1` gate. Anyone who knows the builder's cross-lane ops well is welcome to jump in. Also: the `mesh shader outputs exceed Metal's limit` warning (item 5) and the 10% of profile samples in `mmdevapi` are both phantoms. The audio threads are parked in one Unix call that the profiler's wait list does not know about, and turning audio off gave no gain.
Author
Owner

@⁠jgrizon on GitHub · 2026-11-27 18:58 UTC · original

Follow-up: the dark faces are fixed in #20, and the cause of the green credits panel is narrowed down.

Dark faces and dropped draws: fixed in #20. VICTORY_BUILDER_EXACT=1 with VICTORY_WAVE64_REDUCE=1 lets the title's BVH builder run: 53 made, 0 refused. With VICTORY_AMBIENT=0 the title's own lighting is correct, and the most dropped draws in a frame fell from about 1,400 to 1 or 2. It costs about 15% of frames in release.

Green credits panel: diagnosed, fix not yet verified. VIctory has no Bink or NV12 code. bink2scarlett.dll decodes in its own x86 code into title memory, and the title converts YUV to RGB itself, sampling ordinary textures. The panel is R=B=0 with G between 15 and 43 everywhere. That is exactly Y=U=V=0 through BT.709 (G≈84), dimmed by the panel's fade. So the video planes are sampled while still all zero.

Two shortcuts in texture.rs skip the upload from title memory:

  • flags_title_written: a render target, depth or UAV texture is never uploaded, because the GPU is assumed to own it. A console decoder fills a texture it created as writable.
  • is_host_written: once the host has copied into a texture, the texture keeps the host's contents forever.

The write tracking itself is right; the upload is just never asked for. On our branch, VICTORY_VIDEO_FIX=1 makes the texture take title memory's contents whenever nothing on the host wrote it. It uploads only the subresources whose bytes changed. It is off by default, and I will report once a run confirms or rules it out.

Depth bounds. D3DMetal has no depth bounds test. On our branch, VICTORY_DEPTH_BOUNDS_CLIP=1 imitates it in the pixel shader: a discard against the bounds passed in two root constants. It compares the fragment's own depth, not the stored depth that D3D tests. In D3D12 and Metal a pixel shader cannot read the depth target bound to its own pass. Its effect on looks and speed is not measured yet.

Swizzle(27) (SW_64KB_R_X) copy-back. Every XOR swizzle mode is unaddressable today, so those textures are never written back to title memory. This may be the stale water. A port of addrlib's SW_64K_R_X RBPLUS equations is in progress. The open question is Series X's pipe and packer counts (GB_ADDR_CONFIG). If someone knows them, please post them here.

**@⁠jgrizon** on GitHub · 2026-11-27 18:58 UTC · [original](https://github.com/paveledits/ScarlettMac/issues/17#issuecomment-7226056766) Follow-up: the dark faces are fixed in #20, and the cause of the green credits panel is narrowed down. **Dark faces and dropped draws: fixed in #20.** `VICTORY_BUILDER_EXACT=1` with `VICTORY_WAVE64_REDUCE=1` lets the title's BVH builder run: `53 made, 0 refused`. With `VICTORY_AMBIENT=0` the title's own lighting is correct, and the most dropped draws in a frame fell from about 1,400 to 1 or 2. It costs about 15% of frames in release. **Green credits panel: diagnosed, fix not yet verified.** VIctory has no Bink or NV12 code. `bink2scarlett.dll` decodes in its own x86 code into title memory, and the title converts YUV to RGB itself, sampling ordinary textures. The panel is `R=B=0` with `G` between 15 and 43 everywhere. That is exactly `Y=U=V=0` through BT.709 (`G≈84`), dimmed by the panel's fade. So the video planes are sampled while still all zero. Two shortcuts in `texture.rs` skip the upload from title memory: - `flags_title_written`: a render target, depth or UAV texture is never uploaded, because the GPU is assumed to own it. A console decoder fills a texture it created as writable. - `is_host_written`: once the host has copied into a texture, the texture keeps the host's contents forever. The write tracking itself is right; the upload is just never asked for. On our branch, `VICTORY_VIDEO_FIX=1` makes the texture take title memory's contents whenever nothing on the host wrote it. It uploads only the subresources whose bytes changed. It is off by default, and I will report once a run confirms or rules it out. **Depth bounds.** D3DMetal has no depth bounds test. On our branch, `VICTORY_DEPTH_BOUNDS_CLIP=1` imitates it in the pixel shader: a `discard` against the bounds passed in two root constants. It compares the fragment's own depth, not the stored depth that D3D tests. In D3D12 and Metal a pixel shader cannot read the depth target bound to its own pass. Its effect on looks and speed is not measured yet. **`Swizzle(27)` (`SW_64KB_R_X`) copy-back.** Every XOR swizzle mode is unaddressable today, so those textures are never written back to title memory. This may be the stale water. A port of addrlib's `SW_64K_R_X` RBPLUS equations is in progress. The open question is Series X's pipe and packer counts (`GB_ADDR_CONFIG`). If someone knows them, please post them here.
Author
Owner

@⁠paveledits on GitHub · 2026-11-28 00:48 UTC · original

I tested the exact #20 renderer on a 48 GB M3 Max with D3DMetal 4.0 beta 3. All 53 BVH programs passed the gate. Two late café shots regained visible geometry and both the camera and movement worked in the prison room. Earlier dialogue still appeared over black, and the prison room was darker with exact lighting. The merged recipe exposes SCARLETTMAC_LIGHTING=exact as an option and keeps estimated lighting as the default.

A separate presentation probe reproduced black picture samples before the swap-chain copy. Some preceding FidelityFX outputs in the same native queue had color. The selected picture, copy source and back buffer were black at all four sample points for 11 consecutive Presents, then all three acquired color together. The link from the upscaler output to the intermediate draw that writes the selected picture remains open. The green credits panel, depth bounds and Swizzle(27) copy-back also remain open.

**@⁠paveledits** on GitHub · 2026-11-28 00:48 UTC · [original](https://github.com/paveledits/ScarlettMac/issues/17#issuecomment-7231207937) I tested the exact #20 renderer on a 48 GB M3 Max with D3DMetal 4.0 beta 3. All 53 BVH programs passed the gate. Two late café shots regained visible geometry and both the camera and movement worked in the prison room. Earlier dialogue still appeared over black, and the prison room was darker with exact lighting. The merged recipe exposes `SCARLETTMAC_LIGHTING=exact` as an option and keeps estimated lighting as the default. A separate presentation probe reproduced black picture samples before the swap-chain copy. Some preceding FidelityFX outputs in the same native queue had color. The selected picture, copy source and back buffer were black at all four sample points for 11 consecutive Presents, then all three acquired color together. The link from the upscaler output to the intermediate draw that writes the selected picture remains open. The green credits panel, depth bounds and Swizzle(27) copy-back also remain open.
This discussion has been locked. Commenting is limited to contributors.
No description provided.