startup: upload ring refuses every reservation after 256 MiB in total since #2823 #2829

Closed
opened 2026-11-26 12:47:27 +00:00 by Not-Saii · 1 comment
Not-Saii commented 2026-11-26 12:47:27 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T12:47:27Z.


### Commit or build

7256cecf (dev and release presets). Last good build for the startup run: 25eb746e.

Reproduction

Source-built: a new mode of the existing gate fixture, gate-ring-reuse (diff below). It runs the gate-ring sequence (18 x 16 MiB by-address texture uploads from the shared ring while the queue waits on a gate fence), opens the gate, waits until every submit has completed, then draws one more payload (18) over the right half from the ring.

ctest --preset dev --no-tests=error -R '^startup_address_console_gate' -V

Control: the same tests with src/startup_stubs/d3d12_xs_device.cpp restored to 7256cecf^.

Test change (tests only, applies to 7256cecf)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8396c98..d6801992 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4820,7 +4820,8 @@ if(EXISTS "${INTAKE_PYTHON}")
         set_tests_properties(startup_address_console_${backend} PROPERTIES TIMEOUT 180 SKIP_RETURN_CODE 77)
         # Uploads of by-address textures recorded while the queue waits on a fence keep their bytes until the
         # queue has run them. The ring control fills them from the shared upload ring and must lose the first.
-        foreach(gate IN ITEMS gate gate-ring)
+        # gate-ring-reuse: once those submits have completed, the ring must accept new uploads again.
+        foreach(gate IN ITEMS gate gate-ring gate-ring-reuse)
             string(REPLACE "-" "_" gate_name "${gate}")
             add_test(NAME startup_address_console_${gate_name}_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}"
                 "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_address_console_check.py"
diff --git a/tests/startup_address_console_check.py b/tests/startup_address_console_check.py
index d36db044..2c0aedb7 100644
--- a/tests/startup_address_console_check.py
+++ b/tests/startup_address_console_check.py
@@ -8,6 +8,8 @@
   <consumer> <backend> gate-ring     the same draws with X2W_TEST_ADDRESS_UPLOAD_RING=1: the 256 MiB ring
                                      refuses the uploads past its cap, the refused draws read the null view
                                      and the left half keeps payload 0
+  <consumer> <backend> gate-ring-reuse  gate-ring, then once every submit has completed one more payload from
+                                     the ring, which must not be refused
 
 The backing bytes are built here, independently of src/startup_stubs/gfx10_layout.h, from the address
 equations of AMD addrlib's GFX10 pattern tables, written out below. Reference: addrlib as Mesa carries it
@@ -217,6 +219,43 @@ def gate_colour(payload):
     return bytes(((17 * payload + 3) & 255, (255 - 9 * payload) & 255, payload ^ 0x5a, 255))
 
 
+def check_gate_ring_reuse(directory, consumer, backend):
+    """After the gate-ring sequence has completed, one more payload must find ring capacity again.
+
+    The fixture runs the gate-ring draws, waits until every submit has completed, then draws payload 18 over
+    the right half from the ring. Nothing is in flight any more, so the reservation must succeed: the left half
+    holds payload 0 and the right half payload 18, not the null view.
+    """
+    hlsl = ("Texture2D<float4> t : register(t0);\n"
+            "float4 main(float4 p : SV_Position) : SV_Target {\n"
+            "  return t.Load(int3(uint(p.x) % 2048, uint(p.y) % 2048, 0));\n}\n")
+    trap_log = directory / "trap.log"
+    modes = {"X2W_TEST_CONSOLE_GATE": "1", "X2W_TRAP_LOG": str(trap_log),
+             "X2W_TEST_ADDRESS_UPLOAD_RING": "1", "X2W_TEST_ADDRESS_UPLOAD_RING_REUSE": "1"}
+    actual = draw_texture(directory, consumer, backend, hlsl, modes)
+    if actual is None:
+        return 77
+    if len(actual) != TARGET_W * TARGET_H * 4:
+        raise AssertionError(f"gate-ring-reuse: readback length {len(actual)}")
+    first, last = gate_colour(0), gate_colour(GATE_PAYLOADS)
+    wrong = {"left": 0, "right": 0}
+    seen = set()
+    for y in range(TARGET_H):
+        for x in range(TARGET_W):
+            pixel = actual[4 * (y * TARGET_W + x):4 * (y * TARGET_W + x) + 4]
+            side = "left" if x < TARGET_W // 2 else "right"
+            if pixel != (first if side == "left" else last):
+                wrong[side] += 1
+                seen.add(pixel.hex())
+    if wrong["left"] or wrong["right"]:
+        raise AssertionError(f"gate-ring-reuse: {wrong} wrong pixels, found {sorted(seen)[:4]}; expected "
+                             f"{first.hex()} left, {last.hex()} right (payload {GATE_PAYLOADS} after completion)")
+    half = TARGET_W * TARGET_H // 2
+    print(f"{backend} gate-ring-reuse: after all submits completed, payload {GATE_PAYLOADS} was uploaded from the ring; "
+          f"{half} left pixels hold payload 0 and {half} right pixels payload {GATE_PAYLOADS}")
+    return 0
+
+
 def check_gate(directory, consumer, backend, ring):
     """Uploads recorded while the queue cannot run must still hold their bytes when it does.
 
@@ -282,9 +321,12 @@ def check_gate(directory, consumer, backend, ring):
 
 
 if __name__ == "__main__":
-    if len(sys.argv) not in (3, 4) or (len(sys.argv) == 4 and sys.argv[3] not in ("gate", "gate-ring")):
-        usage = "usage: startup_address_console_check.py <consumer> <backend> [gate | gate-ring]\n"
+    if len(sys.argv) not in (3, 4) or (len(sys.argv) == 4 and sys.argv[3] not in ("gate", "gate-ring", "gate-ring-reuse")):
+        usage = "usage: startup_address_console_check.py <consumer> <backend> [gate | gate-ring | gate-ring-reuse]\n"
         sys.exit(usage + "\n\n".join(__doc__.split("\n\n")[:2]))
+    if len(sys.argv) == 4 and sys.argv[3] == "gate-ring-reuse":
+        with tempfile.TemporaryDirectory() as temporary:
+            sys.exit(check_gate_ring_reuse(Path(temporary), sys.argv[1], sys.argv[2]))
     if len(sys.argv) == 4:
         with tempfile.TemporaryDirectory() as temporary:
             sys.exit(check_gate(Path(temporary), sys.argv[1], sys.argv[2], sys.argv[3] == "gate-ring"))
diff --git a/tests/startup_stream_draw.cpp b/tests/startup_stream_draw.cpp
index 7b328c1c..d387c0dc 100644
--- a/tests/startup_stream_draw.cpp
+++ b/tests/startup_stream_draw.cpp
@@ -480,6 +480,15 @@ int check_stream_draw(IDXGIAdapter* adapter, void* guest, void* pso, const char*
         invoke(list, 9);
         invoke(queue, 10, 1, arg(&list));
         if (FAILED(static_cast<HRESULT>(invoke(queue, 14, arg(fence), payloads + 1))) || !reached(payloads + 1)) return 25;
+        // X2W_TEST_ADDRESS_UPLOAD_RING_REUSE: every earlier upload has now completed, so one more payload over
+        // the right half must find ring capacity again (refs #2823).
+        if (GetEnvironmentVariableW(L"X2W_TEST_ADDRESS_UPLOAD_RING_REUSE", nullptr, 0)) {
+            if (!next_recording()) return 35;
+            if (const int result = draw_gated_console_payload(guest, list, payloads, false)) return result;
+            invoke(list, 9);
+            invoke(queue, 10, 1, arg(&list));
+            if (FAILED(static_cast<HRESULT>(invoke(queue, 14, arg(fence), payloads + 2))) || !reached(payloads + 2)) return 25;
+        }
         return read_stream_target(desktop.Get(), frame, pixels);
     } else if (bc) {
         extern int draw_bc_address_srvs(void*, void*);

Expected behavior

Once every earlier submit has completed, a new ring reservation succeeds: the left half holds payload 0 (03ff5aff) and the right half payload 18 (355d48ff). Storage still in flight is never reused.

Observed behavior

stand-in gate gate-ring gate-ring-reuse left (in flight) gate-ring-reuse right (after completion)
7256cecf pass pass payload 0, correct 00000000 null view: 32,768 wrong pixels
7256cecf^ stand-in pass fail 136f4aff (payload 16): 32,768 wrong pixels payload 18, correct

Same result on WARP and hardware. On 7256cecf, once 256 MiB has been reserved in total, reserve_upload_ring refuses every new reservation for the rest of the process, even after the GPU has finished with all of it. The first diagnostic is x2w-draw upload ring reservation refused: no unused capacity. The old wraparound code reused space without checking completion, which is what #2823 fixed; the new test fails on that code too, so it rejects both behaviors.

Effect on a local startup run (release build, run.ps1 -Render -Translate -FakeUser -GpuMirror, 180 s, no input script), final x2w-render totals:

build textures uploaded null bindings translated draws not drawn ring refusals
7256cecf 38 (114 MiB) 23,949 6,757 8+ (log capped)
7256cecf with #2823 reverted 1,364 (5.3 GiB) 0 1 0

The first refusal is logged before the first non-zero null-binding count; the presented picture stays black.

Proposed fix: record a fence value with each reservation (or per chunk) and reset a chunk's used once that fence has completed, keeping #2823's rule that storage is never reused before completion. gate-ring-reuse should then pass on both halves while gate and gate-ring keep passing.

Environment

Windows 11 build 26300.9974, VS 2022 (MSVC 19.44.35230), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4090 driver 610.88 (32.0.16.1088); WARP and hardware backends; D3D12 debug layer not enabled.

Checklist

  • I reproduced this on a source-built input.
  • I did not include game files, dumps, distribution links or credentials.

Refs #2823

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6626966415 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2837). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T12:47:27Z. --- ### Commit or build `7256cecf` (dev and release presets). Last good build for the startup run: `25eb746e`. ### Reproduction Source-built: a new mode of the existing gate fixture, `gate-ring-reuse` (diff below). It runs the `gate-ring` sequence (18 x 16 MiB by-address texture uploads from the shared ring while the queue waits on a gate fence), opens the gate, waits until every submit has completed, then draws one more payload (18) over the right half from the ring. ```powershell ctest --preset dev --no-tests=error -R '^startup_address_console_gate' -V ``` Control: the same tests with `src/startup_stubs/d3d12_xs_device.cpp` restored to `7256cecf^`. <details><summary>Test change (tests only, applies to 7256cecf)</summary> ```diff diff --git a/CMakeLists.txt b/CMakeLists.txt index c8396c98..d6801992 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4820,7 +4820,8 @@ if(EXISTS "${INTAKE_PYTHON}") set_tests_properties(startup_address_console_${backend} PROPERTIES TIMEOUT 180 SKIP_RETURN_CODE 77) # Uploads of by-address textures recorded while the queue waits on a fence keep their bytes until the # queue has run them. The ring control fills them from the shared upload ring and must lose the first. - foreach(gate IN ITEMS gate gate-ring) + # gate-ring-reuse: once those submits have completed, the ring must accept new uploads again. + foreach(gate IN ITEMS gate gate-ring gate-ring-reuse) string(REPLACE "-" "_" gate_name "${gate}") add_test(NAME startup_address_console_${gate_name}_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}" "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_address_console_check.py" diff --git a/tests/startup_address_console_check.py b/tests/startup_address_console_check.py index d36db044..2c0aedb7 100644 --- a/tests/startup_address_console_check.py +++ b/tests/startup_address_console_check.py @@ -8,6 +8,8 @@ <consumer> <backend> gate-ring the same draws with X2W_TEST_ADDRESS_UPLOAD_RING=1: the 256 MiB ring refuses the uploads past its cap, the refused draws read the null view and the left half keeps payload 0 + <consumer> <backend> gate-ring-reuse gate-ring, then once every submit has completed one more payload from + the ring, which must not be refused The backing bytes are built here, independently of src/startup_stubs/gfx10_layout.h, from the address equations of AMD addrlib's GFX10 pattern tables, written out below. Reference: addrlib as Mesa carries it @@ -217,6 +219,43 @@ def gate_colour(payload): return bytes(((17 * payload + 3) & 255, (255 - 9 * payload) & 255, payload ^ 0x5a, 255)) +def check_gate_ring_reuse(directory, consumer, backend): + """After the gate-ring sequence has completed, one more payload must find ring capacity again. + + The fixture runs the gate-ring draws, waits until every submit has completed, then draws payload 18 over + the right half from the ring. Nothing is in flight any more, so the reservation must succeed: the left half + holds payload 0 and the right half payload 18, not the null view. + """ + hlsl = ("Texture2D<float4> t : register(t0);\n" + "float4 main(float4 p : SV_Position) : SV_Target {\n" + " return t.Load(int3(uint(p.x) % 2048, uint(p.y) % 2048, 0));\n}\n") + trap_log = directory / "trap.log" + modes = {"X2W_TEST_CONSOLE_GATE": "1", "X2W_TRAP_LOG": str(trap_log), + "X2W_TEST_ADDRESS_UPLOAD_RING": "1", "X2W_TEST_ADDRESS_UPLOAD_RING_REUSE": "1"} + actual = draw_texture(directory, consumer, backend, hlsl, modes) + if actual is None: + return 77 + if len(actual) != TARGET_W * TARGET_H * 4: + raise AssertionError(f"gate-ring-reuse: readback length {len(actual)}") + first, last = gate_colour(0), gate_colour(GATE_PAYLOADS) + wrong = {"left": 0, "right": 0} + seen = set() + for y in range(TARGET_H): + for x in range(TARGET_W): + pixel = actual[4 * (y * TARGET_W + x):4 * (y * TARGET_W + x) + 4] + side = "left" if x < TARGET_W // 2 else "right" + if pixel != (first if side == "left" else last): + wrong[side] += 1 + seen.add(pixel.hex()) + if wrong["left"] or wrong["right"]: + raise AssertionError(f"gate-ring-reuse: {wrong} wrong pixels, found {sorted(seen)[:4]}; expected " + f"{first.hex()} left, {last.hex()} right (payload {GATE_PAYLOADS} after completion)") + half = TARGET_W * TARGET_H // 2 + print(f"{backend} gate-ring-reuse: after all submits completed, payload {GATE_PAYLOADS} was uploaded from the ring; " + f"{half} left pixels hold payload 0 and {half} right pixels payload {GATE_PAYLOADS}") + return 0 + + def check_gate(directory, consumer, backend, ring): """Uploads recorded while the queue cannot run must still hold their bytes when it does. @@ -282,9 +321,12 @@ def check_gate(directory, consumer, backend, ring): if __name__ == "__main__": - if len(sys.argv) not in (3, 4) or (len(sys.argv) == 4 and sys.argv[3] not in ("gate", "gate-ring")): - usage = "usage: startup_address_console_check.py <consumer> <backend> [gate | gate-ring]\n" + if len(sys.argv) not in (3, 4) or (len(sys.argv) == 4 and sys.argv[3] not in ("gate", "gate-ring", "gate-ring-reuse")): + usage = "usage: startup_address_console_check.py <consumer> <backend> [gate | gate-ring | gate-ring-reuse]\n" sys.exit(usage + "\n\n".join(__doc__.split("\n\n")[:2])) + if len(sys.argv) == 4 and sys.argv[3] == "gate-ring-reuse": + with tempfile.TemporaryDirectory() as temporary: + sys.exit(check_gate_ring_reuse(Path(temporary), sys.argv[1], sys.argv[2])) if len(sys.argv) == 4: with tempfile.TemporaryDirectory() as temporary: sys.exit(check_gate(Path(temporary), sys.argv[1], sys.argv[2], sys.argv[3] == "gate-ring")) diff --git a/tests/startup_stream_draw.cpp b/tests/startup_stream_draw.cpp index 7b328c1c..d387c0dc 100644 --- a/tests/startup_stream_draw.cpp +++ b/tests/startup_stream_draw.cpp @@ -480,6 +480,15 @@ int check_stream_draw(IDXGIAdapter* adapter, void* guest, void* pso, const char* invoke(list, 9); invoke(queue, 10, 1, arg(&list)); if (FAILED(static_cast<HRESULT>(invoke(queue, 14, arg(fence), payloads + 1))) || !reached(payloads + 1)) return 25; + // X2W_TEST_ADDRESS_UPLOAD_RING_REUSE: every earlier upload has now completed, so one more payload over + // the right half must find ring capacity again (refs #2823). + if (GetEnvironmentVariableW(L"X2W_TEST_ADDRESS_UPLOAD_RING_REUSE", nullptr, 0)) { + if (!next_recording()) return 35; + if (const int result = draw_gated_console_payload(guest, list, payloads, false)) return result; + invoke(list, 9); + invoke(queue, 10, 1, arg(&list)); + if (FAILED(static_cast<HRESULT>(invoke(queue, 14, arg(fence), payloads + 2))) || !reached(payloads + 2)) return 25; + } return read_stream_target(desktop.Get(), frame, pixels); } else if (bc) { extern int draw_bc_address_srvs(void*, void*); ``` </details> ### Expected behavior Once every earlier submit has completed, a new ring reservation succeeds: the left half holds payload 0 (`03ff5aff`) and the right half payload 18 (`355d48ff`). Storage still in flight is never reused. ### Observed behavior | stand-in | `gate` | `gate-ring` | `gate-ring-reuse` left (in flight) | `gate-ring-reuse` right (after completion) | |---|---|---|---|---| | `7256cecf` | pass | pass | payload 0, correct | `00000000` null view: 32,768 wrong pixels | | `7256cecf^` stand-in | pass | fail | `136f4aff` (payload 16): 32,768 wrong pixels | payload 18, correct | Same result on WARP and hardware. On `7256cecf`, once 256 MiB has been reserved in total, `reserve_upload_ring` refuses every new reservation for the rest of the process, even after the GPU has finished with all of it. The first diagnostic is `x2w-draw upload ring reservation refused: no unused capacity`. The old wraparound code reused space without checking completion, which is what #2823 fixed; the new test fails on that code too, so it rejects both behaviors. Effect on a local startup run (release build, `run.ps1 -Render -Translate -FakeUser -GpuMirror`, 180 s, no input script), final `x2w-render totals`: | build | textures uploaded | null bindings | translated draws not drawn | ring refusals | |---|---|---|---|---| | `7256cecf` | 38 (114 MiB) | 23,949 | 6,757 | 8+ (log capped) | | `7256cecf` with #2823 reverted | 1,364 (5.3 GiB) | 0 | 1 | 0 | The first refusal is logged before the first non-zero null-binding count; the presented picture stays black. Proposed fix: record a fence value with each reservation (or per chunk) and reset a chunk's `used` once that fence has completed, keeping #2823's rule that storage is never reused before completion. `gate-ring-reuse` should then pass on both halves while `gate` and `gate-ring` keep passing. ### Environment Windows 11 build 26300.9974, VS 2022 (MSVC 19.44.35230), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4090 driver 610.88 (32.0.16.1088); WARP and hardware backends; D3D12 debug layer not enabled. ### Checklist - [x] I reproduced this on a source-built input. - [x] I did not include game files, dumps, distribution links or credentials. Refs #2823
SimSalabimse commented 2026-11-26 13:03:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T12:52:38Z.


Confirming on a second machine. A dev-preset build of 7256cecf with run.ps1 -Render -Translate -FakeUser -GpuMirror logs x2w-draw upload ring reservation refused: no unused capacity 8 times. The first refusal comes about 80–90 s in, and the presented picture stays black from there. Over the 717 s run, x2w-render totals reports 0 textures uploaded, 668,514 null buffer bindings and 300,468 translated draws not drawn. The same run on 25eb746e the night before had no refusals and uploaded 1,364 textures.

Environment: Windows 11 25H2 (26200), MSVC 19.42, NVIDIA GeForce RTX 4070 Ti driver 621.35 (32.0.16.2135), hardware backend.

Happy to test a fix branch here. If nobody is taking the fence-tagged reuse, I can open a PR against the gate-ring-reuse test above.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7192577393 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2837#issuecomment-7192577393). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T12:52:38Z. --- Confirming on a second machine. A dev-preset build of `7256cecf` with `run.ps1 -Render -Translate -FakeUser -GpuMirror` logs `x2w-draw upload ring reservation refused: no unused capacity` 8 times. The first refusal comes about 80–90 s in, and the presented picture stays black from there. Over the 717 s run, `x2w-render totals` reports 0 textures uploaded, 668,514 null buffer bindings and 300,468 translated draws not drawn. The same run on `25eb746e` the night before had no refusals and uploaded 1,364 textures. Environment: Windows 11 25H2 (26200), MSVC 19.42, NVIDIA GeForce RTX 4070 Ti driver 621.35 (32.0.16.2135), hardware backend. Happy to test a fix branch here. If nobody is taking the fence-tagged reuse, I can open a PR against the `gate-ring-reuse` test above. AI-Assisted
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#2829
No description provided.