d3d12: cap texture passes by default, 24 ms a pass and 8 ms a frame #3510

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u origin "+refs/pull/3510/head:oreofr/texture-smoothing-default"
git switch "oreofr/texture-smoothing-default"
Open
leonida/mandy
OreoFR wants to merge 1 commit from oreofr/texture-smoothing-default into main AGit

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3510/head:oreofr/texture-smoothing-default'
git switch 'oreofr/texture-smoothing-default'
Member

Item: D3D12-TEXTURE-SMOOTHING-DEFAULT (claimed in #3312).

What it changes

The launcher's play set (d3d12/scripts/play-nvidia.ps1) now sets two switches that already exist in the runtime:

  • LEONIDA_TEXTURE_STAGE_MS=24: one pass over textures stops after 24 ms. Before, it stopped after 250 ms.
  • LEONIDA_TEXTURE_FRAME_MS=8 (#3291): all of a frame's texture passes together stop after 8 ms. Before, there was no ceiling for the frame.

Whatever does not fit waits for the next frame, and its slot shows what it showed until then. These are the values Darner's launcher sets (DARNER_TEXTURE_STAGE_MS=24, DARNER_TEXSPK_PASS_MS=8). No runtime code changes. A player's own value (-More, Advanced mode, the F1 file) still wins, and LEONIDA_TEXTURE_STAGE_MS=250 with LEONIDA_TEXTURE_FRAME_MS=0 puts the old behaviour back.

Measured

RTX 4070 Laptop, Core Ultra 7 155H, 40 GB. Base was main f4b0404e9, diag build, Series S, no DLSS or frame generation, BAR 0, texture budget 1024, motion blur on. The cache was fully precompiled. Each run followed the same automatic tour: six teleports to fixed points with running between them, timed per frame with LEONIDA_FRAME_TIMES. Runs were made in the order base, on, on, base.

base 1 on 1 on 2 base 2
median frame 44.9 ms 43.6 ms 44.7 ms 45.7 ms
99th percentile 113 ms 84 ms 87 ms 113 ms
frames over 100 ms 28 10 11 30
frames over 250 ms 5 2 1 0

The frame rate is the same, with about 2.8 times fewer frames over 100 ms. The single longest frame (241 to 1649 ms) varies run to run and does not follow the setting.

Not checked

  • The picture: in a streaming burst a texture can arrive a frame or two later. I could not watch for that during the automatic runs.
  • Other cards: one machine so far. An 8 GB card (RTX 4060) and AMD would be the next ones to try.

The setting has been on in the beta since cfa4af3ae.

Tests

  • tests/test_play_texture_smoothing.py (new, 3 tests: the play set has both values, and the runtime still reads both switches).
  • test_d3d12_switches, with switches.md regenerated.
  • test_play_nvidia_menu_choice.
  • test_text_write_line_endings.
  • check_no_game_data.

No local CI was run, at OreoFR's request.

AI-assisted (Claude Code), on OreoFR's request.

🤖 Generated with Claude Code

Item: D3D12-TEXTURE-SMOOTHING-DEFAULT (claimed in #3312). ## What it changes The launcher's play set (`d3d12/scripts/play-nvidia.ps1`) now sets two switches that already exist in the runtime: - `LEONIDA_TEXTURE_STAGE_MS=24`: one pass over textures stops after 24 ms. Before, it stopped after 250 ms. - `LEONIDA_TEXTURE_FRAME_MS=8` (#3291): all of a frame's texture passes together stop after 8 ms. Before, there was no ceiling for the frame. Whatever does not fit waits for the next frame, and its slot shows what it showed until then. These are the values Darner's launcher sets (`DARNER_TEXTURE_STAGE_MS=24`, `DARNER_TEXSPK_PASS_MS=8`). No runtime code changes. A player's own value (`-More`, Advanced mode, the F1 file) still wins, and `LEONIDA_TEXTURE_STAGE_MS=250` with `LEONIDA_TEXTURE_FRAME_MS=0` puts the old behaviour back. ## Measured RTX 4070 Laptop, Core Ultra 7 155H, 40 GB. Base was main `f4b0404e9`, diag build, Series S, no DLSS or frame generation, BAR 0, texture budget 1024, motion blur on. The cache was fully precompiled. Each run followed the same automatic tour: six teleports to fixed points with running between them, timed per frame with `LEONIDA_FRAME_TIMES`. Runs were made in the order base, on, on, base. | | base 1 | on 1 | on 2 | base 2 | |---|---|---|---|---| | median frame | 44.9 ms | 43.6 ms | 44.7 ms | 45.7 ms | | 99th percentile | 113 ms | 84 ms | 87 ms | 113 ms | | frames over 100 ms | 28 | 10 | 11 | 30 | | frames over 250 ms | 5 | 2 | 1 | 0 | The frame rate is the same, with about 2.8 times fewer frames over 100 ms. The single longest frame (241 to 1649 ms) varies run to run and does not follow the setting. ## Not checked - The picture: in a streaming burst a texture can arrive a frame or two later. I could not watch for that during the automatic runs. - Other cards: one machine so far. An 8 GB card (RTX 4060) and AMD would be the next ones to try. The setting has been on in the beta since `cfa4af3ae`. ## Tests - `tests/test_play_texture_smoothing.py` (new, 3 tests: the play set has both values, and the runtime still reads both switches). - `test_d3d12_switches`, with `switches.md` regenerated. - `test_play_nvidia_menu_choice`. - `test_text_write_line_endings`. - `check_no_game_data`. No local CI was run, at OreoFR's request. AI-assisted (Claude Code), on OreoFR's request. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The play set now sets LEONIDA_TEXTURE_STAGE_MS=24 (a pass over textures
stops after 24 ms instead of 250) and LEONIDA_TEXTURE_FRAME_MS=8 (all of
a frame's texture passes together within 8 ms, #3291, off until now).
What does not fit waits for the next frame, its slot showing what it
showed until then. These are the values Darner's launcher sets.

RTX 4070 Laptop, Core Ultra 7 155H, Series S, main f4b0404e9, a fixed
tour of six teleports with running between them, per-frame times, runs
base/on/on/base: frames over 100 ms 28 and 30 against 10 and 11, 99th
percentile 113 and 113 ms against 84 and 87, median frame unchanged
(44.9/45.7 against 43.6/44.7 ms).

Tests: tests/test_play_texture_smoothing.py (new, 3), test_d3d12_switches
(switches.md regenerated), test_play_nvidia_menu_choice,
test_text_write_line_endings, no game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

Independent local check of this change (I changed no code).

  • Head 7373f449, merge base f4b0404e. The three new cases are absent on the base: git grep -F test_the_play_set_caps_a_pass_at_24_ms f4b0404e -- tests -> exit 1.
  • On the PR head: python -I -m unittest discover -s tests -p test_play_texture_smoothing.py -> Ran 3 tests, OK, 0.003 s. (python -m unittest tests.test_play_texture_smoothing fails with No module named 'tests' because tests/ has no __init__.py; discovery is the working form.)
  • git diff --check f4b0404e 7373f449 -> clean. python -I scripts/check_no_game_data.py on tests/test_play_texture_smoothing.py, d3d12/scripts/play-nvidia.ps1 and d3d12/docs/switches.md -> clean.

What the tests actually cover, so nobody reads more into them: all three read file text. Two assert LEONIDA_TEXTURE_STAGE_MS = '24' and LEONIDA_TEXTURE_FRAME_MS = '8' inside the script's $settings block; the third asserts that draw.rs still mentions both switch names and keeps the ms > 0 ... min(1000) filter. This PR touches no runtime code, so these are regression guards for the play script, not a check of the cap's behaviour, which stays with #3291 in draw.rs.

GPUs tested: none (static text checks, no game run and no card). Driver: n/a. No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied.

Independent local check of this change (I changed no code). - Head `7373f449`, merge base `f4b0404e`. The three new cases are absent on the base: `git grep -F test_the_play_set_caps_a_pass_at_24_ms f4b0404e -- tests` -> exit 1. - On the PR head: `python -I -m unittest discover -s tests -p test_play_texture_smoothing.py` -> Ran 3 tests, OK, 0.003 s. (`python -m unittest tests.test_play_texture_smoothing` fails with `No module named 'tests'` because `tests/` has no `__init__.py`; discovery is the working form.) - `git diff --check f4b0404e 7373f449` -> clean. `python -I scripts/check_no_game_data.py` on tests/test_play_texture_smoothing.py, d3d12/scripts/play-nvidia.ps1 and d3d12/docs/switches.md -> clean. What the tests actually cover, so nobody reads more into them: all three read file text. Two assert `LEONIDA_TEXTURE_STAGE_MS = '24'` and `LEONIDA_TEXTURE_FRAME_MS = '8'` inside the script's `$settings` block; the third asserts that `draw.rs` still mentions both switch names and keeps the `ms > 0 ... min(1000)` filter. This PR touches no runtime code, so these are regression guards for the play script, not a check of the cap's behaviour, which stays with #3291 in `draw.rs`. GPUs tested: none (static text checks, no game run and no card). Driver: n/a. No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied.
First-time contributor

A data point from the 8 GB card you asked for: RTX 3070 8 GB, Ryzen 7 5700X, 16 GB RAM, driver 621.47, Windows 11. Your two values on main f4b0404e9 (#3510 changes no runtime code, only the play script's settings, so I gave the same executable LEONIDA_TEXTURE_STAGE_MS=24 and LEONIDA_TEXTURE_FRAME_MS=8 in -More). Each run was the game gate, 600 s in the world from one save that opens on a story cutscene and ends in a steady indoor scene, standing, -SeriesS -Dlss quality -NoFrameGen, in the order base, on, on, base.

Summary: on this card your values cut the long frames where the world streams, and leave the steady scene as it was. Below, "cuts" is 300-460 s from the start of the log, where the cutscene changes scene several times and the texture queue fills (peaks of 4.9-5.4 thousand slots due in the base runs). "Steady" is 480-660 s.

base 1 on 1 on 2 base 2
Cuts: frame p90 98.6 ms 88.9 ms 78.7 ms 95.4 ms
Cuts: frame p99 299 ms 351 ms 231 ms 253 ms
Cuts: mean frame 67.3 ms 64.9 ms 56.7 ms 63.0 ms
Cuts: frames in the 160 s 2,379 2,465 2,824 2,540
Cuts: the submitting thread's wait for the list ahead of the frame (its own line, mean) 21.3 ms 10.3 ms 7.0 ms 19.3 ms
Steady: median frame / p90 42.1 / 47.8 ms 42.0 / 46.0 ms 40.3 / 43.6 ms 40.4 / 43.9 ms
Steady: that wait 2.1 ms 2.0 ms 1.9 ms 2.0 ms
Most texture slots due at once (cuts) 4,867 10,181 7,681 5,377

Why it works here: this PC is held by the submitting thread, not the card, and in the scene changes that thread waits for the list recorded ahead of each frame. The textures half of that list is the long one there (host textures made and uploaded for the slots picked by index), so a cap on the texture pass shortens what the frame waits for. In the steady scene the buffers half is the longer one, and the cap changes nothing, as the table shows.

The picture: I compared the gate's six screenshots per run at the same times (10 to 570 s after control). The three runs that reached the steady scene show the same scenes with no grey or missing textures between the arms. The cost shows in the counts instead: 1.4 to 2.1 times as many slots due at the peak, and the slots shown after their upload waited 0.16 frames on average instead of 0.11-0.13 (the longest 2 frames in all but one base run). "base 1" ended on the flat screen of #3434 from 360 s after control on (so its steady column was measured on that screen). That is a separate issue I have seen in 4 of 35 runs on this save, all in arms without these settings (none of the 4 runs with a texture-pass cap showed it). Its numbers through the cuts are in line with "base 2".

For comparison, a harder cap I had tried earlier the same night on the same save (LEONIDA_TEXTURE_STAGE_MS=8 with LEONIDA_TEXTURE_CATCHUP=0, two pairs, the second in reverse order): the same wait in the cuts went from 20.7/19.1 to 6.7/7.8 ms, the frame p90 there from 96.8/96.6 to 80.2/78.1 ms, and the slots due at the peak rose to 11-12 thousand, with the steady scene again unchanged. So your values get most of that here with a smaller backlog.

One thing I read in the code while measuring (draw.rs, near the budget for a backlog): with a backlog of due slots (LAST_ON_TIME of 1024 or more) both ceilings are tripled, so in these scene changes the frame's passes may take about 24 ms together instead of 8 (the pass's own span becomes 72 ms, so the frame ceiling is the one that binds). The frame ceiling also counts the title's frame number, not the frame the list ahead is recorded for. Neither stopped the cap from helping here. The log's "passes cut by LEONIDA_TEXTURE_FRAME_MS" also only counts passes skipped whole, not passes cut short by the time, so it stays small: 29 and 26 over the whole run with your values (0 in the base runs, where the cap is off).

GPUs tested: NVIDIA GeForce RTX 3070 8 GB, driver 621.47, Windows 11. No game data, logs or screenshots attached.

AI-assisted: Claude Code (Claude Opus 5.5); figures checked from the run records by a separate read-only Claude Opus 5.5 agent before posting.

A data point from the 8 GB card you asked for: RTX 3070 8 GB, Ryzen 7 5700X, 16 GB RAM, driver 621.47, Windows 11. Your two values on `main` `f4b0404e9` (#3510 changes no runtime code, only the play script's settings, so I gave the same executable `LEONIDA_TEXTURE_STAGE_MS=24` and `LEONIDA_TEXTURE_FRAME_MS=8` in `-More`). Each run was the game gate, 600 s in the world from one save that opens on a story cutscene and ends in a steady indoor scene, standing, `-SeriesS -Dlss quality -NoFrameGen`, in the order base, on, on, base. **Summary: on this card your values cut the long frames where the world streams, and leave the steady scene as it was.** Below, "cuts" is 300-460 s from the start of the log, where the cutscene changes scene several times and the texture queue fills (peaks of 4.9-5.4 thousand slots due in the base runs). "Steady" is 480-660 s. | | base 1 | on 1 | on 2 | base 2 | |---|---|---|---|---| | Cuts: frame p90 | 98.6 ms | 88.9 ms | 78.7 ms | 95.4 ms | | Cuts: frame p99 | 299 ms | 351 ms | 231 ms | 253 ms | | Cuts: mean frame | 67.3 ms | 64.9 ms | 56.7 ms | 63.0 ms | | Cuts: frames in the 160 s | 2,379 | 2,465 | 2,824 | 2,540 | | Cuts: the submitting thread's wait for the list ahead of the frame (its own line, mean) | 21.3 ms | 10.3 ms | 7.0 ms | 19.3 ms | | Steady: median frame / p90 | 42.1 / 47.8 ms | 42.0 / 46.0 ms | 40.3 / 43.6 ms | 40.4 / 43.9 ms | | Steady: that wait | 2.1 ms | 2.0 ms | 1.9 ms | 2.0 ms | | Most texture slots due at once (cuts) | 4,867 | 10,181 | 7,681 | 5,377 | Why it works here: this PC is held by the submitting thread, not the card, and in the scene changes that thread waits for the list recorded ahead of each frame. The textures half of that list is the long one there (host textures made and uploaded for the slots picked by index), so a cap on the texture pass shortens what the frame waits for. In the steady scene the buffers half is the longer one, and the cap changes nothing, as the table shows. The picture: I compared the gate's six screenshots per run at the same times (10 to 570 s after control). The three runs that reached the steady scene show the same scenes with no grey or missing textures between the arms. The cost shows in the counts instead: 1.4 to 2.1 times as many slots due at the peak, and the slots shown after their upload waited 0.16 frames on average instead of 0.11-0.13 (the longest 2 frames in all but one base run). "base 1" ended on the flat screen of #3434 from 360 s after control on (so its steady column was measured on that screen). That is a separate issue I have seen in 4 of 35 runs on this save, all in arms without these settings (none of the 4 runs with a texture-pass cap showed it). Its numbers through the cuts are in line with "base 2". For comparison, a harder cap I had tried earlier the same night on the same save (`LEONIDA_TEXTURE_STAGE_MS=8` with `LEONIDA_TEXTURE_CATCHUP=0`, two pairs, the second in reverse order): the same wait in the cuts went from 20.7/19.1 to 6.7/7.8 ms, the frame p90 there from 96.8/96.6 to 80.2/78.1 ms, and the slots due at the peak rose to 11-12 thousand, with the steady scene again unchanged. So your values get most of that here with a smaller backlog. One thing I read in the code while measuring (`draw.rs`, near the budget for a backlog): with a backlog of due slots (`LAST_ON_TIME` of 1024 or more) both ceilings are tripled, so in these scene changes the frame's passes may take about 24 ms together instead of 8 (the pass's own span becomes 72 ms, so the frame ceiling is the one that binds). The frame ceiling also counts the title's frame number, not the frame the list ahead is recorded for. Neither stopped the cap from helping here. The log's "passes cut by LEONIDA_TEXTURE_FRAME_MS" also only counts passes skipped whole, not passes cut short by the time, so it stays small: 29 and 26 over the whole run with your values (0 in the base runs, where the cap is off). GPUs tested: NVIDIA GeForce RTX 3070 8 GB, driver 621.47, Windows 11. No game data, logs or screenshots attached. AI-assisted: Claude Code (Claude Opus 5.5); figures checked from the run records by a separate read-only Claude Opus 5.5 agent before posting.
Sign in to join this conversation.
No description provided.