startup: leave a cache listing with no entries to the disk #3438

Manually merged
github merged 1 commit from github-bot/gh-3436 into gh-pr/3436/base 2026-11-29 09:51:37 +00:00 AGit
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 08:35 UTC · original
JohnConnorNPC:startup/cache-index-empty-root → main · +9 −6 · 2 files · 1 commits · merged 2026-11-29 09:47 UTC

Follow-up to #3435, which was merged before I could push this commit to its branch.

Change

  • src/startup_stubs/cache_index.h: drop the line that treated an ERROR_FILE_NOT_FOUND from FindFirstFileExW as an empty listing. FindFirstFileExW on "<directory>\*" returns . and .. for an empty directory, so that error only comes from a directory with no entry at all, such as an empty volume root. No test reached that branch: with the line removed, startup_cache_index_check still printed 0 failed, (f) included, under Wine. Without the branch, every listing failure leaves the index unknown, and those lookups use the disk, as the stand-in did before #3435.
  • The header comment and a new comment at the FindFirstFileExW failure state that fallback: an empty directory lists empty through its . and .. entries, and a directory with no entry at all uses the disk.
  • tests/startup_cache_index_check.cpp: fix the (a) count in the header comment, 514 → 515 (512 + 3). The ctest regex and the check's own output already say 515.

There is no behaviour change for a directory that lists, and no test changes beyond the comment.

Tests

ctest --preset dev --no-tests=error -R '^startup_cache_index' -V
ctest --preset dev --no-tests=error -R '^native_fixed_mesh57' -V
python -B tests/bidi_controls_check.py

I don't have MSVC or a Windows machine. I built with clang-cl 19.1.7 and lld-link against the xwin SDK, and ran the same executables and arguments that those ctest entries register, under Proton Experimental (wine-11.0) with vkd3d-proton 3.2.0. Commit 628ff356, on main 70813f02.

Test Result
startup_cache_index pass, startup_cache_index_check: 0 failed; (f) prints missing directory: listing error 3, lookups unknown
startup_cache_index_per_call_control fails as required (exit 1): FAIL: (a) 515 disk probes for 515 lookups of missing profiles, expected 0, no FAIL: (b)–(h)
native_fixed_mesh57{,_mrt,_varying,_uint_heap,_pixel_heap,_waterfall,_waterfall_fine,_buffers,_constant,_mask}_hardware 10/10 pass, each native fixed mesh profile lookups 66, opens 2 (2 profiles, 2000 other cache files)
native_fixed_mesh57*_warp not run: no WARP under Wine
bidi_controls_check.py pass, Checked 2600 tracked source, script and build/CI files: no bidirectional controls.

Hardware variants: NVIDIA GeForce RTX 4070 Ti SUPER, driver 550.163.01, Debian Linux 6.12 host (no Windows build). The fixture calls EnableDebugLayer(), but vkd3d-proton does not provide the Windows debug layer's validation.

Caveat: these are Wine results only. The ERROR_FILE_NOT_FOUND case itself is not covered by a test, here or on Windows; this change only removes the code that handled it differently. The review on #3435 included a Windows run of these tests at adf532c5 (WARP, MSVC 14.44: 12/22 passed, the 10 *_hardware variants skipped). Nobody has run them on Windows at this commit yet.

Refs #3435

AI-assisted

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 08:35 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3436) `JohnConnorNPC:startup/cache-index-empty-root` → `main` · +9 −6 · 2 files · 1 commits · merged 2026-11-29 09:47 UTC Follow-up to #3435, which was merged before I could push this commit to its branch. ## Change - `src/startup_stubs/cache_index.h`: drop the line that treated an `ERROR_FILE_NOT_FOUND` from `FindFirstFileExW` as an empty listing. `FindFirstFileExW` on `"<directory>\*"` returns `.` and `..` for an empty directory, so that error only comes from a directory with no entry at all, such as an empty volume root. No test reached that branch: with the line removed, `startup_cache_index_check` still printed `0 failed`, (f) included, under Wine. Without the branch, every listing failure leaves the index unknown, and those lookups use the disk, as the stand-in did before #3435. - The header comment and a new comment at the `FindFirstFileExW` failure state that fallback: an empty directory lists empty through its `.` and `..` entries, and a directory with no entry at all uses the disk. - `tests/startup_cache_index_check.cpp`: fix the (a) count in the header comment, 514 → 515 (512 + 3). The ctest regex and the check's own output already say 515. There is no behaviour change for a directory that lists, and no test changes beyond the comment. ## Tests ```powershell ctest --preset dev --no-tests=error -R '^startup_cache_index' -V ctest --preset dev --no-tests=error -R '^native_fixed_mesh57' -V python -B tests/bidi_controls_check.py ``` I don't have MSVC or a Windows machine. I built with clang-cl 19.1.7 and lld-link against the xwin SDK, and ran the same executables and arguments that those ctest entries register, under Proton Experimental (wine-11.0) with vkd3d-proton 3.2.0. Commit 628ff356, on main 70813f02. | Test | Result | |---|---| | `startup_cache_index` | pass, `startup_cache_index_check: 0 failed`; (f) prints `missing directory: listing error 3, lookups unknown` | | `startup_cache_index_per_call_control` | fails as required (exit 1): `FAIL: (a) 515 disk probes for 515 lookups of missing profiles, expected 0`, no `FAIL: (b)`–`(h)` | | `native_fixed_mesh57{,_mrt,_varying,_uint_heap,_pixel_heap,_waterfall,_waterfall_fine,_buffers,_constant,_mask}_hardware` | 10/10 pass, each `native fixed mesh profile lookups 66, opens 2 (2 profiles, 2000 other cache files)` | | `native_fixed_mesh57*_warp` | not run: no WARP under Wine | | `bidi_controls_check.py` | pass, `Checked 2600 tracked source, script and build/CI files: no bidirectional controls.` | Hardware variants: NVIDIA GeForce RTX 4070 Ti SUPER, driver 550.163.01, Debian Linux 6.12 host (no Windows build). The fixture calls `EnableDebugLayer()`, but vkd3d-proton does not provide the Windows debug layer's validation. Caveat: these are Wine results only. The `ERROR_FILE_NOT_FOUND` case itself is not covered by a test, here or on Windows; this change only removes the code that handled it differently. The review on #3435 included a Windows run of these tests at adf532c5 (WARP, MSVC 14.44: 12/22 passed, the 10 `*_hardware` variants skipped). Nobody has run them on Windows at this commit yet. Refs #3435 AI-assisted
FindFirstFileExW on "<directory>\*" returns "." and ".." for an empty
directory, so ERROR_FILE_NOT_FOUND only comes from a directory with no
entry at all, such as an empty volume root. No test reached the branch
that treated it as an empty listing: with it removed,
startup_cache_index_check (f) still passed under Wine. Drop it, so that
every listing failure leaves the index unknown and lookups use the disk,
as before the index.

Fix the (a) lookup count in the check's header comment: 512 + 3 = 515.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 08:39:21 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 08:51 UTC · original · reviewed

Reviewed 628ff356 by reading the diff; nothing was built or run. The change reads correct.

  • Before, a FindFirstFileExW failure with ERROR_FILE_NOT_FOUND was turned into success (main, src/startup_stubs/cache_index.h:163):
    if (error == ERROR_FILE_NOT_FOUND) error = ERROR_SUCCESS;  // no entry at all: an empty listing
    
    so listed_.seal() ran on an empty set, ready_ became true, and every lookup in that directory answered absent, which skips the open at native_mesh57.inl:256-257. At 628ff356 the error is kept (cache_index.h:163-166), so lines 183-189 clear the set, store it in listing_error_ and leave ready_ false, and line 103 answers unknown:
    if (!ready_.load(std::memory_order_acquire) || !same_directory(directory)) return CacheLookup::unknown;
    
    which goes on to the open.
  • Nothing else in the listing changes: the mask, the folding of the directory and same_directory are untouched, so separators, case and wide characters are handled as before.
  • Outside the test, the only reader of listing_error() is the log line at d3d12_draw.inl:283.
  • (f) (tests/startup_cache_index_check.cpp:189-197) still asserts the same two outcomes: the empty directory is ready with 0 names and answers absent, the missing directory is unknown with a non-zero error. With the line removed, the first half passes only if listing an empty subdirectory succeeds, through . and ... No test reaches the ERROR_FILE_NOT_FOUND case.
  • The description reports a run under Wine only. The Windows check does not cover this: on pull requests the job runs ctest --preset pr (windows.yml:489-493), and the pr filter (CMakePresets.json:51) does not match startup_cache_index*. A Windows run of ctest --preset dev -R '^startup_cache_index' at 628ff356 would confirm (f).
**@⁠Leyukaka** on GitHub · 2026-11-29 08:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3436#pullrequestreview-6102156159) · **reviewed** Reviewed 628ff356 by reading the diff; nothing was built or run. The change reads correct. - Before, a `FindFirstFileExW` failure with `ERROR_FILE_NOT_FOUND` was turned into success (main, src/startup_stubs/cache_index.h:163): ```cpp if (error == ERROR_FILE_NOT_FOUND) error = ERROR_SUCCESS; // no entry at all: an empty listing ``` so `listed_.seal()` ran on an empty set, `ready_` became true, and every lookup in that directory answered `absent`, which skips the open at native_mesh57.inl:256-257. At 628ff356 the error is kept (cache_index.h:163-166), so lines 183-189 clear the set, store it in `listing_error_` and leave `ready_` false, and line 103 answers `unknown`: ```cpp if (!ready_.load(std::memory_order_acquire) || !same_directory(directory)) return CacheLookup::unknown; ``` which goes on to the open. - Nothing else in the listing changes: the mask, the folding of the directory and `same_directory` are untouched, so separators, case and wide characters are handled as before. - Outside the test, the only reader of `listing_error()` is the log line at d3d12_draw.inl:283. - (f) (tests/startup_cache_index_check.cpp:189-197) still asserts the same two outcomes: the empty directory is ready with 0 names and answers `absent`, the missing directory is `unknown` with a non-zero error. With the line removed, the first half passes only if listing an empty subdirectory succeeds, through `.` and `..`. No test reaches the `ERROR_FILE_NOT_FOUND` case. - The description reports a run under Wine only. The Windows check does not cover this: on pull requests the job runs `ctest --preset pr` (windows.yml:489-493), and the `pr` filter (CMakePresets.json:51) does not match `startup_cache_index*`. A Windows run of `ctest --preset dev -R '^startup_cache_index'` at 628ff356 would confirm (f).
github-bot changed target branch from main to gh-pr/3436/base 2026-11-29 09:51:36 +00:00
github manually merged commit 628ff3564b into gh-pr/3436/base 2026-11-29 09:51:37 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.