Skip to content

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

Merged
JohnConnorNPC merged 1 commit into
R0Y00:mainfrom
JohnConnorNPC:startup/cache-index-empty-root
Nov 29, 2026
Merged

JohnConnorNPC merged 1 commit into
R0Y00:mainfrom
JohnConnorNPC:startup/cache-index-empty-root

Conversation

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Follow-up to #3433, 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 startup: list the shader cache once and skip absent mesh57 profiles #3433.
  • 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 628ff35, on main 70813f0.

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 #3433 included a Windows run of these tests at adf532c (WARP, MSVC 14.44: 12/22 passed, the 10 *_hardware variants skipped). Nobody has run them on Windows at this commit yet.

Refs #3433

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.

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 628ff35 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 628ff35 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 628ff35 would confirm (f).

@JohnConnorNPC
JohnConnorNPC merged commit 36fc27b into R0Y00:main Nov 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants