Skip to content

Runtime: the discard loop's index no longer hides the command loop's (C4456) - #865

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
etcetera-yt:build-c4456-discard
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
etcetera-yt:build-c4456-discard

Conversation

@etcetera-yt

@etcetera-yt etcetera-yt commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: new BUILD item, claim. It has no ID yet: it isn't in the table, so I used a description as CONTRIBUTING.md allows. I'll add the ID here once the coordinator assigns one.

What and why

DiscardResource's per-subresource loop in runtime/src/vulkan_replay.h:1372 declared i. That hides the command loop's i at line 1225. The two came in with D3D-26 (19742b5, c7e450f). On main 4a36bb1, MSVC /W4 reports warning C4456: declaration of 'i' hides previous local declaration once in each of 15 targets that include the header (gta6rt, gta6rt_d3d12_com, d3d12_vulkan_device_test, the other d3d12_* tests, bvh_builder_test). It was the only compiler warning in the whole runtime build.

What was left: nothing had fixed it. No open PR touches that loop: I checked the diff of every open PR that changes vulkan_replay.h. The fix renames the inner index to sub. Behaviour is unchanged. Like #765, this is a shadowing-only fix.

Tested

Windows 10 Home 19045, NVIDIA GeForce RTX 5060 Ti (Resizable BAR on), driver 621.14, Vulkan SDK 1.4.363.0, MSVC (VS 2022 Build Tools), Visual Studio generator, RelWithDebInfo.

cmake -S runtime -B runtime/build
cmake --build runtime/build --config RelWithDebInfo --parallel
ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure
LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure
LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build -C RelWithDebInfo -R ^d3d12_vulkan_device -V
LEONIDA_VK_VALIDATION=1 runtime/build/RelWithDebInfo/vk_command_replay_test.exe
baseline main 4a36bb1 (clean worktree) this PR
Compiler warnings 15 (all C4456 at vulkan_replay.h:1372) 0
ctest 32/32 passed (gameinput disabled) 32/32 passed, including the new d3d12_state_map check
ctest, LEONIDA_VK_VALIDATION=1 32/32 passed, 0 VUIDs 32/32 passed, 0 VUIDs
d3d12_vulkan_device, validation passed passed, 0 VUIDs
vk_command_replay_test, validation — exit 0, part F (buffer and texture discards) passes

New GPU-free unit test, in d3d12_state_map_test (CPU only, already in ctest). It runs a list through prepare() with a fake image binding (3 mips × 2 layers) and checks four things. Two per-subresource discards in one list each give their own ranges, with mip and layer decoded. A partial discard records none. The command loop goes on past the discard's own loop. A range one past the last subresource returns invalid_subresource. Negative control: with the loop changed by hand to stop one short (not committed), the test fails with line 399: first.size() == 3. docs/d3d12_vulkan.md now lists this check, and also the Resizable BAR detection the test already had from D3D-96 (#815).

On the device, the loop's paths are also covered: d3d12_vulkan_device_test uses a {0, 1} discard region and the UINT_MAX range that must be refused, and vk_command_replay_test part F checks the invalid_subresource rejections.

Not tested: any other compiler (clang-cl, GCC, MinGW), Linux, and GPUs other than this one. Tests that need LEONIDA_GAME_DIR printed SKIP, as on the baseline. No workaround branch was needed: nothing failed on the baseline.

AI-assisted (Claude Code).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…mmand loop's (C4456)

DiscardResource's per-subresource loop in vulkan_replay.h declared `i`, which
hides the command loop's `i`. MSVC /W4 reported C4456 in 15 targets. The loop
behaves the same; only the name changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…are()

A CPU-only check of the loop renamed in the previous commit: two per-subresource
discards in one list each give their own ranges (mip and layer decoded), a
partial discard records none, and a range one past the last subresource is
refused. With the loop stopping one short, the test fails at first.size() == 3.
docs/d3d12_vulkan.md now lists this and the Resizable BAR detection the test
already had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kapitche

Copy link
Copy Markdown
Contributor

Tested a03f0c5 on Windows 11, NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1714), MSVC 14.51: pass

  • ctest: 32/32 passed, including d3d12_state_map_test with the new DiscardResource range cases.
  • Code read: renaming the inner i to sub ends the shadowing of the command loop's i. The new test is the right shape: three discards in one list, the second ending exactly on the last subresource, and a partial discard that records nothing. It checks that the loop moves on to the next command, and it also checks that one subresource past the end is refused.

@etcetera-yt

Copy link
Copy Markdown
Contributor Author

Thanks @kapitche, that makes two GPUs and two Windows versions: your RTX 4080 SUPER on Windows 11, and my RTX 5060 Ti on Windows 10, 32/32. Nothing changed on the branch since a03f0c5. AI-assisted (Claude Code).

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested a03f0c5 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • d3d12_state_map_test (changed here): exit=0 validation=0 | state map, enhanced barriers, subresource decoding, layout tracking, discard ranges and BAR detection OK
  • 33 test programs in the build pass with 0 validation errors
  • d3d12_clear_test fails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as on main 4a36bb1 here, so not from this PR; #521 addresses it

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@etcetera-yt

Copy link
Copy Markdown
Contributor Author

Thanks @quackottu. That's a third GPU (RTX 5070, with validation) passing. The d3d12_clear_test tie difference is #521's, as you say. Nothing has changed on the branch since a03f0c5. AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 6b8b2e5 into ItsNotRexed:main Nov 22, 2026
10 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.

4 participants