Render enable also skips compute dispatches, but on the console it only gates 3D work #1514

Open
opened 2026-11-18 01:46:13 +00:00 by mooki · 1 comment
Member

Type: correctness · Area: replay, conditional rendering and compute · Part of: #1493

TL;DR

In the replay, a compute dispatch is skipped whenever render enable is off, either after nvnCommandBufferSetRenderEnable(false) or when a conditional render comes out false. On the console, render enable gates 3D work only (draws and clears), so a dispatch inside a render-disabled region should still run, and skipping it can leave data stale that a later draw reads. We propose to take the render-enable test off both dispatch ops and off the dry pass's compute marking, and to count how often the skip happens.

Breakdown

  • Who it affects: any scene where a region is render-disabled and a compute dispatch is recorded inside it. How often that happens has not been counted in a run yet.
  • What is wrong: s.render_enabled guards NOP_DISPATCH and NOP_DISPATCH_INDIRECT, and the dry pass does not mark a skipped dispatch's outputs as written.
  • What the console does: the render-enable state is read by 3D-class work only. Compute and copy work have their own separate enables, which the port has no handler for (they are not in its NVN header). Whether the game calls those is not known from the study.
  • What we propose: compute is never gated by render enable. Draws and clears stay gated as they are today.
  • What does not change: how the enable is set (SetRenderEnable, SetRenderEnableConditional), clears, all draw forms, and copies.
  • How we would prove it: a game-free test that fails today, a counter that says how many dispatches the old rule skipped in a run, and a paired image compare on any scene where that counter is not zero.

Evidence

Port code is on forge/main at 310e7c9df. Nothing here was run in a game.

What the port does today

  • gpu/vk/vk_replay.cpp:1851-1853 sets render_enabled from the SetRenderEnable op. :1855-1878 sets it from a conditional render (equal or different counters at the address and address + 16). The default is on (gpu/vk/vk_state.h:43).
  • Clears are gated by it: :1917-1918 and :1924-1925. All draw forms are gated: :1934, :1946, :1959, :1976. That matches the console.
  • Dispatches are gated too: :1990 is if (s.render_enabled && !dry) dispatch(cmd, s, x, y, z, 0) and :1995 is the same for the indirect form. That does not match.
  • The dry pass (:2002-2003) marks a work op's outputs as written only if (s.render_enabled && (compute || !s.raster_discard)). A skipped dispatch therefore leaves its outputs unmarked as well.
  • There is no handler for a separate compute enable (git grep ComputeEnable finds nothing in host/ or gpu/vk/).

What the console does (behaviour only)

  • Render enable is a 3D-class state. Draws and clears obey it. A compute dispatch recorded while render enable is off still runs.

This comes from a private study of the console driver (read, then confirmed by running the driver's functions alone in an emulator); no code, addresses or game data from it are here.

Can it change pixels? Yes, when it fires. If a dispatch that fills a buffer or an image for a later draw is recorded inside a render-disabled region, the port skips it and the later draw samples stale or empty data. We would see it as a picture that differs from the console's behaviour only in such scenes, and in the replay dump as a RENDER_COND ... off or RENDER_ENABLE 0 line followed by dispatch ops. If no scene has a dispatch inside a disabled region, nothing changes there. That count is what the proposed counter measures.

Proposed change

  1. gpu/vk/vk_replay.cpp:1990 and :1995: drop s.render_enabled && from both dispatch forms.
  2. :2003: mark compute work as written whatever render enable says. Keep the existing rule for 3D work: compute || (s.render_enabled && !s.raster_discard).
  3. Add a counter of dispatches that the old rule would have skipped, logged with the other per-5-second replay lines. It goes in with the change, so the first run after it already shows the size of the effect.
  4. Do not add a compute-enable handler in this change. That is a separate question (does the game call it).

How we would test it

  • Game-free, fails today (a new tests/test_render_enable_compute.py, built like tests/test_early_split_before_draw.py: cut the real case NOP_DISPATCH, case NOP_DISPATCH_INDIRECT and the work-op marking from vk_replay.cpp with tests/srccut.py, compile with stubs that count dispatch and dry_mark_written):
    1. render enable off, one direct dispatch: 1 dispatch call (today 0);
    2. render enable off, one indirect dispatch: 1 call (today 0);
    3. dry pass, render enable off, one dispatch: compute outputs marked (today not);
    4. render enable off, one draw and one clear: 0 draws, 0 clears (must stay, today passes);
    5. render enable on: everything runs as today.
  • Game run: a run on the same save and spot as the other host checks, with the new counter on. If it stays at 0 in every scene we try, the change is a no-op for the game and we say so. If it is above 0, the same run is compared before and after.
  • Pictures: image hash, same save, same spot, before and after, for each scene where the counter is above 0. Any change must be shown to come from a dispatch that the old rule skipped.
  • Speed: dispatches that were skipped now run, so this adds GPU work where it fires. No speed claim; if one is made later it needs paired timing after a null main-against-main pair.

#1493 (renderer rewrite; this is one of the places where the host answers differently from the console). No thread covers render enable gating compute. Searched open and closed issues and pull requests for render enable, render-enable, SetRenderEnable, conditional rendering, conditional render, compute enable and "dispatch skipped". The only nearby note is in #122 (open, about samples-passed reports): one dumped Kokiri Forest frame had no conditional rendering at all, so how often a render-disabled region exists varies by scene, which is why the counter comes first.

New on this forge; not opened on GitHub.

**Type:** correctness · **Area:** replay, conditional rendering and compute · **Part of:** #1493 ## TL;DR In the replay, a compute dispatch is skipped whenever render enable is off, either after `nvnCommandBufferSetRenderEnable(false)` or when a conditional render comes out false. On the console, render enable gates 3D work only (draws and clears), so a dispatch inside a render-disabled region should still run, and skipping it can leave data stale that a later draw reads. We propose to take the render-enable test off both dispatch ops and off the dry pass's compute marking, and to count how often the skip happens. ## Breakdown - **Who it affects:** any scene where a region is render-disabled and a compute dispatch is recorded inside it. How often that happens has not been counted in a run yet. - **What is wrong:** `s.render_enabled` guards `NOP_DISPATCH` and `NOP_DISPATCH_INDIRECT`, and the dry pass does not mark a skipped dispatch's outputs as written. - **What the console does:** the render-enable state is read by 3D-class work only. Compute and copy work have their own separate enables, which the port has no handler for (they are not in its NVN header). Whether the game calls those is not known from the study. - **What we propose:** compute is never gated by render enable. Draws and clears stay gated as they are today. - **What does not change:** how the enable is set (`SetRenderEnable`, `SetRenderEnableConditional`), clears, all draw forms, and copies. - **How we would prove it:** a game-free test that fails today, a counter that says how many dispatches the old rule skipped in a run, and a paired image compare on any scene where that counter is not zero. ## Evidence Port code is on forge/main at 310e7c9df. Nothing here was run in a game. **What the port does today** - `gpu/vk/vk_replay.cpp:1851-1853` sets `render_enabled` from the SetRenderEnable op. `:1855-1878` sets it from a conditional render (equal or different counters at the address and address + 16). The default is on (`gpu/vk/vk_state.h:43`). - Clears are gated by it: `:1917-1918` and `:1924-1925`. All draw forms are gated: `:1934`, `:1946`, `:1959`, `:1976`. That matches the console. - Dispatches are gated too: `:1990` is `if (s.render_enabled && !dry) dispatch(cmd, s, x, y, z, 0)` and `:1995` is the same for the indirect form. That does not match. - The dry pass (`:2002-2003`) marks a work op's outputs as written only `if (s.render_enabled && (compute || !s.raster_discard))`. A skipped dispatch therefore leaves its outputs unmarked as well. - There is no handler for a separate compute enable (`git grep ComputeEnable` finds nothing in `host/` or `gpu/vk/`). **What the console does** (behaviour only) - Render enable is a 3D-class state. Draws and clears obey it. A compute dispatch recorded while render enable is off still runs. This comes from a private study of the console driver (read, then confirmed by running the driver's functions alone in an emulator); no code, addresses or game data from it are here. **Can it change pixels?** Yes, when it fires. If a dispatch that fills a buffer or an image for a later draw is recorded inside a render-disabled region, the port skips it and the later draw samples stale or empty data. We would see it as a picture that differs from the console's behaviour only in such scenes, and in the replay dump as a `RENDER_COND ... off` or `RENDER_ENABLE 0` line followed by dispatch ops. If no scene has a dispatch inside a disabled region, nothing changes there. That count is what the proposed counter measures. ## Proposed change 1. `gpu/vk/vk_replay.cpp:1990` and `:1995`: drop `s.render_enabled &&` from both dispatch forms. 2. `:2003`: mark compute work as written whatever render enable says. Keep the existing rule for 3D work: `compute || (s.render_enabled && !s.raster_discard)`. 3. Add a counter of dispatches that the old rule would have skipped, logged with the other per-5-second replay lines. It goes in with the change, so the first run after it already shows the size of the effect. 4. Do not add a compute-enable handler in this change. That is a separate question (does the game call it). ## How we would test it - **Game-free, fails today** (a new `tests/test_render_enable_compute.py`, built like `tests/test_early_split_before_draw.py`: cut the real `case NOP_DISPATCH`, `case NOP_DISPATCH_INDIRECT` and the work-op marking from `vk_replay.cpp` with `tests/srccut.py`, compile with stubs that count `dispatch` and `dry_mark_written`): 1. render enable off, one direct dispatch: 1 `dispatch` call (today 0); 2. render enable off, one indirect dispatch: 1 call (today 0); 3. dry pass, render enable off, one dispatch: compute outputs marked (today not); 4. render enable off, one draw and one clear: 0 draws, 0 clears (must stay, today passes); 5. render enable on: everything runs as today. - **Game run:** a run on the same save and spot as the other host checks, with the new counter on. If it stays at 0 in every scene we try, the change is a no-op for the game and we say so. If it is above 0, the same run is compared before and after. - **Pictures:** image hash, same save, same spot, before and after, for each scene where the counter is above 0. Any change must be shown to come from a dispatch that the old rule skipped. - **Speed:** dispatches that were skipped now run, so this adds GPU work where it fires. No speed claim; if one is made later it needs paired timing after a null main-against-main pair. ## Related #1493 (renderer rewrite; this is one of the places where the host answers differently from the console). No thread covers render enable gating compute. Searched open and closed issues and pull requests for render enable, render-enable, SetRenderEnable, conditional rendering, conditional render, compute enable and "dispatch skipped". The only nearby note is in #122 (open, about samples-passed reports): one dumped Kokiri Forest frame had no conditional rendering at all, so how often a render-disabled region exists varies by scene, which is why the counter comes first. New on this forge; not opened on GitHub.
Collaborator

Possibly related, for context:

  • issue #1493 Renderer rewrite — Broader renderer rewrite; this issue is a specific replay behavior within its scope
Possibly related, for context: - issue #1493 Renderer rewrite — Broader renderer rewrite; this issue is a specific replay behavior within its scope
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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
MagicBeanDev/Longshot#1514
No description provided.